CSAP_ORD_BOM_MAINTAIN 销售订单BOM

@ [TOC]

1 BAPI:CSAP_ORD_BOM_MAINTAIN

2 Detail

2.1 Deleted line

STPO_API03-FLDELETE = ‘X’

2 .2 Modified Line

2.21 Please specify below lines .

STPO_API03-ITEM_NODE = STPO-STLKN.
STPO_API03-ITEM_COUNT = STOP-STPOZ.

2.22 Example.
   CONSTANTS : C(1) VALUE '.'.
        DATA: LT_OUT LIKE GT_OUT,
              LS_OUT LIKE GS_OUT.

  DATA: LWA_STKO TYPE STKO_API01,
              LWA_STPO TYPE STPO_API03,
              LIT_STPO TYPE TABLE OF STPO_API03 WITH HEADER LINE.
        DATA : LT_STPO LIKE TABLE OF STPO,
               LW_STPO LIKE LINE OF  LT_STPO.
        DATA:L_FORM TYPE CSAP_KBOM-DATUV.
        DATA:L_DATE TYPE SY-DATUM.

        DATA:HEARDER LIKE CSAP_KBOM .
        DATA: LT_ZPPT018 LIKE TABLE OF ZPPT018,
              LS_ZPPT018 LIKE LINE OF LT_ZPPT018.

       DATA: LT_CDHDR  LIKE TABLE OF CDHDR,
             LS_CDHDR LIKE LINE OF LT_CDHDR.
       DATA:L_INDEX  LIKE SY-TABIX.

        LOOP AT GT_OUT  INTO GS_OUT  WHERE SEL = 'X'.

         MOVE-CORRESPONDING GS_OUT to LS_OUT.
         APPEND LS_OUT TO LT_OUT.
         CLEAR:GS_OUT , LT_OUT.

        ENDLOOP.

        IF LT_OUT  IS NOT INITIAL.

          SELECT * INTO CORRESPONDING FIELDS OF TABLE LT_STPO FROM STPO
            FOR ALL ENTRIES IN LT_OUT
            WHERE STLNR =  LT_OUT-STLNR AND STLKN =  LT_OUT-STLKN AND  STPOZ =  LT_OUT-STPOZ .

         ENDIF.



         READ TABLE LT_OUT INTO LS_OUT   INDEX 1.
           HEARDER-VBELN =  LS_OUT-VBELN.
           HEARDER-VBPOS =  LS_OUT-VBPOS.
           HEARDER-MATNR =  LS_OUT-MATNR.
           HEARDER-WERKS =  LS_OUT-WERKS.
           HEARDER-STLAN =  LS_OUT-STLAN.

        CONCATENATE L_DATE+0(4)  L_DATE+4(2)  L_DATE+6(2) INTO L_FORM SEPARATED BY C.


*        SELECT *  INTO CORRESPONDING FIELDS OF TABLE LT_STPO FROM STPO  WHERE  STLNR = '00000004'  AND STLKN = '00000002'  AND STPOZ = '00000004'  .


        LOOP AT  LT_STPO  INTO Lw_STPO .

         IF p_MENGE   <> Lw_STPO-MENGE .
          Lw_STPO-MENGE   =  p_MENGE .
          ENDIF.
          IF p_POTX12 <> Lw_STPO-POTX1 .
          LWA_STPO-ITEM_TEXT1  =     Lw_STPO-POTX1 .
          ENDIF.
          LWA_STPO-COMP_QTY   =      Lw_STPO-MENGE  .
          LWA_STPO-ITEM_NO    =    Lw_STPO-POSNR  .
          LWA_STPO-ITEM_CATEG  =    Lw_STPO-POSTP  .
          IF p_IDNRK  <> Lw_STPO-IDNRK .
          LWA_STPO-COMPONENT   =   p_IDNRK  .
          ENDIF.
          LWA_STPO-ITEM_COUNT  =   Lw_STPO-STPOZ.
          LWA_STPO-ITEM_NODE   =   Lw_STPO-STLKN .
          LWA_STPO-BOM_NO    =   Lw_STPO-STLNR  .
          APPEND LWA_STPO  TO LIT_STPO.
          CLEAR:Lw_STPO,LWA_STPO.
        ENDLOOP.

        IF SY-SUBRC <> 0.
* Implement suitable error handling here
        ENDIF.
* 订单BOM维护
        CALL FUNCTION 'CSAP_ORD_BOM_MAINTAIN'
          EXPORTING
            ORDER              =  HEARDER-VBELN
            POSITION           =  HEARDER-VBPOS
            MATERIAL           = HEARDER-MATNR
            PLANT              =  HEARDER-WERKS
            BOM_USAGE          =  HEARDER-STLAN
            VALID_FROM         = L_FORM
            I_STKO             = LWA_STKO
            FL_DEFAULT_VALUES  = 'X'
            FL_COMMIT_AND_WAIT = 'X'
          TABLES
            T_STPO             = LIT_STPO
          EXCEPTIONS
            ERROR              = 1
            OTHERS             = 2.


        IF SY-SUBRC = 0.

          COMMIT WORK .

        ELSE.

          ROLLBACK WORK .

        ENDIF.
2.23 Experence

We must take care date format ‘2023.07.26’ for calling .

2.3

Please specify normal value .

你可能感兴趣的:(ABAP,abap,SAP)