Getting field names of an internal table

Hi all,
Does anyone know if exists a statement, function module or method that gets the field names of an internal table ?
Thanks in advance,
David

Hi,
See this
REPORT typedescr_test.
TYPES:
BEGIN OF my_struct,
comp_a type i,
comp_b type f,
END OF my_struct.
DATA:
my_data TYPE my_struct,
descr_ref TYPE ref to cl_abap_structdescr.
FIELD-SYMBOLS:
<comp_wa> TYPE abap_compdescr.
START-OF-SELECTION.
descr_ref ?= cl_abap_typedescr=>describe_by_data( my_data ).
WRITE: / 'Typename :', descr_ref->absolute_name.
WRITE: / 'Kind :', descr_ref->type_kind.
WRITE: / 'Length :', descr_ref->length.
WRITE: / 'Decimals :', descr_ref->decimals.
WRITE: / 'Struct Kind :', descr_ref->struct_kind.
WRITE: / 'Components'.
WRITE: / 'Name Kind Length Decimals'.
LOOP AT descr_ref->components ASSIGNING <comp_wa>.
WRITE: / <comp_wa>-name, <comp_wa>-type_kind,
<comp_wa>-length, <comp_wa>-decimals.
ENDLOOP.

Similar Messages

  • How to get the field name of an internal table during runtime?

    How to get the field name of an internal table during runtime?

    Hi  Sudhir,
    Declare and Use Get Cursor Field in Your Prm to get the field Name of the Intenal Table
    Example Code:
        <b>  DATA: v_field(60).                        " Insert this code.
         GET CURSOR FIELD v_field.        " Insert this code.</b>
         <b>CHECK v_field = 'ITAB-KUNNR'.    " Insert this code. (or)
    Write: v_field.</b>
    Regards,
    Ramganesan K.

  • Reg: field names of an Internal table

    Hi all,
    I'd like to display all the field names of the internal table or a structure.
    I want it very urgent.
    Use ful answers will be awarded greatly.
    Thanks in advance.
    Jagan Mohan.

    Hi Jagan,
      Use the below code.
    TYPE-POOLS: SYDES.
    DATA: TD TYPE SYDES_DESC.
    DATA: BEGIN OF WA OCCURS 0,
           CONTINUE     TYPE C,
           NAME(15)     TYPE C,
          END OF WA.
    TYPES:BEGIN OF STR1,
            NUM(3) TYPE N,
            NAME(20) TYPE C,
          END OF STR1.
    *DATA: ITAB LIKE T247 OCCURS 0 WITH HEADER LINE.
    *DATA: ITAB TYPE STR1 OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF ITAB OCCURS 0,
           NUM(3) TYPE N,
           NAME(20) TYPE C,
          END OF ITAB.
    DESCRIBE FIELD ITAB INTO TD.
    WA[] = TD-NAMES[].
    LOOP AT WA.
      IF WA-NAME = SY-REPID.
        DELETE WA.
        CONTINUE.
      ENDIF.
      SEARCH WA-NAME FOR '-'.
      IF SY-SUBRC = 0.
        DELETE WA.
        CONTINUE.
      ENDIF.
      SEARCH WA-NAME FOR '='.
      IF SY-SUBRC = 0.
        DELETE WA.
        CONTINUE.
      ENDIF.
    ENDLOOP.
    LOOP AT WA.
      WRITE: / WA-NAME.
    ENDLOOP.

  • How to get field name dynamically of a table

    Hi,
    I have a table which has 5 fields, now i want to know the name of the fields dynamically at run time
    not the values each fields hold.
    I have tried field symbols, get reference but all i got the value of the field not the field name.
    is there any way  i can get the field name.
    regards,
    mayank

    1. If it is a DDIC table, you can use the FM 'DDIF_FIELDINFO_GET'. Search in SDN for details.
    2. If it is an internal table, check this code:
    TYPE-POOLS: abap.
    PARAMETERS p_table TYPE tabname .
    DATA: lcl_table TYPE REF TO cl_abap_tabledescr,
          lcl_struc TYPE REF TO cl_abap_structdescr,
          it_fields TYPE abap_compdescr_tab,
          wa_fields TYPE abap_compdescr.
    DATA: dref TYPE REF TO data.
    FIELD-SYMBOLS: <itab> TYPE ANY.
    CREATE DATA dref TYPE STANDARD TABLE OF (p_table).
    ASSIGN dref->* TO <itab>.
    START-OF-SELECTION.
    * Get the Table details
      lcl_table ?= cl_abap_typedescr=>describe_by_data( <itab> ).
    * Get the table line type i.e., structure details
      lcl_struc ?= lcl_table->get_table_line_type( ).
    * Get the components(fields) of the table line
      it_fields = lcl_struc->components.
      LOOP AT it_fields INTO wa_fields.
        WRITE: / wa_fields-name.
      ENDLOOP.
    BR,
    Suhas

  • How can I get the name of an internal table in a textfield?

    Hi,
    I have defined an internal table in a program. Now I need the name of thist table (<u>NOT</u> the components!!!) in a textfield.
    Example for Data-Definitions in my Program:
    data: begin of it_tab occurs 0,
            feld1  like icon-id,
            feld2  like icon-name,
          end of it_tab.
    data: tabname(30) type c.
    How can I transfer the name "IT_TAB" into the field tabname?
    Thanks in andvance!

    No, it has to by 'dynamic'. I don't want to transfer it hard, because it should work for any internal table name.
    The requirement is: There are many function modules that have an input field TABLENAME. I have to give the tablename in the Form 'IT_TAB'.
    But I look for a possibiltity not to write:
    tabname = 'IT_TAB'.
    For DDIC-Tables its not a problem, but I dont know a way for internal tables.

  • How can i read the field name in the internal table

    Hi friends
    i want to read the internal table filed name.
    my requirement is like this:
    data: begin of t_header occurs 0,
           extno(12),
           priotiy(5),
           ecnumber(10).
          end of t_header.
    loop at t_header.
    if the field name is priority i want to write some other
    logic here.....
    endloop.
    Please tell me how can i do this.

    data: wf_fld_cat type slis_t_fieldcat_alv .
    data: wf_repid like sy-repid .
    data: int_tab_name type slis_tabname .
    move: sy-repid to wf_repid  ,
            'INT_OUTPUT' to int_tab_name .
      call function 'REUSE_ALV_FIELDCATALOG_MERGE'
       exporting
         i_program_name              = wf_repid
         i_internal_tabname          = int_tab_name
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
        i_inclname                   = wf_repid
        i_bypassing_buffer           = 'X'
      I_BUFFER_ACTIVE              =
        changing
          ct_fieldcat                  = wf_fld_cat[]
       exceptions
         inconsistent_interface       = 1
         program_error                = 2
         others                       = 3
      if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    wf_fld_cat[] will hold the itab definition.
    Regards
    Raja

  • Get field names of an internal structure

    Hi,
    In my program, I have a structure created via begin-of/end-of.
    A table is based on this structure and later on, I use a macro that deals with the field names and values.
    I'd like to make the macro dynamic, in that it gets the table field names with hardcoded values.
    Is there anyway to get the names of my structure field names via an FM or through coding?
    Thanks,
    John

    Two ways:
    1) If you define your structure based on a data dictionary structure, you can use function module DDIF_TABL_GET to get the structure field names.
    2) In NetWeaver version 6.0 and above, you can use Run Time Type Services (RTTS) classes for this purpose.
    Here is sample code for RTTS:
    data: BEGIN OF wa,
            field1 type c,
            field2 type d,
            field3 type i,
          END OF wa.
    DATA: r_descr TYPE REF TO cl_abap_structdescr,
          wa_comp TYPE abap_compdescr.
    r_descr ?= cl_abap_typedescr=>describe_by_data( wa ).
    LOOP AT r_descr->components INTO wa_comp.
      WRITE:/ wa_comp-name.
    ENDLOOP.

  • Debugging ECC6: how to see the fields name when download internal table?

    When we debug a reprot in ECC6 and save to a local file an internal table, the fields are not appearing only the data,
    Is there a way to download also the table fields name?

    From the new debugger switch to the classic debugger using menu path Debugger->Switch to Classic Debugger. Form the classic debugger you can download internal table data with column name(s).
    Regards,
    Joy.

  • To read the column names of an internal table

    Hi ,
    I want to read the column/field names of an internal table into another internal table.
    How can this be done?
    Kind Regards,
    hgarsht Rungta

    Hi ,
    you can get the attributes of any internal table into another ..
    check the following code ..
    DATA : it_mara TYPE STANDARD TABLE OF mara  WITH HEADER LINE.
    DATA : it_detail   TYPE abap_compdescr_tab,
               wa_comp TYPE abap_compdescr.
    DATA : ref_descr TYPE REF TO cl_abap_structdescr.
    ref_descr ?= cl_abap_typedescr=>describe_by_data( it_mara ).
    it_detail[] = ref_descr->components .
    loop at it_detail into wa_comp.
    write:/ wa_comp-name .
    endloop.
    Regards,
    Rajesh Kumar

  • How to add one more field to an exist internal table

    hi abapers
    i am a very new abap programmer and just started learning it.
    i want to know How to add one more field to an exist internal table.
    lemme me put my question in a very simple way.
    i have a internal table having fields f1,f2,f3 and which also that internal also contains some data.
    now i want to add two more fields (mm & nn) to that internal table now.
    how can i do that.
    and i wanna know the websites names where i can find some brain teasing questions in abap programming.
    eagerly waiting for ur reply
    regards,
    Maqsood A Khan

    Hi, MAQSOOD.
    You can insert more fields in your internal table like this.
    refer this code snippet.
    DATA : BEGIN OF tbl_itab OCCURS 0.
            INCLUDE STRUCTURE zsdtc009.
    DATA :  vkorg   LIKE vbak-vkorg,  "inserted one
            vtweg   LIKE vbak-vtweg,  "inserted one
            vkbur   LIKE vbak-vkbur,  "inserted one
            vkgrp   LIKE vbak-vkgrp,  "inserted one
           END OF tbl_itab.
    you can also read the book "Teach yourself abap in 21 days"
    at http://cma.zdnet.com/book/abap/
    but that book is just about basic concept of abap and report program.
    it doesn't give a lecture for on-line program.
    you can get pdf version books(about abap, sap...things) from sap.
    http://help.sap.com/printdocu/core/Print46c/en/Data/htm/english.htm
    I wish I could help you.
    Regards
    Kyung Woo.

  • Field description of an internal table

    Hi,
    I am trying to read the field description of an internal table, which consists of fields from different DD tables. I am able to read the descriptions of a DD table by using FM 'DDIF_FIELDINFO_GET'.
    Can you please suggest me how can read the text descriptions of an internal table fields in a Language other than English.
    Thanks
    Lokman

    Here is my code. I am trying to use imternal table instead of DD table. If I use internal table I get short dump. The language is OK withh DD table.
    CALL FUNCTION 'DDIF_FIELDINFO_GET'
           EXPORTING
              TABNAME   = 'ZFISB_TRANSFERS'
               TABNAME    = trsf_sel_tab
               LANGU     =  SY-LANGU
            TABLES
                DFIES_TAB = trsf_field_tab.
    *delete trsf_field_tab where fieldname <> 'NR' OR FIELDNAME <> 'TDATE'
    *OR
    FIELDNAME <> 'FYEAR'.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
           EXPORTING
                retfield         = 'NR'
                value_org        = 'S'
                callback_program = 'ZFI_SCHOOL_BANKING_APP'
                callback_form    = 'TRANSFERS_F4CALLBACK'
           TABLES
                field_tab        = trsf_field_tab
                value_tab        = trsf_sel_tab
                return_tab       = return_tab
           EXCEPTIONS
                parameter_error  = 1
                no_values_found  = 2
                OTHERS           = 3.

  • Can I get field name of Selection screen ?

    Hi, experts.
    I'd like to manage PGM's screens & fields of screens. I need to know field names of selection screen in  external PGMs to manage input values of those fields.
    For values, I'll use 'Dynp_values_read', but what should I use for getting field names of selection screen?
    Is there any functions, classes or tables for PGM's fields of selection screen?
    I've found tables&functions for this and I found D020S, D020T, D021T for PGM's screen. But I counld't see proper field names that shows on a selection screen when I excuted PGM. I guess there's a conversion routine between data that saved in repository and field name on screen.
    Please let me know what should I use a function, tables or else.
    Thanks.

    Hi
    Use Read text pool syntax
    READ TEXTPOOL program name
    INTO T_TPOOL
    LANGUAGE 'NL'.
    within TB_TPOOL all select option field namees will be stored under field ID with type S
    Edited by: Lavanya K on Apr 22, 2009 10:02 AM

  • How to Copy data from field symbol to Dynamic Internal Table

    Hi,
    I want to copy the data between two dynamic Internal tables . Following is the code were I have data in the field symbol wanted to transfer it to the other Internal table :
    REPORT  ztest.
    DATA:
           gd_dref          TYPE REF TO data,
           gd_dref1          TYPE REF TO data.
    FIELD-SYMBOLS:  <fs1>   TYPE any,
                               <fs_wa> TYPE any,
                                <field>    TYPE any,                  
                                <fs_wa1> TYPE ANY TABLE.  * Contains data from p_src
    *Copy data from p_src to p_dest*
    PARAMETERS: p_src LIKE dd02l-tabname .    * Name of Dynamic Internal table *
                             p_dest LIKE dd02l-tabname .  * Name of Dynamic Internal table*
    *DATA : lt_csks LIKE p_dest WITH HEADER LINE.
    START-OF-SELECTION.
      CREATE DATA gd_dref TYPE (p_src).
      CREATE DATA gd_dref1 TYPE TABLE OF (p_src).
       ASSIGN gd_dref->* TO <fs_wa>.
       ASSIGN gd_dref1->* TO <fs_wa1>.
       SELECT * FROM (p_src) INTO TABLE <fs_wa1>.
    *Write out data from FIELD SYMBOLS TO Table.
       loop at <fs_wa1> into <fs_wa>.
         do.
           assign component  sy-index
              of structure <fs_wa> to <field>.
           if sy-subrc <> 0.
           exit.
           endif.
           if sy-index = 1.
             write:/ <field>.
           else.
           write: / <field>.
           endif.
         enddo.
       endloop.
    *Need Logic To Copy the Data to p_dest table from <fs_wa1>.
    *p_dest is a table having a similar structure to table p_src .
    *Need Logic To Copy the Data to p_dest table from <fs_wa1>.
    EXIT.
    Thanks in Advance.

    try this...
    I have extended your source code and just used vbak/vbap as an example as they have some common fields like vbeln/erdat etc which corresponds with your requirement of 'similar structure' i.e. shared/common fields in both.
    Cheers...
    report  ztest.
    data:
      gd_dref type ref to data,
      gd_dref1 type ref to data,
      gd_dref_str type ref to data,
      gd_dref_tab type ref to data.
    field-symbols:
      <fs1> type any,
      <fs_wa> type any,
      <fs1_dest_str> type any,
      <fs_dest_tab> type any table,
      <field> type any,
      <fs_wa1> type any table.
    * contains data from p_src
    *Copy data from p_src to p_dest*
    parameters: p_src like dd02l-tabname default 'vbak',
    * name of dynamic internal table *
                p_dest like dd02l-tabname default 'vbap'.
    * name of dynamic internal table*
    *data : lt_csks like p_dest with header line.
    start-of-selection.
      create data gd_dref type (p_src).
      create data gd_dref1 type table of (p_src).
      assign gd_dref->* to <fs_wa>.
      assign gd_dref1->* to <fs_wa1>.
      select * from (p_src) into corresponding fields of table <fs_wa1>
      up to 3 rows
      where vbeln ne space.
      create data gd_dref_str type (p_dest).
      create data gd_dref_tab type standard table of (p_dest).
      assign gd_dref_str->* to <fs1_dest_str>.
      assign gd_dref_tab->* to <fs_dest_tab>.
    *write out data from field symbols to table.
      loop at <fs_wa1> into <fs_wa>.
        " break-point here - can see vbeln/waers/create date/ etc move over to new structure
        " the 'common' fields of your structures - the same will happen. if they not the same name you will have to do an
        " explicit move i.e. if fieldname = xyz ....move fieldxyz to new field123....after the move-corre
        break-point.
        move-corresponding <fs_wa> to <fs1_dest_str>.
        insert <fs1_dest_str> into table <fs_dest_tab>.
    **    do.
    **      assign component  sy-index
    **         of structure <fs_wa> to <field>.
    **      if sy-subrc <> 0.
    **        exit.
    **      endif.
    **      if sy-index = 1.
    **        write:/ <field>.
    **      else.
    **        write: / <field>.
    **      endif.
    **    enddo.
      endloop.
      " write out some dest data from the dest table build from previous loop
      loop at <fs_dest_tab> assigning <fs1_dest_str>.
        do.
          assign component sy-index of structure <fs_wa> to <field>.
          if sy-subrc <> 0.
            exit.
          endif.
          if sy-index = 1.
            write:/ <field>.
          else.
            write: / <field>.
          endif.
        enddo.
      endloop.

  • Data from field symbol into an internal table or workarea

    Hi Experts,
    I have field symbol in which i get the data. I want to get this data into an internal table of type any or into an work area. How is this possible.
    My declaration for field symbol is as follow:
    FIELD-SYMBOLS: <l_t_data> TYPE any.
    DATA l_r_data TYPE REF TO data.
        CREATE DATA l_r_data type STANDARD TABLE OF (l_local_tab).
        ASSIGN l_r_data->* TO <l_t_data>.
    I get the data in this field symbol <l_t_data>. by passing into a funtion module. and I get the data into it. Now i have to assign the values of this field symbol to any internal table or to a work are how do i do it. Please help.
    Regards,
    Prashant.

    Not exactly sure what you need here, but.....
    FIELD-SYMBOLS: <l_t_data> TYPE TABLE.   "<<-- Change this
    FIELD-SYMBOLS: <l_s_data> TYPE ANY.      "<<---Add This
    DATA l_r_data TYPE REF TO data.
    CREATE DATA l_r_data type STANDARD TABLE OF (l_local_tab).
    ASSIGN l_r_data->* TO <l_t_data>.
    Loop at <l_t_data> assigning <l_s_data>.
    * Do what ever using <l_s_data>
    Endloop.
    Regards,
    Rich Heilman
    Edited by: Rich Heilman on Feb 28, 2008 2:42 PM

  • Help needed to get unique record from an internal table

    Hi Everybody,
    I have to get unique record from an internal table. i know we can use read statement with key condition .
    But the problem is i have to use some relational operators like GE or LE.
    eg
    read table itab into wa with key width GE itab-widthfrom
                                                       width LE itab-widthto
                                                       machno eq itab-machno.
    Its giving me error when I use the operators GE , LE.( I think since it can't find a unique record with those relational
    operators in the with key statement)
    Is there any other way to get unique record from internal table without using the loop?
    Thanks,
    Sunny

    Using the read statement you will need some kind of loop. For example.
    DO.
    READ TABLE......
      WITH KEY ......
                        READ = SPACE
    IF SY-SUBRC EQ 0
      TABLE-READ = 'X'.
      MODIFY TABLE
      ADD 1 TO W_FOUND.
    ELSE
      EXIT.
    ENDIF
    ENDDO.
    IF W_FOUND EQ 1.
    ...record is unique.
    ENDIF.

Maybe you are looking for

  • Shuts down out of the blue

    when restarted, the clock is back to year 2000 and the wi-fi connection out. any clues?

  • How to pass (String[] args), as a parameter.

    * StringMethods * @author (Robin) * @version (1) public class StringMethods     private String[] args;     private int numArgs;     public void printIt(String[] args)         System.out.print ("You have entered " + numArgs + " Strings");            

  • Action method never called

    Hello, I have identified a problem with my app which really puzzles me: When I specify programmatically whether a command button should be rendered, the action method never gets called whereas the button does get rendered. See below: <h:commandButton

  • Apple logo

    Hi there I need help my ipod 30gb with video it has been working fine till 2 days ago. The apple logo is on screen and thats all tried to restart it but it didnt work. It doesnt show up in itunes. I have updated software but nothing i have charged it

  • New ECC system with new org structure into existing CRM 7 system

    Hi, We have a situation where we have a current ECC 6 system which distributes organisation structure to a CRM 7 system using ALE (org units, positions, personnel numbers). We are implementing a new ECC 6 instance as a result of a merger which will h