Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Create Structure dynamically

Former Member
0 Kudos

Hello All.....

I wan to create a structure dynamically at the run time... Is this possible........ Can you please let me know abou this.....

1 ACCEPTED SOLUTION

uwe_schieferstein
Active Contributor
0 Kudos

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

5 REPLIES 5

Former Member
0 Kudos

Hi,

Check out this link, may be this link will help you out.

http://www.sap-basis-abap.com/sapab037.htm

Regards

Abhijeet

Former Member
0 Kudos

This message was moderated.

former_member188685
Active Contributor

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

uwe_schieferstein
Active Contributor
0 Kudos

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