DB_CREATE_TABLE

Hi,
Plz tell me how to create a database table using function module DB_CREATE_TABLE in ABAP Editor.
I was tried it but raise an exception "PROGRAM_NOT_GENERATED".
Plz if you have any solution share with me.

Hi,
Use the below 2 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.
Example Code:
DATA:
           LT_FIELDS TYPE TABLE OF DD03P,
            WA_FIELD TYPE DD03P,
            TABLE_HEADER TYPE DD02V,
            TECHN_SET TYPE DD09V.
TABLE_HEADER-TABNAME = 'ZMARA1'.
TABLE_HEADER-DDTEXT = 'ZMARA1 TABLE'.
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 = 'ZMARA1'.
TECHN_SET-TABKAT = 0.
TECHN_SET-TABART = 'APPL1'.
TECHN_SET-BUFALLOW = 'X'.
TECHN_SET-PUFFERUNG = 'X'.
WA_FIELD-TABNAME = 'ZMARA1'.
WA_FIELD-DDLANGUAGE = SY-LANGU.
WA_FIELD-NOTNULL = 'X'.
WA_FIELD-KEYFLAG = 'X'.
WA_FIELD-FIELDNAME = 'ID'.
WA_FIELD-POSITION = '1'.
WA_FIELD-ROLLNAME = 'CHAR10'.
APPEND WA_FIELD TO LT_FIELDS.
CALL FUNCTION 'DDIF_TABL_PUT'
   EXPORTING
     NAME              = 'ZMARA1'
     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              = 'ZMARA1'
* 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.

