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: 

BAPI_PO_CHANGE

Former Member
0 Kudos

Hi All

I am using BAPI_PO_CHANGE to set deletion indicator loekx field in ekko.

  ls_poitem-po_item    = lv_last_item_no.

  ls_poitem-delete_ind = 'X'.

  APPEND ls_poitem TO  lt_poitem.

*

  ls_poitemx-po_item    = lv_last_item_no.

  ls_poitemx-po_itemx   = 'X'.

  ls_poitemx-delete_ind = 'X'.

  APPEND ls_poitemx TO lt_poitemx.

      CALL FUNCTION 'BAPI_PO_CHANGE'

        EXPORTING

          purchaseorder = iv_order_no

*         testrun       = iv_test

        IMPORTING

          expheader     = ls_expheader

        TABLES

          return        = lt_return

          poitem        = lt_poitem

          poitemx       = lt_poitemx.

used bapi_transaction_commit also

I am unable to set flag.

Thanks

Vamsi

7 REPLIES 7

SandySingh
Active Contributor
0 Kudos

Hi Vamsi,

Use the following code

Regards

Sandy

    


REFRESH: lt_poitem, lt_poitemx.

     ls_poheader-po_number  = ls_sl-ebeln.

     ls_poheaderx-po_number = 'X'.

     ls_poitem-po_item      = ls_sl-ebelp.

     ls_poitem-delete_ind   = 'X'.

     ls_poitemx-po_item     = ls_sl-ebelp.

     ls_poitemx-delete_ind  = 'X'.

     APPEND ls_poitem  TO lt_poitem.

     APPEND ls_poitemx TO lt_poitemx.

     REFRESH lt_msg.

     CALL FUNCTION 'BAPI_PO_CHANGE'

       EXPORTING

         purchaseorder = ls_sl-ebeln

         poheader      = ls_poheader

         poheaderx     = ls_poheaderx

       TABLES

         poitem        = lt_poitem

         poitemx       = lt_poitemx

         return        = lt_msg.

     LOOP AT lt_msg TRANSPORTING NO FIELDS WHERE type CA 'EA'.

       EXIT.

     ENDLOOP.

     IF sy-subrc EQ 0"at least one E or A

       CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

     ELSE.

       "successful

       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

         EXPORTING

           wait = 'X'.

     ENDIF.

0 Kudos

H Sandy

Tried ,not working

Thanks

Vamsi

kesavadas_thekkillath
Active Contributor
0 Kudos

It cannot be set by BAPI_PO_CHANGE.  You will have to set the item level indicator.

Please search in SCN for more details.

Kesav

raymond_giuseppi
Active Contributor
0 Kudos

Try DELETE_IND = 'L'. " Löschen as in

APPEND INITIAL LINE TO poitem ASSIGNING <poitem>.
MOVE  <ekpo>-ebelp     TO   <poitem>-po_item.
MOVE  'L'              TO   <poitem>-delete_ind.

APPEND INITIAL LINE TO poitemx ASSIGNING <poitemx>.
MOVE  <ekpo>-ebelp     TO   <poitemx>-po_item.
MOVE  'X'              TO   <poitemx>-po_itemx.
MOVE  'X'              TO   <poitemx>-delete_ind.

CALL FUNCTION 'BAPI_PO_CHANGE'
   EXPORTING
     purchaseorder = purchaseorder
     no_messaging  = 'X' " Just for test one
   TABLES
     return        = return
     poitem        = poitem
     poitemx       = poitemx.

LOOP AT return ASSIGNING <return> WHERE type CA 'EA'.
   MESSAGE ID <return>-id TYPE 'S' NUMBER <return>-num DISPLAY LIKE <return>-type.
ENDLOOP.
IF sy-subrc EQ 0.
   CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
     EXPORTING
       wait = abap_true.
ELSE.
   CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.

Does RETURN parameter contains some error or warning messages?

Regards,

Raymond

0 Kudos

Hi

I have checked,only line item indicator fields is setting,header level is not setting.Is that correct.

Thanks

Vamsi

0 Kudos

If you also want to set deletion at header (are every item deleted, no receipt, no invoice, etc.) add the deletion flag to poheader[x] too.

(But test step by step.)

0 Kudos

Hi

Everything is correct

Please change like this

This is your code

ls_poitem-po_item    = lv_last_item_no.

  ls_poitem-delete_ind = 'X'.

Now change like this

ls_poitem-po_item    = lv_last_item_no.

  ls_poitem-delete_ind = 'X'.

ls_poitemx-delete_ind = 'X'.

delete_ind is available in  po_itemx also so you have to use ls_poitemx-delete_ind = 'x'.