Skip to Content
author's profile photo Former Member
Former Member

Need code

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 21, 2006 at 05: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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 21, 2006 at 05: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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.