08-30-2006 12:03 PM
Hi,
i would to declare an itab dynamicly.
normaly i di this:
DATA: ITAB TYPE table of MARA.
OR
DATA: BEGIN OF ITAB OCCURS 0.
INCLUDE STRUCTURE MARA.
DATA: END OF ITAB.
Now i want this:
PARAMETER: <b>DB_TAB</b> LIKE DATABROWSE-TABLENAME.
DATA: ITAB TYPE table OF <b>DB_TAB</b>.
OR
DATA: BEGIN OF ITAB OCCURS 0.
INCLUDE STRUCTURE <b>DB_TAB</b>.
DATA: END OF ITAB.
Has anyone an idea?
thanks
Regards, Dieter
08-30-2006 12:06 PM
Hello Dieter
You will need a field symbol and a data reference for your task:
DATA:
gdo_data TYPE REF TO DATA.
FIELD-SYMBOLS:
<gt_itab> TYPE TABLE.
CREATE DATA gdo_data TYPE (db_tab).
ASSIGN gdo_data->* to <gt_itab>.
<gt_itab> has now the line structure of (db_tab).
Regards
Uwe
08-30-2006 12:06 PM
Hello Dieter
You will need a field symbol and a data reference for your task:
DATA:
gdo_data TYPE REF TO DATA.
FIELD-SYMBOLS:
<gt_itab> TYPE TABLE.
CREATE DATA gdo_data TYPE (db_tab).
ASSIGN gdo_data->* to <gt_itab>.
<gt_itab> has now the line structure of (db_tab).
Regards
Uwe
08-30-2006 1:06 PM
Hi Uwe,
thank for your answer.
i try it in this way:
REPORT ZGRO_TEST.
*
PARAMETER: DB_TAB LIKE DATABROWSE-TABLENAME.
*
DATA: GDO_DATA TYPE REF TO DATA.
FIELD-SYMBOLS: <GT_ITAB> TYPE TABLE.
*
CREATE DATA GDO_DATA TYPE (DB_TAB).
<b>ASSIGN GDO_DATA->* TO <GT_ITAB></b>.
*
BREAK-POINT.
I get an shot Dump in the bold line with
ASSIGN_TYPE_CONFLICT
What mistake?
regards, Dieter
08-30-2006 1:43 PM
Hello Dieter
I made a mistake. Simply change:
CREATE DATA gdo_data TYPE <b>TABLE OF</b> (db_tab).
Regards
Uwe
08-30-2006 1:58 PM
Hi Uwe,
sorry now i get an syntax-error
The type specification of "TABLE" is incomplete
for the new Line.
REPORT ZGRO_TEST.
*
PARAMETER: DB_TAB LIKE DATABROWSE-TABLENAME.
*
DATA: GDO_DATA TYPE REF TO DATA.
FIELD-SYMBOLS: <GT_ITAB> TYPE TABLE.
*
<b>CREATE DATA GDO_DATA TYPE TABLE OF (DB_TAB)</b>.
*CREATE DATA GDO_DATA TYPE (DB_TAB).
ASSIGN GDO_DATA->* TO <GT_ITAB>.
*
BREAK-POINT.
Any idea.
Regards, Dieter
We have 4.6C
08-30-2006 2:47 PM
Hello Dieter
I am sorry but my solution will only work with >= 6.20. Here is a solution for 4.6c.
DATA:
gt_fcat type lvc_t_fcat,
gdo_data TYPE REF TO data.
*
FIELD-SYMBOLS:
<gt_itab> TYPE table.
*
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'MARA'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
* I_STYLE_TABLE =
it_fieldcatalog = gt_fcat
IMPORTING
ep_table = gdo_data
* E_STYLE_FNAME =
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ASSIGN gdo_data->* TO <gt_itab>.
Regards
Uwe
08-30-2006 5:06 PM
Hi Uwe,
thanks for help. It works very good.
When we change to ECC? i try your first idea.
Regards, Dieter
08-30-2006 12:29 PM
hi
good
PARAMETER: DB_TAB LIKE DATABROWSE-TABLENAME.
THIS STATEMENT LL WORK FINE.
DATA: BEGIN OF ITAB OCCURS 0.
INCLUDE STRUCTURE DB_TAB.
DATA: END OF ITAB.
THIS STATETMENT ALSO WORK FINE.
THANKS
MRUTYUN
08-30-2006 1:14 PM
Hi,
check this link:
http://www.sap-img.com/ab030.htm
REPORT zxx_create_data_dynamic .
TYPE-POOLS: slis.
DATA: it_fcat TYPE slis_t_fieldcat_alv,
is_fcat LIKE LINE OF it_fcat.
DATA: it_fieldcat TYPE lvc_t_fcat,
is_fieldcat LIKE LINE OF it_fieldcat.
DATA: new_table TYPE REF TO data.
DATA: new_line TYPE REF TO data.
FIELD-SYMBOLS: <l_table> TYPE ANY TABLE,
<l_line> TYPE ANY,
<l_field> TYPE ANY.
Build fieldcat
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SYST'
CHANGING
ct_fieldcat = it_fcat[].
LOOP AT it_fcat INTO is_fcat WHERE NOT reptext_ddic IS initial.
MOVE-CORRESPONDING is_fcat TO is_fieldcat.
is_fieldcat-fieldname = is_fcat-fieldname.
is_fieldcat-ref_field = is_fcat-fieldname.
is_fieldcat-ref_table = is_fcat-ref_tabname.
APPEND is_fieldcat TO it_fieldcat.
ENDLOOP.
Create a new Table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = new_table.
Create a new Line with the same structure of the table.
ASSIGN new_table->* TO <l_table>.
CREATE DATA new_line LIKE LINE OF <l_table>.
ASSIGN new_line->* TO <l_line>.
Test it...
DO 30 TIMES.
ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.
<l_field> = sy-index.
INSERT <l_line> INTO TABLE <l_table>.
ENDDO.
LOOP AT <l_table> ASSIGNING <l_line>.
ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.
WRITE <l_field>.
ENDLOOP.
Regards,
Laxmi.