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

Function Module for Creation of Data Dictionary Object Structure

former_member188829
Active Contributor
0 Likes
5,639

Hi All,

I would like to know the Function Module name for creating the Data Dictionary Object Structure.

If i give input as the table name, NEW structure name and (Development class, Transport Request or Local Object), it has to create the NEW structure based on the Database table fields and structure(If table contains any structure).

Example: I pass input as Table name 'MARA' and New Structure name as 'YS_MARA', then it has to copy the all fields and structures in MARA to New structure 'YS_MARA'.

If there is no SAP standard Function module available then i can go for BDC.

Could you please suggest me on this?

Thank you in advance.

Thanks,

Vishnu.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,580

Hi,

I guess you could use FM DDIF_TABL_GET, DDIF_TABL_PUT & DDIF_TABL_ACTIVATE for that...

Kr,

Manu.

23 REPLIES 23
Read only

Former Member
0 Likes
4,580

Hi,

There is a copy function for all most all Repository objects in Workbench, which will do the exact functionality that you are askign for. What is your exact requirement, please be more specific.

Regards

Senthil.

Read only

0 Likes
4,580

Hello Senthil,

Thanks for your reply.

We are developing one automation tool which needs to create the structure based on the table fields.

I really do not require it manually. Because, we need to do it through program.

How ever, If there is no SAP standard function module then i will go for BDC.

Thanks,

Vishnu

Read only

0 Likes
4,580

Hi ,

I just debugged the standard copy functionality and found this fm DDUT_OBJECT_COPY.Its documented too.

But there are lot of other functions getting triggered related to development class,locks etc. May be you can have alook into it.

Read only

0 Likes
4,580

Thanks Keshav. I will get back to you.

Thanks,

Vishnu

Read only

Former Member
0 Likes
4,581

Hi,

I guess you could use FM DDIF_TABL_GET, DDIF_TABL_PUT & DDIF_TABL_ACTIVATE for that...

Kr,

Manu.

Read only

0 Likes
4,580

Hi Manu,

Thanks for your reply.

That function modules can be used for read a table from the ABAP Dictionary, to write a table in the ABAP Dictionary

and to activate a table.

Thanks,

Vishnu

Read only

0 Likes
4,580

Or a structure... If you don't define the parameter DD09L_WA...

Kr,

Manu.

Edited by: Manu D'Haeyer on Nov 16, 2011 10:18 AM

Read only

0 Likes
4,580

Hi Manu,

Yes, it is for Table only. I have read the Function module documentation.

Thanks,

Vishnu

Read only

0 Likes
4,580

Check method GENERATE_STRUCTURE defined in class CL_HRPAYIT_DDIC_GENERATOR for an example...

Kr,

m.

Read only

0 Likes
4,580

re-read it

it says:

The following constellations (or combinations) are possible:

1. The table should be completely revised or redefined:

In this case all the parameters should be defined. If it is a structure, the technical settings (DD09L_WA) should not be defined

Kr,

m.

Edited by: Manu D'Haeyer on Nov 16, 2011 10:22 AM

Read only

0 Likes
4,580

Hi Manu,

Let me check again, I will get back to you.

Thanks,

Vishnu

Read only

0 Likes
4,580

Hi Manu/Keshav,

Below is the sample which i have written and it is working fine. I have done the mistake while passing the Table Class.

DATA:dd03p_tab       LIKE dd03p OCCURS 2 WITH HEADER LINE,
     lwa_dd02v       TYPE dd02v.

dd03p_tab-tabname = 'YSVISHNU1'.
dd03p_tab-fieldname = 'MANDT'.
dd03p_tab-position = '1'.
dd03p_tab-keyflag = 'X'.
dd03p_tab-rollname = 'MANDT'.
APPEND dd03p_tab.

dd03p_tab-tabname = 'YSVISHNU1'.
dd03p_tab-fieldname = 'VBELN'.
dd03p_tab-position = '2'.
dd03p_tab-keyflag = ' '.
dd03p_tab-rollname = 'VBELN'.
APPEND dd03p_tab.

lwa_dd02v-ddlanguage = 'E'.
lwa_dd02v-ddtext = 'Vishnu Test'.
lwa_dd02v-tabname = 'YSVISHNU1'.
lwa_dd02v-tabclass = 'INTTAB'.

CALL FUNCTION 'DDIF_TABL_PUT'
  EXPORTING
    name        = 'YSVISHNU1'
    dd02v_wa    = lwa_dd02v
  TABLES
    dd03p_tab   = dd03p_tab
  EXCEPTIONS
    put_failure = 01
    OTHERS      = 02.
IF sy-subrc = 0.
  WRITE / 'Structure YSVISHNU1 is created successfully'.
ELSE.
  WRITE / 'Structure YSVISHNU1 is NOT created'.
