Skip to Content
author's profile photo Former Member
Former Member

How to know who create db table (in code)

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 03, 2014 at 03:49 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 03, 2014 at 03:49 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 03, 2014 at 03:51 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 04, 2014 at 03:11 AM

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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 06, 2014 at 10:42 AM

    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


    1.JPG (26.9 kB)
    2.JPG (40.0 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 06, 2014 at 11:04 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 06, 2014 at 11:58 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 06, 2014 at 12:00 PM

    check in attributes tab of database table in se11.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.