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

Dynamic value to Dynamic field

Former Member
0 Likes
1,036

Hello experts,

i want to assign dynamic value to dynamic field.

my code is like

assign (lv_field1) to <any>."this is value like 70.000

assign lv_field2 to <any2>."this is field like <output>-field1

<any2> = <any>.

I wanna see <output>-field1 = 70.000. But its not working.

Thanks,

1 ACCEPTED SOLUTION
Read only

jascha_meiswinkel
Product and Topic Expert
Product and Topic Expert
0 Likes
955

This works. Does it help?

DATA:
  BEGIN OF struc1,
    field1 TYPE int4,
  END OF struc1,

  BEGIN OF struc2,
    field2 TYPE int4,
  END OF struc2.

struc1-field1 = 70000. " 70.000
DATA(lv_field1) = 'STRUC1-FIELD1'.
ASSIGN (lv_field1) TO FIELD-SYMBOL(<any>).
DATA(lv_field2) = 'STRUC2-FIELD2'.
ASSIGN (lv_field2) TO FIELD-SYMBOL(<any2>).
<any2> = <any>.

WRITE <any2>. " 70.000

This works. Does it help?

DATA:
  BEGIN OF struc1,
    field1 TYPE int4,
  END OF struc1,

  BEGIN OF struc2,
    field2 TYPE int4,
  END OF struc2.

struc1-field1 = 70000. " 70.000
DATA(lv_field1) = 'STRUC1-FIELD1'.
ASSIGN (lv_field1) TO FIELD-SYMBOL(<any>).
DATA(lv_field2) = 'STRUC2-FIELD2'.
ASSIGN (lv_field2) TO FIELD-SYMBOL(<any2>).
<any2> = <any>.

WRITE <any2>. " 70.000
3 REPLIES 3
Read only

jascha_meiswinkel
Product and Topic Expert
Product and Topic Expert
0 Likes
956

This works. Does it help?

DATA:
  BEGIN OF struc1,
    field1 TYPE int4,
  END OF struc1,

  BEGIN OF struc2,
    field2 TYPE int4,
  END OF struc2.

struc1-field1 = 70000. " 70.000
DATA(lv_field1) = 'STRUC1-FIELD1'.
ASSIGN (lv_field1) TO FIELD-SYMBOL(<any>).
DATA(lv_field2) = 'STRUC2-FIELD2'.
ASSIGN (lv_field2) TO FIELD-SYMBOL(<any2>).
<any2> = <any>.

WRITE <any2>. " 70.000
Read only

0 Likes
955

Thanks Jascha,

Your answer was usefull.

so i had to assign lv_field2 like;

(lv_field2) to field-symbol(<any2>).

not like;

lv_field2 to field-symbol(<any2>) .

Read only

RaymondGiuseppi
Active Contributor
0 Likes
955
" dynamic assign Here <any> reference the field whose name is content/value of lv_field1 
assign (lv_field1) to <any>.
" static assignment - here <any2> reference the field lv_field2, so <any2> is not very useful?
assign lv_field2 to <any2>.

What were you trying to do? (Look at online help for ASSIGN - mem_area)