‎2007 Jan 24 9:50 AM
Hi Experts,
This is Sasidhar, I am trying to develop a coding to upload any flat file into one internal table. Here Based upon the flat file structure internal table structure also have to change. By using some coding (INSERT REPORT 'zdynpro'(001) FROM T_INTAB) i had created one dynamical internal table in zdynpro program. Now i have to use this dynamical internal table structure in my report to upload flat file. Please suggest me regarding this issue.
Thanks
Sasidhar.V
‎2007 Jan 24 10:05 AM
Hello Sasidhar,
Check out the code developd by Rich.
report zrich_0003
no standard page heading.
type-pools: slis.
field-symbols: <dyn_table> type standard table,
<dyn_wa>.
data: alv_fldcat type slis_t_fieldcat_alv,
it_fldcat type lvc_t_fcat.
selection-screen begin of block b1 with frame title text-001.
parameters: p_check type c.
selection-screen end of block b1.
start-of-selection.
perform build_dyn_itab.
perform build_report.
loop at <dyn_table> into <dyn_wa>.
write:/ <dyn_wa>.
endloop.
************************************************************************
* Build_dyn_itab
************************************************************************
form build_dyn_itab.
data: index(3) type c.
data: new_table type ref to data,
new_line type ref to data,
wa_it_fldcat type lvc_s_fcat.
* Create fields
clear index.
do 10 times.
index = sy-index.
clear wa_it_fldcat.
concatenate 'Field' index into
wa_it_fldcat-fieldname .
condense wa_it_fldcat-fieldname no-gaps.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-intlen = 5.
append wa_it_fldcat to it_fldcat .
enddo.
* Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fldcat
importing
ep_table = new_table.
assign new_table->* to <dyn_table>.
* Create dynamic work area and assign to FS
create data new_line like line of <dyn_table>.
assign new_line->* to <dyn_wa>.
endform.
*********************************************************************
* Form build_report
*********************************************************************
form build_report.
data: fieldname(20) type c.
data: fieldvalue(5) type c.
data: index(3) type c.
field-symbols: <fs1>.
do 10 times.
index = sy-index.
* Set up fieldname
concatenate 'FIELD' index into
fieldname .
condense fieldname no-gaps.
* Set up fieldvalue
concatenate 'FLD' index into
fieldvalue.
condense fieldvalue no-gaps.
assign component fieldname of structure <dyn_wa> to <fs1>.
<fs1> = fieldvalue.
enddo.
* Append to the dynamic internal table
append <dyn_wa> to <dyn_table>.
endform.Also check out the links for better understanding...
/people/ravikumar.allampallam/blog/2005/05/31/expand-the-list-of-columns-in-a-report-dynamically
/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table
/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap
Regards