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

delete line within BAPI_SALESDOCUMENT_CHANGE

Former Member
0 Likes
768

Hi ;

I am working on the BAPI_SALEDOCUMENT_CHANGE trying to delete line item with type 'ZTDC' from sales order.

For this purpose, I am writing a program bellow and I am calling BAP_TRANSACTION_COMMIT FM.

Unfotunately, nothing is changed with no return error. can you help me to understand what's wrong in my program!

header_ch_inx-UPDATEFLAG = 'U'.


select * from vbap INTO CORRESPONDING FIELDS OF TABLE it_vbap
   WHERE vbeln eq v_vbeln and PSTYV eq 'ZTDC'.


loop at it_vbap.

     header_ch_inx-updateflag = 'U'.
     item_ch-itm_number       = it_vbap-POSNR.

   item_ch_inx-ITM_NUMBER = it_vbap-POSNR .
   item_ch_inx-UPDATEFLAG = 'D'.
APPEND item_ch_inx.

ENDLOOP.

CALL FUNCTION 'BAPI_SALESDOCUMENT_CHANGE' "BAPI Change Sales Document
   EXPORTING
     salesdocument    =   v_vbeln       " bapivbeln-vbeln  Sales and Distribution Document Number
     order_header_in  =   header_ch       " bapisdhead1   Sales Document Header
     order_header_inx =   header_ch_inx         " bapisdhead1x  Sales Document Header Checkbox
*   simulation = SPACE          " bapiflag-bapiflag  Simulation Mode

   TABLES
     return  =   return_ch            " bapiret2      Return Code
     item_in =   item_ch                " bapisditem    Sales and Distribution Document Item
     item_inx =  item_ch_inx                " bapisditemx   Sales Document Item Checkbox

Hi ;

I am working on the BAPI_SALEDOCUMENT_CHANGE trying to delete line item with type 'ZTDC' from sales order.

For this purpose, I am writing a program bellow and I am calling BAP_TRANSACTION_COMMIT FM.

Unfotunately, nothing is changed with no return error. can you help me to understand what's wrong in my program!

header_ch_inx-UPDATEFLAG = 'U'.


select * from vbap INTO CORRESPONDING FIELDS OF TABLE it_vbap
   WHERE vbeln eq v_vbeln and PSTYV eq 'ZTDC'.


loop at it_vbap.

     header_ch_inx-updateflag = 'U'.
     item_ch-itm_number       = it_vbap-POSNR.

   item_ch_inx-ITM_NUMBER = it_vbap-POSNR .
   item_ch_inx-UPDATEFLAG = 'D'.
APPEND item_ch_inx.

ENDLOOP.

CALL FUNCTION 'BAPI_SALESDOCUMENT_CHANGE' "BAPI Change Sales Document
   EXPORTING
     salesdocument    =   v_vbeln       " bapivbeln-vbeln  Sales and Distribution Document Number
     order_header_in  =   header_ch       " bapisdhead1   Sales Document Header
     order_header_inx =   header_ch_inx         " bapisdhead1x  Sales Document Header Checkbox
*   simulation = SPACE          " bapiflag-bapiflag  Simulation Mode

   TABLES
     return  =   return_ch            " bapiret2      Return Code
     item_in =   item_ch                " bapisditem    Sales and Distribution Document Item
     item_inx =  item_ch_inx                " bapisditemx   Sales Document Item Checkbox

2 REPLIES 2
Read only

Former Member
0 Likes
614

This message was moderated.

Read only

Former Member
0 Likes
614

Anouar

After invoking the BAPI

     BAPI_SALESDOCUMENT_CHANGE

You must call the  BAPI

     BAPI_TRANSACTION_COMMIT


always  that the execution of the BAPI BAPI_SALESDOCUMENT_CHANGE was  successful


regards

Pedro