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

abap

SELECT MATNR

WERKS

LGORT

LABST

FROM MARD

INTO TABLE IT_MARD

WHERE MATNR = S_MATNR.

IF NOT IT_MARD[] IS INITIAL.

SELECT MATNR

WERKS

LGORT

CHARG

FROM MCHB

INTO TABLE IT_MCHB

FOR ALL ENTRIES IN IT_MARD

WHERE MATNR = IT_MARD-MATNR

AND WERKS = IT_MARD-WERKS

AND LGORT = IT_MARD-LGORT.

ENDIF.

DATA : L_LABST LIKE MARD-LABST,

G_LABST LIKE MARD-LABST,

H_LABST LIKE MARD-LABST,

I_LABST LIKE MARD-LABST.

LOOP AT IT_MCHB INTO ST_MCHB.

MOVE-CORRESPONDING ST_MCHB TO ST_FINAL.

APPEND ST_FINAL TO IT_FINAL.

READ TABLE IT_MARD INTO ST_MARD WITH KEY MATNR =

ST_MCHB-MATNR

WERKS = ST_MCHB-WERKS

LGORT = ST_MCHB-LGORT.

IF SY-SUBRC = 0.

MOVE-CORRESPONDING ST_MARD TO ST_FINAL.

APPEND ST_FINAL TO IT_FINAL.

CLEAR IT_FINAL.

ENDIF.

endloop.

loop at it_final into st_final.

AT NEW CHARG.

MOVE ST_final-LABST TO L_LABST.

G_LABST = ( 45 * L_LABST ) / 100.

H_LABST = ( 25 * L_LABST ) / 100.

I_LABST = ( 30 * L_LABST ) / 100.

WRITE :/ ST_final-CHARG,

ST_final-LABST,

G_LABST,

H_LABST,

I_LABST.

ENDAT.

AT END OF CHARG.

SUM.

CHECK ST_final-LABST = S_QUAN.

IF SY-SUBRC <> 0.

WRITE:/ 'stock not availabale'.

ELSE.

MOVE ST_final-LABST TO L_LABST.

G_LABST = ( 45 * L_LABST ) / 100.

H_LABST = ( 25 * L_LABST ) / 100.

I_LABST = ( 30 * L_LABST ) / 100.

WRITE :/ ST_final-CHARG,

ST_final-LABST,

G_LABST,

H_LABST,

I_LABST.

ENDIF.

ENDAT.

ENDLOOP.

ENDFORM. " z_get_data

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 24, 2006 at 01:10 PM

    Hi Rakhee,

    The it_final table population should be like the below

    LOOP AT IT_MCHB INTO ST_MCHB.

    MOVE-CORRESPONDING ST_MCHB TO ST_FINAL.

    READ TABLE IT_MARD INTO ST_MARD

    WITH KEY MATNR = ST_MCHB-MATNR

    WERKS = ST_MCHB-WERKS

    LGORT = ST_MCHB-LGORT.

    IF SY-SUBRC = 0.

    ST_FINAL-LABST = IT_MARD-LABST.

    ENDIF.

    APPEND ST_FINAL TO IT_FINAL.

    CLEAR IT_FINAL.

    ENDLOOP.

    Try this and let me know whether it is working or not.

    Regards,

    Satya.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 24, 2006 at 01:12 PM

    I don't even see a question here?

    Regards,

    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 24, 2006 at 01:13 PM

    Hi rakhee,

    Modify this part of the code:

    LOOP AT IT_MCHB INTO ST_MCHB.

    <b>*MOVE-CORRESPONDING ST_MCHB TO ST_FINAL.

    *APPEND ST_FINAL TO IT_FINAL.</b>READ TABLE IT_MARD INTO ST_MARD WITH KEY MATNR =

    ST_MCHB-MATNR

    WERKS = ST_MCHB-WERKS

    LGORT = ST_MCHB-LGORT.

    IF SY-SUBRC = 0.

    <b>MOVE-CORRESPONDING ST_MCHB TO ST_FINAL.</b>

    MOVE-CORRESPONDING ST_MARD TO ST_FINAL.

    APPEND ST_FINAL TO IT_FINAL.

    CLEAR IT_FINAL.

    ENDIF.

    endloop.

    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.