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

Function "DDIF_NAMETAB_GET"

Hi,

I am reading a database table's attributed using DDIF_NAMETAB_GET function. My code is:

DATA: IO_TABLE_NAME TYPE tabname,
  it_dfies TYPE TABLE OF dfies,
  is_dfies TYPE dfies.
DATA: is_x030l  TYPE x030l.

*IO_TABLE_NAME is getting from user

CALL FUNCTION 'DDIF_NAMETAB_GET'
           EXPORTING
                tabname   = IO_TABLE_NAME
           IMPORTING
                x030l_wa  = is_x030l
           TABLES
                dfies_tab = it_dfies
           EXCEPTIONS
                OTHERS    = 1.

LOOP AT it_dfies INTO is_dfies.
ENDLOOP.

Above, When I watching the is_dfies, there are some informations as:

"ZCALISAN ID 0002000004 AKCNT"

I know that ZCALISAN is the name of database table, ID is the attribute of this table, AKCNT is the field type of this attribute.

Now,

1. I don't know 0002000004 mean? Or how to interpret this value?

2. I want to learn this table's primary key(s). But the table "it_dfies" includes only attribute information. How can I read primary keys? Is it possible to read primary keys using FUNCTION 'DDIF_NAMETAB_GET'?

3. I want to see the field type AKCNT or another field type's Data Type. Is it char? If char what is long? Or is it Decimal? How can I do this operation?

4. The purpose of all of these operations copying one database table. For this purpose, I will read table's information then using EXEC SQL I will create the copied table. Using EXEC SQL can I define DECIMAL like in SAP, or all other types like in SAP? Is there any restriction?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 16, 2005 at 08:29 AM

    Hi Huseyin,

    1. The value 0002000004 should be interpreted as two values: 0002 and 000004. The first gives away the field position (starting from 0001) and the second will give you the character (or byte) offset (where it starts).

    2. The primary key is supp;lied in the DFIES_TAB (field = KEYFLAG) in your example the table is named IT_DFIES. If this contains an X it's a key field.

    3. The structured table DFIES_TAB contains the information: The field DATATYPE contains what type it is and the field LENG contains it's length. The fields INTLEN and OUTPUTLEN contain the internal fieldlength (when using binary transfers) and the outputlength when using a 'WRITE' statement.

    4. In SAP there are several restrictions when creating tables. However you can bypass this by using NATIVE SQL. With this option it is possible to use the underlying database's own SQL format and thus allowing you greater freedom. NATIVE SQL is invoked as follows:

    EXEC SQL.
      CREATE TABLE ...
    ENDEXEC.

    Hope this gives you the answers,

    Regards,

    Rob.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      Since you do not know the structure of ITAB before-hand, you will have to use Field Symbols and Data References. Here is a sample code:

      DATA d_ref TYPE REF TO DATA.
      FIELD-SYMBOLS: <fs> TYPE ANY.
      
      CREATE DATA d_ref TYPE (SOURCE_TABLE).
      ASSIGN d_ref->*  TO <fs>.
      
      SELECT * FROM (SOURCE_TABLE) INTO <fs>.
       MODIFY (TARGET_TABLE) FROM <fs>.
      ENDSELECT.
      

      Please excuse the syntax errors if any, I have only tried to give you an idea. Hope it helps.

      Regards

      Message was edited by: Shehryar Khan

  • author's profile photo Former Member
    Former Member
    Posted on Feb 16, 2005 at 08:21 AM

    Hi,

    In the internal table dfies

    0002 is the <b>position</b> of of the field AKCNT in the table.

    000004 is the <b>offset</b> for the field in the table.

    There is a field <b>K(KEYFLAG)</b> in the internal field which will have value <b>'X'</b> if the field is a key field.

    The data type is stored in field '<b>DATATYPE</b>'

    Regards,

    Saji

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 16, 2005 at 08:22 AM

    Hi Huseyin!

    I'm too lazy to analyze output of DDIF_NAMETAB_GET, but you can find your information in table DD03L.

    Select with tabname = 'sourcetable', order by position, your key fields are marked in keyflag and also datatypes are available.

    But why do you have to create a copy, which is not visible in SAP?

    Regards,

    Christian

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 17, 2005 at 08:00 AM

    Hi Huseyin,

    Have a look at Class CL_ALV_TABLE_CREATE.

    Thanks

    Lakshman

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 17, 2005 at 08:44 AM

    Hi,

    Here's a example for dynamic program:

    Source_table = 'ZTAB'.

    Dest_table = 'ZCOPY'.

    create data dyn_tab type standard table of (source_table).

    assign dyn_tab->* to <dyn_tab>.

    SELECT * FROM (source_table) INTO table <dyn_tab>.

    INSERT (DEST_TABLE) FROM TABLE <dyn_tab>.

    Regards Andreas

    Message was edited by: Andreas Mann

    sorry Shehryar Khan ,

    but i did'nt see your posting on page 2 !

    so you shall get the points, if your solution is correct !

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi to everybody that wants to help me,

      I made a mistake about giving points. This thread has several questions. So, I must open several threads.

      I apologize everybody who gives answer espacially from Anand. I try to give points to everybody. But I must give 10 points to Anand for best alternative solution.

  • Posted on Feb 16, 2005 at 12:17 PM

    Hi Huseyin,

    you do'nt need a fm.

    take this:

    select * from z1 into table itab.

    insert z2 from table itab.

    Grx Andreas

    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.