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_transcation_commit is not working

Former Member
0 Likes
1,600

Hi Experts,

I am using below code to update SO but it is not updating.

In the same program, First I am creating SO then updating SO later on.

    "    li_order_header_in-ord_reason = '000'."lc_augru.

        li_order_header_in-cust_grp5 = '246'."lc_kvgr5.\

        li_order_header_inx-updateflag = 'U'.

        li_order_header_inx-ord_reason = 'X'.

        li_order_header_inx-cust_grp5 = 'X'.

      call function 'SD_SALES_DOCUMENT_INIT'

*       EXPORTING

*         STATUS_BUFFER_REFRESH       = 'X'

*         KEEP_LOCK_ENTRIES           = ' '

*         SIMULATION_MODE_BAPI        = ' '

*         CALL_ACTIVE                 = ' '

                .

       call function 'BAPI_SALESORDER_CHANGE'  destination 'NONE'

         exporting

           salesdocument    =  p_l_vbeln

           order_header_in  = li_order_header_in

           order_header_inx = li_order_header_inx

         tables

           return           = li_return.

        loop at li_return into lst_return

          where type eq 'E'

             or type eq 'A'.

          exit.

        endloop.

        clear: lst_return.

       call function 'BAPI_TRANSACTION_COMMIT'."

Please let me know if i am doing something wrong.

Regards,

Shiv

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,444

Your code is very strange: you call the BAPI in a separate RFC mode ('NONE') but you call BAPI_TRANSACTION_COMMIT in the current mode. You must be coherent, either call both of them in 'NONE', or call both of them in the current mode (remove DESTINATION 'NONE').

7 REPLIES 7
Read only

Former Member
0 Likes
1,444

Hi Shivshanker,

What is in the return table li_return of BAPI_SALESORDER_CHANGE?

And, are you creating the SO in the same program and trying to change the same SO that you created?

Thanks,

Sowbhagya

Read only

Former Member
0 Likes
1,444

It could be that the sales order is still locked from creating. Check return table.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,444

Did you insure that the SO il already commited to database before calling the second BAPI (select or BAPI_SALESORDER_GETSTATUS) also add some code to manage errors returned  by BAPI, not a single EXIT, in case of COMMIT with WAIT option errors may also be raised by the commit.

Regards,

Raymond

Read only

Former Member
0 Likes
1,444

Hi,

I suggest to test both the functionalities separately before calling then in sequence. It could be reason system is not updating data.

Regards,

Venu

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,445

Your code is very strange: you call the BAPI in a separate RFC mode ('NONE') but you call BAPI_TRANSACTION_COMMIT in the current mode. You must be coherent, either call both of them in 'NONE', or call both of them in the current mode (remove DESTINATION 'NONE').

Read only

0 Likes
1,444

I didn't notice the DESTINATION 'NONE', so now i got some serious doubt on the relevance of the loop at return table

(an exported parameter would have raise an error, alas a TABLE parameter can be import or export, too sad)

Read only

Clemenss
Active Contributor
0 Likes
1,444

Hi,

if you want the process done in own LUW, then create a new function module, put BAPI_SALESORDER_CHANGE AND BAPI_TRANSACTION_COMMIT in this function, call it DESTINATION 'NONE' if you need own LUW without commit in current LUW.


Your evaluation of li_return is wrong. It will call BAPI_TRANSACTION_COMMIT anyway.

Better

LOOP AT li_return transporting no fields where type ca 'EAX'.

* E, A or X error: Roll Back any Changes

  call function 'BAPI_TRANSACTION_ROLLBACK'.

RETURN. "Leave current Function (form/method) - Exits only exits the LOOP

endloop.

* Get here only without errors

call function 'BAPI_TRANSACTION_COMMIT'.


Best regards,

Clemens