0% found this document useful (0 votes)
169 views17 pages

External Batch Management

This document describes code for external batch number assignment in SAP. It includes functions for reading field values from screens, updating those field values, and checking whether batch numbers should be replicated for different transaction types and order types based on the plant and order type. The code performs validation of batch numbers, extracts them into internal tables based on transaction type, and compares the tables to identify any issues.

Uploaded by

koushik goswamy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
169 views17 pages

External Batch Management

This document describes code for external batch number assignment in SAP. It includes functions for reading field values from screens, updating those field values, and checking whether batch numbers should be replicated for different transaction types and order types based on the plant and order type. The code performs validation of batch numbers, extracts them into internal tables based on transaction type, and compares the tables to identify any issues.

Uploaded by

koushik goswamy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

External Batch Number Assignment

T Code: CMOD

Put project name.

Like: YCORK

Double Click

FUNCTION EXIT_SAPLCORU_001.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(I_CAUFVD) LIKE CAUFVD STRUCTURE CAUFVD
*" OPTIONAL
*" VALUE(I_AFVGD) LIKE AFVGD STRUCTURE AFVGD OPTIONAL
*" TABLES
*" T_CUAFC STRUCTURE CUAFCODE
*"----------------------------------------------------------------------
Double Click

INCLUDE ZXCOCU01.

ENDFUNCTION.

After double click

*----------------------------------------------------------------------*
* INCLUDE ZXCOCU01 *
*----------------------------------------------------------------------*
*TABLES: AFPO.
*UPDATE AFPO SET CHARG = '987'
*WHERE AUFNR = '10000061' AND
* MATNR = '201000000022'.
*COMMIT WORK.

DATA: BEGIN OF DYNPRO_FIELDTAB OCCURS 3.


INCLUDE STRUCTURE DYNPREAD.
DATA: END OF DYNPRO_FIELDTAB.

DATA: PROCESS_ORDER LIKE MDCO-AUFNR,


PROGRAM LIKE D020S-PROG,
SCREEN LIKE D020S-DNUM.

REFRESH DYNPRO_FIELDTAB.
CLEAR DYNPRO_FIELDTAB.

MOVE 'MDPM-CHARG' TO DYNPRO_FIELDTAB-FIELDNAME.


MOVE '01' TO DYNPRO_FIELDTAB-STEPL.
MOVE '0000000020' TO DYNPRO_FIELDTAB-FIELDVALUE.
APPEND DYNPRO_FIELDTAB.

MOVE 'MDPM-CHARG' TO DYNPRO_FIELDTAB-FIELDNAME.


MOVE '02' TO DYNPRO_FIELDTAB-STEPL.
MOVE '0000000020' TO DYNPRO_FIELDTAB-FIELDVALUE.
APPEND DYNPRO_FIELDTAB.

PROGRAM = 'SAPLM61Q'.
SCREEN = '0536'.

CALL FUNCTION 'DYNP_UPDATE_FIELDS'


EXPORTING
DYNAME = PROGRAM
DYNUMB = SCREEN
* REQUEST = ' '
TABLES
DYNPFIELDS = DYNPRO_FIELDTAB
EXCEPTIONS
INVALID_ABAPWORKAREA = 1
INVALID_DYNPROFIELD = 2
INVALID_DYNPRONAME = 3
INVALID_DYNPRONUMMER = 4
INVALID_REQUEST = 5
NO_FIELDDESCRIPTION = 6
UNDEFIND_ERROR = 7
OTHERS = 8.

MESSAGE W398(00) WITH SY-SUBRC 'hello'.


*BREAK-POINT.
* CALL FUNCTION 'DYNP_VALUES_UPDATE'
* EXPORTING
* DYNAME = PROGRAM " sy-cprog
* DYNUMB = SCREEN "sy-dynnr
* TABLES
* DYNPFIELDS = DYNPRO_FIELDTAB
* EXCEPTIONS
* INVALID_ABAPWORKAREA = 1
* INVALID_DYNPROFIELD = 2
* INVALID_DYNPRONAME = 3
* INVALID_DYNPRONUMMER = 4
* INVALID_REQUEST = 5
* NO_FIELDDESCRIPTION = 6
* UNDEFIND_ERROR = 7
T Code: SE37

FUNCTION FIELD_EXIT_CHARG_D
FUNCTION FIELD_EXIT_CHARG_D.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(INPUT)
*" EXPORTING
*" VALUE(OUTPUT)
*"----------------------------------------------------------------------

*******$$$$$$ in the process of modification ************$$$$$$$$$$$$$$$

************************************************************************
* Internal table for the DYNP function call.
************************************************************************

TYPES: BEGIN OF DYNPRO_FIELDSTRUC.


INCLUDE STRUCTURE DYNPREAD.
TYPES: END OF DYNPRO_FIELDSTRUC.
DATA: S_AUFNR LIKE AUFK-AUFNR.

DATA: FLAG VALUE 1. " Whether copying should be done(0) or not(1).

OUTPUT = INPUT.

* Reinitialize flag.
FLAG = 1.

* Check whether the batch numbers for 261 and 101 movement types should
* same for this order type.
PERFORM CHECK_PLANT_ORDTYPE USING FLAG.

IF FLAG = 0. " Do check for replication.

* Determine how many steps in the table are having data.


* perform determine_maximum_rec_no using dynpro_fieldtab
* max_pos.

* Read the max_pos no of ( quantity/movement types, batch numbers )


* from the screen. In the present version this functin also does
* the validation for batch management flag. It then compares
* the 101 and 261 batch values and then issues the error message.
PERFORM PROCESS_QUANTITY_BATCH USING 10. "max_pos = 10.

* Extract the batch values into two internal tables - one for 261
* movement types (i.e. quantity is negative) and another for 101
* movement types (i.e. quantity is positive).
* perform extract_batch_values_into_2sets using quant_batch_tab
* 261_batch_tab
* 101_batch_tab.

* Compare the two internal tables (261_batch_tab and 101_batch_tab)


* and issue any message if necessary.
* perform compare_batch_tabs using 261_batch_tab
* 101_batch_tab.

ENDIF. " End of if replication is required.


ENDFUNCTION.
*&---------------------------------------------------------------------*
*& Form UPDATE_SCREEN_VALUE
*&---------------------------------------------------------------------*
* This function updates the fieldvalue of the mentioned field.
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPDATE_SCREEN_VALUE USING FIELDNAME LIKE DYNPREAD-FIELDNAME
STEPL LIKE SY-STEPL
FIELDVALUE LIKE DYNPREAD-FIELDVALUE
PROGRAM LIKE D020S-PROG
SCREEN LIKE D020S-DNUM.

REFRESH DYNPRO_FIELDTAB.
CLEAR DYNPRO_FIELDTAB.

MOVE: FIELDNAME TO DYNPRO_FIELDTAB-FIELDNAME,


STEPL TO DYNPRO_FIELDTAB-STEPL,
FIELDVALUE TO DYNPRO_FIELDTAB-FIELDVALUE.

APPEND DYNPRO_FIELDTAB.
* Update the screen fields.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
DYNAME = PROGRAM
DYNUMB = SCREEN
* REQUEST = ' '
TABLES
DYNPFIELDS = DYNPRO_FIELDTAB
EXCEPTIONS
INVALID_ABAPWORKAREA = 1
INVALID_DYNPROFIELD = 2
INVALID_DYNPRONAME = 3
INVALID_DYNPRONUMMER = 4
INVALID_REQUEST = 5
NO_FIELDDESCRIPTION = 6
UNDEFIND_ERROR = 7
OTHERS = 8.

ENDFORM. " UPDATE_SCREEN_VALUE

*&---------------------------------------------------------------------*
*& Form CHECK_PLANT_ORDTYPE
*&---------------------------------------------------------------------*
* This function reads the process order number from the
* screen. Then it determines(flag value is '0' or '1') whether
* the two batch values should be same('0') or not('1').
*----------------------------------------------------------------------*
* <--P_FLAG text *
*----------------------------------------------------------------------*
FORM CHECK_PLANT_ORDTYPE CHANGING VALUE(P_FLAG).

TABLES: AUFK. " Table for process order check.

DATA: DYNPRO_FIELDTAB LIKE DYNPREAD OCCURS 1,


WS_DYNPRO_FIELDTAB LIKE LINE OF DYNPRO_FIELDTAB.

DATA: PROCESS_ORDER LIKE AUFK-AUFNR,


FIN_PROCESS_ORDER(12). " For fun tricks!!!
* Fill the internal table with required values.
* thef follwoing code done by sushmita for 4.6C
* WS_DYNPRO_FIELDTAB-FIELDNAME = 'MDCO-AUFNR'.
WS_DYNPRO_FIELDTAB-FIELDNAME = 'G_COWB_HEADER-AUFNR'.

WS_DYNPRO_FIELDTAB-STEPL = '0'.
APPEND WS_DYNPRO_FIELDTAB TO DYNPRO_FIELDTAB.

* Read the process order number.


* thef follwoing code done by sushmita for 4.6C -11/07/03
PERFORM READ_SCREEN_VALUES USING DYNPRO_FIELDTAB
* 'SAPLM61Q'
* '5804'.
'SAPLCOWB'
'5802'.

* Read the process order from the internal table.


READ TABLE DYNPRO_FIELDTAB INDEX 1 INTO WS_DYNPRO_FIELDTAB.
PROCESS_ORDER = WS_DYNPRO_FIELDTAB-FIELDVALUE.
a_aufnr = PROCESS_ORDER." DEVK945081

*message e000(zsdint) with PROCESS_ORDER .

