Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to update EKPO-LOEKZ for multiple level release in PO

former_member574106
Participant
0 Kudos

Hi friends,

After running my code i found that those PO's which are released at 2nd and 3rd level are not getting updated . SELECT ebeln

frgzu      
                         frgke                
             bedat                     
        FROM ekko
        INTO TABLE i_ekko
        WHERE  ebeln IN  so_po
        AND   bedat IN  so_date
        and   frgzu EQ 'X'
        AND   frgke EQ 'R'.
  LOOP AT i_ekko.

    IF i_ekko-frgzu = ' '.
      DELETE i_ekko.
    ENDIF.
  ENDLOOP.



  IF sy-subrc EQ 0.

    IF NOT i_ekko[] IS INITIAL.
      SELECT ebeln                      
             ebelp     
             lewed        
                
             elikz                        
             loekz                       
             FROM ekpo
             INTO TABLE i_ekpo
             FOR ALL ENTRIES IN i_ekko
             WHERE ebeln EQ i_ekko-ebeln.

      IF sy-subrc NE 0.
        WRITE : ' Item not found'.
      ENDIF.


      DELETE i_ekpo WHERE lewed GT sy-datum OR lewed EQ 0 OR elikz EQ
      'X'
      OR loekz EQ 'L' OR loekz EQ 'S'.

      SORT i_ekpo BY ebeln ebelp.

      LOOP AT i_ekpo  .
        AT NEW ebeln.
          CLEAR : i_item,
                  i_itemx,
                  i_ekpo.
          REFRESH : i_itemx,i_item.
        ENDAT.

        i_item-po_item = i_ekpo-ebelp.
        i_item-no_more_gr = 'X'.
        APPEND i_item.

        i_itemx-po_item = i_ekpo-ebelp.
        i_itemx-po_itemx = 'X'.
        i_itemx-no_more_gr = 'X'. 
        l_ebeln = i_ekpo-ebeln.
        APPEND i_itemx.


        AT END OF ebeln.
          CALL FUNCTION 'BAPI_PO_CHANGE'
            EXPORTING
              purchaseorder = l_ebeln
            TABLES
              return        = i_return
              poitem        = i_item[]
              poitemx       = i_itemx[].

          LOOP AT i_return WHERE type = 'A' OR type = 'E'.
            EXIT.
          ENDLOOP.

          IF sy-subrc NE 0.
            WRITE: l_ebeln.
            COMMIT WORK.
          ENDIF.
        ENDAT.
      ENDLOOP.

    ENDIF.
  ELSE.
    WRITE : / ' PO is not found'.
  ENDIF.

Regards,

SAURAV LAHIRY

4 REPLIES 4

Former Member
0 Kudos

Are you getting any error (Message type E in return) after BAPI execution ?

Regards

Vinod

0 Kudos

No, there is no error message. I am unable to update LOEKZ for those PO's which are released in the 2nd and 3rd stage

0 Kudos

Call function module "BAPI_TRANSACTION_COMMIT" After calling Bapi "BAPI_PO_CHANGE".

Regards

Vinod

0 Kudos

thanks. i will try it and revert