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: 

Reg Field Symbols

Former Member
0 Kudos

Hi I am using the fallowing statement

ASSIGN COMPONENT <wa_itab1>-value of STRUCTURE <wa_itab1> to <ty_temp> CASTING.

but when i execute in debugging mode it says <ty_temp> is not assigned.

Please let me know what might be the problem.

Regards,

Kumar

1 ACCEPTED SOLUTION

SuhaSaha
Advisor
Advisor
0 Kudos

Your statement is incorrect:

"ASSIGN COMPONENT <wa_itab1>-value of STRUCTURE <wa_itab1> to <ty_temp> CASTING.

ASSIGN COMPONENT 'VALUE' of STRUCTURE <wa_itab1> to <ty_temp> CASTING.

Try this way & check.

BR,

Suhas

10 REPLIES 10

Former Member
0 Kudos

Hi Kumar,

Check <wa_itab1> is a structure or not and also sy-subrc value.

If <wa_itab1> is not a structure, the assignment is not executed and sy-subrc is set to 4.

Thanks.

Ramya.

0 Kudos

Hi Ramya,

here in that Structure value is coming but it is not assigned to the target field symbol. the two field symbol structures are different.

Regards,

kumar

0 Kudos

Can you please post your code.

0 Kudos

DATA: lv_col TYPE sy-index.

*Pick Data

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = p_infile

i_begin_col = '1'

i_begin_row = '3' "Do not require headings

i_end_col = '40'

i_end_row = '10000'

TABLES

intern = it_itab1

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE e711 WITH text-052. "Problem uploading Excel Spreadsheet

ENDIF.

LOOP at it_itab1 INTO wa_itab1.

  • Get first row retrieved

lv_col = sy-tabix + 1.

READ TABLE it_itab1 INTO wa_itab1 WITH KEY row = '1'

col = lv_col.

FIELD-SYMBOLS: <ty_temp> TYPE ty_temp,

<wa_itab1> TYPE alsmex_tabline.

ASSIGN wa_itab1 to <wa_itab1>.

ASSIGN COMPONENT <wa_itab1>-value of STRUCTURE <wa_itab1> to <ty_temp>.

if sy-subrc NE 0.

BREAK-POINT.

endif.

CLEAR:lv_col.

ENDLOOP.

0 Kudos

Hello Kumar

With this command :

ASSIGN COMPONENT <wa_itab1>-value of STRUCTURE <wa_itab1> to <ty_temp>.

I understand you want access the field "value" in structure <wa_itab1> via field symbol <ty_temp> right?

You can assign directly like :

ASSIGN <wa_itab1>-value TO <ty_temp>.

or you can assign with field name :

ASSIGN COMPONENT 'VALUE' of STRUCTURE <wa_itab1> to <ty_temp>.

or you can assign field number in structure :

ASSIGN COMPONENT 2 of STRUCTURE <wa_itab1> to <ty_temp>.

But your command tries to assign field '3300' of structure <wa_itab1>,

since field name 3300 does not exist in structure <wa_itab1> it won't work.

I hope it helps.

craig_scott2
Explorer
0 Kudos

How is <ty_temp> defined?

SuhaSaha
Advisor
Advisor
0 Kudos

Your statement is incorrect:

"ASSIGN COMPONENT <wa_itab1>-value of STRUCTURE <wa_itab1> to <ty_temp> CASTING.

ASSIGN COMPONENT 'VALUE' of STRUCTURE <wa_itab1> to <ty_temp> CASTING.

Try this way & check.

BR,

Suhas

Former Member
0 Kudos

Hi Suhas,

My Statement is Correct i am getting value in <wa_itab1>-value as 3300 but it is not assigned to the target field suymbol <ty_temp>.

Regards,

Kumar

0 Kudos

When using the ASSIGN COMPONENT statement, the component value needs to be a component of the structure. So if you specify <wa_itab1>-value as the conponent, then the value stored in <wa_itab1>-value needs to be the column which you are trying to assign in the <wa_itab1> structure. This is why the previous poster, said to use 'VALUE', as he is assuming that you want the VALUE column of the structure and not the value stored in this column.

So in the below code, we want to assign <FS_FIELD> to the FLD2 column of the WA_STRUCT structure.

Types: begin of t_struct,
              fld1 type string,
              fld2 type string,
           end of t_struct.
data: wa_struct type t_struct.

field-symbols: <fs_field>.

Assign component 'FLD2' of structure wa_struct to <fs_field>.

Regards,

Rich Heilman

Former Member
0 Kudos

Answered thanx..