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

Showing MisMatches between Phantom Items & Backflush Ind



 
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:05 pm    Post subject: Showing MisMatches between Phantom Items & Backflush Ind Reply with quote

List of BOM's (Bills of Material Routings) - showing MisMatches between Phantom Items & Backflush Indicator

Code:
REPORT ZBOMMISM MESSAGE-ID ZZ NO STANDARD PAGE HEADING
               LINE-SIZE 132 LINE-COUNT 65.
***********************************************************************
* Listing of Bills of Materials - Mis Matches between              *
*   Phantom Items & Backflush Indicator                            *
***********************************************************************
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,
  TTL_REC_COUNT LIKE REC_COUNT,
  LOOP-COUNT   TYPE P VALUE 0,
  START-TIME LIKE SY-UZEIT,
  END-TIME   LIKE SY-UZEIT,
  BIG-TEXT(150).

DATA:
  DO-PRINT,
  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,
      LOEKZ LIKE MAPL-LOEKZ,
      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 DEFAULT 'EV01'.
*SELTEXT*E*  "Specific Plant to Select
PARAMETERS: SELPLNTY LIKE MAPL-PLNTY DEFAULT 'N'.
*SELTEXT*E*  "Routing Type to Select *=All
PARAMETERS: FULLLIST AS CHECKBOX DEFAULT ' '.
*SELTEXT*E*  "Include Non Component Info

SET BLANK LINES ON.
MOVE SY-UZEIT TO START-TIME.
MOVE SY-DATUM  TO PM_DATUV.
MOVE 1         TO QTY.

PERFORM STATUS-LINE-MSG  USING
     'Reading Data Base to Determine Records to be Processed'.
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.
DESCRIBE TABLE TAB LINES TTL_REC_COUNT.
LOOP AT TAB.
  ADD 1 TO REC_COUNT.
  PERFORM PROCESS-REC.
  IF REC_COUNT+6(2) EQ '00'.
    COMMIT WORK.
  ENDIF.
  PERFORM STATUS-LINE-MESSAGE USING REC_COUNT TTL_REC_COUNT.
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.
  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 DO-PRINT.
  LOOP AT XSTPOX.                      "Modify BackFlush Ind in BOM
    SELECT * FROM PLMZ WHERE PLNTY EQ TAB-PLNTY
                         AND PLNNR EQ TAB-PLNNR
                         AND STLTY EQ XSTPOX-STLTY
                         AND STLNR EQ XSTPOX-STLNR
                         AND STLKN EQ XSTPOX-STLKN.
      MOVE PLMZ-RGEKZ TO XSTPOX-RGEKZ.
    ENDSELECT.
    CLEAR MARA.
    SELECT SINGLE * FROM MARA WHERE MATNR EQ XSTPOX-IDNRK.
    IF NOT MARA-LVORM IS INITIAL.
      IF  XSTPOX-LOEKZ IS INITIAL.
        MOVE 'X' TO XSTPOX-LOEKZ.      "Turn on Deletion Ind
        MOVE 'Y' TO DO-PRINT.
      ENDIF.
    ENDIF.
    MODIFY XSTPOX.
  ENDLOOP.
  LOOP AT XSTPOX.
    IF  NOT XSTPOX-DUMPS IS INITIAL    "Is a Phantom Item
    AND NOT XSTPOX-RGEKZ IS INITIAL.   "Backflush Indicator is ON
      MOVE 'Y' TO DO-PRINT.
    ENDIF.
    IF      XSTPOX-DUMPS IS INITIAL    "Is Not a Phantom Item
    AND     XSTPOX-RGEKZ IS INITIAL.   "Backflush Indicator is OFF
      MOVE 'Y' TO DO-PRINT.
    ENDIF.
  ENDLOOP.
  CLEAR MARA.
  SELECT SINGLE * FROM MARA WHERE MATNR EQ TAB-MATNR.
  IF NOT MARA-LVORM IS INITIAL.
    MOVE 'Y' TO DO-PRINT.
  ENDIF.
  CHECK DO-PRINT EQ 'Y'.
  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.
  IF NOT FULLLIST IS INITIAL.
    NEW-PAGE.
  ENDIF.

  WRITE: / 'Plant', TAB-WERKS, 'Group Type', TAB-PLNTY,
           'Material', TAB-MATNR, TAB-MAKTX.
  IF NOT MARA-LVORM IS INITIAL.
    WRITE: / '*********Master Item is Tagged for Deletion *******'.
  ENDIF.
  WRITE: / '                                 '.
  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.
  IF NOT FULLLIST IS INITIAL.
    WRITE: / 'Product Costing                 =', MBEW-EKALR.
    WRITE: / 'Origin Group                    =', MBEW-HRKFT.
    WRITE: / 'Special Procurement             =', MARC-SOBSL.
    WRITE: / '                                 '.
  ENDIF.

  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.
    MOVE   'P='             TO BIG-TEXT+126(2).
    MOVE  XSTPOX-DUMPS      TO BIG-TEXT+128(1).
    MOVE   'B='             TO BIG-TEXT+129(2).
    MOVE  XSTPOX-RGEKZ TO BIG-TEXT+131(1).
    IF  NOT XSTPOX-DUMPS IS INITIAL    "Is a Phantom Item
    AND NOT XSTPOX-RGEKZ IS INITIAL.   "Backflush Indicator is ON
      MOVE '****' TO BIG-TEXT+133(4).
    ENDIF.
    IF      XSTPOX-DUMPS IS INITIAL    "Is Not a Phantom Item
    AND     XSTPOX-RGEKZ IS INITIAL.   "Backflush Indicator is OFF
      MOVE '****' TO BIG-TEXT+133(4).
    ENDIF.
    IF NOT XSTPOX-LOEKZ IS INITIAL.
      MOVE '****' TO BIG-TEXT+133(4).
      MOVE 'Tagged-4-Del'      TO BIG-TEXT+137(12).
    ENDIF.
    CONDENSE BIG-TEXT.
    WRITE: / '    ', BIG-TEXT(120).
    CHECK NOT FULLLIST IS INITIAL.
    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'.
    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.
    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.
  IF NOT TAB-LOEKZ IS INITIAL.
    WRITE: / '********Routing is Tagged for Deletion**********'.
  ENDIF.
  CHECK NOT FULLLIST IS INITIAL.
  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=', XPLPO-VORNR,
             'WorkCenter=', CRHD-ARBPL,
             'ControlKey=', XPLPO-STEUS,
             'BaseQty=', XPLPO-BMSCH.
  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.