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

abap program to create tables from spread sheet

Former Member
0 Likes
3,067

Any one developed a program to create custom tables in a mass like 100 + Z* tables.

We will have table name, field name and semantic attributes of fields in spread sheet file, program should take care creating them automatically based on input file.

Appreciate if any one can help.

Thanks,

Mahesh.

1 ACCEPTED SOLUTION
Read only

satyabrata_sahoo3
Contributor
0 Likes
2,368

Search for Function Modules in SE37 using ' DDIF_* '.  or search from table TFDIR. You will get many function modules which can help to create a dictionary object. Upload the excel and pass the parameters to the function module to create the respective objects. Ex- DDIF_TABL_PUT, DDIF_TABT_ACTIVATE, DDIF_TABT_PUT etc..

Hope this helps.

-SS-

8 REPLIES 8
Read only

satyabrata_sahoo3
Contributor
0 Likes
2,369

Search for Function Modules in SE37 using ' DDIF_* '.  or search from table TFDIR. You will get many function modules which can help to create a dictionary object. Upload the excel and pass the parameters to the function module to create the respective objects. Ex- DDIF_TABL_PUT, DDIF_TABT_ACTIVATE, DDIF_TABT_PUT etc..

Hope this helps.

-SS-

Read only

0 Likes
2,368

Thanks Sahoo, for your inputs, I was wondering if we have any method given by sap throw LSMW or any BDC program or utility given by SAP to make it simpler.

I cannot spend more time to do some research with FM and creating program... now..

Thanks,

Mahesh

Read only

0 Likes
2,368

Hi Mahesh,

I think there is no standard program to accomplish this. You can create a BDC for SE11 for this otherwise. Found this link useful while searching..

http://saptechnical.com/Tutorials/ABAP/BDC/DatabaseTable.htm

Good Luck!

-SS-

Read only

Former Member
0 Likes
2,368

Hi,

Go through this following code,

DATA:
   BEGIN OF FS_TABLE,
     TNAME TYPE TABNAME16,
     TDESC TYPE AS4TEXT,
     F1 TYPE NAME_FELD,
     D1 TYPE FIELD_TYPE,
     F2 TYPE NAME_FELD,
     D2 TYPE FIELD_TYPE,
     F3 TYPE NAME_FELD,
     D3 TYPE FIELD_TYPE,
   END OF FS_TABLE.

DATA:T_TABLE LIKE TABLE OF FS_TABLE.

CALL FUNCTION 'GUI_UPLOAD'
   EXPORTING
     FILENAME      =
     'C:\Documents and Settings\Test\Desktop\TABLE.TXT'
*   FILETYPE                      = 'ASC'
    HAS_FIELD_SEPARATOR           = 'X'
*   HEADER_LENGTH                 = 0
*   READ_BY_LINE                  = 'X'
*   DAT_MODE                      = ' '
*   CODEPAGE                      = ' '
*   IGNORE_CERR                   = ABAP_TRUE
*   REPLACEMENT                   = '#'
*   CHECK_BOM                     = ' '
*   VIRUS_SCAN_PROFILE            =
*   NO_AUTH_CHECK                 = ' '
* IMPORTING
*   FILELENGTH                    =
*   HEADER                        =
   TABLES
     DATA_TAB                      = T_TABLE
* EXCEPTIONS
*   FILE_OPEN_ERROR               = 1
*   FILE_READ_ERROR               = 2
*   NO_BATCH                      = 3
*   GUI_REFUSE_FILETRANSFER       = 4
*   INVALID_TYPE                  = 5
*   NO_AUTHORITY                  = 6
*   UNKNOWN_ERROR                 = 7
*   BAD_DATA_FORMAT               = 8
*   HEADER_NOT_ALLOWED            = 9
*   SEPARATOR_NOT_ALLOWED         = 10
*   HEADER_TOO_LONG               = 11
*   UNKNOWN_DP_ERROR              = 12
*   ACCESS_DENIED                 = 13
*   DP_OUT_OF_MEMORY              = 14
*   DISK_FULL                     = 15
*   DP_TIMEOUT                    = 16
*   OTHERS                        = 17
           .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

INCLUDE BDCRECX1.

START-OF-SELECTION.

PERFORM OPEN_GROUP.

