Posted: Mon Sep 03, 2007 11:41 pm Post subject: Остаток материала на складе на дату.
Code:
PROGRAM Z_OBOR_MAT LINE-SIZE 100.
TABLES: MARA, MAKT, MSEG, T001W, T001L.
SELECT-OPTIONS: MATNR FOR MARA-MATNR ,
WERKS FOR MSEG-WERKS ,
LGORT FOR MSEG-LGORT.
PARAMETERS: DATE LIKE MARA-ERSDA DEFAULT SY-DATUM OBLIGATORY.
DATA: BEGIN OF ITOG OCCURS 0,
WERKS LIKE MSEG-WERKS,
LGORT LIKE MSEG-LGORT,
MATNR LIKE MSEG-MATNR,
MAKTX LIKE MAKT-MAKTX,
MENGE LIKE MSEG-MENGE,
END OF ITOG.
DATA: HD LIKE BAPI2017_GM_HEAD_02 OCCURS 0 WITH HEADER LINE,
IT LIKE BAPI2017_GM_ITEM_SHOW OCCURS 0 WITH HEADER LINE,
RET LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE,
TT156 LIKE T156 OCCURS 0 WITH HEADER LINE,
OSTAT LIKE MSEG-MENGE.
CALL FUNCTION 'BAPI_GOODSMVT_GETITEMS'
TABLES
MATERIAL_RA = MATNR
PLANT_RA = WERKS
STGE_LOC_RA = LGORT
PSTNG_DATE_RA = DP
GOODSMVT_HEADER = HD
GOODSMVT_ITEMS = IT
RETURN = RET.
SKIP.
LOOP AT IT.
CLEAR: TT156, OSTAT.
READ TABLE TT156 WITH KEY BWART = IT-MOVE_TYPE.
CASE TT156-SHKZG.
WHEN 'S'. ADD IT-ENTRY_QNT TO OSTAT.
WHEN 'H'. SUBTRACT IT-ENTRY_QNT FROM OSTAT.
ENDCASE.
CLEAR: ITOG.
ITOG-WERKS = IT-PLANT.
ITOG-LGORT = IT-STGE_LOC.
ITOG-MATNR = IT-MATERIAL.
ITOG-MENGE = OSTAT.
COLLECT ITOG.
ENDLOOP.
DELETE ITOG WHERE MENGE = 0.
LOOP AT ITOG.
SELECT SINGLE MAKTX INTO ITOG-MAKTX FROM MAKT WHERE MATNR = ITOG-MATNR.
MODIFY ITOG.
ENDLOOP.
SORT ITOG BY WERKS LGORT MAKTX.
LOOP AT ITOG.
AT NEW WERKS.
CLEAR: T001W.
SELECT SINGLE * FROM T001W WHERE WERKS = ITOG-WERKS.
ULINE.
WRITE:/ ITOG-WERKS COLOR 1, T001W-NAME1 COLOR 1.
ULINE.
ENDAT.
AT NEW LGORT.
CLEAR: T001L.
SELECT SINGLE * FROM T001L WHERE WERKS = ITOG-WERKS
AND LGORT = ITOG-LGORT.
ULINE.
WRITE:/5 ITOG-LGORT COLOR 1 INTENSIFIED OFF,
T001L-LGOBE COLOR 1 INTENSIFIED OFF.
ULINE.
ENDAT.
WRITE:/12 ITOG-MATNR, ITOG-MAKTX, ITOG-MENGE.
ENDLOOP.
ULINE.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.