‎2007 Apr 13 8:40 AM
Hi,
I want to define an internal table where the structure (which is a table name) in after syntax "INCLUDE STRUCTURE" is defined at runtime. How do I do this, I get the syntax error "The included type has no structure":
I want to do:
DATA: BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE i_table_name.
DATA: END OF itab.
where i_table_name is a imported string which refers to the database table in question.
regards
Baran
‎2007 Apr 13 8:48 AM
Hi Baran,
Just click on the below link.
Here you can see the complete details of HOW TO CREATE DYANMIC INTERNAL TABLE( Defining structure at runtime ). It is Crystal Clear.
" http://www.saptechnical.com/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm "
<b>Hope you can understand it easily.
Reward if helpful.</b>
Regards,
V.Raghavender.
‎2007 Apr 13 8:46 AM
Hi baran,
1. Just give the Table name on selection screen, and it will consruct dynamic internal table.
2. just copy paste.
REPORT abc.
*----
COMPULSORY
FIELD-SYMBOLS: <dyntable> TYPE ANY TABLE.
FIELD-SYMBOLS: <dynline> TYPE ANY.
DATA: lt TYPE lvc_t_fcat.
DATA: ls TYPE lvc_s_fcat.
FIELD-SYMBOLS: <fld> TYPE ANY.
DATA : fldname(50) TYPE c.
*----
parameters : tabname LIKE dd02l-tabname DEFAULT 'T001' OBLIGATORY.
*----
START-OF-SELECTION.
*----
PERFORM
PERFORM mydyntable USING lt.
PERFORM GET_DATA.
PERFORM SHOW_DATA.
BREAK-POINT.
*----
FORM
*----
FORM GET_DATA.
SELECT * FROM (TABNAME)
INTO TABLE <DYNTABLE>.
ENDFORM. "GET_DATA
*----
FORM
*----
FORM SHOW_DATA.
loop at <dyntable> ASSIGNING <dynline>.
sy-subrc = 0.
write 😕 .
WHILE SY-SUBRC = 0.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE <DYNLINE> TO <FLD>.
WRITE : <FLD>.
ENDWHILE.
endloop.
ENDFORM. "SHOW_DATA
*----
INDEPENDENT FORM
*----
FORM mydyntable USING ptabname.
*----
Create Dyn Table From FC
FIELD-SYMBOLS: <fs_data> TYPE REF TO data.
FIELD-SYMBOLS: <fs_1>.
FIELD-SYMBOLS: <fs_2> TYPE ANY TABLE.
DATA: lt_data TYPE REF TO data.
data : lt TYPE lvc_t_fcat .
DATA : ddfields LIKE ddfield OCCURS 0 WITH HEADER LINE.
*----
CALL FUNCTION 'DD_NAMETAB_TO_DDFIELDS'
EXPORTING
tabname = tabname
TABLES
ddfields = ddfields.
.
*----
CONSTRUCT FIELD LIST
LOOP AT ddfields.
ls-fieldname = ddfields-fieldname.
APPEND ls TO lt.
ENDLOOP.
ASSIGN lt_data TO <fs_data>.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt
IMPORTING
ep_table = <fs_data>
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
*----
Assign Dyn Table To Field Sumbol
ASSIGN <fs_data>->* TO <fs_1>.
ASSIGN <fs_1> TO <fs_2>.
ASSIGN <fs_1> TO <dyntable>.
ENDFORM. "MYDYNTABLE
regards,
amit m.
‎2007 Apr 13 8:48 AM
You can use
field-symbols: <dyn_table> type standard table,
and than
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>.
Hope this answers your question.
Assign reward points if it helps.
-Gaurang
‎2007 Apr 13 8:48 AM
Hi Baran,
Just click on the below link.
Here you can see the complete details of HOW TO CREATE DYANMIC INTERNAL TABLE( Defining structure at runtime ). It is Crystal Clear.
" http://www.saptechnical.com/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm "
<b>Hope you can understand it easily.
Reward if helpful.</b>
Regards,
V.Raghavender.