* Some tricks!!!
WRITE PROCESS_ORDER TO FIN_PROCESS_ORDER RIGHT-JUSTIFIED.
CONDENSE FIN_PROCESS_ORDER NO-GAPS.
WRITE FIN_PROCESS_ORDER TO FIN_PROCESS_ORDER RIGHT-JUSTIFIED.
OVERLAY FIN_PROCESS_ORDER WITH '000000000000'.

SELECT SINGLE *
FROM AUFK
WHERE AUFNR = FIN_PROCESS_ORDER AND
AUART IN ('ZHD1', 'ZHD2', 'ZLD1', 'ZPP1') AND
WERKS IN ('HDPE', 'LLDP', 'PP') .

IF SY-SUBRC EQ 0. " Record found meeting criteria.


P_FLAG = 0. " Replication is required.
ELSE.
P_FLAG = 1. " Replication not required.
ENDIF.

ENDFORM. " CHECK_PLANT_ORDTYPE


*&---------------------------------------------------------------------*
*& Form PROCESS_QUANTITY_BATCH
*&---------------------------------------------------------------------*
* This function reads the material no, quantity, the batch values.
* It first checks whether batch management flag is set for a
* material. Then depending on the quantity, it puts the batch
* value in one of the two sets. It also

*----------------------------------------------------------------------*
* -->P_0071 text *
*----------------------------------------------------------------------*
FORM PROCESS_QUANTITY_BATCH USING VALUE(P_MAX_POS) TYPE I.
ranges : matnr for mara-matnr.
TYPES: BEGIN OF BATCH_STRUC,
BATCH LIKE AFPO-CHARG,
END OF BATCH_STRUC.
** Changes by RS for checking Batch no on 23/08/01.
TABLES aufm.
DATA: MATNO LIKE aufm-MATNR,
BATNO LIKE aufm-CHARG.
** endchange

* Internal tables for storing the batch values. 101 and 261 specify
* their movement types.
DATA: 101_BATCH_TAB TYPE BATCH_STRUC OCCURS 10,
261_BATCH_TAB TYPE BATCH_STRUC OCCURS 10,
WS_101_BATCH_TAB LIKE LINE OF 101_BATCH_TAB,
WS_261_BATCH_TAB LIKE LINE OF 261_BATCH_TAB.

DATA: DYNPRO_FIELDTAB LIKE DYNPREAD OCCURS 2,


WS_DYNPRO_FIELDTAB LIKE LINE OF DYNPRO_FIELDTAB.

DATA: LOOP_COUNT TYPE I VALUE 0.


DATA: QUANT(20). "like mdpm-erfmg.
DATA: BATCH_MGMNT_FLAG(1).

LOOP_COUNT = 1.
REFRESH: 101_BATCH_TAB,
261_BATCH_TAB.

WHILE LOOP_COUNT <= P_MAX_POS.


REFRESH DYNPRO_FIELDTAB.
CLEAR : WS_101_BATCH_TAB,
WS_261_BATCH_TAB.

* Fill the internal table with required values.


*-----------start (10/07/2003) *********
* the following added by sushmita ...for 4.6C corrention COWB_COMP
* WS_DYNPRO_FIELDTAB-FIELDNAME = 'MDPM-ERFMG'.
WS_DYNPRO_FIELDTAB-FIELDNAME = 'COWB_COMP-ERFMG'.

WS_DYNPRO_FIELDTAB-STEPL = LOOP_COUNT.
APPEND WS_DYNPRO_FIELDTAB TO DYNPRO_FIELDTAB.

* WS_DYNPRO_FIELDTAB-FIELDNAME = 'MDPM-CHARG'.
WS_DYNPRO_FIELDTAB-FIELDNAME = 'COWB_COMP-CHARG'.

WS_DYNPRO_FIELDTAB-STEPL = LOOP_COUNT.
APPEND WS_DYNPRO_FIELDTAB TO DYNPRO_FIELDTAB.

* WS_DYNPRO_FIELDTAB-FIELDNAME = 'MDPM-MATNR'.
WS_DYNPRO_FIELDTAB-FIELDNAME = 'COWB_COMP-MATNR'. "COWB_COMP

WS_DYNPRO_FIELDTAB-STEPL = LOOP_COUNT.
APPEND WS_DYNPRO_FIELDTAB TO DYNPRO_FIELDTAB.

WS_DYNPRO_FIELDTAB-FIELDNAME = 'COWB_COMP-WERKS'. "COWB_COMP

WS_DYNPRO_FIELDTAB-STEPL = LOOP_COUNT.
APPEND WS_DYNPRO_FIELDTAB TO DYNPRO_FIELDTAB.

* message e398(00) with WS_DYNPRO_FIELDTAB-FIELDVALUE . "sushmi

* Read the process order number.


* PERFORM READ_SCREEN_VALUES USING DYNPRO_FIELDTAB
* 'SAPLM61Q'
* '0536'.
PERFORM READ_SCREEN_VALUES USING DYNPRO_FIELDTAB
'SAPLCOWB'
'0500'.
*
********************end 10/07/2003 (sushmita for 4.06C)
* message e398(00) with WS_DYNPRO_FIELDTAB-FIELDVALUE . "sushmi
*****************************

