2005 Jul 04 2:03 PM
Hi, i have to extend a dynamic table like this:
FIELD-SYMBOLS: <g_data> TYPE table.
I have to build a custom structure with all the fields
of g_data plus some other fixed fields.
In other words if g_data looks like this
AUFNR POSNR
100 10
200 20
My structure must be:
AUFNR POSNR F1 F2
100 10 23 21
200 20 234 32
Thanks in advance.
Is anybody here who haves some ideas
Hi, i have to extend a dynamic table like this:
FIELD-SYMBOLS: <g_data> TYPE table.
I have to build a custom structure with all the fields
of g_data plus some other fixed fields.
In other words if g_data looks like this
AUFNR POSNR
100 10
200 20
My structure must be:
AUFNR POSNR F1 F2
100 10 23 21
200 20 234 32
Thanks in advance.
Is anybody here who haves some ideas
2005 Jul 04 2:10 PM
Here is a sample program of how to build a dynamic internal table.
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.
clear wa_it_fldcat.
wa_it_fldcat-fieldname = 'AUFNR'.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-intlen = 12.
append wa_it_fldcat to it_fldcat .
clear wa_it_fldcat.
wa_it_fldcat-fieldname = 'POSNR'.
wa_it_fldcat-datatype = 'CHAR'.
wa_it_fldcat-intlen = 6.
append wa_it_fldcat to it_fldcat .
* Create fields
clear index.
do 2 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>.
assign component 'AUFNR' of structure <dyn_wa> to <fs1>.
<fs1> = '123456789'.
assign component 'POSNR' of structure <dyn_wa> to <fs1>.
<fs1> = '000001'.
do 2 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.
Regards,
Rich Heilman
Message was edited by: Rich Heilman
I have modified the sample to include your requirement
2005 Jul 05 6:11 AM
These weblogs also should help you.
/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table
or
/people/ravikumar.allampallam/blog/2005/05/31/expand-the-list-of-columns-in-a-report-dynamically
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |