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

Problem in BAPI SALES ORDER CHANGE

Former Member
0 Likes
2,946

Hi All,

My requirement is: while creating and saving new sales order for a customer(say 100014), system will check is any credit memo request( i.e. sales order) already exist with this customer 100014. If so, system will first releas this credit memo by clearing the billing block and then create new sales order. To change the billing block of credit memo request i am accumulating header and item info and passing it to the BAPI_SALESORDER_CHANGE inside the user exit USEREXIT_SAVE_DOCUMENT in VA01 so that it will change the billing block of the credit memo reuest before saving the new sales order.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = wa_vbak-vbeln

order_header_in = wa_hdr

order_header_inx = wa_hdrx

behave_when_error = 'P'

TABLES

return = i_ret

order_item_in = i_itm[]

order_item_inx = i_itmx[]

PARTNERS = i_order_partners[].

Its not changing the credit memo request.

Even if i am testing the BAPI_SALESORDER_CHANGE stanalone from SE37 passing header and item info and clearing the header billing block, it is not changing the billing block of the credit memo request (sales order) though its giving me succesfful message that 'Sales order is saved' from RETURN Table.

Can some one help me for the same.

Thanks a lot.

Hi All,

My requirement is: while creating and saving new sales order for a customer(say 100014), system will check is any credit memo request( i.e. sales order) already exist with this customer 100014. If so, system will first releas this credit memo by clearing the billing block and then create new sales order. To change the billing block of credit memo request i am accumulating header and item info and passing it to the BAPI_SALESORDER_CHANGE inside the user exit USEREXIT_SAVE_DOCUMENT in VA01 so that it will change the billing block of the credit memo reuest before saving the new sales order.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = wa_vbak-vbeln

order_header_in = wa_hdr

order_header_inx = wa_hdrx

behave_when_error = 'P'

TABLES

return = i_ret

order_item_in = i_itm[]

order_item_inx = i_itmx[]

PARTNERS = i_order_partners[].

Its not changing the credit memo request.

Even if i am testing the BAPI_SALESORDER_CHANGE stanalone from SE37 passing header and item info and clearing the header billing block, it is not changing the billing block of the credit memo request (sales order) though its giving me succesfful message that 'Sales order is saved' from RETURN Table.

Can some one help me for the same.

Thanks a lot.

5 REPLIES 5
Read only

Former Member
0 Likes
1,093

>

> Hi All,

>

> My requirement is: while creating and saving new sales order for a customer(say 100014), system will check is any credit memo request( i.e. sales order) already exist with this customer 100014. If so, system will first releas this credit memo by clearing the billing block and then create new sales order. To change the billing block of credit memo request i am accumulating header and item info and passing it to the BAPI_SALESORDER_CHANGE inside the user exit USEREXIT_SAVE_DOCUMENT in VA01 so that it will change the billing block of the credit memo reuest before saving the new sales order.

>

> CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

> EXPORTING

> salesdocument = wa_vbak-vbeln

> order_header_in = wa_hdr

> order_header_inx = wa_hdrx

> behave_when_error = 'P'

> TABLES

> return = i_ret

> order_item_in = i_itm[]

> order_item_inx = i_itmx[]

> PARTNERS = i_order_partners[].

>

> Its not changing the credit memo request.

>

> Even if i am testing the BAPI_SALESORDER_CHANGE stanalone from SE37 passing header and item info and clearing the header billing block, it is not changing the billing block of the credit memo request (sales order) though its giving me succesfful message that 'Sales order is saved' from RETURN Table.

>

> Can some one help me for the same.

>

> Thanks a lot.

Have you called BAPI_TRANSACTION_COMMIT?

Read only

Former Member
0 Likes
1,093

this BAPI needs explicit commit, so you need to call BAPI_TRANSACTION_COMMIT after calling it.

Read only

Former Member
0 Likes
1,093

Try using 'BAPI_TRANSACTION_COMMIT' after the BAPI call for Sales Order create.

Read only

Former Member
0 Likes
1,093

SEE THE FOLLOWING EXAMPLE

REPORT ZSALESORDER_CHANGE MESSAGE-ID 38.

*----


  • Selection Screen Definitions *

*----


PARAMETERS: p_vbeln TYPE vbap-vbeln OBLIGATORY, "Order Number

p_posnr TYPE vbap-posnr OBLIGATORY, "Order Item

p_etenr TYPE vbep-etenr OBLIGATORY, "Schedule Line

p_reqqty TYPE bapischdl-req_qty OBLIGATORY. " Order Qty

*----


  • Internal Tables/Structures/Variables for calling BAPI. *

*----


DATA: i_hdr TYPE bapisdh1,

i_hdrx TYPE bapisdh1x,

i_ret TYPE bapiret2 OCCURS 0 WITH HEADER LINE,

wa_ret TYPE bapiret2.

DATA: BEGIN OF i_sched OCCURS 10.

INCLUDE STRUCTURE bapischdl.

DATA: END OF i_sched.

DATA: BEGIN OF i_schedx OCCURS 10.

INCLUDE STRUCTURE bapischdlx.

DATA: END OF i_schedx.

*----


  • START-OF-SELECTION Event *

*----


START-OF-SELECTION.

*"----


*" Initialize internal tables.

*"----


REFRESH: i_sched, i_schedx, i_ret.

CLEAR: i_sched, i_schedx, i_ret.

*"----


*" Fill required ORDER_HEADER_IN data.

*"----


i_hdrx-updateflag = 'U'.

*"----


*" Fill required SCHEDULE_LINES data.

*"----


i_sched-itm_number = p_posnr.

i_sched-sched_line = p_etenr.

i_sched-req_qty = p_reqqty.

i_schedx-updateflag = 'U'.

i_schedx-itm_number = p_posnr.

i_schedx-sched_line = p_etenr.

i_schedx-req_qty = 'X'.

APPEND i_sched.

APPEND i_schedx.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = p_vbeln

order_header_in = i_hdr

order_header_inx = i_hdrx

TABLES

return = i_ret

schedule_lines = i_sched

schedule_linesx = i_schedx.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

LOOP AT i_ret.

WRITE / i_ret-message.

ENDLOOP.

Read only

0 Likes
1,093

Yes i know i need to call BAPI_TRANSACTION_COMMIT after BAPI_SALESORDER_CHANGE.

But, i am using the BAPI_SALESORDER_CHANGE inside the user exit of the sales order before saving other sales order. So, i can not call BAPI_TRANSACTION_COMMIT to commit the work.

Anyways, even i tried using this BAPI_TRANSACTION_COMMIT , but no result.