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

REF TO DATA to Structure

Former Member
0 Likes
1,762

Hi Folks!

I got a little problem with moving data.

I'm using ref to data for a general data definition. Unfortunately after I create the data using a certain type, let's say 'A', I cant move the data of the created data to a structure of type 'A'. (It can also be type 'B'; that depends on the user input; thats why I am using ref to data).

Is there a way to move the data from the cre3ated structure to the static type structure?

I'm looking forward to reading from you

Best Regards!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,620

Hey Kamil,

You can use a field symbol to move the data like this:


data: dyn_struc type ref to data.
stat_struc type A.

field-symbols <fs> type data.

create data dyn_struc type A.
assign dyn_struc->* to <fs>.
stat_struc = <fs>.

Of course, this will only work if dyn_struc was actually created with type A. Otherwise, the last line will cause a runtime error.

Best regards,

Erik

3 REPLIES 3
Read only

Former Member
0 Likes
1,621

Hey Kamil,

You can use a field symbol to move the data like this:


data: dyn_struc type ref to data.
stat_struc type A.

field-symbols <fs> type data.

create data dyn_struc type A.
assign dyn_struc->* to <fs>.
stat_struc = <fs>.

Of course, this will only work if dyn_struc was actually created with type A. Otherwise, the last line will cause a runtime error.

Best regards,

Erik

Read only

0 Likes
1,620

Hi !

Thanks a lot !! That solved my problem.

What tried to do was to move the REF TO DATA to the static structure. (doh)

Then I assigned each component of both structures to a field symbol and moved the data then, but I never thought about moving the whole assigned structure field symbol to the static fields.

Thanks a lot!

Best regards,

Kamil

Read only

Former Member
0 Likes
1,620

Hi

Can't u create it dynamically?

DATA W_DYN TYPE REF TO DATA.

CREATE DATA W_DYN TYPE (<TYPE>).

If u can know the type of structure B, u can use it in order to create the variable dynamically.

Max