BATCH_MGMNT_FLAG = 1.
READ TABLE DYNPRO_FIELDTAB INDEX 3 INTO WS_DYNPRO_FIELDTAB.

PERFORM CHECK_BATCH_MGMNT_MATERIAL USING


WS_DYNPRO_FIELDTAB-FIELDVALUE
BATCH_MGMNT_FLAG.

IF BATCH_MGMNT_FLAG = 0.
** Change for checking batch no by RS on 23/08/01
IF LOOP_COUNT = 1.
MOVE WS_DYNPRO_FIELDTAB-FIELDVALUE TO MATNO.
ENDIF.
*********
*message e398(00) with WS_DYNPRO_FIELDTAB-FIELDVALUE . "sushmi
**************
** End of change
READ TABLE DYNPRO_FIELDTAB INDEX 1 INTO WS_DYNPRO_FIELDTAB.
IF NOT ( WS_DYNPRO_FIELDTAB-FIELDVALUE IS INITIAL ).
WRITE WS_DYNPRO_FIELDTAB-FIELDVALUE TO QUANT RIGHT-JUSTIFIED.
OVERLAY QUANT WITH '00000000000000000000'.
READ TABLE DYNPRO_FIELDTAB INDEX 2 INTO WS_DYNPRO_FIELDTAB.

** Change for checking batch no by RS on 23/08/01


IF LOOP_COUNT = 1.
MOVE WS_DYNPRO_FIELDTAB-FIELDVALUE TO BATNO.
ENDIF.
** End of change

* message e398(00) with quant quant+19(1)


* ws_dynpro_fieldtab-fieldvalue '00'.
IF NOT ( WS_DYNPRO_FIELDTAB-FIELDVALUE IS INITIAL ).
IF QUANT+19(1) EQ '-'.
MOVE WS_DYNPRO_FIELDTAB-FIELDVALUE TO WS_101_BATCH_TAB.
COLLECT WS_101_BATCH_TAB INTO 101_BATCH_TAB.
* message e398(00) with ws_101_batch_tab-batch quant '1'.
ELSE.
MOVE WS_DYNPRO_FIELDTAB-FIELDVALUE TO WS_261_BATCH_TAB.
COLLECT WS_261_BATCH_TAB INTO 261_BATCH_TAB.
* message e398(00) with ws_261_batch_tab-batch quant '2'.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
LOOP_COUNT = LOOP_COUNT + 1.
ENDWHILE.

** Change for checking batch no by RS on 23/08/01


** Check if batch no already exists
*
*----------------------24/08/2009
DATA : CCHARG LIKE MCHA-CHARG,
PLANT LIKE MCHA-WERKS.
IF SY-SUBRC = 0.
PLANT = WS_DYNPRO_FIELDTAB-FIELDVALUE.
ENDIF.
IF MATNO(3) = '201'.
IF NOT BATNO IS INITIAL.
* begin of DEVK945081
* added by kiran on 19.08.2009
* to increase database performance
* SELECT SINGLE CHARG INTO MSEG-CHARG FROM MSEG WHERE MATNR = MATNO
* AND CHARG = BATNO.
refresh matnr.
matnr-low = '201*'.
matnr-option = 'CP'.
matnr-sign = 'I'.
append matnr.
*CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
* EXPORTING
* INPUT = a_aufnr
* IMPORTING
* OUTPUT = a_aufnr
.
* SELECT SINGLE CHARG INTO AUFM-CHARG FROM aufm
* WHERE MATNR = MATNO
* AND CHARG = BATNO
* and aufnr = a_aufnr.
SELECT SINGLE charg FROM MCHA INTO CCHARG WHERE
MATNR IN matnr AND
CHARG = BATNO AND
WERKS in ('HDPE', 'LLDP', 'PP') .
* end of DEVK945081
IF SY-SUBRC EQ 0.
MESSAGE s398(00) WITH 'Warning : Batch no already exists'.
* MESSAGE MATNO type 'S'.

* INSERTED BY PRASAD ON 26/02/2002


ELSE.
*MATNO IS ADDED BY KIRAN ON 30.01.2007
PERFORM BATCH_CHECK USING BATNO MATNO.
ENDIF.
* END OF INSERTION.
ENDIF.
** End of change
SORT 101_BATCH_TAB.
SORT 261_BATCH_TAB.

* IF NOT ( 261_BATCH_TAB IS INITIAL ).


