cancel
Showing results for 
Search instead for 
Did you mean: 

RAP Action: The command "COMMIT-ENTITIES" is not allowed in a BEHAVIOR class

jheisler
Explorer
0 Kudos
2,330

I have a business use case in which an enduser selects one or more sales orders in a custom app and presses an action to allocate them to another department.

In this allocation process the selected sales orders need to be modified in the backend.

My backend is a RAP-based OData v2 service with an action to allocate the sales orders an modify them:

 

action AfterSalesAllocate result [1..*] $self;

 

In my action implementation i am modifying the sales orders via EML and trying to commit the changes:

 

LOOP AT lt_aggr_ic_so ASSIGNING <ls_aggr_ic_so>.
            MODIFY ENTITIES OF r_salesordertp
                   ENTITY salesorderitem
                   EXECUTE removebillingblock
                   FROM VALUE #( ( %key-salesorder     = <ls_aggr_ic_so>-receivingreturnorder
                                   %key-salesorderitem = <ls_aggr_ic_so>-receivingreturnitem ) )
                   " TODO: variable is assigned but never used (ABAP cleaner)
                   FAILED   DATA(ls_failed_removebillingblock)
                   " TODO: variable is assigned but never used (ABAP cleaner)
                   REPORTED DATA(ls_reported_removebillingblock).

            MODIFY ENTITIES OF r_salesordertp
                   ENTITY salesorderitem
                   UPDATE
                   FIELDS ( requestedquantity )
                   WITH VALUE #( ( requestedquantity   = <ls_aggr_ic_so>-quantity
                                   %key-salesorder     = <ls_aggr_ic_so>-receivingreturnorder
                                   %key-salesorderitem = <ls_aggr_ic_so>-receivingreturnitem ) )
                   " TODO: variable is assigned but never used (ABAP cleaner)
                   FAILED   DATA(ls_failed_update)
                   " TODO: variable is assigned but never used (ABAP cleaner)
                   REPORTED DATA(ls_reported_update).

            COMMIT ENTITIES
                   RESPONSE OF i_salesordertp
                     " TODO: variable is assigned but never used (ABAP cleaner)
                   FAILED   DATA(ls_save_failed)
                   " TODO: variable is assigned but never used (ABAP cleaner)
                   REPORTED DATA(ls_save_reported).
          ENDLOOP.

 

But unfortunately i am receiving the error "The command "COMMIT-ENTITIES" is not allowed in a BEHAVIOR class." when activating and i don´t get why.

Aren´t actions meant to be able to modify its entities objects? Is there any workaround someone can suggest?

View Entire Topic
junwu
SAP Champion
SAP Champion
0 Kudos

you are allow to make change in action, but it doesn't mean you have to use COMMIT-ENTITIES to persist the change.

just remove it.

Priya_Saindhavi22
Discoverer
0 Kudos
Hi, You can use cl_abap_behaviour_saver_failed implementation to get failed records.