‎2012 Sep 27 10:20 AM
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!
‎2012 Sep 27 10:28 AM
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
‎2012 Sep 27 10:28 AM
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
‎2012 Sep 27 12:45 PM
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..
‎2012 Sep 27 1:30 PM
Ok, you were right. I've written
assign l_string1 to <src>
instead of:
assign (l_string1) to <src>
thanks a lot!