* IF NOT ( 101_BATCH_TAB[] IS INITIAL ).
* IF 101_BATCH_TAB[] <> 261_BATCH_TAB.
* MESSAGE E398(00) WITH 'Batch numbers for the 101 & 261 movement'
* ' types should be same!!!'.
* ENDIF.
* ENDIF.
* ENDIF.
ENDIF.
ENDFORM. " READ_QUANTITY_BATCH
*&---------------------------------------------------------------------*
*& Form CHECK_BATCH_MGMNT_MATERIAL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_WS_DYNPRO_FIELDTAB text *
* -->P_BATCH_MGMNT_FLAG text *
*----------------------------------------------------------------------*
FORM CHECK_BATCH_MGMNT_MATERIAL CHANGING
P_MATNR LIKE DYNPREAD-FIELDVALUE
VALUE(P_BATCH_MGMNT_FLAG).
TABLES: MARA.
DATA : BATCH_FLAG,
MATNR_VALUE LIKE MARA-MATNR.

CLEAR BATCH_FLAG.
MATNR_VALUE = P_MATNR(18).

* Performance enhancement possible here. Can do the selection at a go


* for all the material before hand. For later consideration.
IF NOT MATNR_VALUE IS INITIAL. " Minimising the selection.
SELECT SINGLE XCHPF
INTO BATCH_FLAG
FROM MARA
WHERE MATNR = MATNR_VALUE.
ENDIF.

*message e398(00) with matnr_value sy-subrc batch_flag.


IF BATCH_FLAG = 'X'.
P_BATCH_MGMNT_FLAG = 0. " Batch management allowed
ENDIF.

ENDFORM. " CHECK_BATCH_MGMNT_MATERIAL


*&---------------------------------------------------------------------*
*& Form READ_SCREEN_VALUES1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_DYNPRO_FIELDTAB1 text *
* -->P_0472 text *
* -->P_0473 text *
*----------------------------------------------------------------------*
FORM READ_SCREEN_VALUES1
CHANGING P_DYNPRO_FIELDTAB1 LIKE DYNPRO_FIELDTAB[]
PROGRAM LIKE D020S-PROG
SCREEN LIKE D020S-DNUM.

CALL FUNCTION 'DYNP_VALUES_READ'


EXPORTING
DYNAME = PROGRAM
DYNUMB = SCREEN
TRANSLATE_TO_UPPER = 'X'
TABLES
DYNPFIELDS = P_DYNPRO_FIELDTAB1
EXCEPTIONS
INVALID_ABAPWORKAREA = 1
INVALID_DYNPROFIELD = 2
INVALID_DYNPRONAME = 3
INVALID_DYNPRONUMMER = 4
INVALID_REQUEST = 5
NO_FIELDDESCRIPTION = 6
INVALID_PARAMETER = 7
UNDEFIND_ERROR = 8
DOUBLE_CONVERSION = 9
STEPL_NOT_FOUND = 10
OTHERS = 11.

ENDFORM. " READ_SCREEN_VALUES1


*&---------------------------------------------------------------------*
*& Form BATCH_CHECK
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_BATNO text *
*----------------------------------------------------------------------*
FORM BATCH_CHECK USING P_BATNO LIKE aufm-CHARG
P_MATNO LIKE aufm-MATNR.
"ADDED BY KIRAN ON 30.01.2008

DATA:S_WERKS LIKE aufm-WERKS, " Plant


S_BUDAT(10), " LIKE MKPF-BUDAT, " Posting date
S_AUFNR LIKE AFFW-AUFNR, " Order
S_CHARG LIKE aufm-CHARG, " Batch
*added by kiran on 30.01.2008
S_MATNR LIKE aufm-MATNR, " Material Number
S_KOSCH LIKE MARA-KOSCH,
" Product allocation determination procedure
*END ON 30.01.2008
S_ARBPL LIKE AFRV-ARBPL. " Resource
DATA: DYNPRO_FIELDTAB LIKE DYNPREAD OCCURS 1,
WS_DYNPRO_FIELDTAB LIKE LINE OF DYNPRO_FIELDTAB.
CLEAR S_CHARG.
* Fill the internal table with required values.
* WS_DYNPRO_FIELDTAB-FIELDNAME = 'AFRUD-ARBPL'. " Resource
* APPEND WS_DYNPRO_FIELDTAB TO DYNPRO_FIELDTAB.
WS_DYNPRO_FIELDTAB-FIELDNAME = 'AFRUD-WERKS'. " Plant
APPEND WS_DYNPRO_FIELDTAB TO DYNPRO_FIELDTAB.
WS_DYNPRO_FIELDTAB-FIELDNAME = 'AFRUD-BUDAT'. " Posting Date
APPEND WS_DYNPRO_FIELDTAB TO DYNPRO_FIELDTAB.

* Read the Resource Plant Posting date


*------------------
PERFORM READ_SCREEN_VALUES USING DYNPRO_FIELDTAB
* 'SAPLCORU' '5160'.
'SAPLCORU' '5900' . "done by sushmita
"5830 'SAPLM61Q'

* Read the Resource from the internal table.


