cancel
Showing results for 
Search instead for 
Did you mean: 

behavior_illegal_statement in ABAP RAP

AbhishekSharma
Active Contributor
0 Kudos
6,702

Hello,

I am trying to use RAP un-Managed scenario. I have created custom FM and inside which I am calling standard FM like below.

CALL FUNCTION '/SCWM/TO_CREATE'
EXPORTING
iv_lgnum = 'ABCD'
iv_update_task = abap_false
iv_commit_work = abap_false
it_create = lt_create
IMPORTING
et_ltap_vb = lt_ltap_vb
et_bapiret = lt_return
ev_severity = ev_severity.
IF ev_severity CA wmegc_severity_eax.
EV_SEVERITY = 'E'.
* ROLLBACK WORK.
ELSE.
EV_SEVERITY = 'S'.
* COMMIT WORK AND WAIT.
* /scwm/cl_tm=>cleanup( ).
ENDIF. SPAN { font-family: "Courier New"; font-size: 16pt; color: #000000; background: #FFFFFF; }.L0S31 { font-style: italic; color: #808080; }.L0S33 { color: #4DA619; }.L0S52 { color: #0000FF; }.L0S55 { color: #800080; }

I am passing

iv_update_task = abap_false

iv_commit_work = abap_false

But its still failing on below statement

My question is how we can use standard Function Module which has Update Task and Commit work inside of standard FM ?

ramjee.korada

@pavankumarjagadeesh89

pavankumarjagadeesh89

Thanks-

Abhishek

Accepted Solutions (1)

Accepted Solutions (1)

sagarprusty1988
Explorer

RAP framework doesn't allow external COMMIT WORK. So you are getting the runtime error.

You are also writing the LOG using the FM which also use the COMMIT WORK.

For this kind of requirement where you need to use standard API. Create a wrapper RFC FM with the runtime data and call on background task so that another LUW will be started. ( This should be done in the save method ) in the implementation.

You can do whatever you want in that function module.

You can go for enabling the notification service which can be linked to the application log you are updating.

This will be a asynchronous solution. So once transaction is completed, the notification should be populated.

Notification service Link.

Thanks

Sagar Prusty

Answers (3)

Answers (3)

j_pavan_kumar
Product and Topic Expert
Product and Topic Expert

Hi Abhishek,

Usage of COMMIT WORK / ROLLBACK WORK statements will cause the runtime error as RAP framework only manages it and also the update task or background task can be called in the late-save phase only.

Ideally it would be better to validate in check before save and then call the update task FM in the save method of the RAP handler class in case of unmanaged RAP BO and also in case of Managed implementation with unmanaged save.

Please go through the below blogs for more details.

https://blogs.sap.com/2022/11/30/using-bapis-in-rap/

https://blogs.sap.com/2022/12/05/the-sap-luw-in-abap-cloud/#_ftn4

Thanks,

Pavan

AbhishekSharma
Active Contributor
0 Kudos

Hi pavankumarjagadeesh89 and sagarprusty1

Thanks much for your quick guidance... based on suggestion I have updated code and now FM called in Create method executes but I am still getting Same error in Save Method...

On Save method I have called another FM which only has COMMIT_WORK.

Please see below Images for reference. Please guide me how to resolve this, If you have any demo code (NOT Airlines example code used by SAP in DEMO application) that would really Help me...

Custom FM called (made IT RFC enabled)

SAVE method

CLASS lsc_ziewm_openwt IMPLEMENTATION.<br>  METHOD finalize.<br>  ENDMETHOD.<br>  METHOD check_before_save.<br>  ENDMETHOD.<br>  METHOD save.<br>    CALL FUNCTION 'ZEWM_HUWT_SAVE'.<br>  ENDMETHOD.<br>  METHOD cleanup.<br>    CALL FUNCTION 'ZEWM_HUWT_CLEANUP'.<br>  ENDMETHOD.<br>  METHOD cleanup_finalize.<br>  ENDMETHOD.<br>ENDCLASS.

koradaramjee789 ramjee.korada marcel.hermanns

Please help...

Thanks-

Abhishek

Andre_Fischer
Product and Topic Expert
Product and Topic Expert

Hi Abishek,

you should try to use the new released API's that are available to handle the application log.

Classes and Interfaces of the Application Log API | SAP Help Portal

These are also released to be used in ABAP for Cloud Development in SAP BTP, ABAP Environment and SAP S/4HANA, ABAP Environment.

I have used this in my class that shows how to schedule an application job from within RAP. There the application job is configured to use a certain application log object.

abap-platform-application-jobs/zapp_cl_demo_01.clas.abap at main · SAP-samples/abap-platform-applica...

Kind regards,

Andre

AbhishekSharma
Active Contributor
0 Kudos

Thanks much andre.fischer for helping me...

I am able to Save record in Un-Managed scenario thanks to pavankumarjagadeesh89 and sagarprusty1

I am getting success message displayed correctly... Now I am facing Issue in case of Failed scenario, Error message is not getting displayed, though I have filled Failed and Reported structures..

My scenario is Error messages are coming from standard FM in LT_BAPIRET parameter... and when this fails I didn't get any value of Key field. and so Dump is happening... Please have a look to below Images for reference.

Dump I am getting

my code (I know its not clean and well written)

Please help...

Thanks-

Abhishek

AleGuarneri
Explorer
0 Kudos

abhi.sharma05 I'm dealing with something very similar, using standard BAL classes and getting the same error.

Have you fixed this?

BR

Alex

AbhishekSharma
Active Contributor
0 Kudos

Hi a.guarneri

Based on my experience (assuming unmanaged) this is happening because somewhere in code (standard/custom) COMMIT is getting triggered.

RAP does not allow COMMIT statement, the solution whish was suggested is to use FM or code in new LUW by using DESTINATION = NONE

RAP takes care of all COMMIT during SAVE sequence.

Just to share I have heard from latest Teched , there are planned w.r.t asynchronous call for this kind of scenarios.

Hope this helps...

Thanks-

Abhishek