Skip to Content

Modify ENTITIES in local mode on ABAP Behavior Implementation

Hi, I have been struggling on Creating default id. I already following https://developers.sap.com/tutorials/abap-environment-behavior-action.html#b553cc9d-5349-43ad-bd7a-eb1ecf05188d step 4 on method METHOD calculatetravelkey, on different entity and table.

I have this behavior class

managed implementation in class zbp_i_family_asd unique;

define behavior for ZI_FAMILY_ASD alias Family
persistent table ZFAMILY_ASD
lock master
etag master lastchanged_at
{
...
  create;
  update;
  delete;
...
determination CalculateDefault on modify { create; }
}

And this implement class

  ...
    METHODS CalculateDefault FOR DETERMINATION Family~CalculateDefault
      IMPORTING keys FOR Family.
...
METHOD CalculateDefault.
    Select From zfamily_asd
        FIELDS MAX( family_id ) INTO @DATA(lv_max_familyId).

        lv_max_familyId = lv_max_familyId + 1.
        Loop AT keys INTO DATA(key).
        MODIFY ENTITIES OF ZI_FAMILY_ASD IN LOCAL MODE
            ENTITY Family
            UPDATE SET FIELDS WITH VALUE #( ( family_id = lv_max_familyId ) )
            REPORTED DATA(newData).
        APPEND LINES OF newData-family To reported-family.
        ENDLOOP.
  ENDMETHOD.
...

Output :

  • Change not possible; entity does not exist.
  • FamilyId = 0
Can anyone help me ? Can anyone give links of Modify Entities in local mode's documentation? I can't find it.Thank you!
Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Jun 30 at 10:14 AM

    Hi Mary Franklin,

    Is family_id the key field property in your table ? if yes i guess it will not work. Even i faced the same issue but later found out it works well with non key fields.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.