09-05-2006 3:36 AM
Hi all,
I am using a single program to upload data into many tables(only one at a time).
The table name is a parameter to the program. Following is a snippet of the code I have. I need help in moving from the internal table(itab) to the table structure (<tab>) which I use with the modify command.
parameters: p_table(20) default 'ZTEST'.
DATA dref TYPE REF TO data.
DATA tabdref TYPE REF TO data.
FIELD-SYMBOLS <fs_struc> TYPE ANY.
FIELD-SYMBOLS <fs_tab> TYPE table.
CREATE DATA dref TYPE (p_table).
ASSIGN dref->* TO <fs_struc>.
CREATE DATA tabdref TYPE TABLE OF (p_table).
ASSIGN tabdref->* TO <fs_tab>.
perform read_from_excel into an internal table - itab
itab has fields col1, col2, col3, col4
-- I NEED TO MOVE FROM INTERNAL TABLE itab to <fs_tab>
(The table will not have more than 4 fields + mandt)
modify (p_table) FROM TABLE <fs_tab>.
PS: This is my first time in the SDN network. So, I hope this is the correct forum. It would be great, if u could provide detailed code, as I have been stuck for quite some time with this and need to resolve it at the earliest.
Thanks,
AP
09-05-2006 6:19 AM
Hi ani,
Probably this code may help u a bit.
1. To display data of internal table, using field-symbols
2. just copy paste
Report abc.
*----
data : itab like t001 occurs 0 with header line.
*----
field-symbols : <ft> type table.
FIELD-SYMBOLS: <dynline> TYPE ANY.
FIELD-SYMBOLS: <fld> TYPE ANY.
select * from t001 into table itab.
*----
assign itab[] to <FT>.
LOOP AT <ft> ASSIGNING <DYNLINE>.
sy-subrc = 0.
write 😕 '----
'.
WHILE SY-SUBRC = 0.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE <DYNLINE> TO <FLD>.
WRITE : <FLD>.
ENDWHILE.
ENDLOOP.
regards,
amit m.
09-05-2006 4:50 AM
It's a bit unclear if you mean that the spreadsheet will have the same number of columns as the table to be updated. I have assumed so.
tRY THIS before your modify:
field-symbols: <itab_colx>,<out_colx>.
loop at itab.
do.
assign component sy-index of STRUCTURE <FS_STRUC> to <out_colx>.
assign component sy-index of STRUCTURE itab to <itab_colx>.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
<OUT_COLX> = <ITAB_COLX>.
enddo.
APPEND <FS_STRUC> TO <FS_TAB>.
endloop.
09-05-2006 6:19 AM
Hi ani,
Probably this code may help u a bit.
1. To display data of internal table, using field-symbols
2. just copy paste
Report abc.
*----
data : itab like t001 occurs 0 with header line.
*----
field-symbols : <ft> type table.
FIELD-SYMBOLS: <dynline> TYPE ANY.
FIELD-SYMBOLS: <fld> TYPE ANY.
select * from t001 into table itab.
*----
assign itab[] to <FT>.
LOOP AT <ft> ASSIGNING <DYNLINE>.
sy-subrc = 0.
write 😕 '----
'.
WHILE SY-SUBRC = 0.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE <DYNLINE> TO <FLD>.
WRITE : <FLD>.
ENDWHILE.
ENDLOOP.
regards,
amit m.