Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Need code

Former Member
0 Likes
587

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

2 REPLIES 2
Read only

Former Member
0 Likes
533

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.

Read only

Former Member
0 Likes
533

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