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

How to get the mapped fieldnames from a result value in an action method?

handri_gunawan
Explorer
0 Likes
592

Hi,

I try to read the actual entity with the following EML:

READ ENTITIES OF zrap_a_sales IN LOCAL MODE
      ENTITY zsaleshd
      ALL FIELDS WITH
     CORRESPONDING #( keys )
     RESULT DATA(lt_zsales).

The signature of the method:

checkdataset FOR MODIFY
     IMPORTING keys FOR ACTION zsaleshd~checkdataset RESULT result.

In "lt_zsales" I got the correct values, but not the mapped field names. I tried already all combinations of "MAPPING FROM ENTITY" but nothing works until yet.

In "lt_zsales" I got the following result:

handri_gunawan_0-1741340649054.png

What I need is the field names from the legacy structure (i.e. document_date, dist_channel, etc). Mapping is already defined in the behaviour definition:

handri_gunawan_1-1741340749546.png

Thank's for any hints!

Accepted Solutions (1)

Accepted Solutions (1)

patrick_winkler
Product and Topic Expert
Product and Topic Expert
0 Likes

 

    READ ENTITY IN LOCAL MODE zi_cubco6
      ALL FIELDS WITH CORRESPONDING #( keys )
      RESULT DATA(cubco6_entities).

    DATA table_data TYPE TABLE OF zcubcot6 WITH EMPTY KEY.
    table_data = CORRESPONDING #( cubco6_entities MAPPING FROM ENTITY ).

 

Prerequisites: in the BDEF of entity zi_cubco6 there is a "mapping for zcubcot6"
See also https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abapeml_corresponding.htm

handri_gunawan
Explorer
0 Likes

The following coding leads to error:

handri_gunawan_0-1741343718204.png

handri_gunawan_1-1741343758763.png

The following coding in the method SAVE_MODIFIED works.

      DATA: lt_zsalehd TYPE TABLE OF /pt4/s_zsalehd.

      lt_zsalehd = CORRESPONDING #( create-zsaleshd MAPPING FROM ENTITY ).

patrick_winkler
Product and Topic Expert
Product and Topic Expert
0 Likes

@handri_gunawanI cannot explain the error message "No mapping is defined...". If the mapping from the create structure is fine you can try to create a variable like "DATA change TYPE REQUEST FOR CHANGE ZI_Header_S." and then first move the data from the read structure to the change structure with corresponding #( ) and then move the data from the change structure to the table.

handri_gunawan
Explorer
0 Likes
It works for me now, many thanks! But I don't understand why we should use this workaround with CHANGE structure.

Answers (0)