LOOP AT T_TABLE INTO FS_TABLE.

PERFORM BDC_DYNPRO      USING 'SAPMSRD0' '0102'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                               'RSRD1-TBMA_VAL'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                               '=ADD'.
PERFORM BDC_FIELD       USING 'RSRD1-TBMA'
                               'X'.
PERFORM BDC_FIELD       USING 'RSRD1-TBMA_VAL'
                               'Z_EMP'.
PERFORM BDC_DYNPRO      USING 'SAPMSRD0' '0102'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                               'RSRD1-TBMA_VAL'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                               '=ADD'.
PERFORM BDC_FIELD       USING 'RSRD1-TBMA'
                               'X'.
PERFORM BDC_FIELD       USING 'RSRD1-TBMA_VAL'
                                FS_TABLE-TNAME.   .
PERFORM BDC_DYNPRO      USING 'SAPLSD41' '2200'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                               '=CHANGE_MAINTFLAG'.
PERFORM BDC_FIELD       USING 'DD02D-DDTEXT'
                               FS_TABLE-TDESC." 'Employee Details'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                               'DD02D-MAINFLAG'.
PERFORM BDC_FIELD       USING 'DD02D-CONTFLAG'
                               'A'.
PERFORM BDC_FIELD       USING 'DD02D-MAINFLAG'
                               'X'.
PERFORM BDC_DYNPRO      USING 'SAPLSD41' '2200'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                               '=WB_SAVE'.
*perform bdc_field       using 'DD02D-DDTEXT'
*                              'Employee Details'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                               'DD02D-MAINFLAG'.
PERFORM BDC_FIELD       USING 'DD02D-CONTFLAG'
                               'A'.
PERFORM BDC_FIELD       USING 'DD02D-MAINFLAG'
                               'X'.
PERFORM BDC_DYNPRO      USING 'SAPLSTRD' '0100'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                               'KO007-L_DEVCLASS'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                               '=TEMP'.
PERFORM BDC_FIELD       USING 'KO007-L_AUTHOR'
                               'MOHAN'.
PERFORM BDC_DYNPRO      USING 'SAPLSD41' '2200'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                               '=DEF'.
*perform bdc_field       using 'DD02D-DDTEXT'
*                              'Employee Details'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                               'DD02D-MAINFLAG'.
PERFORM BDC_FIELD       USING 'DD02D-CONTFLAG'
                               'A'.
PERFORM BDC_FIELD       USING 'DD02D-MAINFLAG'
                               'X'.
PERFORM BDC_DYNPRO      USING 'SAPLSD41' '2200'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                               '/00'.
*perform bdc_field       using 'DD02D-DDTEXT'
*                              'Employee Details'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                               'DD03D-ROLLNAME(01)'.
PERFORM BDC_FIELD       USING 'DD03D-ROLLNAME(01)'
                               FS_TABLE-F1. "'LIFNR'.
PERFORM BDC_FIELD       USING 'DD03D-FIELDNAME(01)'
                               FS_TABLE-D1.
PERFORM BDC_DYNPRO      USING 'SAPLSD41' '2200'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                               '/00'.
*perform bdc_field       using 'DD02D-DDTEXT'
*                              'Employee Details'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                               'DD03D-ROLLNAME(02)'.
PERFORM BDC_FIELD       USING 'DD03D-ROLLNAME(02)'
                               FS_TABLE-F2.
PERFORM BDC_FIELD       USING 'DD03D-FIELDNAME(02)'
                               FS_TABLE-D2.
PERFORM BDC_FIELD       USING 'DD03P-KEYFLAG(01)'
                               'X'.
PERFORM BDC_DYNPRO      USING 'SAPLSD41' '2200'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                               '/00'.
*perform bdc_field       using 'DD02D-DDTEXT'
*                              'Employee Details'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                               'DD03D-ROLLNAME(03)'.
PERFORM BDC_FIELD       USING 'DD03D-ROLLNAME(03)'
                               FS_TABLE-F3.
PERFORM BDC_FIELD       USING 'DD03D-FIELDNAME(03)'
                               FS_TABLE-D3.