* READ TABLE DYNPRO_FIELDTAB INDEX 1 INTO WS_DYNPRO_FIELDTAB.
* S_ARBPL = WS_DYNPRO_FIELDTAB-FIELDVALUE.
* Read the Plant from the internal table.
READ TABLE DYNPRO_FIELDTAB INDEX 1 INTO WS_DYNPRO_FIELDTAB.
S_WERKS = WS_DYNPRO_FIELDTAB-FIELDVALUE.
*----------
* message e398(00) with S_WERKS. "sushmi
*----------
* Read the Posting Date from the internal table.
READ TABLE DYNPRO_FIELDTAB INDEX 2 INTO WS_DYNPRO_FIELDTAB.
S_BUDAT = WS_DYNPRO_FIELDTAB-FIELDVALUE.

* Read the Process order no from the internal table.


REFRESH: DYNPRO_FIELDTAB. CLEAR: WS_DYNPRO_FIELDTAB.
* the following changes done by sushmita - 4.6C-14/07/2003
*-
* WS_DYNPRO_FIELDTAB-FIELDNAME = 'MDCO-AUFNR'. " Posting Date
WS_DYNPRO_FIELDTAB-FIELDNAME = 'G_COWB_HEADER-AUFNR'. " Posting Date
APPEND WS_DYNPRO_FIELDTAB TO DYNPRO_FIELDTAB.

