Application Development and Automation 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: 
Read only

Create a Database Table through ABAP Code

Former Member
4,966

Hello!

Is there any way to create a Database table or a database structure through ABAP code?

Thanks in advance, mastuerzos!

11 REPLIES 11
Read only

Former Member
0 Likes
2,233

HI Yashir,

Check this

hope it helps you

Thanks!

Read only

naveen_inuganti2
Active Contributor
0 Likes
2,233

Hi,

Good Question...,

No . As of my knowledge its not possible. But we can create internal table from transaction code SE11.

Thanks,

Naveen Inuganti.

Read only

Former Member
0 Likes
2,233

Hi,

Hope this can be done to simulate Table creation using BDC methods.

Create recording for Table creation in Se11,then program this in SE38.

Read only

Former Member
0 Likes
2,233

Hi,

Its is not possible from se38.

In order to create Table from se38 you have to use BDC concept, even I have done this....

Regards,

Rajesh Sadula.

Read only

Former Member
0 Likes
2,233

Hi,

What about FM DDIF_TABL_PUT?

by the way, all DDIC objects can be created with DDIF* fms...

Cheers,

Manu.

Read only

0 Likes
2,233

Let's note:

1) the date of the OP

2) the OP.

Rob

Read only

0 Likes
2,233

arff...sorry for that...haven't noticed, was just focused on the last reply...

Kr,

Manu.

Read only

0 Likes
2,233

It happens

I was able to change a table using this FM, but not actually able to create one.

Rob

Read only

0 Likes
2,233

ah? I thought I used it in the past... or perhaps it was DD_CREATE_TABLE... For sure one of them can be used to do this.

Manu

Read only

Former Member
0 Likes
2,233

Hi,

I have gone through some SDN links, and I found we can create table using FM

1) DDIF_TABL_PUT - Create New Transparent Table.

2) DDIF_TABL_ACTIVATE - To active the table.

While using DDIF_TABL_PUT

DATA:

          lt_fields TYPE TABLE OF dd03p,

           wa_field TYPE dd03p,

           table_header TYPE dd02v,

           techn_set TYPE dd09v.

table_header-tabname = p_tabnam.

table_header-ddtext = p_tabtxt.

table_header-ddlanguage = sy-langu.

table_header-tabclass = 'TRANSP'.

table_header-as4user = sy-uname.

table_header-contflag = 'A'.

table_header-mainflag = 'X'.

techn_set-tabname = p_tabnam.

techn_set-tabkat = 0.

techn_set-tabart = 'APPL1'.

techn_set-bufallow = 'X'.

techn_set-pufferung = 'X'.

wa_field-tabname = p_tabnam.

wa_field-ddlanguage = sy-langu.

wa_field-notnull = 'X'.

wa_field-keyflag = 'X'.

wa_field-fieldname = 'ID'.

wa_field-position = position.

wa_field-rollname = 'CHAR10'.

APPEND wa_field TO lt_fields.

CALL FUNCTION 'DDIF_TABL_PUT'

  EXPORTING

    name              = 'Table Name'

    dd02v_wa          = table_header

    dd09l_wa          = techn_set

  TABLES

    dd03p_tab         = lt_fields " Table fields

  EXCEPTIONS

    tabl_not_found    = 1

    name_inconsistent = 2

    tabl_inconsistent = 3

    put_failure       = 4

    put_refused       = 5

    OTHERS            = 6.

IF sy-subrc = 0.

  WRITE: /, 'Table Created'.

ELSE.

  WRITE: /, 'Error occurred'.

ENDIF.

*Activating the Table

CALL FUNCTION 'DDIF_TABL_ACTIVATE'

  EXPORTING

    name              = 'Table Name'

* IMPORTING

*   RC                =

EXCEPTIONS

   not_found         = 1

   put_failure       = 2

   OTHERS            = 3.

IF sy-subrc <> 0.

  WRITE: /, 'Table could not be activated.'.

  RETURN.

ELSE.

  WRITE: /, 'Table has been activated.'.

ENDIF.

I believe this will solve your problem...

Regads,

Rajesh Sadula.

Read only

Sergiu
Contributor
0 Likes
2,233

I imagine batch input or LSWM also could be a solution.