‎2009 Feb 04 12:37 PM
Dear All,
Let me put it straight, if I am having a list of tables from table T682I, field KOTABNR prefixed with 'A',
and the I am able to get the fields for these tables starting with A from DD03L table.
How do I generate an dynamic internal table with all the fields that are selected in internal table same as DD03L, wherein I am selecting multiple tables?
Hope you get it.
-
Select * from T682I where into internal_table_X where kozgf eq 'PR00'.
then, get KOTABNR from internal_table_X and prefix it with A,
so now I have say, 20 tables with A as prefix,
now for these 20 tables I may get 25 unique fields from DD03L,
Then how do I create a internal table dynamically with all these 25 fields with are decided at runtime.
-
Awaiting reply and help.
Regards,
Dantham Conpolwedson
Edited by: Dantham Conpolwedson on Feb 4, 2009 1:39 PM
‎2009 Feb 04 2:48 PM
Hi,
Say you have all the fields in a int tab named it_fields, then
"Declare field cat
DATA: it_fieldcat TYPE lvc_t_fcat.
DATA: wa_fieldcat TYPE lvc_s_fcat.
FIELD-SYMBOLS: <outtab> TYPE ANY TABLE,
<l_line> TYPE ANY.
LOOP AT it_fields INTO wa_fields.
"fill it_fieldcat from the field name in it_fields.
ENDLOOP.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = new_table.
ASSIGN new_table->* TO <outtab>.
CREATE DATA new_line LIKE LINE OF <outtab>.
ASSIGN new_line->* TO <l_line> .Now <out_tab> is the req int tab with all fields and <l_line> is the work area for it
Regards,
Manoj Kumar P
‎2009 Feb 04 12:39 PM
‎2009 Feb 04 1:25 PM
Here is an example code
PARAMETERS : p_table(10) TYPE C.
DATA: w_tabname TYPE w_tabname,
w_dref TYPE REF TO data,
w_grid TYPE REF TO cl_gui_alv_grid.
FIELD-SYMBOLS: <t_itab> TYPE ANY TABLE.
w_tabname = p_table.
CREATE DATA w_dref TYPE TABLE OF (w_tabname).
ASSIGN w_dref->* TO <t_itab>.
‎2009 Feb 04 2:48 PM
Hi,
Say you have all the fields in a int tab named it_fields, then
"Declare field cat
DATA: it_fieldcat TYPE lvc_t_fcat.
DATA: wa_fieldcat TYPE lvc_s_fcat.
FIELD-SYMBOLS: <outtab> TYPE ANY TABLE,
<l_line> TYPE ANY.
LOOP AT it_fields INTO wa_fields.
"fill it_fieldcat from the field name in it_fields.
ENDLOOP.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = new_table.
ASSIGN new_table->* TO <outtab>.
CREATE DATA new_line LIKE LINE OF <outtab>.
ASSIGN new_line->* TO <l_line> .Now <out_tab> is the req int tab with all fields and <l_line> is the work area for it
Regards,
Manoj Kumar P