cancel
Showing results for 
Search instead for 
Did you mean: 

RAP: Side Effect for child entity table

lars_kr
Participant
285

Hello Community,

So far, I have only ever applied side effects to individual fields. But can they also be used to create entire entities in child tables?

My Example:

sideeffect.PNG

In this example, I have a field of a root entity in the creation process. If something is entered in this field using the value help, for example. The table below (child entity) should be filled out. There may be several items that need to be entered here. Normally, of course, the user should click on the Create button and create the child entity themselves, but sometimes there is already data in the SAP system with which the table can be filled. 

regards,

Lars

 

UPDATE:

In the meantime, I came across this blog entry LINK which apparently had the same problem. Unfortunately, I am missing a few things to solve my problem.

I also get the correct lines from the database. Andre Fischer suggests the following solution there:

 

 

 

 

DATA create_nodes TYPE TABLE FOR CREATE ZDMO_R_RAPG_ProjectTP\_Node.  

MODIFY ENTITIES OF ZDMO_R_RAPG_ProjectTP IN LOCAL MODE               
ENTITY Node UPDATE FIELDS ( ) WITH update               
ENTITY Project CREATE BY \_Node FIELDS (  ) WITH create_nodes        
MAPPED  mapped        
FAILED  failed        
REPORTED reported.

 

 

 

Unfortunately, I am not an ABAP expert, so I am not yet fully aware of what the specification “WITH update” does here.

And what would be the correct specification of the side effect in the behavior definition?

 

 

 

side effects {
field Benutzername affects entity _ChildEntity;
}

 

 

 

Would this information be sufficient to trigger the side effect?

UPDATE 2:

I have implemented something that probably corresponds to the solution proposed by Andre Fischer. But I get an error message.

 

 

  DATA: lt_create_child TYPE TABLE FOR CREATE zi_antrag\_child.

  READ ENTITIES OF zi_antrag IN LOCAL MODE
         ENTITY antrag
             FIELDS ( Uuid User ) WITH CORRESPONDING #( keys )
     RESULT DATA(root).

  READ TABLE root INTO DATA(roots) INDEX 1.

  SELECT AGR_NAME FROM agr_users
    WHERE UNAME = -User
    INTO TABLE (roles).

  LOOP AT roles ASSIGNING FIELD-SYMBOL(<fs_roles>).

   lt_create_child = VALUE #( ( %cid_ref             = 'My%CID_1'
                                %is_draft            = if_abap_behv=>mk-on
                                %target = VALUE #( (
                                                      %cid  ='My%ItemCID_1'
                                                      Role = <fs_roles>-agr_name ) ) ) ).

   MODIFY ENTITIES OF zi_antrag IN LOCAL MODE
      ENTITY antrag CREATE BY \_child
          FIELDS ( Role ) with lt_create_child
    MAPPED DATA(ls_mapped)
    FAILED DATA(ls_failed)
    REPORTED DATA(ls_reported).

  ENDLOOP.

 

 

 

View Entire Topic
SerhiiMartynkov
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

Can you share the content of ls_reported? It should contain the info about which entity is failing and for what reason. Please tell more about this error of yours.

BR, Serhii.