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

Access deep structures using string

Former Member
0 Likes
630

Dear All,

I have to develop dynamic mapping between two different structures (not a BOL objects, just structures so bPath doesn't work here).

I know exactly how both structures look like - got the info in two strings.

Let's say I have these two strings:

1) 'struct1-childStruct1-childStruct2-someField1'

2) 'struct2-childStruct3-someField2'

let's saym I'm sure the types inside are the same, so there will be no conflicts. What I need to do is following:

struct1-childStruct1-childStruct2-someField1 = struct2-childStruct3-someField2.

Seems to be easy, but I have only string representation of both structures. How can I achieve it?

Thanks in advance!

1 ACCEPTED SOLUTION
Read only

hendrik_brandes
Contributor
0 Likes
507

Hello Pawel,

have you tried to use field symbols:

types: begin of t_struc1,
  field1 type c,
  field2 type numc04.
types: end of t_struc1.

types: begin of t_struc2,
  field1 type c,
  field2 type numc04,
  struc1 type t_struc1.
types: end of t_struc2.


field-symbols:
  <src>   type any,
  <dest>  type any.

data:
  ls_struc1  type t_struc1,
  ls_struc2  type t_struc2,
  l_string1  type string value 'ls_struc1-field2',
  l_string2  type string value 'ls_struc2-struc1-field2'.

ls_struc1-field2 = '0014'.
ls_struc2-struc1-field2 = '0027'.

assign:
  (l_string1) to <src>,
  (l_string2) to <dest>.
assert <src> is assigned and <dest> is assigned.

<dest> = <src>.

Kind regards,

Hendrik

3 REPLIES 3
Read only

hendrik_brandes
Contributor
0 Likes
508

Hello Pawel,

have you tried to use field symbols:

types: begin of t_struc1,
  field1 type c,
  field2 type numc04.
types: end of t_struc1.

types: begin of t_struc2,
  field1 type c,
  field2 type numc04,
  struc1 type t_struc1.
types: end of t_struc2.


field-symbols:
  <src>   type any,
  <dest>  type any.

data:
  ls_struc1  type t_struc1,
  ls_struc2  type t_struc2,
  l_string1  type string value 'ls_struc1-field2',
  l_string2  type string value 'ls_struc2-struc1-field2'.

ls_struc1-field2 = '0014'.
ls_struc2-struc1-field2 = '0027'.

assign:
  (l_string1) to <src>,
  (l_string2) to <dest>.
assert <src> is assigned and <dest> is assigned.

<dest> = <src>.

Kind regards,

Hendrik

Read only

0 Likes
507

Hi Hendrik,

I've tried your suggestion. In debugger all fine, no errors, but at the end new value is not present in the structure..

Read only

0 Likes
507

Ok, you were right. I've written

assign l_string1 to <src>

instead of:

assign (l_string1) to <src>

thanks a lot!