‎2006 Jun 21 5:45 AM
Dear Friends,
Can anyone give me the code for the below requirements,
1. Read table RESB using index M (Matnr, werks, xloek, and KZEAR). Internal table to create should capture fields RSNUM, RSPOS, RSART, MATNR, WERKS, LGORT, KZEAR, XLOEK, XWAOK, SHKZG, BDMNG, and ENMNG).
2. Delete resulting table entries where storage location (LGORT) is not RCD and movement allowed is not blank (XWAOK) and Debit Credit Indicator (SHKZG) is not H.
3. For each lines remaining, calculate the remaining requirement. BDMNG ENMNG. Accumulate the differences into a total requirement work field.
4. Subtract the total available stock from the total requirement field. If the result is negative raise exception NOT_ENOUGH_STOCK.
Thanks in advance
‎2006 Jun 21 6:19 AM
Hi Karthik,
Please check this piece of code and change it according to ur requirement,
REPORT ysimple.
TABLES : resb.
DATA : BEGIN OF itab OCCURS 0,
rsnum TYPE resb-rsnum,
rspos TYPE resb-rspos,
rsart TYPE resb-rsart,
matnr TYPE resb-matnr,
werks TYPE resb-werks,
lgort TYPE resb-lgort,
kzear TYPE resb-kzear,
xloek TYPE resb-xloek,
xwaok TYPE resb-xwaok,
shkzg TYPE resb-shkzg,
bdmng TYPE resb-bdmng,
enmng TYPE resb-enmng,
END OF itab.
DATA : SUM TYPE RESB-ENMNG VALUE '0.000',
TEMP TYPE RESB-ENMNG,
RESULT TYPE RESB-ENMNG,
TOT_AVAIL_STOCK TYPE RESB-ENMNG.
SELECT * FROM resb
INTO CORRESPONDING FIELDS OF TABLE itab
WHERE matnr = 'UR INPUT' AND
werks = 'UR INPUT' AND
xloek = 'UR INPUT' AND
kzear = 'UR INPUT'.
LOOP AT itab.
IF itab-lgort NE 'RCD' AND
itab-xwaok NE ' ' AND
itab-shkzg NE 'H'.
DELETE itab.
MODIFY itab.
ENDIF.
ENDLOOP.
LOOP AT ITAB.
TEMP = ITAB-BDMNG - ITAB-ENMNG.
SUM = SUM + TEMP.
ENDLOOP.
RESULT = SUM - TOT_AVAIL_STOCK.
IF RESULT < 0.
MESSAGE e001(ZOMSGCLASS) WITH TEXT-001.
ENDIF.
If found helpful, please do reward.
‎2006 Jun 21 6:25 AM
Hi Karthik,
In above code...
u can avoid the second loop....this way
Please check this piece of code and change it according to ur requirement,
REPORT ysimple.
TABLES : resb.
DATA : BEGIN OF itab OCCURS 0,
rsnum TYPE resb-rsnum,
rspos TYPE resb-rspos,
rsart TYPE resb-rsart,
matnr TYPE resb-matnr,
werks TYPE resb-werks,
lgort TYPE resb-lgort,
kzear TYPE resb-kzear,
xloek TYPE resb-xloek,
xwaok TYPE resb-xwaok,
shkzg TYPE resb-shkzg,
bdmng TYPE resb-bdmng,
enmng TYPE resb-enmng,
END OF itab.
DATA : SUM TYPE RESB-ENMNG VALUE '0.000',
TEMP TYPE RESB-ENMNG,
RESULT TYPE RESB-ENMNG,
TOT_AVAIL_STOCK TYPE RESB-ENMNG.
SELECT * FROM resb
INTO CORRESPONDING FIELDS OF TABLE itab
WHERE matnr = 'UR INPUT' AND
werks = 'UR INPUT' AND
xloek = 'UR INPUT' AND
kzear = 'UR INPUT'.
LOOP AT itab.
IF itab-lgort NE 'RCD' AND
itab-xwaok NE ' ' AND
itab-shkzg NE 'H'.
DELETE itab.
MODIFY itab.
ELSE.
TEMP = ITAB-BDMNG - ITAB-ENMNG.
SUM = SUM + TEMP.
ENDIF.
ENDLOOP.
RESULT = SUM - TOT_AVAIL_STOCK.
IF RESULT < 0.
MESSAGE e001(ZOMSGCLASS) WITH TEXT-001.
ENDIF.
Rgds,
Prakash
Reward point if helpful.
Message was edited by: Prakashsingh Mehra