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: 

Assign a value to a fieldname which is in a variable.

Former Member
0 Kudos
3,215

Hi,

I have a requirement where in I have a dynamic internal table which is been refererred by a work area.

Say <ls_table> for which the columns can be FIELD1, FIELD2, FIELD3,..... I exactly donno the no of columns.

I have a string separated by a delimiter. The no of delimiters decides the no of columns for <ls_table>.

Say, string = 'ABC | GH '.

Then my <ls_table> has <ls_table>-FIELD1 and <ls_table>-FIELD2.

Now my problem is how can i assign the value to this workarea?

I mean, i know the value of <ls_table>-FIELD1 is ABC but how can I assign it to <ls_table>-FIELD1 without specifying the field name?

To conclude,

I have fieldname and fieldvalue in two different variables... how can i equate them?

say, l_fieldname = <ls_table>-field1.

l_fieldvalue = 'XYZ'.

Now, all i want is to get <ls_table>-field1 = 'XYZ'.

Anyone has any idea how i can achieve this?

Regards,

Suganya

1 ACCEPTED SOLUTION

Former Member
597

this might help u...

count the number of delimiters.


assign component count of structure <ls_table> to <fs>.

<fs> = l_fieldvalue .

4 REPLIES 4

Former Member
598

this might help u...

count the number of delimiters.


assign component count of structure <ls_table> to <fs>.

<fs> = l_fieldvalue .

0 Kudos
597

Thanks a ton... It worked...

Regards,

Suganya

former_member305388
Active Contributor
0 Kudos
597

HI,

You can try this...

DATA: data(100),

tb_final(100) OCCURS 0 WITH HEADER LINE,

lines TYPE i.

FIELD-SYMBOLS: <fs_data> TYPE ANY.

data = 'ABC hcbu ffr vfg vergreg vfg'.

ASSIGN data TO <fs_data>.

DO.

IF NOT data IS INITIAL.

SPLIT data AT space INTO <fs_data> data.

tb_final = <fs_data>.

APPEND tb_final.

CLEAR tb_final.

ELSE.

EXIT.

ENDIF.

ENDDO.

DESCRIBE TABLE tb_final LINES lines.

Now lines will give you the number of columns for the output. Now, based on this you can decide how to proceed further.

Hope this helps...

dev_parbutteea
Active Contributor
0 Kudos
597

Hi,

Check this logic:

DATA: wa_mara TYPE mara,

lv_var TYPE char30 VALUE '<FS_MARA>-MATNR',

lv_value TYPE mara-matnr VALUE '000001'.

FIELD-SYMBOLS: <fs_mara> TYPE mara,

<fs> TYPE ANY.

ASSIGN wa_mara TO <fs_mara>.

IF sy-subrc = 0.

ASSIGN (lv_var) TO <fs>.

IF sy-subrc = 0.

<fs> = lv_value.

ENDIF.

ENDIF.

write: 'MATNR value : ', wa_mara-matnr.

Hope that this helps you,

Regards.