2008 Jul 22 9:16 AM
Hello All.....
I wan to create a structure dynamically at the run time... Is this possible........ Can you please let me know abou this.....
2008 Jul 27 10:49 PM
Hello
You may want to have a look at my Wiki posting [Creating Flat and Complex Internal Tables Dynamically using RTTI|https://wiki.sdn.sap.com/wiki/display/Snippets/CreatingFlatandComplexInternalTablesDynamicallyusingRTTI] showing how to create structures and itabs (flat and complex) dynamically using RTTI.
Regards
Uwe
Strcture you mean Dictionary one or Program Structure.
if it is inside the program check this..
REPORT zdynamic.
DATA: struct_type TYPE REF TO cl_abap_structdescr, "Structure
table_type TYPE REF TO cl_abap_tabledescr,"Table type
dataref TYPE REF TO data. "Dynamic data
*-Component Table and Work area
DATA: comp_tab TYPE cl_abap_structdescr=>component_table,
comp_wa LIKE LINE OF comp_tab.
FIELD-SYMBOLS: <t_table> TYPE STANDARD TABLE,
<s_table> TYPE ANY.
comp_wa-name = 'VBELN'.
comp_wa-type ?= cl_abap_datadescr=>describe_by_name( 'CHAR10' ).
APPEND comp_wa TO comp_tab.
*Create Dynamic table using component table
struct_type = cl_abap_structdescr=>create( comp_tab ).
table_type = cl_abap_tabledescr=>create( p_line_type = struct_type ).
*Create Dynamic Internal table and work area
CREATE DATA dataref TYPE HANDLE table_type.
ASSIGN dataref->* TO <t_table>. "Dynamic table
CREATE DATA dataref TYPE HANDLE struct_type.
ASSIGN dataref->* TO <s_table>. "Dyanmic Structure
break-point.Regards
Vijay babu Dudla
2008 Jul 22 9:20 AM
2008 Jul 22 9:51 AM
Hi,
Check out this link, may be this link will help you out.
http://www.sap-basis-abap.com/sapab037.htm
Regards
Abhijeet
2008 Jul 24 7:13 AM
2008 Jul 27 4:13 PM
Strcture you mean Dictionary one or Program Structure.
if it is inside the program check this..
REPORT zdynamic.
DATA: struct_type TYPE REF TO cl_abap_structdescr, "Structure
table_type TYPE REF TO cl_abap_tabledescr,"Table type
dataref TYPE REF TO data. "Dynamic data
*-Component Table and Work area
DATA: comp_tab TYPE cl_abap_structdescr=>component_table,
comp_wa LIKE LINE OF comp_tab.
FIELD-SYMBOLS: <t_table> TYPE STANDARD TABLE,
<s_table> TYPE ANY.
comp_wa-name = 'VBELN'.
comp_wa-type ?= cl_abap_datadescr=>describe_by_name( 'CHAR10' ).
APPEND comp_wa TO comp_tab.
*Create Dynamic table using component table
struct_type = cl_abap_structdescr=>create( comp_tab ).
table_type = cl_abap_tabledescr=>create( p_line_type = struct_type ).
*Create Dynamic Internal table and work area
CREATE DATA dataref TYPE HANDLE table_type.
ASSIGN dataref->* TO <t_table>. "Dynamic table
CREATE DATA dataref TYPE HANDLE struct_type.
ASSIGN dataref->* TO <s_table>. "Dyanmic Structure
break-point.Regards
Vijay babu Dudla
2008 Jul 27 10:49 PM
Hello
You may want to have a look at my Wiki posting [Creating Flat and Complex Internal Tables Dynamically using RTTI|https://wiki.sdn.sap.com/wiki/display/Snippets/CreatingFlatandComplexInternalTablesDynamicallyusingRTTI] showing how to create structures and itabs (flat and complex) dynamically using RTTI.
Regards
Uwe
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |