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: 

Problem with typing field-symbols 4.6c versus ERP 6.0

Former Member
0 Kudos

dear fellows,

i'm facing a problem.

once it was allowed to type field-symbols like:

FIELD-SYMBOLS: <fs_csks> TYPE csks,

<lvs_fcat> TYPE lvc_s_fcat,

<wa_totex> TYPE ANY.

and i was able to assign components in that way:

LOOP AT gt_fcat ASSIGNING <lvs_fcat>.

IF <lvs_fcat>-fieldname = 'KOSTL'.

ASSIGN COMPONENT <lvs_fcat>-fieldname OF STRUCTURE ls_csks

TO <fs_csks>-kostl.

ENDIF.

IF <lvs_fcat>-fieldname = DATBI'.

ASSIGN COMPONENT <lvs_fcat>-fieldname OF STRUCTURE ls_csks

TO <fs_csks>-datbi.

ENDIF.

ENDLOOP.

i found that quite usefull, when ls_csks and the internal table it belonged to were created dynamical.

with our new release i get an error message that says, <fs_csks>-kostl is not a field-symbol.

How can i get the same logic under ERP 6.0?

many thanks,

Robert

Example could be:

REPORT z_csks.

TABLES: csks.

DATA: gt_fcat TYPE STANDARD TABLE OF lvc_s_fcat,

gt_csks TYPE STANDARD TABLE OF csks,

ls_csks LIKE LINE OF gt_csks.

FIELD-SYMBOLS: <fs_csks> TYPE csks,

<lvs_fcat> TYPE lvc_s_fcat,

<wa_totex> TYPE ANY.

ASSIGN csks TO <fs_csks> .

CALL FUNCTION

'LVC_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = 'CSKS'

CHANGING

ct_fieldcat = gt_fcat.

LOOP AT gt_fcat ASSIGNING <lvs_fcat>.

IF <lvs_fcat>-fieldname = 'KOSTL'.

ASSIGN COMPONENT <lvs_fcat>-fieldname OF STRUCTURE ls_csks

TO <fs_csks>-kostl.

ENDIF.

ENDLOOP.

SELECT * FROM csks INTO TABLE gt_csks

WHERE kosar = 'R'.

LOOP AT gt_csks into ls_csks.

ENDLOOP.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Yes, that doesn't really make sense, which is why it has been fixed in 6.0. You should not be able to do that in previous releases.

Instead, you should assign to a field symbol with a generic structure.

FIELD-SYMBOLS: <fs_csks> TYPE csks,
<lv_fs> type any,    "<-- Add this
<lvs_fcat> TYPE lvc_s_fcat,
<wa_totex> TYPE ANY.

and i was able to assign components in that way:

LOOP AT gt_fcat ASSIGNING <lvs_fcat>.

IF <lvs_fcat>-fieldname = 'KOSTL'.
ASSIGN COMPONENT <lvs_fcat>-fieldname OF STRUCTURE ls_csks
TO <lv_fs>.     "<-- Change
ENDIF.
IF <lvs_fcat>-fieldname = DATBI'.
ASSIGN COMPONENT <lvs_fcat>-fieldname OF STRUCTURE ls_csks
TO <lv_fs>.     "<-- Change
ENDIF.

ENDLOOP.

Regards,

Rich Heilman

2 REPLIES 2

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Yes, that doesn't really make sense, which is why it has been fixed in 6.0. You should not be able to do that in previous releases.

Instead, you should assign to a field symbol with a generic structure.

FIELD-SYMBOLS: <fs_csks> TYPE csks,
<lv_fs> type any,    "<-- Add this
<lvs_fcat> TYPE lvc_s_fcat,
<wa_totex> TYPE ANY.

and i was able to assign components in that way:

LOOP AT gt_fcat ASSIGNING <lvs_fcat>.

IF <lvs_fcat>-fieldname = 'KOSTL'.
ASSIGN COMPONENT <lvs_fcat>-fieldname OF STRUCTURE ls_csks
TO <lv_fs>.     "<-- Change
ENDIF.
IF <lvs_fcat>-fieldname = DATBI'.
ASSIGN COMPONENT <lvs_fcat>-fieldname OF STRUCTURE ls_csks
TO <lv_fs>.     "<-- Change
ENDIF.

ENDLOOP.

Regards,

Rich Heilman

Former Member
0 Kudos

dear rich,

thanks for your reply. it really made sense, believe me i worked with generated views for different Z-Tables and the tables had all the same append. So i was able to work with a structured field-symbol and to adress the single fields of the structure. i didn't have to create a single field-symbol for every field of the structure.

any further guesses?