cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Calling BAPI in RAP Action - managed scenario - BEHAVIOR_ILLEGAL_STATEMENT

0 Likes
12,959

Hi Experts,

We are using RAP managed scenario which performs CRUD on a custom table which is working fine. Also, we have added a custom action to perform Goods movement 101. For which, I want to call BAPI_GOODSMVT_CREATE.


How can I achieve this ?

I tried below options:

1. ) Calling BAPI directly in Action

2. ) Calling a wrapper FM in update task

both are failing with dump BEHAVIOR_ILLEGAL_STATEMENT.

Accepted Solutions (1)

Accepted Solutions (1)

Andre_Fischer
Product and Topic Expert
Product and Topic Expert

I don't see an issue with this. It's the workaround that is available.

In future releases we will offer the option to perform asynchronous calls using a wrapper that we (SAP) will provide for the bgrfc framwork.

In general the problem with using features such as calling a function moduel using destination 'NONE' is that this "breaks" the logical unit of work.

So it can happen that the changes performed by your remote call are committed while the changes in the calling implementation fail late an something like a dump occurs.

Yes Andre, Thanks for explaining it perfectly as always !!! For me it works fine as we are not calling the RFC on 'SAVE' but on an Action Button. We want to just perform an action while major part is to save data that is already performed and after that only this Action is enabled using feature control. So this is an independent event which can not break my SAVE implementation.

My query is answered.

rammel_sapdev
Participant
0 Likes
Hi Andre, what is the better approach here? We are having a similar issue where we have a custom fiori app that post goods movement using the released RAP BO I_MATERIALDOCUMENTTP. I have created my fiori app using MANAGED with UNMANAGED SAVE. Within the SAVE_MODIFIED, I am trying to create the goods movement but only to realize that this is not allowed. I tried adding the code in the custom determinations but I still think that the code shouldn't be there and should be in the SAVE_MODIFIED. So now, I am looking for ways on how to bundle the updates within the calling RAP BO and the standard RAP BO updates. So far, my options points me to either using CALL RFC DESTINATION NONE and the bgpf framework. In both cases, I want to pass the calling RAP BO data so that I can bundle the updates from within the RFC/class method implementation. Is this the proper way of doing it?

Answers (2)

Answers (2)

Andre_Fischer
Product and Topic Expert
Product and Topic Expert

The BAPI has to be called in the save_modified method of the save sequence, not in the interaction phase.

So you have to change your behavior definition so that your RAP BO supports an unmanged save

define behavior for /DMO/I_BookSuppl_M alias booksuppl
implementation in class /DMO/BP_BOOKINGSUPPLEMENT_M unique
persistent table /DMO/BOOKSUPPL_M
with unmanaged save

as described here in the documentation

Integrating Unmanaged Save in Managed Business Objects | SAP Help Portal

matiasmiano1982
Explorer
0 Likes

Hi Andre,I set the code as you explained, but a dump is appearing while calling a BAPI inside SAVE_MODIFIED method.

I need to modify a field from LFA1 using a BAPI and executing a COMMIT WORK, but it seems that it's not working:

CALL METHOD lo_vmd_ei_api->maintain_bapi

EXPORTING

is_master_data = l_ti_is_master_data

iv_collect_messages = 'X'

IMPORTING

es_master_data_correct = lv_a

es_message_correct = lv_b

es_master_data_defective = lv_c

es_message_defective = lv_d.

IF lv_d-is_error IS INITIAL AND

lv_d-messages[] IS INITIAL.

"CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

APPEND VALUE #( %tky = lv_lifnr

%msg = new_message( id = 'ZRAP'

number = '000'

v1 = lv_lifnr

severity = if_abap_behv_message=>severity-success )

) TO reported-proveedor.

ELSE.

"CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

ENDIF.

S0025160864
Explorer
0 Likes

can we call commit in unamanged save

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Likes

If you need to perform a commit (please double-check if this is really necessary) you have to do this asynchronously in a separate session. E.g. by using the new background processing framework that is availble in SAP BTP ABAP Environement and as of 2023 on premise as well.

Introducing the Background Processing Framework | SAP Blogs

vrishtijain
Explorer
0 Likes

Hi Andre

I have done the changes in behavior definition and now can see save modified method in my implementation class.

But the keys field(i.e) the input payload is only available in the Action method. (I am creating Inbound Service to be consumed by integration suite)

Is there any way to use BAPI 'BAPI_GOODSMVT_CREATE' in Action method. If not how can pass my payload to the save modified method and also the result as output.

Thanks in advance

0 Likes

Hi Andre,

First of all thanks for your reply and sorry for replying this late, I was really tied up with some other work and I had found a workaround by calling the BAPI as RFC with DESTINATION 'NONE' and it is working fine within the Action code.

Do you see any issue with this ?

Regards.

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Likes

I converted your comment to an answer since it solved your problem.

You can accept it if you agree.

And you can upvote my answers as well if these have been helpful.

Thank you very much and best regards,

Andre

rammel_sapdev
Participant
0 Likes
Hi @Andre_Fischer, also is calling a custom RFC with DESTINATION NONE considered as Tier 1 and upgrade safe?