Application Development and Automation 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: 
Read only

BAPI_PO_CHANGE

former_member599326
Participant
0 Likes
605

Hi,

I want to delete STO through BAPI 'BAPI_PO_CHANGE', but i always gets error "No data changed".  Is there any parameter i m missing..??

CLEAR gs_poitem.

REFRESH gt_poitem.

gs_poitem-po_item       = '00010'.

gs_poitem-delete_ind    = gc_x .

APPEND gs_poitem TO gt_poitem.

CLEAR gs_poitemx.

REFRESH gt_poitemx.

gs_poitemx-po_item      = '00010'.

gs_poitemx-po_itemx     = gc_x .

gs_poitemx-delete_ind   = gc_x .

APPEND gs_poitemx TO gt_poitemx.

REFRESH gt_return.

CALL FUNCTION 'BAPI_PO_CHANGE'

   EXPORTING

     purchaseorder     = <fs_ekko>-ebeln

   IMPORTING

     expheader         = gs_expheader

     exppoexpimpheader = gs_exppoexpimpheader

   TABLES

     return            = gt_return

     poitem            = gt_poitem

     poitemx           = gt_poitemx.

Hi,

I want to delete STO through BAPI 'BAPI_PO_CHANGE', but i always gets error "No data changed".  Is there any parameter i m missing..??

CLEAR gs_poitem.

REFRESH gt_poitem.

gs_poitem-po_item       = '00010'.

gs_poitem-delete_ind    = gc_x .

APPEND gs_poitem TO gt_poitem.

CLEAR gs_poitemx.

REFRESH gt_poitemx.

gs_poitemx-po_item      = '00010'.

gs_poitemx-po_itemx     = gc_x .

gs_poitemx-delete_ind   = gc_x .

APPEND gs_poitemx TO gt_poitemx.

REFRESH gt_return.

CALL FUNCTION 'BAPI_PO_CHANGE'

   EXPORTING

     purchaseorder     = <fs_ekko>-ebeln

   IMPORTING

     expheader         = gs_expheader

     exppoexpimpheader = gs_exppoexpimpheader

   TABLES

     return            = gt_return

     poitem            = gt_poitem

     poitemx           = gt_poitemx.

2 REPLIES 2
Read only

bhanurustagi
Newcomer
0 Likes
556

Hello Santosh

If your requirement is to delete the entire document, provide POHEADER and POHEADERX import parameters of the BAPI. Set the following values:

POHEADER-PO_NUMBER = <PO_NUMBER>

POHEADER-DELET_IND = 'X'

POHEADERX-PO_NUMBER = <PO_NUMBER>

POHEADERX-DELETE_IND = 'X'

Regards

Bhanu

Read only

Former Member
0 Likes
556

Hi Santosh,

What's the value of your variable gc_x ? it must be "X".

And after calling FM BAPI_PO_CHANGE, did you call BAPI_TRANSACTION_COMMIT?

Below code refers to my STO Delete FM which may help you.

  DATA:   lt_poitem     LIKE bapimepoitem OCCURS 0 WITH HEADER LINE,

           lt_poitemx    LIKE bapimepoitemx OCCURS 0 WITH HEADER LINE,

           lt_return     LIKE bapiret2 OCCURS 0 WITH HEADER LINE,

           ld_ponum      LIKE bapimepoheader-po_number,

           lt_ekko       LIKE ekko OCCURS 0 WITH HEADER LINE,

           lt_ekpo       LIKE ekpo OCCURS 0 WITH HEADER LINE,

           lv_ebeln      LIKE ekko-ebeln.

   CLEAR lv_ebeln.

   MOVE DOCUMENT_NUMBER to lv_ebeln.

   REFRESH: lt_ekko, lt_ekpo, lt_poitem, lt_poitemx.

   SELECT * FROM ekko INTO TABLE lt_ekko WHERE ebeln = lv_ebeln.

   SELECT * FROM ekpo INTO TABLE lt_ekpo WHERE ebeln = lv_ebeln.

   READ TABLE lt_ekko WITH KEY ebeln = lv_ebeln.

   if sy-subrc EQ 0.

   ld_ponum = lt_ekko-ebeln.

   endif.

   LOOP AT lt_ekpo WHERE ebeln = lt_ekko-ebeln.

*input parameter table

     CLEAR: lt_poitem, lt_poitemx.

     lt_poitem-po_item     = lt_ekpo-ebelp.

     lt_poitem-delete_ind  = 'X'.

     lt_poitemx-po_item     = lt_ekpo-ebelp.

     lt_poitemx-po_itemx    = 'X'.

     lt_poitemx-delete_ind  = 'X'.

     APPEND: lt_poitem, lt_poitemx.

   ENDLOOP.

   CALL FUNCTION 'BAPI_PO_CHANGE'

     EXPORTING

       purchaseorder = ld_ponum

     TABLES

       return        = lt_return

       poitem        = lt_poitem

       poitemx       = lt_poitemx.

   READ TABLE lt_return WITH KEY type = 'E'.

   IF sy-subrc EQ 0.

     CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

       MOVE: lt_return-message TO RETURN_MESSAGE,

             'E'               TO RETURN_STATUS.

   ELSE.

     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

       EXPORTING

         wait = 'X'.

     MOVE: 'STOCK TRANSFER ORDER ITEMS HAS BEEN DELETED' TO RETURN_MESSAGE,

           'S'                                           TO RETURN_STATUS.

   ENDIF.