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.

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.

  • 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.

  • 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

  • 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.

  • 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.

  • Are field symbols and Dynamic internal tables consistant?

    Hi,
    Are field symbols and Dynamic internal tables
    always consistent?
    In my program I m creating a dynamic itab and assignig values to it using <FS>, sometimes the program fails to execute assign <Fs> statement...
    this happens once in 3 to 4 runs
    any solution...
    I have proper clear and refresh statements in program.
    Thanks,
    Hardik

    Anurag,
    Thanks for a quick reply. Here I am sending a small piece of my code.
    MOVE-CORRESPONDING OUTTAB TO DYNTAB.
          CLEAR IT_UDATE.
          CLEAR : T_KBETR .
          READ TABLE IT_UDATE WITH KEY UDATE = OUTTAB-UDATE.
          CONCATENATE 'DYNTAB-KBETR' IT_UDATE-CO_POS INTO T_KBETR.
          ASSIGN (T_KBETR) TO <FS> .
          SUBRC5 = SY-SUBRC .
          IF SUBRC5 = 0 .
              <FS> =  OUTTAB-KBETR .
          ENDIF .
    read statement will always return CO_POS .
    while debuging this code a few times
    <b>ASSIGN (T_KBETR) TO <FS> .</b>
    returns sy-subrc = 4
    and that was leading the program to short dump earlier.
    now, as I have a check DYNTAB-KBETR holds no value on display.
    this happens very few times. (most of the times report is displaying desired output)
    Thanks,
    Hardik

  • 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.

  • Move Field symbol data to Internal table

    Dear All,
                     Please suggest how to move field symbol data to internal table. The requirement is I have dynamic data in Field symbol which to move to table parameter of a function module.
    Thanks in Advance
    Rams.

    Dear All,
                    In need to pass tabular data  i.e. multiple entries from field symbol to the table parameter of the custom function module.
    Field symbol is declared as below:
    FIELD-SYMBOLS: <FS_EXCEL_TAB> TYPE STANDARD TABLE,
                                 <FS_TABLE_HEADER> .
    DATA WA_PD LIKE PRICE_DOWNLOAD.
    APPEND <FS_TABLE_HEADER> TO <FS_EXCEL_TAB>.
    CLEAR <FS_TABLE_HEADER>.
      WA_PD-VKORG = <FS_EXCEL_TAB>-VKORG.u201D Problem while using this statement
      APPEND WA_PD TO PRICE_DOWNLOAD.
       CLEAR WA_PD.
    Field symbol <FS_EXCEL_TAB>  is populated like this.
    VKORG | KUNNR_SH | KUNNR_SP |
    0015      | 102105       | 102105       |
    Now I need to move this data to table in tables parameter of custom fucntion module.
    Thanks in advance,
    Rams

  • ALV display using dynamic field catalog and dynamic internal table

    hi ,
    please guide me for ALV display using dynamic field catalog and dynamic internal table.
    Thank you.

    Hi Rahul,
    maybe thread dynamic program for alv is helpful for you. More information about the [SAP List Viewer (ALV)|http://help.sap.com/saphelp_nw70/helpdata/EN/5e/88d440e14f8431e10000000a1550b0/frameset.htm]. Also have a look into the example programs SALV_DEMO_TABLE*.
    Regards Rudi

  • 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

  • How To Know The Column Name Of The Internal Table

    HI ,
            i have an internal table .
    f1          f2           f 3         f4            f5  
    matnr   mbrsh    mtart     meins       minbe
    i want to know the column name which depending on the value i.e . if it is matnr then f1 , if mbrsh it is f2 ..so on
    Thanks.

    Hi ,
          thanks for your replies . i am elaborating my query .
            I have an internal table with 80 fields i.e.f1,f2,f3......f80 . In the first index i will be having the fieldnames
    i.e.matnr , mbrsh , meins , mtart ..... . From second index onwards i will be having the corresponding data  for the field name.  i need to display a particular field in a table control . Here i will be knowing the fieldname. If i can get to know the column name i.e whether f1 or f2 or ... .i Can populate the data into the table control.
    Wht i have done is taken a field symbol  and used the following code.
    read table i_upload index 1  assigning <lv_upload>.
    here i will get the initial first record i.e
    F1                                             MATNR
    F2                                             MBRSH
    F3                                             MTART
    F4                                             WERKS
    F5                                             LGORT
    F6                                             VKORG
    F7                                             VTWEG
    F8                                             MAKTX
    F9                                             MEINS
    F10                                             MATKL
    F11                                             BISMT
    F12                                             BRGEW
    F13                                             GEWEI
    F14                                             NTGEW
    F15                                             GROES
    F16                                             KLART
    F17                                             CLASS
    F18                                             SPART
    F19                                             VRKME
    F20                                             UMREN
    now i want to the field name .
    Hope it is clear this time .
    Thanks.

  • 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.

Maybe you are looking for