Skip to Content
0
Former Member
Oct 24, 2006 at 11:19 AM

abap

22 Views

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