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: 

Table creation in Dictionary at Run Time

sinan_keklik
Participant
0 Kudos

Hi,

is it possible to create Tables at run time with ABAP in the Dictionary?

Sinan

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Sinan,

Can you plz give the scenario for which you need to create table at runtime in dictionary.

One of the options could be BDC of SE11. But when you do the recording of SE11 with some table, while recording only the table will be created in database. So at runtime, you may give different table name. But again, what is the use of creating the same structure of two tables in database.

Moreover, database design plays a very important role in design of any solution. So you first create the table in SE11. and then plan all the necessary tables, which will be linked to your first table. And then go for programming usage of it.

Hope this clears your query.

PS If the answer solves your query, plz close the thread by rewarding each reply.

Regards

6 REPLIES 6

Former Member
0 Kudos

Hi sinan,

You can't create a Ztables at Runtime.

Thanks.

Former Member
0 Kudos

Hi Sinan,

You can use this code in ABAP Editor for your problem.

call transaction 'SE11'.

Thanks.

Former Member
0 Kudos

hi Sinan

You cant create Ztables during runtime since they have to created before they are been used.

Ztables are SAP realted tables which can be created using top down or bottom up approach by giving their domain and data element.

REWARD PLEASE IF USEFUL

Former Member
0 Kudos

Hi,

With Call Transaction 'SE11' it is possible.

Regards

Ganesh

Former Member
0 Kudos

Hi Sinan,

Can you plz give the scenario for which you need to create table at runtime in dictionary.

One of the options could be BDC of SE11. But when you do the recording of SE11 with some table, while recording only the table will be created in database. So at runtime, you may give different table name. But again, what is the use of creating the same structure of two tables in database.

Moreover, database design plays a very important role in design of any solution. So you first create the table in SE11. and then plan all the necessary tables, which will be linked to your first table. And then go for programming usage of it.

Hope this clears your query.

PS If the answer solves your query, plz close the thread by rewarding each reply.

Regards

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Check whether it helps you.This is taken from SDN.

try this example:

=====================================

REPORT zmaschl_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.