cancel
Showing results for 
Search instead for 
Did you mean: 

SAVE Sequence BAPI Commit Issue, ABAP RESTful Programming On-Premise

reachoutnagendra
Explorer

Hi Experts,

I am trying to implement unmanaged scenario for a create operation. I am using 'BAPI_EPM_SO_CREATE' to create a sales order with create method.

This BAPI has a parameter 'persist_to_db' which is by default true. When I am calling the BAPI , getting dump because the BAPI contains 'COMMIT WORK'. As we know we cannot use commit work during transnational phase.

So then passed 'abap_false' to persist_to_db and placed commit work in save method (part of save sequence). But still I am getting dump for using commit.

Due to this reason I am unable to persist the data even after successful execution of the BAPI. How do I commit the data in save seqeunce. Kindly help.

Regards,

ABAPer.

Sandra_Rossi
Active Contributor
0 Kudos

COMMIT WORK leads to a runtime error (please give details about your runtime error) when it's called inside an update task (your case?). The only way to trigger an update task is to use COMMIT WORK, so when you call the BAPI you're already inside COMMIT WORK.

In fact, that's a scenario to avoid: don't call a BAPI inside the update task. The solution depends on your exact scenario. Eventually one possibility is to call the BAPI inside a separate SAP LUW, for instance via tRFC (DESTINATION 'NONE' IN BACKGROUND TASK).

reachoutnagendra
Explorer
0 Kudos

Hi , This is the error 'cannot use commit work during transnational phase.' I was getting. FYI I am asking this question in the context of ABAP RESTful Programming.

As per my understanding we cannot use 'Commit work' in interactive phase, so I have decided to keep the commit work in save sequence.(Save method), still getting the same error. How do I commit the data in this scenario. perhaps andre.fischer could help me on this 🙂

former_member515329
Participant
0 Kudos

Hello sandra.rossi ,

What is the solution for this type of issues :

Even i am able to create a SO in debug mode - but it is not visible in VA03 tcode - if i try to write the commit statement - it is throwing dump.

Without Commit, how can the SO will be saved in database?

Please help.

Sandra_Rossi
Active Contributor
0 Kudos

ravi.kumar183 My comment was not relevant for this RAP question. I suggest that you first try your code separately as a simple test Executable program (type 1) including a COMMIT WORK and see whether it works. If yes, as far as I understand what is said here about RAP, COMMIT WORK should not be present in your code and is done by the RAP framework.

former_member515329
Participant
0 Kudos

Thanks for your reply.

But when will commit happen?

As i need the SO number to be captured after the BAPI call - if i forcefully write commit, then DUMP is occured.

Is there any workaround to get the SO number to be saved in database after the BAPI call.

Accepted Solutions (0)

Answers (7)

Answers (7)

Föß
Active Participant

Hi,

to avoid the COMMIT WORK issue, I used an aRFC function which executes the BAPI (CALL FUNCTION <new_arfc_function> STARTING NEW TASK <task_name> CALLING <method> ON END OF TASK. ... WAIT FOR ASYNCHRONOUS TASKS .... - Also possible is just DESTINATION 'NONE'.

Regards, Föß

umtyzc
Participant
0 Kudos

Thanks Johann, Can you send example code?

nick_giannakis
Explorer

As far as I know the commit will be handled by the framework.

Even in "Save" method you will encounter the message "The command COMMIT is not allowed in a BEHAVIOR class."

Your "save" class is called in context of method "_PROCESS_SAVE_SEQUENCE" from class CL_RAP_TRANSACTION_MANAGER. That method will handle the commit. Of course all these if there are no "failed" entities.

I had a similar issue where I had to call a posting for FI documents. Due to update task usage from std tools, I had to call the FMs in background unit.

Former Member
0 Kudos

Is there a solution here in the meantime? I am currently facing the problem myself and would like to execute a BAPI in a RAP managed scenario.

I would be particularly interested in how exactly the call should take place. Somehow it doesn't seem to work in the same LUW.

piyush_831
Discoverer
0 Kudos

Hello reachoutnagendra,

I am also trying the same thing but I am not able to pass multiple item records from the UI to backend to call the BAPI, can you explain how you achieved this?

Raju
Explorer
0 Kudos

You can create as RFC FM inside of it can write BAPI logic and call as below starting new task & destination as None

CALL FUNCTION 'ZRFC_FM'

STARTING NEW TASK 'UPDATE'

DESTINATION 'NONE'.

0 Kudos

Hi nick.giannakis

Our requirement is also similar,
However, our business object does not get updated via BAPI_TRANSACTION_COMMIT.
We have to use a different COMMIT (diwps_rev_save ) and for this, we need to pass the values from the corresponding method to SAVE( standard method provided by RAP). How do I pass those values in the SAVE method?

Any idea on this?

Regards,

former_member683250
Discoverer
0 Kudos

I have also encountered the same issue. BAPI internally calls a commit work and we have second commit by the framework.

I have updated comments here -

https://blogs.sap.com/2019/05/23/sap-cloud-platform-abap-restful-programming-model-rap-for-beginners...

Here is Runtime Error that we get -

What happened?

Error in the ABAP application program.

The current ABAP program “SAPMV45A” had to be terminated because it found a
statement that could not be executed.

Error analysis

There is probably an error in the program
“SAPMV45A”.
A BEHAVIOR implementation is active for XYZ While this is the case,
the following ABAP statements are illegal:

– COMMIT
– ROLLBACK
– SUBMIT
– CALL TRANSACTION
– LEAVE
all DYNPRO-related statements, such as MESSAGE, CALL DIALOG, and CALL
SCREEN

The following statement is only allowed in the “Save” phase: – CALL
FUNCTION IN UPDATE TASK

Raju
Explorer
0 Kudos

Have u find any solution for this