Skip to Content
0
Former Member
Sep 05, 2006 at 06:46 PM

BAPI_SALESORDER_CHANGE

48 Views

I was trying to update VBEP-LIFSP to ' ' using BAPI_SALESORDER_CHANGE. everything is going fine, but VBEP-LIFSP is not updated.

Please Help. Thank You.

DATA: LT_SDH1  TYPE TABLE OF BAPISDH1   WITH HEADER LINE, 
      LT_SDH1X TYPE TABLE OF BAPISDH1X  WITH HEADER LINE, 
      LT_SCHDL  TYPE TABLE OF BAPISCHDL  WITH HEADER LINE, 
      LT_SCHDLX TYPE TABLE OF BAPISCHDLX WITH HEADER LINE, 
      LT_RETURN TYPE TABLE OF BAPIRET2   WITH HEADER LINE, 
      LS_RETURN TYPE TABLE OF BAPIRET2   WITH HEADER LINE. 

SELECT  A~VBELN 
          A~ERDAT 
          A~AUART 
          A~VKORG 
          A~VTWEG 
          A~KUNNR 
          B~POSNR 
          B~MATNR 
          B~WERKS 
          B~LGORT 
          C~WMENG 
          C~LIFSP    FROM VBAK AS A INNER JOIN VBAP AS B ON 
                                          A~VBELN = B~VBELN 
                                    INNER JOIN VBEP AS C ON 
                                          C~VBELN = A~VBELN  AND 
                                          C~POSNR = B~POSNR 
                     INTO TABLE IT_BLOCK 
                     WHERE A~VBELN  IN S_VBELN 
                       AND A~ERDAT  IN S_ERDAT 
                       AND A~AUART  IN S_AUART 
                       AND A~VKORG  IN S_VKORG 
                       AND A~VTWEG  IN S_VTWEG 
                       AND A~KUNNR  IN S_KUNNR 
                       AND B~MATNR  IN S_MATNR 
                       AND B~WERKS  IN S_WERKS 
                       AND B~LGORT  IN S_LGORT 
                       AND C~LIFSP  IN S_LIFSP 
                       AND C~ETTYP  =  'DN' 
                       AND B~PSTYV  =  'ZREN' . 

  SORT IT_BLOCK BY VBELN. 

 LOOP AT IT_BLOCK. 

      CLEAR   : LT_SCHDL, LT_SCHDLX, LS_RETURN. 
      REFRESH : LT_RETURN. 

      MOVE 'U' TO LT_SDH1X-UPDATEFLAG. 
      MOVE 'U' TO LT_SCHDLX-UPDATEFLAG. 

      IF IT_BLOCK-LIFSP <> ''. 
          MOVE : '' TO LT_SCHDL-REQ_DLV_BL, 
                 'X' TO LT_SCHDLX-REQ_DLV_BL. 
      ENDIF. 


      CALL FUNCTION 'BAPI_SALESORDER_CHANGE' 
        EXPORTING 
          SALESDOCUMENT               = IT_BLOCK-VBELN 
          ORDER_HEADER_IN             = LT_SDH1 
          ORDER_HEADER_INX            = LT_SDH1X 
*         SIMULATION                  = 
*         BEHAVE_WHEN_ERROR           = ' ' 
*         INT_NUMBER_ASSIGNMENT       = ' ' 
*         LOGIC_SWITCH                = 
        TABLES 
          RETURN                      = LS_RETURN 
*         ORDER_ITEM_IN               = 
*         ORDER_ITEM_INX              = 
*         PARTNERS                    = 
*         PARTNERCHANGES              = 
*         PARTNERADDRESSES            = 
*         ORDER_CFGS_REF              = 
*         ORDER_CFGS_INST             = 
*         ORDER_CFGS_PART_OF          = 
*         ORDER_CFGS_VALUE            = 
*         ORDER_CFGS_BLOB             = 
*         ORDER_CFGS_VK               = 
*         ORDER_CFGS_REFINST          = 
         SCHEDULE_LINES              = LT_SCHDL 
         SCHEDULE_LINESX             = LT_SCHDLX . 
*         ORDER_TEXT                  = 
*         ORDER_KEYS                  = 
*         CONDITIONS_IN               = 
*         CONDITIONS_INX              = 
*         EXTENSIONIN                 = 


      LOOP AT LS_RETURN. 
         MOVE-CORRESPONDING LS_RETURN TO LT_RETURN. 
         APPEND LT_RETURN. 
         CLEAR  LT_RETURN. 
      ENDLOOP. 

  ENDLOOP. 

      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' 
       EXPORTING 
         WAIT          = 'X' 
       IMPORTING 
         RETURN        = LS_RETURN. 

      MOVE-CORRESPONDING LS_RETURN TO LT_RETURN. 
      APPEND LT_RETURN. 
      CLEAR  LT_RETURN.