Similar Messages

  • Creation of Database table using function module DB_CREATE_TABLE

    I used the function module DB_CREATE_TABLE to create a database table from a report program.
    The SY-SUBRC value being returned is 0 but I am not able to access the table using SE11(that is if it gets created). Kindly let me know if you know how to resolve this problem.
    Is there any other function module to create a database table from a report program?
    Thanks & Regards,
    Pranjali

    Hello,
    Check this programs how they are using the this FM.
    LSDB3U14
    LSDB6U04                               DD: Creation of temporary tables (only keys or complete)
    LSMC2F00                               Procedures for Creating and Deleting Dependent Matchcode ID Objects
    LSUGXU08
    LSUGXU18                             Rückgabe aller DB-spezifischen Parameter der Freiplatzprüfung im Upgra
    RCNV0002                               DD: Convert CDHDR and CDPOS
    RDDMV4TB                               Generate Exchange TADIR
    RDDMVCUA                               Generate Exchange TADIR
    RDDMVFTX                               Repository Switch: Generate New Empty Clone Table DDFTX
    RDDMVNTB                               Filling the Exchange Nametabs (DDYTT, DDYTF)
    RDDMVTRE                               Generate Exchange TADIR
    RSINFINI                               INFORMIX Performance Monitor: Additional DB Definitions for SAP R/3
    RTXWCF1F                               Include LTXW4F01

  • Error in transpoting info object

    Hello,
    Need help to solve this please!
    I am getting an error while tranporting an info object!
    Error 1 with function module RSDRX_FILL_INITIAL_PQTABLE (Fill Master Data)
    Message no. R7195
    Diagnosis
    Possible causes:
    Function module DB_CREATE_TABLE
    There is not enough room in the table space.
    Procedure
    In this case, check the logs on the database and extend the table space if it is too small.
    Help me please!
    Regards
    RAm

    Hello,
    Help me to solve this !
    I cant transport the info object !
    It says:
    Function module DB_CREATE_TABLE
    There is not enough room in the table space.
    Procedure
    In this case, check the logs on the database and extend the table space if it is too small.
    Help me!!
    Regards
    Ram

  • How to create a table dynamically

    Hello All,
    I want to create a table dynamically in DDIC. I know that there is function module exist DB_CREATE_TABLE but i am getting some errors while using it.
    Could any please post some code for it.
    Regards,
    Lisa

    Here is the code i have writen my self.
    PARAMETERS: tabname TYPE dd02l-tabname,
                fldname TYPE dd03p-fieldname,
                rollname TYPE dd03p-rollname.
    DATA: gt_cl_bc_dyn TYPE REF TO zcl_bc_dyn,
          status TYPE sy-subrc.
    data: lct_table type ZTT_ZTSITAB.
    INITIALIZATION.
      tabname = 'ZTEST1'.
      CREATE OBJECT gt_cl_bc_dyn.
    START-OF-SELECTION.
      CALL METHOD gt_cl_bc_dyn->create_table
        EXPORTING
          tabname   = tabname
          fieldname = fldname
          rollname  = rollname
          itab      = lct_table
        IMPORTING
          status    = status    .
      IF status = 0.
        WRITE: 'Table creation is successful'.
      ELSE.
        WRITE: 'Table creation is unsuccessful'.
      ENDIF.
    Code in the method
    METHOD create_table.
      DATA: ls_dd02v_wa TYPE dd02v,
            ls_dd09l_wa TYPE dd09l,
            ls_dd03p TYPE dd03p,
            lt_dd03p TYPE TABLE OF dd03p,
            rc TYPE sy-subrc.
      ls_dd02v_wa-tabname = tabname.
      ls_dd02v_wa-tabclass = 'TRANSP'.
      ls_dd02v_wa-contflag = 'A'.
      ls_dd09l_wa-tabname = tabname.
      ls_dd09l_wa-tabkat = '0'.
      ls_dd09l_wa-tabart = 'APPL0'.
      ls_dd03p-tabname = tabname.
      ls_dd03p-fieldname = fieldname.
      ls_dd03p-position = '0001'.
      ls_dd03p-keyflag = 'X'.
      ls_dd03p-rollname = rollname.
      APPEND ls_dd03p TO lt_dd03p.
      CALL FUNCTION 'DDIF_TABL_PUT'
        EXPORTING
          name                    = tabname
         dd02v_wa                = ls_dd02v_wa
         dd09l_wa                = ls_dd09l_wa
       TABLES
         dd03p_tab               = lt_dd03p
       EXCEPTIONS
         tabl_not_found          = 1
         name_inconsistent       = 2
         tabl_inconsistent       = 3
         put_failure             = 4
         put_refused             = 5
         OTHERS                  = 6
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CALL FUNCTION 'DDIF_TABL_ACTIVATE'
        EXPORTING
          name              = tabname
       IMPORTING
         rc                = rc
       EXCEPTIONS
         not_found         = 1
         put_failure       = 2
         OTHERS            = 3
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      status = rc.
    ENDMETHOD.

  • Problem when creating a transparent ddic table in a report

    Hi!
    I have a problem creating a transparent table dynamical in a report. I tried both function modules that I could find (DDIF_TABL_PUT and RPY_TABLE_INSERT) but I wasn't able to get a table created.
    Now I'm trying it with RPY_TABLE_INSERT (seems easier) but I'm getting an error (i think IX008) after running the report that the name is not proper for a view... I don't even want to create an view... I want to create a transparent table.
    Here is the coding passage:
    lv_tabname = 'ZD000000_0000000'.
    CLEAR: lt_tabl_fields.
    lt_tabl_fields-tablname = lv_tabname.
    lt_tabl_fields-fieldname = 'GUID'.
    lt_tabl_fields-dtelname = 'ZMODULE_GUID'.
    lt_tabl_fields-checktable = ''.
    lt_tabl_fields-keyflag = 'X'.
    lt_tabl_fields-position = 1.
    lt_tabl_fields-reftable = ''.
    lt_tabl_fields-reffield = ''.
    lt_tabl_fields-inclname = ''.
    lt_tabl_fields-notnull = 'X'.
    APPEND lt_tabl_fields.
    CLEAR: lt_tabl_fields.
    lt_tabl_fields-tablname = lv_tabname.
    lt_tabl_fields-fieldname = 'TIMESTAMP'.
    lt_tabl_fields-dtelname = 'ZCREATION_TSTMP'.
    lt_tabl_fields-checktable = ''.
    lt_tabl_fields-keyflag = ''.
    lt_tabl_fields-position = 2.
    lt_tabl_fields-reftable = ''.
    lt_tabl_fields-reffield = ''.
    lt_tabl_fields-inclname = ''.
    lt_tabl_fields-notnull = 'X'.
    APPEND lt_tabl_fields.
    j = 3.
    *& Get structure of current module
    CALL METHOD lr_analysis_module->get_field_list
      IMPORTING
        er_field_list = lr_field_list.
    *& Get first field
    i = 1.
    CALL METHOD lr_field_list->get_field
      EXPORTING
        index = i
      RECEIVING
        field = lr_field.
    WHILE lr_field IS NOT INITIAL.
      CLEAR: lt_tabl_fields.
      lt_tabl_fields-tablname = lv_tabname.
      lt_tabl_fields-fieldname = lr_field->get_name( ). "fieldname in module
      lt_tabl_fields-dtelname = lr_field->get_reference_type( ). "fieldtype for current field
      IF lt_tabl_fields-dtelname IS INITIAL.
        lt_tabl_fields-dtelname = lr_field->get_type( ).
      ENDIF.
      lt_tabl_fields-checktable = ''.
      lt_tabl_fields-keyflag = ''.
      lt_tabl_fields-position = j.
      lt_tabl_fields-reftable = ''.
      lt_tabl_fields-reffield = ''.
      lt_tabl_fields-inclname = ''.
      lt_tabl_fields-notnull = 'X'.
      APPEND lt_tabl_fields.
      j = j + 1.
      i = i + 1.
      CALL METHOD lr_field_list->get_field
        EXPORTING
          index = i
        RECEIVING
          field = lr_field.
    ENDWHILE.
    CLEAR: ls_tabl_inf.
    ls_tabl_inf-tablname = lv_tabname.
    ls_tabl_inf-language = sy-langu.
    ls_tabl_inf-tablclass = 'TRANSP'.
    ls_tabl_inf-sqltab = ''.
    ls_tabl_inf-buffered = ''.
    ls_tabl_inf-shorttext = lv_comment.
    ls_tabl_inf-acttype = '00'.
    ls_tabl_inf-inclexist = ''.
    ls_tabl_inf-masterlang = sy-langu.
    ls_tabl_inf-maintflag = 'X'.
    ls_tabl_inf-deliverycl = 'A'.
    ls_tabl_inf-mod_user = sy-uname.
    ls_tabl_inf-mod_date = sy-datum.
    ls_tabl_inf-mod_time = sy-uzeit.
    CLEAR: ls_tabl_technics.
    ls_tabl_technics-tablname = lv_tabname.
    ls_tabl_technics-language = sy-langu.
    ls_tabl_technics-tablcat = 4.
    ls_tabl_technics-tablclass = 'APPL0'.
    ls_tabl_technics-buffering = ''.
    ls_tabl_technics-keyfieldno = ''.
    ls_tabl_technics-logging = ''.
    ls_tabl_technics-storetype = ''.
    ls_tabl_technics-moduser = sy-uname.
    ls_tabl_technics-moddate = sy-datum.
    ls_tabl_technics-modtime = sy-uzeit.
    ls_tabl_technics-transpflag = 'X'.
    ls_tabl_technics-translate = ''.
    CALL FUNCTION 'RPY_TABLE_INSERT'
      EXPORTING
    *   LANGUAGE                = SY-LANGU
        table_name              = lv_tabname
    *   WITH_DOCU               = ' '
    *   DOCUTYPE                = 'T'
    *   TRANSPORT_NUMBER        = ' '
       DEVELOPMENT_CLASS       = 'ZD000000'
        tabl_inf                = ls_tabl_inf
       tabl_technics            = ls_tabl_technics
      TABLES
        tabl_fields             = lt_tabl_fields
    *   DOCU_TABLE_USER         =
    *   DOCU_TABLE_TECH         =
    * EXCEPTIONS
    *   CANCELLED               = 1
    *   ALREADY_EXIST           = 2
    *   PERMISSION_ERROR        = 3
    *   NAME_NOT_ALLOWED        = 4
    *   NAME_CONFLICT           = 5
    *   DB_ACCESS_ERROR         = 6
    *   OTHERS                  = 7
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Any ideas?
    Thanks and best regards.

    thanks for the quick response Volker.
    When I use the DB_CREATE_TABLE fm I only can create fields with datatype declaration (ddfield-datatype), but I need a fm where I can also create a field with a data element, because I'm generating the fields dynamically in the report based on the datatype/data element for a field.
    edit: I'll use the datatype/length/decimal of the corresponding data element. this should work...
    Edited by: Toni Fabijancic on Feb 10, 2009 3:42 PM

  • Funktion for "Create Table" Statement

    Dear all,
    I am looking for a function to create a "create table"-SQL statement from an existing SAP Dictionary table. Does anybod y know a abap function to do this. With the SQL Statement I want to create the table in an external Database.
    Kind Regards
    Roman Becker

    Hi please enter db_create* in se37 and pick the desired function needed.
    here are few Function modules for u.
    DB_CREATE_TABLE
    DB_CREATE_TABLE_AS_SELECT
    DB_CREATE_TABLE_AS_SELECT_S
    DB_CREATE_TABLE_S              As DB_CREATE_TABLE, also returns the generated statements
    Satish

