2008 Apr 25 6:16 AM
Dear All,
Could anyone help me in the below topic:
I want to create Internal Table at runtime with different Names.
Name of the Internal Table should be decided at runtime. Type of all Internal Tables is same.
Ex. In loop, I want to create the as many Internal Tables as much times the loop will be executed.
TAB1
TAB2
TAB3
...
...
...
TABn
i.e.Name of the Internal Table will be concatenation of 'TAB' & <Loop Index>.
Please help ASAP.
Thanks in advance.
Best Regards,
Prasad
Dear All,
Could anyone help me in the below topic:
I want to create Internal Table at runtime with different Names.
Name of the Internal Table should be decided at runtime. Type of all Internal Tables is same.
Ex. In loop, I want to create the as many Internal Tables as much times the loop will be executed.
TAB1
TAB2
TAB3
...
...
...
TABn
i.e.Name of the Internal Table will be concatenation of 'TAB' & <Loop Index>.
Please help ASAP.
Thanks in advance.
Best Regards,
Prasad
2008 Apr 25 6:32 AM
Hi,
check the code below:
DATA: d_ref TYPE REF TO data,
d_ref2 TYPE REF TO data,
i_alv_cat TYPE TABLE OF lvc_s_fcat,
ls_alv_cat LIKE LINE OF i_alv_cat.
TYPES: tabname LIKE dcobjdef-name ,
fieldname LIKE dcobjdef-name,
desc LIKE dntab-fieldtext.
PARAMETER: p_tablen TYPE tabname. -
> Input table field
DATA: BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE dntab.
DATA: END OF itab.
FIELD-SYMBOLS : <f_fs> TYPE table,
<f_fs1> TYPE table,
<f_fs2> TYPE ANY,
<f_fs3> TYPE ANY,
<f_fs4> type any,
<f_field> TYPE ANY.
REFRESH itab.
CALL FUNCTION 'NAMETAB_GET' -
> Fetches the fields
EXPORTING
langu = sy-langu
tabname = p_tablen
TABLES
nametab = itab
EXCEPTIONS
no_texts_found = 1.
LOOP AT itab .
ls_alv_cat-fieldname = itab-fieldname.
ls_alv_cat-ref_table = p_tablen.
ls_alv_cat-ref_field = itab-fieldname.
ls_alv_cat-seltext = itab-fieldtext.
ls_alv_cat-reptext = itab-fieldtext.
APPEND ls_alv_cat TO i_alv_cat.
ENDLOOP.
internal table build
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = i_alv_cat
IMPORTING
ep_table = d_ref.
ASSIGN d_ref->* TO <f_fs>. -
> Dynamic table creation with fields of the table
DATA: l_field TYPE fieldname,
l_field1 type fieldname.
SELECT * FROM (p_tablen) INTO CORRESPONDING FIELDS OF TABLE <f_fs>.
Fetching of the data from the table
LOOP AT <f_fs> ASSIGNING <f_fs2>.
Here u can check the validations and process
ASSIGN COMPONENT 2 OF STRUCTURE <f_fs2> TO <f_fs3>.
ASSIGN COMPONENT 3 OF STRUCTURE <f_fs2> TO <f_fs4>.
IF sy-subrc = 0.
MOVE <f_fs3> TO l_field.
MOVE <f_fs4> TO l_field1.
WRITE:/1 l_field(20),
22 l_field1(10).
ENDIF.
ENDLOOP.
Regards
Kannaiah
2008 Apr 25 6:45 AM
Many thanks for the reply.
But, here Internal Table will be created with the same name at each time or with different names.
And can I decide the NAME of Internal Table (& not Transperent Table), as I explaied in my query?
Thanks in advance.
Best Regards,
Prasad
2008 Apr 25 6:49 AM
Here the structure of the internal table will be created dynamically, it will create internal table header based on the name what you have given inthe input.
Regards
Kannaiah
2008 Apr 25 6:54 AM
No, my table type is same for all tables.
So, it will not work my my requirement as Internal tables will be created with same name.
Thanks in advance.
Kind Regards,
Prasad
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |