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: 

How to know who create db table (in code)

Former Member
0 Kudos

Hello,

I writing a function module. I have string that contains the name of database table, and I need to know if the table is SAP standart table, or z table that not created by SAP.

Thanks,

Ednri.

12 REPLIES 12

Former Member
0 Kudos

Ednri,

Custom table should always start either with Z or Y so check for first character in the string and find out if it is a stanndard table or custom table

To find out who created table look into table DD02L

Thanks

Bala Duvvuri

Sudhakargadde
Participant
0 Kudos

Hi ednri,

you can use this link Where all the database tables are stored? | SCN.

and the table name is DD02L help to solve your problem.

Regards

sudhakar

nishantbansal91
Active Contributor
0 Kudos

HI Ednri,

   There is a Table for the TABLE DD02L that table store the SAP Table name with Author.

     Select TABNAME from DD02l where AS4user = (Function module paramter name) and Tabname like 'Z%' .

Try this code its works fine for me.

Regards.

Nishant

karun_prabhu
Active Contributor
0 Kudos

DD02L table does not contain the user who created the table but contains only who last changed that table.

0 Kudos

Do you have other way to solve the problem?

0 Kudos

Hi,

You can find the table history in DBTABLOG table!  check the report RSTBZAHL

0 Kudos

I don't understand how should I use this table in order to check who created the table.

0 Kudos

It is stored in TADIR table : AUTHOR field.

     TADIR -> OBJECT= TABL and OBJ_NAME = Table Name -> AUTHOR

Regards.

Former Member
0 Kudos

Hi Ednri,

you can try this code on your Function Module. i think it works fine.

goto se37,

make the following entries.

import parameter

export parameter

include the below code in source code

   TYPES : BEGIN OF ty_tables,

     tabname TYPE tabname,

     END OF ty_tables.

   TYPES : BEGIN OF ty_tadir,

     author TYPE author,

     END OF ty_tadir.

   DATA lt_dd02l TYPE TABLE OF ty_tables.

   DATA ls_tadir TYPE ty_tadir.

   SELECT tabname

     FROM dd02l

     INTO TABLE lt_dd02l

     WHERE tabname EQ im_tabname.

   IF sy-subrc NE 0.

     return-type    = 'W'.

     return-message = 'NO tables found'.

     ELSE.

     return-type    = 'S'.

     return-message = 'Table exists'.

SELECT SINGLE author

   FROM tadir

   INTO  ls_tadir

   WHERE obj_name EQ im_tabname.

   IF sy-subrc eq 0.

MOVE ls_tadir-author to author.

MOVE im_tabname to tablename.

ELSE.

   return-type = 'E'.

   return-message = 'Could not found'.

   ENDIF.

   ENDIF.

save and activate.

Cheers

raymond_giuseppi
Active Contributor
0 Kudos

As already written, information is stored in repository table TADIR. Access the table with the full primary key (as another type of object may share the same name) PGMID = 'R3TR', OBJECT = 'TABL',OBJ_NAME = name of the table .

  • AUTHOR :id of (e.g. SAP)
  • SRCSYSTEM : was created on (e.g. SAP)
  • DEVCLASS : package

In most systems, customer namespace are the default 'Y*' or 'Z*' range (1), in some other some namespace were reserved (2), so from package DEVCLASS you could check in table TDEVC the value of NAMESPACE which should be /0CUST/ for your customer developments and start with /0SAP for SAP standard /0SAP/, /0SAPBAS/, etc.) or even check owner of namespace in table TRNSPACETT.


DD02L -> TADIR -> TDEVC -> TRNSPACETT

Regards,
Raymond

(1) 16466 - Customer name range for SAP objects

(2) http://service.sap.com/namespaces

anupam_anand
Participant
0 Kudos

Hi Ednri,

As most of us have already indicated above, use table TADIR with the fields PGMID as R3TR, OBJECT as TABL and OBJ_NAME as the table name that you want to check. The correct field to retrieve the name of the user who created the table is TADIR-AUTHOR. Use this for your results.

Also, to find if the table is standard or a custom, check the first character of the table name and it should be Z or Y. Thats a standard coding practice for mostly all SAP implementations.

Hope it helped.

Thanks,

Anupam

hiriyappa_myageri
Participant
0 Kudos

check in attributes tab of database table in se11.