2007 Jan 30 3:36 PM
Hi,
I have a program in which I have to fill 20 ranges all with similar names range01 to range20.
I assign the values to the header of the ranges dinamically ussing field-symbols. Example:
do 20 times.
contador = contador + 1.
concatenate 'range' contador '-sign' into lv_fieldname.
assign (lv_fieldname) to does not work, append lv_whatever neither...)
enddo.
2007 Jan 31 7:14 AM
Hi ,
Have a look at the below code .
FIELD-SYMBOLS: <FS_DATA> type ref to DATA,
<FS_1> type any table,
<FS_2>,
<FS_3>.
LS_FIELDCATALOG-FIELDNAME = 'MANDT'.
append LS_FIELDCATALOG to LT_FIELDCATALOG.
LS_FIELDCATALOG-FIELDNAME = 'CARRID'. "Fieldname
LS_FIELDCATALOG-INTTYPE = 'C'. "Internal Type C-> Character
append LS_FIELDCATALOG to LT_FIELDCATALOG.
LS_FIELDCATALOG-FIELDNAME = 'CONNID'.
LS_FIELDCATALOG-INTTYPE = 'N'.
append LS_FIELDCATALOG to LT_FIELDCATALOG.
LS_FIELDCATALOG-FIELDNAME = 'FLDATE'.
LS_FIELDCATALOG-INTTYPE = 'D'.
append LS_FIELDCATALOG to LT_FIELDCATALOG.
LS_FIELDCATALOG-FIELDNAME = 'PRICE'.
LS_FIELDCATALOG-INTTYPE = 'P'.
append LS_FIELDCATALOG to LT_FIELDCATALOG.
LS_FIELDCATALOG-FIELDNAME = 'CURRENCY'.
LS_FIELDCATALOG-INTTYPE = 'C'.
append LS_FIELDCATALOG to LT_FIELDCATALOG.
assign LT_DATA to <FS_DATA>.
call method cl_alv_table_create=create_dynamic_table
exporting
it_fieldcatalog = LT_FIELDCATALOG
importing
ep_table = FS_DATA
exceptions
generate_subpool_dir_full = 1
others = 2
.
if sy-subrc <> 0.
endif.
So <FS_1> now points to our dynamic internal table.
assign <FS_DATA>->* to <FS_1>.
Next step is to create a work area for our dynamic internal table.
create data NEW_LINE like line of <FS_1>.
A field-symbol to access that work area
assign NEW_LINE->* to <FS_2>.
And to put the data in the internal table
select MANDT CARRID CONNID FLDATE PRICE CURRENCY
from SFLIGHT
into corresponding fields of table <FS_1>.
Access contents of internal table
loop at <FS_1> assigning <FS_2>.
assign component 1 of structure <FS_2> to <FS_3>.
write: / <FS_3>.
endloop.
data: lv_tablename type string value 'SFLIGHT'.
data: lv_dref type ref to DATA.
CREATE DATA lv_dref type table of (lv_tablename).
FIELD-SYMBOLS: <FS> TYPE STANDARD TABLE.
ASSIGN lv_dref->* TO <FS>.
Please reward if useful.