SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

List of BOM's only Issue Location Errors



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> PP
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Mon Sep 08, 2008 4:02 pm    Post subject: List of BOM's only Issue Location Errors Reply with quote

List of BOM's (Bills of Material Routings) - showing only Issue Location Errors

Code:
REPORT ZBOMERR MESSAGE-ID ZZ NO STANDARD PAGE HEADING
               LINE-SIZE 132 LINE-COUNT 65.
***********************************************************************
* Listing of Bills of Materials  Errors                            *
***********************************************************************
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,
  LOOP-COUNT   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: 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 DEFAULT '*'.
*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.

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.
NEW-PAGE.
WRITE: / 'Program Started at', START-TIME.
WRITE: / 'Program Ended at  ', END-TIME.
WRITE: / '                            '.
CLEAR LOOP-COUNT.
LOOP AT SEL_MAT.
  ADD 1 TO LOOP-COUNT.
  IF LOOP-COUNT 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 LOOP-COUNT.
LOOP AT SEL_PLT.
  ADD 1 TO LOOP-COUNT.
  IF LOOP-COUNT EQ 1.
    WRITE: / '                            '.
    WRITE: / 'Specific Plant  Selection'.
    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=', SELPLNTY.
WRITE: / '                            '.
CLEAR LOOP-COUNT.
LOOP AT PLNTY-TYPE.
  ADD 1 TO LOOP-COUNT.
  IF LOOP-COUNT EQ 1.
    WRITE: / '                            '.
    WRITE: / 'Counts of Records by Routing Type'.
    WRITE: / '___________________________________'.
    WRITE: / 'Type', 20 'Number Records'.
  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.
  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.

  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 =' TO BIG-TEXT.
    MOVE  XSTPOX-IDNRK      TO BIG-TEXT+20.
    MOVE  'Level Number'    TO BIG-TEXT+40.
    WRITE  XSTPOX-STUFE     TO BIG-TEXT+60(3).
    MOVE   MAKT-MAKTX       TO BIG-TEXT+85.
    CONDENSE 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: / 'Plant', TAB-WERKS, 'Group Type', TAB-PLNTY,
            'Material', TAB-MATNR, TAB-MAKTX.
      WRITE: / '    ', BIG-TEXT.
      WRITE: / 'Costing View is NOT SET UP'.
      WRITE: / '   '.
    ELSE.
      IF MBEW-PEINH EQ 0.
        CLEAR STANDARD-COST.
*       write: / 'Standard Cost=', standard-cost.
      ELSE.
        STANDARD-COST = MBEW-STPRS / MBEW-PEINH.
*       write: / 'Standard Cost=', standard-cost.
      ENDIF.
    ENDIF.
    IF     MARC-SCHGT IS INITIAL.      "Bulk Ind for MM
      SELECT  SINGLE * FROM MARD WHERE MATNR EQ XSTPOX-IDNRK
                            AND WERKS EQ XSTPOX-WERKS
                            AND LGORT EQ XSTPOX-LGORT.
      IF SY-SUBRC NE 0.
        WRITE: / 'Plant', TAB-WERKS, 'Group Type', TAB-PLNTY,
           'Material', TAB-MATNR, TAB-MAKTX.
        WRITE: / '   InValid Issue Locations      =', XSTPOX-LGORT,
               'For Component', XSTPOX-IDNRK.
        WRITE: / '   '.
      ENDIF.
    ELSE.
      IF  NOT XSTPOX-LGORT IS INITIAL.
        WRITE: / 'Plant', TAB-WERKS, 'Group Type', TAB-PLNTY,
           'Material', TAB-MATNR, TAB-MAKTX.
        WRITE: / '   Issue Locations              =', XSTPOX-LGORT,
               'For Component', XSTPOX-IDNRK.
        WRITE: / '   Issue Locations should be blank',
                 'Because Bulk IND is turned on'.
        WRITE: / '   '.
      ENDIF.
    ENDIF.
  ENDLOOP.
ENDFORM.

* search this include on the forum
INCLUDE ZCONINC3.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> PP All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
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.