cancel
Showing results for 
Search instead for 
Did you mean: 

Static factory action for child nodes - no access to parent key?

Liesbeth
Explorer
1,587

Good evening,

I have a question about static factory actions in RAP. In our managed RAP application, we have a root and 1 child node. For the child entity, we want to implement a static factory action with a popup for the barcode and then let the action create the child with the necessary data.

In the behavior definition, we've defined the static factory action ScanBarcode for our child:

 static factory action ScanBarcode parameter ZSD_I_SCL_BARCODE_INPUT [1];<br>

But now, when we want to create the child entity, we don't seem to have access to the parent key? The method only receives 1 parameter: keys. This parameter only contains the %CID of the child entity and %PARAM with the fields of the abstract entity.

    METHODS scanbarcode FOR MODIFY
      IMPORTING keys FOR ACTION sampleloanitem~scanbarcode.

METHOD scanbarcode.

    LOOP AT keys ASSIGNING FIELD-SYMBOL(<fs_instance>).
      MODIFY ENTITY ztest IN LOCAL MODE
      CREATE BY \_Child
      SET FIELDS WITH VALUE #(  (
               %cid_ref = ?????
                 %target = VALUE #(
                  (  %cid = <fs_instance>-%cid
                     Barcode = <fs_instance>-%param-barcode
                     .... ) )
        ))
      FAILED   failed
      REPORTED reported
      MAPPED mapped.
    ENDLOOP.

ENDMETHOD.
<br>

Is there a way to get the key of the parent entity, so that we can link this child to the right parent?

What am I doing wrong or are static factory actions not supported for child entities?

Accepted Solutions (0)

Answers (6)

Answers (6)

Hi Liesbeth,

I'm got a similar scenario here. Were you able to find a workaround for this?

I thought of placing this action at parent entity instead and refreshing the association with a side effect, but then I'm unable to find ways to put the button on the right spot (alongside with the child table).

hill-wei
Employee
Employee
0 Kudos

Hi Liesbeth,

Have you solve the problem.

Jens_Busse
Discoverer
0 Kudos

Hi,

i usually use a action on parent level to create childs:

at defining Behavior definition:

action ( features : instance ) AddProject parameter ZDIAMOND_I_INPUT_ADDPROJECT result [1] entity ZDIAMOND_I_PROJECT_M;

on Projection Behavior Definition:

use action AddProject result entity ZDIAMOND_C_PARTNER_PROJECT_M;

I hope it helps.

best regards

baiba_blumberga62
Discoverer
0 Kudos

Hi!

Thank you for Hint.

Could please give some more details? How you implement action? And how you get action button on item level within Object page? Do you call from one action another action?

baiba_blumberga62
Discoverer
0 Kudos

Hi,

Has anyone found solution for this? Maybe we are trying wrong approach? Does someone know how to make child entity with action (pre-field data), not with create and user input? andre.fischer maybe you could help us out what would be correct aprouch for this scenariou?

suzanne_alivand
Explorer
0 Kudos

Hi,
I have the same issue, did you find any ansewr for that?

Liesbeth
Explorer
0 Kudos

No, I'm afraid not.

Ramjee_korada
Active Contributor
0 Kudos

Hi

You can use Read by association to get information about parent node.

" Read all parent UUIDs

READ ENTITIES OF /DMO/R_Travel_D IN LOCAL MODE

ENTITY Booking BY \_Travel

FIELDS ( TravelUUID )

WITH CORRESPONDING #( keys )

RESULT DATA(travels).

Best wishes

Ramjee Korada

Liesbeth
Explorer
0 Kudos

Hi Ramjee,

Thank you for your reply.

I did try this, but unforturnately the keys parameter only contains the %CID of the child entity. So this read does not find anything.

Best regards

Liesbeth