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

can I use CORRESPONDING # for deep internal tables?

sh4il3sh
Participant
0 Kudos
332

as of now I am doing the value assignment using FOR LOOP as shown below, I was curious the same can be done using MAPPING keyword?

Source and Target structure are not identical. Source is a simple internal table and target is a deep internal table.

 

et_ds_rel_map_upd = VALUE #( FOR <fs_ds_rel_map> IN lt_ds_relmap_upd_U
                             ( %key-ds     = <fs_ds_rel_map>-ds_id
                               %key-dsfld  = <fs_ds_rel_map>-ds_fld
                               %key-rcon   = 'M'
                               sourceds    = <fs_ds_rel_map>-for_ds_id
                               sourcedsfld = <fs_ds_rel_map>-for_ds_fld
                          %control = VALUE #( sourceds = if_abap_behv=>mk-on
                                           sourcedsfld = if_abap_behv=>mk-on
                                          sourcedsexpr = if_abap_behv=>mk-on )
                             ) ).

 



Thanks in advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Kudos

I think you can use CORRESPONDING with MAPPING. Have you tried it?

Here is ABAP documentation link and example code from it:

DATA: BEGIN OF struct1,
        mcomp1 TYPE i VALUE 1,
        mcomp2 TYPE i VALUE 2,
        BEGIN OF substruc,
          subcomp1 TYPE i VALUE 1,
          subcomp2 TYPE i VALUE 2,
          subcomp3 TYPE i VALUE 3,
        END OF substruc,
      END OF struct1.

DATA: BEGIN OF struct2,
        comp2 TYPE i,
        comp1 TYPE i,
        BEGIN OF substruc,
          comp3 TYPE i,
          comp2 TYPE i,
          comp1 TYPE i,
        END OF substruc,
      END OF struct2.

struct2 =
  CORRESPONDING #(
    struct1 MAPPING comp1    = mcomp1
                    comp2    = mcomp2
                  ( substruc = substruc MAPPING comp1 = subcomp1
                                                comp2 = subcomp2
                                                comp3 = subcomp3 ) ).

 

sh4il3sh
Participant
0 Kudos

I have read that above and tried my best but I failed.
Also my case is of an Internal Table not a structure so maybe that is why..

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Kudos
@sh4il3sh it should work for internal tables too. Maybe create a sample test code (including local TYPES) and post it here.