on 2024 Oct 05 1:21 PM
Hi All,
I am working on RAP Application where it consists of a Parent Entity with 3 child entities.
The Application is Managed with Late numbering.
I added a Action button at Child entity that it should create an entry/entries depends on inputs of action button pop-up.
When Purchase Order and/or Purchase item input is given, child entities are to be created and added at line item.
In Root view behavior, action is defined as
static factory action getPurc parameter YINV_COPY_PO [1];
For action button input, created an Abstract entity YINV_COPY_PO
@EndUserText.label: 'Copy PO Abstract entity'
define abstract entity YINV_COPY_PO
{
@Consumption.valueHelpDefinition: [{ entity: { name: 'I_PurchaseOrder', element: 'PurchaseOrder' } }]
ebeln : ebeln;
ebelp : ebelp;
}
yi_rbkp is parent entity with belnr, gjahr as key fields whereas yi_rseg is child entity with key fields as belnr,gjahr,buzei. The child entities have to be created based on ebeln and ebelp as these are not dependent of the Parent entity key fields.
The below method logic could be incorrect and it ends up in below runtime error.
Method logic in Behavior
METHOD getPurc.
DATA lt_item TYPE TABLE FOR CREATE yi_rbkp\\yi_rbkp\_itm.
DATA(ls_param) = VALUE #( keys[ 1 ]-%param OPTIONAL ).
IF ls_param-ebelp IS INITIAL.
SELECT * FROM
ekpo INTO TABLE
@DATA(lt_ekpo)
WHERE ebeln = @LS_param-ebeln.
ELSEIF ls_param-ebeln IS NOT INITIAL AND ls_param-ebelp IS NOT INITIAL.
SELECT * FROM
ekpo INTO TABLE
@LT_ekpo
WHERE ebeln = @LS_param-ebeln
AND ebelp = @LS_param-ebelp.
ELSEIF ls_param IS INITIAL.
EXIT.
ENDIF.
READ ENTITIES OF yi_rbkp IN LOCAL MODE
ENTITY yi_rseg BY \_hdr
ALL FIELDS
WITH CORRESPONDING #( keys )
RESULT DATA(lt_rbkp).
LOOP AT keys ASSIGNING FIELD-SYMBOL(<key>).
APPEND INITIAL LINE TO lt_item ASSIGNING FIELD-SYMBOL(<item>).
<item>-%cid_ref = <key>-%cid.
<item>-%is_draft = <key>-%param-%is_draft.
LOOP AT lt_ekpo ASSIGNING FIELD-SYMBOL(<ekpo>).
APPEND INITIAL LINE TO <item>-%target ASSIGNING FIELD-SYMBOL(<targ>).
<targ>-%data = CORRESPONDING #( <ekpo> ).
<targ>-%cid = <key>-%cid.
<targ>-%is_draft = '01'.
<targ>-%control-ebeln = if_abap_behv=>mk-on.
<targ>-%control-ebelp = if_abap_behv=>mk-on.
<targ>-%control-gjahr = if_abap_behv=>mk-on.
<targ>-%control-matnr = if_abap_behv=>mk-on.
<targ>-%control-menge = if_abap_behv=>mk-on.
<targ>-%control-shkzg = if_abap_behv=>mk-on.
<targ>-%control-waers = if_abap_behv=>mk-on.
<targ>-%control-werks = if_abap_behv=>mk-on.
<targ>-%control-wrbtr = if_abap_behv=>mk-on.
<targ>-%control-zekkn = if_abap_behv=>mk-on.
ENDLOOP.
ENDLOOP.
MODIFY ENTITIES of yi_rbkp IN LOCAL MODE
ENTITY yi_rseg
CREATE BY \_itm
AUTO FILL CID
FROM lt_item
MAPPED DATA(ls_mapped)
FAILED DATA(ls_failed_modify)
REPORTED DATA(ls_reported_modify).
IF ls_failed_modify IS NOT INITIAL.
failed = ls_failed_modify.
reported = ls_reported_modify.
RETURN.
ENDIF.
mapped-yi_rseg = ls_mapped-yi_rseg.
ENDMETHOD.
Runtime error
Request clarification before answering.
The Dump clearly indicates that there is reference error . Which means you are trying to assign a field using the field symbols which is not existing in the original internal structure of the RAP object.
Please check the RAP Object Fields and in your code map them to the correct field names of the structure.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you @Kangkana. I will correct it . Can you also please check if Modify entities is a valid syntax. Since the scenario is to create child entity independent of Parent entity and I am getting error that create child entity is not possible.
Thank you @Kangkana. I will correct it . Can you also please check if Modify entities is a valid syntax. Since the scenario is to create child entity independent of Parent entity and I am getting error that create child entity is not possible.
User | Count |
---|---|
75 | |
30 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.