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

Move Date to dynamic structure

Former Member
0 Likes
1,007

Hello!

I have the following problem.

I built a function with the INFOTYP and PERNR as Import parameters.

regarding to the infotyp i define my structure

DATA:
  wa_line TYPE REF TO   data,

FIELD-SYMBOLS:
  <wa>    TYPE ANY.

CREATE DATA wa_line TYPE infotyp '' which is e.g  p0001
ASSIGN wa_line->* TO <wa>.

So if i Import the infotyp "p0001" i have a structure now <wa> with type of p0001.

Now i want to fill this structure with data.

Of course its not possible to say <wa>-pernr, because during compile time <wa> is no structure.

I tried to use

move-corresponding pernr to <wa>

but this is not working as well because you can't move a single data into a structure

move pernr to <wa>

didn't work as well

Is there a way to add data into an dynamic created structure?

greets thomas

1 ACCEPTED SOLUTION
Read only

peter_ruiz2
Active Contributor
0 Likes
972

hi,

use this code.

ASSIGN COMPONENT 'PERNR' OF STRUCTURE <wa> TO <fs_field>.

now, assign values to <fs_field> and it will reflect on <wa>-pernr.

regards,

Peter

Hello!

I have the following problem.

I built a function with the INFOTYP and PERNR as Import parameters.

regarding to the infotyp i define my structure

DATA:
  wa_line TYPE REF TO   data,

FIELD-SYMBOLS:
  <wa>    TYPE ANY.

CREATE DATA wa_line TYPE infotyp '' which is e.g  p0001
ASSIGN wa_line->* TO <wa>.

So if i Import the infotyp "p0001" i have a structure now <wa> with type of p0001.

Now i want to fill this structure with data.

Of course its not possible to say <wa>-pernr, because during compile time <wa> is no structure.

I tried to use

move-corresponding pernr to <wa>

but this is not working as well because you can't move a single data into a structure

move pernr to <wa>

didn't work as well

Is there a way to add data into an dynamic created structure?

greets thomas

6 REPLIES 6
Read only

peter_ruiz2
Active Contributor
0 Likes
973

hi,

use this code.

ASSIGN COMPONENT 'PERNR' OF STRUCTURE <wa> TO <fs_field>.

now, assign values to <fs_field> and it will reflect on <wa>-pernr.

regards,

Peter

Read only

JozsefSzikszai
Active Contributor
0 Likes
972

hi Thomas,

it only works like this:

FIELD-SYMBOLS : <field> TYPE ANY.

ASSIGN COMPONENT 'PERNR' OF structure <wa> TO <field>.
<field> = '00000001'.

you have to repeat the ASSIGN for each field you want to give value.

hope this helps

ec

Read only

Former Member
0 Likes
972

ok, one things is now not clear for me...

to be sure, lets say i have a import variable of the function named gc_pernr

this variable i want to assign to my structure <wa> to the field 'PERNR'

how can i handle this?

<wa> is my dynamic structure with no values so far.

now i want to assign the variable gc_pernr to <wa>-pernr?

(something like assign gc-pernr to component 'PERNR' of structure <wa> i know thats not an valid code but i think it shows what i want to do)

Read only

0 Likes
972

do you mean in gc_pernr you have a value (an employee number) and you want <wa>-pernr to have this value? If yes, just follow my code in my first comment, but replace the last line:

<field> = gc_pernr.

Read only

0 Likes
972

As Eric said in the previous reply


FIELD-SYMBOLS : <field> TYPE ANY.
 
ASSIGN COMPONENT 'PERNR' OF structure <wa> TO <field>.
<field> = gc_pernr.   "<<<<

Read only

Former Member
0 Likes
972

ah ok, now i understand

the field symbol reflects the value back, that was the hint i missed

thanks!