05-27-2008 4:20 PM
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.
05-27-2008 4:31 PM
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
05-27-2008 4:31 PM
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
05-27-2008 4:40 PM
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?