ABAP Forum
cancel
Turn on suggestions
Showing results for
Search instead for
Did you mean:
The next set of progression badges have been announced! Let's Discuss!
Read only

Is it possible to MODIFY a custom table using EML in RAP app for the following scenario?

gilberto_parga
Participant

‎2025 Oct 02 6:00 AM

0 Kudos
1,178

Hi experts,

I have tried to MODIFY a custom table by using an ABAP RAP development exposed as Web API via EML, but no luck. I am using Eclipse ADT. There are some restrictions that are not allowing me to accomplish this simple thing:

1. Many records of such table must be sent and accepted in a single POST method, and
2. No RFC or external ABAP class methods should be called to modify the custom table.

To do this I utilized the technique of dummy root custom entity with dummy key field I found on a scribd document, along the child item that actually represents the fields of the database table to be modified:

@EndUserText.label: 'Header Entity'
define root custom entity ZSAC_R_HEADER
{ 
key Dummy : abap.char(10);
_Item : composition [1..*] of ZSAC_I_ITEM; 
}

Child structure with table fields (2 table fields besides dummy key only to set up simplest example scenario):

@EndUserText.label: 'Item Entity'
define custom entity ZSAC_I_ITEM
{
key Dummy : abap.char(10);
key mlc : abap.char(3);
werks : werks_d;
_Header : association to parent ZSAC_R_HEADER on $projection.Dummy = _Header.Dummy;
}

I did not create projection view. Immediate creation of behavior definition was possible:

unmanaged implementation in class zbp_sac_r_header unique;
strict ( 2 ); 
define behavior for ZSAC_R_HEADER //alias <alias_name>
lock master
authorization master ( instance )
{
create;
update;
delete;
field ( readonly : update ) dummy;
association _Item {create;}
}
define behavior for zsac_i_item
lock dependent by _Header
authorization dependent by _Header
{
update;
delete;
field ( readonly ) Dummy, mlc;
association _Header;
}

After creating the behavior implementation class and creating the local class inherited from cl_abap_behavior_handler, I defined
another local class just to save information and declare auxiliar class references

CLASS lcl_hold_data DEFINITION.
 PUBLIC SECTION.
 CLASS-DATA lo_process TYPE REF TO zcl_my_process_modify_class.
 CLASS-DATA lt_data TYPE Z_MY_TABLE_TYPE.
 CLASS-DATA lt_return TYPE zcl_my_process_modify_class=>gtt_return.
ENDCLASS.

All good so far, I implemented logic into method cba_item:

DATA: lt_final TYPE STANDARD TABLE OF z_my_table.
 DATA: ls_upd_table TYPE z_my_table_structure. //Structure with simple data definitions as ZSAC_I_ITEM
 TRY.
 lt_final = CORRESPONDING #( entities_cba[ 1 ]-%target
 MAPPING 
 mlc = mlc
 werks = werks ).
 CATCH cx_sy_itab_line_not_found.
 ENDTRY.

That is the point I don't know how to proceed. I have all records I require from the JSON payload in the table lt_final, all info that
could be inserted or updated using a very simple classical MODIFY sentence over Z_MY_TABLE but I understand I cannot use explicit MODIFY
sentence here, and what I was doing is to use my processing class this way after aforementioned code in same cba_item method:

lcl_hold_data=>lo_process = NEW zcl_my_process_modify_class( ).
lcl_hold_data=>lt_data = CORRESPONDING #( lt_final ).
IF lt_final IS NOT INITIAL.
 lcl_hold_data=>lo_process->my_modifying_method( IMPORTING et_return = lcl_hold_data=>lt_return
 CHANGING ct_request = lcl_hold_data=>lt_data ).
ENDIF.

MY_MODIFYING_METHOD creates an instance of a wrapper class that calls a method which calls and RFC to finally MODIFY my
table. That way I am free to manipulate the data and do validations and changes as I want, even I can delete records, all in a single
POST. Problem is my customer disapprove this mechanism and they want me to modify/update the Z_MY_TABLE using only EML
inside the RAP object behavior implementation class. Do you have ideas about how to do this? Remember I use the dummy key
structure to accept many records in a single POST. BTW I define my service as follows

@EndUserText.label: 'Service definition'
define service Zsac_sd_header {
expose ZSAC_R_HEADER as Header;
expose ZSAC_I_ITEM as item;
}

And I defined service binding as OData v2 Web API, it could be also OData v4. But problem remains, I dont know how to change my
Z_CUSTOM_TABLE using only EML as I did not define any root entity selecting from such custom table because that avoids me to
receive many records at one POST time. Please help me with any ideas you have, preferably describe them as much as possible. Hint: this is the payload example:
{
"Dummy" : "0",
"to_Item" : [
{
"mlc" : "111",
"werks" : "1111"
},
{
"mlc" : "222",
"werks" : "2222"
}
]
}

Labels
1 ACCEPTED SOLUTION
Read only

junwu
SAP Champion
SAP Champion

‎2025 Oct 02 3:33 PM

1,103

you should model a proper BO for your z table.

consumer can send request in batch for update

if they want to send bulk data in json, you can define a action to receive those data and then do the modify.

1 REPLY 1
Read only

junwu
SAP Champion
SAP Champion

‎2025 Oct 02 3:33 PM

1,104

you should model a proper BO for your z table.

consumer can send request in batch for update

if they want to send bulk data in json, you can define a action to receive those data and then do the modify.

AltStyle によって変換されたページ (->オリジナル) /