Posted: Tue Sep 04, 2007 3:29 pm Post subject: Listing of Bills of Material (BOM)
Code:
*&---------------------------------------------------------------------*
*& Report ZBILLOFMAT
*&
*&---------------------------------------------------------------------*
*& Author: Aveek Ghose
*&
*&---------------------------------------------------------------------*
REPORT ZBOM MESSAGE-ID ZZ NO STANDARD PAGE HEADING
LINE-SIZE 132 LINE-COUNT 65.
***********************************************************************
* Listing of Bills of Materials *
***********************************************************************
TABLES: MARA, MARC, MBEW, T001L, MARD, MAKT,
MAST, "Item/Plant Link to Bill of Material
STPO, "Bill of Material Component Line Item
MAPL, "Item/Plant Link to Routing
PLMZ, "Already Created Allocation
PLKO, "Routing Header
PLAS, "Link Between Routing Header & Detail
PLPO, *PLPO, "Routing Details
CRHD. "Work Center
DATA:
REC_COUNT(8) TYPE N VALUE 0,
LOOPCOUNT TYPE P VALUE 0,
START-TIME LIKE SY-UZEIT,
END-TIME LIKE SY-UZEIT,
BIG-TEXT(132).
DATA:
SUBRC-MBEW LIKE SY-SUBRC,
STANDARD-COST(7) TYPE P DECIMALS 5,
TEMP-VORNR LIKE PLPO-VORNR,
TEMP-LINE-POS-ON-SCREEN TYPE I,
X-PLNTY LIKE PLPO-PLNTY.
DATA: BEGIN OF PLNTY-TYPE OCCURS 20,
PLNTY LIKE MAPL-PLNTY,
COUNT TYPE P,
END OF PLNTY-TYPE.
DATA: BEGIN OF TAB OCCURS 500.
INCLUDE STRUCTURE MAST.
DATA: PLNTY LIKE MAPL-PLNTY,
PLNNR LIKE MAPL-PLNNR,
PLNAL LIKE MAPL-PLNAL,
ZKRIZ LIKE MAPL-ZKRIZ,
ZAEHL LIKE MAPL-ZAEHL,
MAKTX LIKE MAKT-MAKTX,
END OF TAB.
DATA: BEGIN OF XSTPOX OCCURS 500.
INCLUDE STRUCTURE STPOX.
DATA: END OF XSTPOX.
DATA: BEGIN OF XPLPO OCCURS 500.
INCLUDE STRUCTURE PLPO.
DATA: END OF XPLPO.
DATA: BEGIN OF XCSTMAT.
INCLUDE STRUCTURE CSTMAT.
DATA: END OF XCSTMAT.
DATA: RPTID.
DATA: XFELD LIKE CSDATA-XFELD,
QTY LIKE STKO-BMENG,
FTREL(1),
PM_STLAL LIKE STKO-STLAL,
PM_STLAN LIKE STZU-STLAN,
PM_CAPID LIKE TC04-CAPID,
PM_DATUV LIKE STKO-DATUV,
PM_EMENG LIKE STKO-BMENG,
PM_HEMNG(13) TYPE N,
PM_DSPRF LIKE KLAH-CLASS VALUE 'SAPCSMLVMP01 ',
PM_PRPRF LIKE KLAH-CLASS VALUE 'SAPCSMLVMP01 ',
PM_AUSCH(1) TYPE C,
PM_LTEXT(1) TYPE C,
PM_DSPCO(1) TYPE C,
PM_ALTVO(1) TYPE C,
PM_UPSAZ(1) TYPE C,
PM_GBRAZ(1) TYPE C,
PM_BREMS(1) TYPE C VALUE 'X',
PM_ERSKZ(1) TYPE C,
PM_ERSSL(1) TYPE C,
PM_BEIKZ(1) TYPE C,
PM_BESSL(1) TYPE C,
PM_BAGRP LIKE MARA-MATNR,
PM_POSTP(1) TYPE C,
PM_SANKO LIKE STPO-SANKO,
PM_SANFE LIKE STPO-SANFE,
PM_SANKA LIKE STPO-SANKA,
PM_SANIN LIKE STPO-SANIN,
PM_SANVS LIKE STPO-SANVS,
PM_RVREL LIKE STPO-RVREL,
PM_SCHGT LIKE STPO-SCHGT,
PM_STKKZ LIKE STPO-STKKZ.
SELECTION-SCREEN SKIP.
SELECT-OPTIONS:
SEL_MAT FOR MAST-MATNR.
*SELTEXT*E* "Specific Material to Select
SELECT-OPTIONS:
SEL_PLT FOR MAST-WERKS.
*SELTEXT*E* "Specific Plant to Select
PARAMETERS: SELPLNTY LIKE MAPL-PLNTY.
*SELTEXT*E* "Routing Type to Select *=All
SET BLANK LINES ON.
MOVE SY-UZEIT TO START-TIME.
MOVE SY-DATUM TO PM_DATUV.
MOVE 1 TO QTY.
MOVE '1' TO RPTID.
SELECT * FROM MAST WHERE MATNR IN SEL_MAT "Get BOM Info
AND WERKS IN SEL_PLT.
CLEAR TAB.
MOVE-CORRESPONDING MAST TO TAB.
CLEAR MAKT.
SELECT SINGLE * FROM MAKT WHERE MATNR EQ MAST-MATNR
AND SPRAS EQ SY-LANGU.
MOVE MAKT-MAKTX TO TAB-MAKTX.
SELECT * FROM MAPL WHERE MATNR EQ MAST-MATNR "Get Routing Info
AND WERKS EQ MAST-WERKS.
MOVE-CORRESPONDING MAPL TO TAB.
EXIT.
ENDSELECT.
IF TAB-PLNTY EQ SELPLNTY
OR SELPLNTY EQ '*'.
APPEND TAB.
ENDIF.
ENDSELECT.
COMMIT WORK.
SORT TAB BY WERKS PLNTY MATNR.
COMMIT WORK.
LOOP AT TAB.
ADD 1 TO REC_COUNT.
PERFORM PROCESS-REC.
IF REC_COUNT+6(2) EQ '00'.
COMMIT WORK.
ENDIF.
ENDLOOP.
COMMIT WORK.
MOVE SY-UZEIT TO END-TIME.
REFRESH TAB.
CLEAR RPTID.
NEW-PAGE.
WRITE: / 'Program Started at'(001), START-TIME.
WRITE: / 'Program Ended at '(002), END-TIME.
WRITE: / ' '.
CLEAR LOOPCOUNT.
LOOP AT SEL_MAT.
ADD 1 TO LOOPCOUNT.
IF LOOPCOUNT EQ 1.
WRITE: / ' '.
WRITE: / 'Specific Material Number Selection'.
WRITE: / '___________________________________'.
WRITE: / 'Start', 20 'End', 40 'Operator', 60 'Inc/Exc'.
ENDIF.
WRITE : / SEL_MAT-LOW, 20 SEL_MAT-HIGH,
40 SEL_MAT-OPTION, 60 SEL_MAT-SIGN.
ENDLOOP.
CLEAR LOOPCOUNT.
LOOP AT SEL_PLT.
ADD 1 TO LOOPCOUNT.
IF LOOPCOUNT EQ 1.
WRITE: / ' '.
WRITE: / 'Specific Plant Selection'(003).
WRITE: / '___________________________________'.
WRITE: / 'Start', 20 'End', 40 'Operator', 60 'Inc/Exc'.
ENDIF.
WRITE : / SEL_PLT-LOW, 20 SEL_PLT-HIGH,
40 SEL_PLT-OPTION, 60 SEL_PLT-SIGN.
ENDLOOP.
WRITE: / ' '.
WRITE: / 'Types of Routing Types to Select='(004), SELPLNTY.
WRITE: / ' '.
CLEAR LOOPCOUNT.
LOOP AT PLNTY-TYPE.
ADD 1 TO LOOPCOUNT.
IF LOOPCOUNT EQ 1.
WRITE: / ' '.
WRITE: / 'Counts of Records by Routing Type'(005).
WRITE: / '___________________________________'.
WRITE: / 'Type', 20 'Number Records'(006).
ENDIF.
WRITE : / PLNTY-TYPE-PLNTY, 20 PLNTY-TYPE-COUNT.
ENDLOOP.
*---------------------------------------------------------------------*
* FORM PROCESS-REC *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM PROCESS-REC.
READ TABLE PLNTY-TYPE WITH KEY TAB-PLNTY
BINARY SEARCH.
IF SY-SUBRC EQ 0.
ADD 1 TO PLNTY-TYPE-COUNT.
MODIFY PLNTY-TYPE INDEX SY-TABIX.
ELSE.
CLEAR PLNTY-TYPE.
MOVE TAB-PLNTY TO PLNTY-TYPE-PLNTY.
ADD 1 TO PLNTY-TYPE-COUNT.
INSERT PLNTY-TYPE INDEX SY-TABIX.
ENDIF.
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
FTREL = FTREL
ALTVO = PM_ALTVO
AUFSW = ' '
AUSKZ = PM_AUSCH
BAGRP = PM_BAGRP
BEIKZ = PM_BEIKZ
BESSL = PM_BESSL
BREMS = PM_BREMS
CAPID = PM_CAPID
DATUV = PM_DATUV
EMENG = QTY
ERSKZ = PM_ERSKZ
ERSSL = PM_ERSSL
MBWLS = ' '
MTNRV = TAB-MATNR
MEHRS = 'X'
MMORY = '1'
POSTP = PM_POSTP
SANKO = PM_SANKO
SANFR = PM_SANFE
SANKA = PM_SANKA
SANIN = PM_SANIN
SANVS = PM_SANVS
RNDKZ = ' '
RVREL = PM_RVREL
SCHGT = PM_SCHGT
STKKZ = PM_STKKZ
* stlal = mast-stlal
STLAN = TAB-STLAN
WERKS = TAB-WERKS
IMPORTING
TOPMAT = XCSTMAT
DSTST = XFELD
TABLES
STB = XSTPOX
* MATCAT =
EXCEPTIONS
ALT_NOT_FOUND = 1
CALL_INVALID = 2
MATERIAL_NOT_FOUND = 3
MISSING_AUTHORIZATION = 4
NO_BOM_FOUND = 5
NO_PLANT_DATA = 6
NO_SUITABLE_BOM_FOUND = 7
OTHERS = 8.
NEW-PAGE.
CLEAR MARC.
SELECT SINGLE * FROM MARC WHERE MATNR EQ TAB-MATNR
AND WERKS EQ TAB-WERKS.
CLEAR MBEW.
SELECT * FROM MBEW WHERE MATNR EQ TAB-MATNR
AND BWKEY EQ TAB-WERKS.
EXIT.
ENDSELECT.
WRITE: / 'Product Costing'(007), MBEW-EKALR.
WRITE: / 'Origin Group'(008), MBEW-HRKFT.
WRITE: / 'Special Procurement'(009), MARC-SOBSL.
WRITE: / ' '.
LOOP AT XSTPOX.
CLEAR BIG-TEXT.
CLEAR MAKT.
SELECT SINGLE * FROM MAKT WHERE MATNR EQ XSTPOX-IDNRK
AND SPRAS EQ SY-LANGU.
MOVE 'Component Item'(010) TO BIG-TEXT.
MOVE XSTPOX-IDNRK TO BIG-TEXT+20.
MOVE 'Level Number'(011) TO BIG-TEXT+40.
WRITE XSTPOX-STUFE TO BIG-TEXT+60(3).
MOVE MAKT-MAKTX TO BIG-TEXT+85.
CONDENSE BIG-TEXT.
WRITE: / ' ', BIG-TEXT.
CLEAR MARC.
SELECT SINGLE * FROM MARC WHERE MATNR EQ XSTPOX-IDNRK
AND WERKS EQ XSTPOX-WERKS.
CLEAR MBEW.
SELECT * FROM MBEW WHERE MATNR EQ XSTPOX-IDNRK
AND BWKEY EQ XSTPOX-WERKS.
EXIT.
ENDSELECT.
MOVE SY-SUBRC TO SUBRC-MBEW.
IF SUBRC-MBEW NE 0.
WRITE: / 'Costing View is NOT SET UP'(012).
ELSE.
IF MBEW-PEINH EQ 0.
CLEAR STANDARD-COST.
WRITE: / 'Standard Cost'(013), STANDARD-COST.
ELSE.
STANDARD-COST = MBEW-STPRS / MBEW-PEINH.
WRITE: / 'Standard Cost'(014), STANDARD-COST.
ENDIF.
ENDIF.
WRITE: / ' Costing Relevancy=', XSTPOX-SANKA,
' Bulk Ind for MM=', MARC-SCHGT,
' Bulk Ind for BOM=', XSTPOX-SCHGT.
WRITE: / ' BOM Issue Location =', XSTPOX-LGORT.
SELECT * FROM MARD WHERE MATNR EQ XSTPOX-IDNRK
AND WERKS EQ XSTPOX-WERKS.
WRITE: / ' -Valid Issue Locations =', MARD-LGORT.
ENDSELECT.
WRITE: / ' '.
ENDLOOP.
REFRESH XPLPO.
SELECT * FROM MAPL WHERE MATNR EQ TAB-MATNR
AND WERKS EQ TAB-WERKS
AND PLNTY EQ TAB-PLNTY
AND PLNNR EQ TAB-PLNNR
AND PLNAL EQ TAB-PLNAL
AND ZKRIZ EQ TAB-ZKRIZ
AND ZAEHL EQ TAB-ZAEHL.
CLEAR PLAS.
SELECT * FROM PLAS WHERE PLNTY EQ MAPL-PLNTY
AND PLNNR EQ MAPL-PLNNR
AND PLNAL EQ MAPL-PLNAL
AND LOEKZ EQ ' '.
CLEAR *PLPO.
SELECT * FROM PLPO WHERE PLNTY EQ PLAS-PLNTY
AND PLNNR EQ PLAS-PLNNR
* and datuv ge mapl-datuv.
AND ZAEHL EQ PLAS-ZAEHL.
IF NOT PLPO-VPLNR IS INITIAL.
MOVE PLPO TO *PLPO.
MOVE-CORRESPONDING PLPO TO XPLPO.
APPEND XPLPO.
EXIT.
ELSE.
MOVE-CORRESPONDING PLPO TO XPLPO.
APPEND XPLPO.
ENDIF.
ENDSELECT.
IF NOT *PLPO IS INITIAL.
IF *PLPO-PLNTY EQ 'R'.
MOVE 'M' TO X-PLNTY.
ELSE.
MOVE 'S' TO X-PLNTY.
ENDIF.
SELECT * FROM PLPO WHERE PLNTY EQ X-PLNTY
AND PLNNR EQ *PLPO-VPLNR
* and datuv ge mapl-datuv.
AND ZAEHL EQ PLAS-ZAEHL.
MOVE-CORRESPONDING PLPO TO XPLPO.
APPEND XPLPO.
ENDSELECT.
ENDIF.
ENDSELECT.
ENDSELECT.
LOOP AT XPLPO.
CLEAR CRHD.
SELECT SINGLE * FROM CRHD WHERE OBJTY EQ 'A '
AND OBJID EQ XPLPO-ARBID.
WRITE: / 'Routing Operation Number'(015), XPLPO-VORNR,
'WorkCenter'(016), CRHD-ARBPL,
'ControlKey'(017), XPLPO-STEUS,
'BaseQty'(018), XPLPO-BMSCH.
ENDLOOP.
ENDFORM.
INCLUDE ZCONINC3.
IF RPTID EQ '1'.
WRITE: / 'Plant'(019), TAB-WERKS, 'Group Type', TAB-PLNTY,
'Material'(020), TAB-MATNR, TAB-MAKTX.
WRITE: / ' '.
ENDIF.
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.