*-------------- 10/7/2003 *
* the following lines comment by sushmita ( rectification done for 4.6C
* added new prog and screen no.
* PERFORM READ_SCREEN_VALUES USING DYNPRO_FIELDTAB
* 'SAPLM61Q' '5804'.
PERFORM READ_SCREEN_VALUES USING DYNPRO_FIELDTAB
'SAPLCOWB' '5802'.
*---------end------10/7/2003 *

READ TABLE DYNPRO_FIELDTAB INDEX 1 INTO WS_DYNPRO_FIELDTAB.


CLEAR S_ARBPL.
S_AUFNR = WS_DYNPRO_FIELDTAB-FIELDVALUE.
*------------
*------------
CONCATENATE '0000' S_AUFNR INTO S_AUFNR.
*- comment by sushmita for Train 1 / 2 (71/72) for 4.6C
* SELECT SINGLE ARBPL INTO S_ARBPL FROM MCAFVGV
* WHERE AUFNR = S_AUFNR AND VORNR = '0012'.
* added by sushmita
SELECT SINGLE PLNNR INTO S_ARBPL FROM AFKO
WHERE AUFNR = S_AUFNR .

S_ARBPL = S_ARBPL+4(2) .

*---end-30/08/2003
S_CHARG = P_BATNO.
*ADDED BY KIRAN ON 30.01.2008
S_MATNR = P_MATNO.
SELECT SINGLE KOSCH FROM MARA INTO S_KOSCH WHERE MATNR = S_MATNR.
*ENDED BY KIRAN ON 30.01.2008
SHIFT S_CHARG LEFT DELETING LEADING SPACE.
TRANSLATE S_WERKS TO UPPER CASE.
TRANSLATE S_ARBPL TO UPPER CASE.

* MESSAGE E398(00) with S_CHARG+1(2) .

* MESSAGE E398(00) WITH S_CHARG . "S_WERKS S_BUDAT S_AUFNR.

*..................................................................... *
* Logic : for checking the batch number
* BATCH NO : X XX XX XXX
* | | | \-----> any 3- digit number
* | | \--------> Posting Date month ( 2-digit)
* | \----> Plant ( If PP --> 91 ,92 or 93
* | LLDP --> 81 ,82 or 83
* | HDPE --> If HD_T1_01 71
* | If HD_T1_02 72
* |\--------------> Year last digit (4- digit)
*..................................................................... *
*** MESSAGE E398(00) WITH S_BUDAT+3(2). -sushmita
*Added kiran batch digit extention on 25.01.2010
*..................................................................... *
* Logic : for checking the batch number
* BATCH NO : XX XX XX XXX
* | | | \-----> any 3- digit number
* | | \--------> Posting Date month ( 2-digit)
* | \----> Plant ( If PP --> 91 ,92 or 93
* | LLDP --> 81 ,82 or 83
* | HDPE --> If HD_T1_01 71
* | If HD_T1_02 72
* |\--------------> Year last 2 digits (4- digit)
*..................................................................... *
*ended on kiran on 25.01.2010

*ADDED BY KIRAN ON 30.01.2008


************************************************************************
**********************
*LOGIC :: checking Product allocation determination
*procedure(S_KOSCH)
************************************************************************
**********************
*BATCH NO : X XX XX XXX 3rd POSITION PLANT PROD
*ALLOC DETER PROCE
* |
*\----> 1 PP HOMO
*2 PP HECO
*3 PP RECO
*1 LLDP LLDP
*2 LLDP LHDP
*3 LLDP ROTO
************************************************************************
***********************
*ENDED BY KIRAN ON 30.01.2008
*added by kiran on 25.01.2010
* IF S_CHARG+0(1) NE S_BUDAT+9(1).
IF S_CHARG+0(2) NE S_BUDAT+8(2).

* MESSAGE E398(00) WITH 'First digit in batch should denote'


* ' Posting year last digit ' 'that is' S_BUDAT+9(1).
MESSAGE E398(00) WITH 'First 2 digits in batch should denote'
' Posting year last 2 digits ' 'that is' S_BUDAT+8(2).
ENDIF.
*ended on kiran 25.01.2010
IF S_WERKS = 'PP'.
*added by kiran on 25.01.2010
* IF S_CHARG+1(2) NE '91' AND S_CHARG+1(2) NE '92' AND
* S_CHARG+1(2) NE '93'.
IF S_CHARG+2(2) NE '91' AND S_CHARG+2(2) NE '92' AND
S_CHARG+2(2) NE '93'.
*ended on kiran 25.01.2010

MESSAGE E398(00) WITH '3 and 2 digits must be 91,92 or 93'


' for Plant ' S_WERKS.
*-----------------added by kiran on 30.01.2008
ELSE.
*here checking Product allocation determination procedure
CASE S_KOSCH.
*if Product allocation determination procedure = 'HOMO',then
*below condition batch number will be checked.
WHEN 'HOMO'.
*added by kiran on 25.01.2010
* IF S_CHARG+2(1) NE '1'.
IF S_CHARG+3(1) NE '1'.
* MESSAGE E398(00) WITH
* '3rd digit of batch must be 1 for plant & grade'
* S_WERKS ',' S_KOSCH.
MESSAGE E398(00) WITH
'4th digit of batch must be 1 for plant & grade'
S_WERKS ',' S_KOSCH.
*ended on kiran 25.01.2010
ENDIF.
*if Product allocation determination procedure = 'HECO',then
*below condition batch number will be checked.
WHEN 'HECO'.
*added by kiran on 25.01.2010
* IF S_CHARG+2(1) NE '2'.
* MESSAGE E398(00) WITH
* '3rd digit of batch must be 2 for plant & grade'
* S_WERKS ',' S_KOSCH .
IF S_CHARG+3(1) NE '2'.
MESSAGE E398(00) WITH
'4th digit of batch must be 2 for plant & grade'
S_WERKS ',' S_KOSCH .
*ended on kiran 25.01.2010
ENDIF.
*if Product allocation determination procedure = 'RECO',then
*below condition batch number will be checked.
WHEN 'RECO'.
*added by kiran on 25.01.2010

* IF S_CHARG+2(1) NE '3'.
* MESSAGE E398(00) WITH
* '3rd digit of batch must be 3 for plant & grade'
* S_WERKS ',' S_KOSCH.
IF S_CHARG+3(1) NE '3'.
MESSAGE E398(00) WITH
'4th digit of batch must be 3 for plant & grade'
S_WERKS ',' S_KOSCH.
*ended by kiran on 25.01.2010

ENDIF.

ENDCASE.
*-------------------ended by kirn on 30.01.2008
ENDIF.
*added by kiran on 25.01.2010
ELSEIF S_WERKS = 'LLDP'.
* IF S_CHARG+1(2) NE '81' AND S_CHARG+1(2) NE '82' AND
* S_CHARG+1(2) NE '83'.
* MESSAGE E398(00) WITH '2 and 3 digits must be 81,82 or 83'
* ' for Plant ' S_WERKS.
IF S_CHARG+2(2) NE '81' AND S_CHARG+2(2) NE '82' AND
S_CHARG+2(2) NE '83'.
MESSAGE E398(00) WITH '3 and 4 digits must be 81,82 or 83'
' for Plant ' S_WERKS.
*ended by kiran on 25.01.2010
*-----------------added by kiran on 30.01.2008
ELSE.
*here checking Product allocation determination procedure
CASE S_KOSCH.
*if Product allocation determination procedure = 'ROTO',then
*below condition batch number will be checked.
WHEN 'ROTO'.
*added by kiran on 25.01.2010
* IF S_CHARG+2(1) NE '3'.
* MESSAGE E398(00) WITH
* '3rd digit of batch must be 3 for plant & grade'
* S_WERKS ',' S_KOSCH.
IF S_CHARG+3(1) NE '3'.
MESSAGE E398(00) WITH
'4th digit of batch must be 3 for plant & grade'
S_WERKS ',' S_KOSCH.
*ended by kiran on 25.01.2010
ENDIF.
*if Product allocation determination procedure = 'LHDP',then
*below condition batch number will be checked.
WHEN 'LHDP'.
*added by kiran on 25.01.2010
* IF S_CHARG+2(1) NE '2'.
* MESSAGE E398(00) WITH
* '3rd digit of batch must be 2 for plant & grade'
* S_WERKS ',' S_KOSCH.
IF S_CHARG+3(1) NE '2'.
MESSAGE E398(00) WITH
'4th digit of batch must be 2 for plant & grade'
S_WERKS ',' S_KOSCH.
*ended by kiran on 25.01.2010

ENDIF.
*if Product allocation determination procedure = 'LLDP',then
*below condition batch number will be checked.
WHEN 'LLDP'.
*added by kiran on 25.01.2010
* IF S_CHARG+2(1) NE '1'.
* MESSAGE E398(00) WITH
* '3rd digit of batch must be 1 for plant & grade'
* S_WERKS ',' S_KOSCH.
IF S_CHARG+3(1) NE '1'.
MESSAGE E398(00) WITH
'4th digit of batch must be 1 for plant & grade'
S_WERKS ',' S_KOSCH.
ENDIF.
*ended by kiran on 25.01.2010
ENDCASE.
*-------------------ended by kirn on 30.01.2008

ENDIF.

ELSEIF S_WERKS = 'HDPE'.


***add by sushmita
**********
* added by sushmita for train 1/2
*---
*added by kiran on 25.01.2010
IF S_ARBPL = '71'. " OR S_ARBPL = 'HD_T1_02'.
* IF S_CHARG+1(2) NE '71' .
* MESSAGE E398(00) WITH '2 and 3 digits must be 71 for Plant '
* S_WERKS ' for Resource Train 1'.
IF S_CHARG+2(2) NE '71' .
MESSAGE E398(00) WITH '3 and 4 digits must be 71 for Plant '
S_WERKS ' for Resource Train 1'.
ENDIF.
ELSEIF S_ARBPL = '72'. " OR S_ARBPL = 'HD_T2_01'
* IF S_CHARG+1(2) NE '72' .
* MESSAGE E398(00) WITH '2 and 3 digits must be 72 for Plant '
* S_WERKS ' for Resource Train 2'.
IF S_CHARG+2(2) NE '72' .
MESSAGE E398(00) WITH '3 and 4 digits must be 72 for Plant '
S_WERKS ' for Resource Train 2'.
ENDIF.
* ELSEIF S_CHARG+1(2) NE '71' AND S_CHARG+1(2) NE '72' .
* MESSAGE E398(00) WITH '2 and 3 digits must be 71 or 72'
* ' for Plant ' S_WERKS.
ELSEIF S_CHARG+2(2) NE '71' AND S_CHARG+2(2) NE '72' .
MESSAGE E398(00) WITH '3 and 4 digits must be 71 or 72'
' for Plant ' S_WERKS.
ENDIF.
*ended by kiran on 25.01.2010
*********sushmita
ENDIF .
**************error - check - sushmita - 15/07/2003
* MESSAGE E398(00) WITH S_CHARG+3(2).
********************************
*added by kiran on 25.01.2010
* IF S_CHARG+3(2) NE S_BUDAT+3(2).
DATA NUM(2) TYPE N.
IF S_CHARG+4(2) NE S_BUDAT+3(2).
NUM = S_BUDAT+3(2).
* MESSAGE E398(00) WITH '4 and 5 digits must be'
* ' Posting date month' 'that is' S_BUDAT+3(2).
MESSAGE E398(00) WITH '5 and 6 digits must be'
' Posting date month' ' i.e.' NUM.
ENDIF.
*Added by Prakash on 27.11.2002
* IF S_CHARG+5(3) EQ '000'.
* MESSAGE E398(00) WITH 'final 3 digits should be '
* 'started with 001'.

*IF S_CHARG+6(4) EQ '0000'.


IF S_CHARG+6(4) IS INITIAL.
* MESSAGE E398(00) WITH 'final 4 digits should be '
* 'started with 0001'.
MESSAGE E398(00) WITH 'Batch no. incomplete '.

ENDIF.
*ended by kiran on 25.01.2010
* ENDIF.
*End Changes by Prakash on 27.11.2002
ENDFORM. " BATCH_CHECK

*&---------------------------------------------------------------------*
*& Form READ_SCREEN_VALUES
*&---------------------------------------------------------------------*
* This function reads the field value of the mentioned field.
*----------------------------------------------------------------------*
* -->P_0055 text *
* -->P_0056 text *
* -->P_0057 text *
*----------------------------------------------------------------------*
FORM READ_SCREEN_VALUES
CHANGING P_DYNPRO_FIELDTAB LIKE DYNPRO_FIELDTAB[]
PROGRAM LIKE D020S-PROG
SCREEN LIKE D020S-DNUM.

* Call the function to reall the screen values.


CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = PROGRAM
DYNUMB = SCREEN
TRANSLATE_TO_UPPER = 'X'
TABLES
DYNPFIELDS = P_DYNPRO_FIELDTAB
EXCEPTIONS
INVALID_ABAPWORKAREA = 1
INVALID_DYNPROFIELD = 2
INVALID_DYNPRONAME = 3
INVALID_DYNPRONUMMER = 4
INVALID_REQUEST = 5
NO_FIELDDESCRIPTION = 6
INVALID_PARAMETER = 7
UNDEFIND_ERROR = 8
DOUBLE_CONVERSION = 9
STEPL_NOT_FOUND = 10
OTHERS = 11.
ENDFORM. " READ_SCREEN_VALUES

You might also like