ENDIF.

Thanks for your help,

Thanks,

Vishnu

Read only

0 Likes
4,580

You asked for

I pass input as Table name 'MARA' and New Structure name as 'YS_MARA', then it has to copy the all fields and structures in MARA to New structure 'YS_MARA'.

and now you are manually populating it ?

Kesav

Read only

0 Likes
4,580

May be he is doing that in Original program...For simplicity he is doing like that in sample code. I am just guessing

Read only

0 Likes
4,580

Hi Keshav,

Yes, Vijay guess is correct , That structure name every thing can do my original program and that was the sample program only.

Thanks,

Vishnu

Read only

0 Likes
4,580

Hi Vishnu,

How are you going to copy a a structure using DDIF_TABL_PUT ?

Anyways , no more confusions, happy that its resolved...Good Luck

Kesav

Read only

0 Likes
4,580

Hi Keshav,

We can get the all details of the table by using the Function module "DDIF_TABL_GET" and we can get the all field details into table DD03P_TAB of the Function module "DDIF_TABL_GET". After that i can use the Function module 'DDIF_TABL_PUT'.

Suppose, If i pass the table name 'MARA' to FM "DDIF_TABL_GET" and we can get the field details of that table to DD03P_TAB table of the Function module "DDIF_TABL_GET".

Thanks,

Vishnu.

Edited by: Vishnu on Nov 16, 2011 4:18 PM

Read only

0 Likes
4,580

Instead of that two step process, you can directly use DDUT_OBJECT_COPY. SAP standard functionality uses this.


CALL FUNCTION 'DDUT_OBJECT_COPY'
  EXPORTING
    type                  = 'STRU'
    src_name              = 'MARA'
*   SRC_ID                = ' '
    dst_name              = 'YTESTMARA'
*   DST_ID                = ' '
*   STATE                 = 'A'
*   WITH_SUBOBJECTS       = 'X'
*   WITH_DOCU             = 'X'
* EXCEPTIONS
*   ILLEGAL_INPUT         = 1
*   SRC_NOT_FOUND         = 2
*   COPY_FAILURE          = 3
*   COPY_REFUSED          = 4
*   OTHERS                = 5
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Kesav

Read only

0 Likes
4,580

Hi Keshav,

Sure, I will check it and get back to you. Thank you very much for your help.

Thanks,

Vishnu.

Read only

0 Likes
4,580

Indeed...and if you look deeper, you'll see that this FM is just calling the DDIF_* ones...

Moreover, this one is very restrictive as it does not allow to add extra/custom fields...

Kr,

Manu.

Read only

Former Member
0 Likes
4,580

HI,

Fm : DDIF_TABL_PUT should work.

Search for all DDIF* in SE37

Regards,

Jhings

Read only

0 Likes
4,580

Hi Jhings,

Thanks for your reply.

The Function module which suggested you is work for Table only.

Thanks,

Vishnu

Read only

Former Member
0 Likes
4,580

Dear friend,

to create dynamic ddic object

this might be useful...create 1 table in data dictionary here in this case i have created ZAVI_TST

and run below program..

REPORT ZAVI_LOGIC.

data : DD03P_TAB LIKE DD03P OCCURS 2 WITH HEADER LINE.

DD03P_TAB-TABNAME = 'ZAVI_TST'.

DD03P_TAB-FIELDNAME = 'F1'.

DD03P_TAB-POSITION = '1'.

DD03P_TAB-KEYFLAG = 'X'.

DD03P_TAB-ROLLNAME = 'CHAR1'.

APPEND DD03P_TAB.

DD03P_TAB-TABNAME = 'ZAVI_TST'.

DD03P_TAB-FIELDNAME = 'F2'.

DD03P_TAB-POSITION = '2'.

DD03P_TAB-KEYFLAG = ' '.

DD03P_TAB-ROLLNAME = 'CHAR2'.

APPEND DD03P_TAB.

COMMIT WORK.

CALL FUNCTION 'DDIF_TABL_PUT'

EXPORTING

NAME = 'ZAVI_TST'

TABLES

DD03P_TAB = DD03P_TAB

EXCEPTIONS

PUT_FAILURE = 01

OTHERS = 02.

IF SY-SUBRC = 1.

ROLLBACK WORK.

ENDIF.

IF SY-SUBRC = 0.

COMMIT WORK.

WRITE / 'Table ZAVI_TST is now revised with two fields.'.

WRITE / 'The active version is unchanged.'.

ELSE.

WRITE / 'Table ZAVI_TST is still active in the old state.'.

ENDIF.

after successful completion of the program...

open tcode se14

press enter with table name selection

then press button active and adjust data

with option save data or delete data (as per your choice)

revert back if any help needed... enjoy programming.... good luck...

avirat