PERFORM BDC_DYNPRO      USING 'SAPLSD41' '2200'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                               '=WB_SAVE'.
*perform bdc_field       using 'DD02D-DDTEXT'
*                              'Employee Details'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                               'DD03D-ROLLNAME(03)'.
PERFORM BDC_DYNPRO      USING 'SAPLSD41' '2200'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                               '=SE13'.
*perform bdc_field       using 'DD02D-DDTEXT'
*                              'Employee Details'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                               'DD03D-ROLLNAME(03)'.
PERFORM BDC_DYNPRO      USING 'SAPMSEDS' '0050'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                               'DD09V-TABKAT'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                               '=SICH'.
PERFORM BDC_FIELD       USING 'DD09V-TABART'
                               'APPL0'.
PERFORM BDC_FIELD       USING 'DD09V-TABKAT'
                               '0'.
PERFORM BDC_FIELD       USING 'ALLOWSTATE-NOT_ALLOWED'
                               'X'.
PERFORM BDC_DYNPRO      USING 'SAPMSEDS' '0050'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                               'DD09V-TABART'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                               '=BACK'.
PERFORM BDC_FIELD       USING 'DD09V-TABART'
                               'APPL0'.
PERFORM BDC_FIELD       USING 'DD09V-TABKAT'
                               '0'.
PERFORM BDC_FIELD       USING 'ALLOWSTATE-NOT_ALLOWED'
                               'X'.
PERFORM BDC_DYNPRO      USING 'SAPLSD41' '2200'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                               '=WB_CHECK'.
*perform bdc_field       using 'DD02D-DDTEXT'
*                              'Employee Details'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                               'DD03D-ROLLNAME(03)'.
PERFORM BDC_DYNPRO      USING 'SAPMSSY0' '0120'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                               '=BACK'.
PERFORM BDC_DYNPRO      USING 'SAPLSD41' '2200'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                               '=WB_ACTIVATE'.
*perform bdc_field       using 'DD02D-DDTEXT'
*                              'Employee Details'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                               'DD03D-ROLLNAME(03)'.
PERFORM BDC_DYNPRO      USING 'SAPLSEWORKINGAREA' '0205'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                               '=WEIT'.
PERFORM BDC_DYNPRO      USING 'SAPLSPO1' '0300'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                               '=NO'.
PERFORM BDC_DYNPRO      USING 'SAPLSD41' '2200'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                               'DD02D-DDTEXT'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                               '=WB_BACK'.
*perform bdc_field       using 'DD02D-DDTEXT'
*                              'Employee Details'.
PERFORM BDC_DYNPRO      USING 'SAPMSRD0' '0102'.
PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                               'RSRD1-TBMA_VAL'.
PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                               '=BACK'.
PERFORM BDC_FIELD       USING 'RSRD1-TBMA'
                               'X'.
PERFORM BDC_FIELD       USING 'RSRD1-TBMA_VAL'
                               FS_TABLE-TNAME.
PERFORM BDC_TRANSACTION USING 'SE11'.

ENDLOOP.
PERFORM CLOSE_GROUP.

Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Likes
2,368

Hi Mahesh,

In addition to what wrote, you can refer function module COM_CFG_DB_CREATE_VTABLE. This may not be doing exactly what you need (looking up an excel and creating tables) but it does create database tables. The logic to create database tables can be found in the subroutine cfgdb_create_ddic_table which is called from the above mentioned FM.

Read only

Former Member
0 Likes
2,368

Thanks Kumar,

I could not able to run the above FM successfully.

getting activation error.

I have entered table name and field names.

But not sure what to use in change parameters for CFG_Tables.

Could you try once and let me know what are all required parameters.

Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Likes
2,368

Do not try to execute that function module. Creating database tables is one of the things it does. I shared the name of the FM (and the relevant subroutine it calls) so that you can have a look at the code and pick the relevant parts. The FM is a part of a bigger and complex process and it may not be so simple to execute it independently (plus, executing it may lead to creation of unwanted objects/data in the system.)

If you look into the subroutine I had mentioned, you would see that it also uses the DDIF* function modules pointed out by Satyabrata.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,368

Did you perform some search at scn, as there are already some (...) threads that suggest FM

DDIF_TABL_PUT and DDIF_TABL_ACTIVATE (*)  to create and activate db tables.

Regards,

Raymond

(*) On older threads DB_CREATE_TABLE.