Application Development 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: 

Dynamic fied assigment

Former Member
0 Kudos

Hello,

Is there a dynamic way of doing this:

CASE lv_iobj.

WHEN 'net_price'.

ls_keyf-net_price = <fs_keyf1>.

WHEN 'net_value'.

ls_keyf-net_value = <fs_keyf1>.

WHEN '/bic/znet_valu'.

ls_keyf-/bic/znet_valu = <fs_keyf1>.

WHEN '/bic/zknbasunt'.

ls_keyf-/bic/zknbasunt = <fs_keyf1>.

WHEN '/bic/zknvalbas'.

ls_keyf-/bic/zknvalbas = <fs_keyf1>.

WHEN '/bic/zknvalind'.

ls_keyf-/bic/zknvalind = <fs_keyf1>.

WHEN '/bic/zknindunt'.

ls_keyf-/bic/zknindunt = <fs_keyf1>.

ENDCASE.

Thanks

Matthieu

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try this..

FIELD-SYMBOLS: <FS>.

ASSIGN COMPONENT LV_OBJ OF STRUCTURE LS_KEYF TO <FS>.

IF SY-SUBRC = 0.
  <FS> = <fs_keyf1>.
ENDIF.

Thanks

Naren

6 REPLIES 6

Former Member
0 Kudos

Yes it's possible.

Do an F1 on the statement ASSIGN. You should look for ASSIGN COMPONENT

Former Member
0 Kudos

Hi,

Try this..

FIELD-SYMBOLS: <FS>.

ASSIGN COMPONENT LV_OBJ OF STRUCTURE LS_KEYF TO <FS>.

IF SY-SUBRC = 0.
  <FS> = <fs_keyf1>.
ENDIF.

Thanks

Naren

0 Kudos

To have a working version of

ASSIGN COMPONENT LV_OBJ OF STRUCTURE LS_KEYF TO <FS>.
 
IF SY-SUBRC = 0.
  <FS> = <fs_keyf1>.
ENDIF.

You'll need to do the following:

LV_OBJECT = 'insert your fieldname'.
ASSIGN COMPONENT LV_OBJ OF STRUCTURE LS_KEYF TO <FS>.
 
IF SY-SUBRC = 0.
  <FS> = <fs_keyf1>.
ENDIF.

So you will need to repeat that part for each single field in your structure; better create a FORM that you call for each field in your structure.

But if this is not what you want, maybe yo ushould post a bit more: where does <fs_keyf1> get its value from?

naimesh_patel
Active Contributor
0 Kudos

Yes.

Do like this:


ASSIGN COMPONENT lv_iobj OF STRUCTURE LS_KEYF TO <FS_FIELD>
<FS_FIELD> = <FS_KEYF1>.

Regards,

Naimesh Patel

Former Member
0 Kudos

Sorry my question was not precise enough.

I want a copy of the value of the field symbol to be stored into the correct field of my structure.

Thanks

Matthieu

Former Member
0 Kudos

I've got it.

Thanks for your help.

Matthieu