cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Can we fill child entity in ( RAP APP ) before create the new object ?

amo_ry
Participant
0 Likes
3,680

I tried to insert a record in the ( draft table and the persistent ) of the child entity while calling the 'early Numbering' function 

but it did not work . 

My Requirement is to show the approvers of the request while creating it . 

amo_ry_0-1707871781758.png

Can any one help ? 

 

Accepted Solutions (0)

Answers (2)

Answers (2)

Mikhail_Minakov
Explorer
0 Likes

You can use determination on modify ( create; ), it will be called directly after the root record will be created and create the initial child records (approvals) from there:

 

determination setInitialApprovals on modify { create; }

  METHOD setInitialApprovals.
    READ ENTITIES OF ZI_ONCALL_ROOT IN LOCAL MODE
         ENTITY ONCALL
         FIELDS ( guid ) WITH CORRESPONDING #( keys )
         RESULT DATA(lt_oncall).
    LOOP AT lt_oncall ASSIGNING FIELD-SYMBOL(<fs_oncall>).
	MODIFY ENTITIES OF ZI_ONCALL_ROOT IN LOCAL MODE
       ENTITY ONCALL
       CREATE BY \_Approvers
                FROM VALUE #( ( %key = <fs_oncall>-%key
				%target = VALUE #( ( %cid = 'CID_DUMMY'
				                UserName = 'USER01'
                                %control-UserName = if_abap_behv=>mk-on
                                ApprovalName = 'Jon Doe'													 
                                %control-ApprovalName = if_abap_behv=>mk-on ) ) ) )
       MAPPED DATA(lt_mapped)
       FAILED DATA(lt_failed)
       REPORTED DATA(lt_reported).
	ENDLOOP.
  ENDMETHOD.

 

Side Effects are supported in S4/HANA onPremise depending of the version in backend and frontend.

Frontend Side Effects are supported anyway, you can make them as following:

 

      <Annotation Term="Common.SideEffects" Qualifier="Entity_Approvers">
        <Record Type="Common.SideEffectsType">
            <PropertyValue Property="SourceProperties">
                <Collection>
                    <PropertyPath>Status</PropertyPath>
                </Collection>
            </PropertyValue>
            <PropertyValue Property="TargetEntities">
                <Collection>
                    <NavigationPropertyPath>_Approvers</NavigationPropertyPath>
                </Collection>
            </PropertyValue>        
        </Record>
    </Annotation> 

 

The _Approvals data will be refreshed when the value of field "Status" is changed.

You can set the Status field value (or any other field) in the same determination to trigger side effects.

amo_ry
Participant
0 Likes

Hi Mikhail_Minakov ,

Thank you very much . 

I face a problem when i click on Create button which in failed  : 

amo_ry_0-1708966323864.png

but when click on save every thing is good . 

 

0 Likes
@Mikhail_Minakov I have a similar requirement. When create button at Root is clicked, child records should be created and shown on UI. My determination works fine, creates entries in child tables. However, nothing is shown on the UI. What am I missing?
Mikhail_Minakov
Explorer
0 Likes

What exactly did not work by creating child records in draft?

Did you create them using EML create by association?

Actually on your screenshot the object is already created in draft so there should be no problem to create child records on this step.

amo_ry
Participant
0 Likes

Yes, you're right

But i need to show the approvers of the request while clicking on the Create button  . 

I think it will be achieved by the Side Effects feature  but it is not working on the SAP S/4HANA on-premise system .