Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Syntax for mapping to nested field

Former Member
0 Likes
656

Hi,

Consider the following mapping (7.4 SP8):

"define and fill data strucures

  BEGIN OF person,

    name          TYPE string,

    BEGIN OF address,

      city         TYPE string,

      zip_code      TYPE string, "if I remove this (in this case redundant) line, I get a dump (why?!?)

    END OF address,

  END OF person,

  BEGIN OF employee,

    name          TYPE string,

    city          TYPE string,

  END OF employee.

  DATA(person) = VALUE person(

      name    = 'John Doe'

      address = VALUE #(

        city         = 'Manassass'

      )

  ).

"Map from employees to person. This works fine.

  DATA(employee) = CORRESPONDING employee( person

     MAPPING

       city         = address-city

  ).

"Vice versa does not work out of the box.

  DATA(person2) = CORRESPONDING person( employee

  MAPPING

    name = name

    address-city = city "this does not compile.

  ).

The syntax checker claims that the red marked "component" does not exist.

Primary question: What is the correct syntaxt to map to the nested "city" element?

Secondary question (came up during the creation of the minimal demo code): Why do I get a core dump if the zip_code line is removed?


Thanks!

1 ACCEPTED SOLUTION
Read only

nikolayevstigneev
Contributor
0 Likes
622

Hi, Simon!

Here's what the doc says for CORRESPONDING - mapping:

Addition 1

... MAPPING t1 = s1 t2 = s2 ...

Effect

[...] A component of a target object cannot appear more than once in the list after MAPPING and the structure component selector cannot be used to access subcomponents. Neither of these rules apply for components of the source object.

And considering your second question - yep, the dump is reproduced but I can't figure out why two subcomponents for a structure is ok and one is not ok. Let's read the doc together

2 REPLIES 2
Read only

nikolayevstigneev
Contributor
0 Likes
623

Hi, Simon!

Here's what the doc says for CORRESPONDING - mapping:

Addition 1

... MAPPING t1 = s1 t2 = s2 ...

Effect

[...] A component of a target object cannot appear more than once in the list after MAPPING and the structure component selector cannot be used to access subcomponents. Neither of these rules apply for components of the source object.

And considering your second question - yep, the dump is reproduced but I can't figure out why two subcomponents for a structure is ok and one is not ok. Let's read the doc together

Read only

0 Likes
622

Hi,

seems I like I missed this limitation, thanks for the pointer.

Too bad it exists, would make certain mappings much easier.

Best Regards,

Simon