Maybe you are looking for

  • Character sets and ado

    I have a table with a clob field on an Oracle 8.1.7.4 database. When querying the clob field via odbc and ado the value is truncated. The Oracle server and client are using a WE8ISO8859P1 character set. Has anyone come across this before. Thanks.

  • How do I restore my 80gb ipod if it doesn't show up in itunes?

    My ipod seems to have gotten corrupted somehow, it show everything stored on it as "other" an orange bar, no music, no videos, no pics. Also it doesn't show up in the itunes source area so I can not restore from there. I tried the 5 R's, didn't reall

  • ITunes stops during playback and won't start until I restart the computer

    I'm hoping someone can help me with this. I just reformated my computer and placed all the updates and programs back onto my computer. I had iTunes on my computer before and I reinstalled it then upgraded it to version 7.3.2.6. Now I've been reintrod

  • KUNNR in IDOC COND_A

    High, I have some problems with sending conditions to the other systems. I have to send the condition which is relevant for only one customer. I have tabel with SO/DC/Customer (KUNNR) only. When I send the condition out via VK11 --> conrition info --

  • QuickOffice Pro fails to Install on Symbian Anna

    I have a Nokia N8 with Symbian Anna. I purchased QuickOffice Pro from Ovi Store and it downloads but then fails to install. The trial version from the QuickOffice site also fails to install. Before I purchased QuickOffice I deleted the version of Qui