cancel
Showing results for 
Search instead for 
Did you mean: 

BEHAVIOR_STATEMENT_ILLEGAL error using EML for entity I_ServiceOrderTP

TajShaik
Discoverer
0 Kudos
212

 While using RAP EML to update the startdatetime of a service order, I encountered the following ABAP runtime error: 

Help me understand why am I getting this error.

Short Text:
Statement "MODIFY ENTITIES" is not allowed with this status.

Runtime Error:
BEHAVIOR_STATEMENT_ILLEGAL

Program:
CL_IRES_RESERVATION===========CP

Application Component:
MM-IM-RS


Scenario and Code Overview:

I have developed a managed RAP application for stock transfer. Within this application, I have implemented an Action to handle stock transfer, and inside the action method of the behavior implementation class, I am invoking the API API_MATERIAL_DOCUMENT_SRV.

Everything works fine up to this point. However, after successfully creating the material document, there is a requirement to update the start date of the service order. To achieve this, I attempted to use EML (Entity Manipulation Language) to update the requestedservicestartdatetime field.

Unfortunately, this results in a BEHAVIOR_STATEMENT_ILLEGAL error.


Code Snippet:

Inside the action method, the public API is called to create a material document:

** Call public API for warehouse-managed scenario
public_api_post( EXPORTING is_param = ls_param
it_items = lt_items
it_srnobin = lt_srnobin
it_issueqty = lt_issueqty
it_srnoprofile = lt_srnoprofile
IMPORTING ev_get_resp_stat = DATA(lv_get_resp_stat)
ev_get_resp_text = DATA(lv_get_resp_text)
ev_post_resp_stat = DATA(lv_post_resp_stat)
ev_post_resp_text = DATA(lv_post_resp_text)
ev_exception_msg = DATA(lv_exception_msg) ).

IF lv_post_resp_stat-code = '201' OR lv_post_resp_stat-code = '200'.

** Fetch the requested service start date based on service order
SELECT SINGLE requestedservicestartdatetime FROM i_serviceordertp
WHERE serviceorder = @iv_serviceorder INTO @DATA(lv_startdate).

** Add 60 seconds (1 minute) to the start time
CALL METHOD cl_abap_tstmp=>add
EXPORTING
tstmp = lv_startdate
secs = 60
RECEIVING
r_tstmp = lv_startdate.

** Attempt to update the service order with the new start date
MODIFY ENTITIES OF i_serviceordertp FORWARDING PRIVILEGED
ENTITY serviceorder
UPDATE FIELDS ( requestedservicestartdatetime )
WITH VALUE #( ( serviceorder = iv_serviceorder
requestedservicestartdatetime = lv_startdate
* %control = VALUE #( requestedservicestartdatetime = cl_abap_behv=>flag_changed )
) )
FAILED DATA(lt_failed_modify)
MAPPED DATA(lt_mapped_modify)
REPORTED DATA(lt_reported_modify).

ENDIF.

 

Runtime Error Details:

The ABAP program "CL_IRES_RESERVATION===========CP" terminated due to an invalid statement execution.

Error Analysis:

  • The statement "MODIFY ENTITIES" is only permitted in specific phases of RAP behavior execution.
  • The execution is currently in the "SAVE" phase, where modifying data using MODIFY ENTITIES is not allowed.
  • The error message confirms that EML statements like "MODIFY ENTITY" and "COMMIT ENTITY" are not permitted in certain contexts, including:
    • UPDATE TASK processing
    • PERFORM ON COMMIT
    • PERFORM ON ROLLBACK
    • Event handlers for COMMIT WORK and ROLLBACK WORK

      Termination Point:

      • Program: CL_IRES_RESERVATION===========CP
      • Include: CL_IRES_RESERVATION===========CM00K
      • Line Number: 15

         

Accepted Solutions (0)

Answers (0)