Dynamic Creation of Internal table WITH HEADER LINE

Dear,
Please show me the way of creating Internal table WITH HEADER LINE dynamically..
Thanks,
Nirav

<font color='blue'>Hi Parekh,
Have a look at the sample program for Dynamic internal table
This program has been developed to update any table data in the dictionary. We give table name and File name as Input fields.
<pre>
REPORT znpmmm0201.
*Types
TYPES:
      BEGIN OF ty_file,
        data(4096) TYPE c,
      END OF ty_file.
*Type-pools
TYPE-POOLS:
      truxs.
*Work areas
DATA:
      wa_file      TYPE ty_file.
*Internal tables
DATA:
      it_file      TYPE STANDARD TABLE OF ty_file,
      it_data      TYPE truxs_t_text_data.
DATA:
      gv_dref TYPE REF TO data,
      file_name TYPE string.
*FIELD-SYMBOLS
FIELD-SYMBOLS:
               <gf_itab> TYPE STANDARD TABLE,
               <wa>      TYPE ANY.
*& Selection-screen
PARAMETERS:
      p_table TYPE rsrd1-tbma_val,
      p_file  TYPE ibipparms-path.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  PERFORM f4_for_p_file CHANGING file_name .
*& START-OF-SELECTION
START-OF-SELECTION.
  CREATE DATA gv_dref TYPE TABLE OF (p_table).
  ASSIGN gv_dref->* TO <gf_itab>.
  PERFORM upload_data USING file_name.
  MODIFY (p_table) FROM TABLE <gf_itab>.
*&      Form  UPLOAD_DATA
FORM upload_data USING file.
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                = file
      filetype                = 'ASC'
    TABLES
      data_tab                = it_file.
  APPEND LINES OF it_file TO it_data.
  CLASS cl_abap_char_utilities DEFINITION LOAD.
  DATA: l_field_seperator.
  l_field_seperator = cl_abap_char_utilities=>horizontal_tab.
  REPLACE ALL OCCURRENCES OF '|' IN TABLE it_data WITH l_field_seperator.
  CALL FUNCTION 'TEXT_CONVERT_TEX_TO_SAP'
    EXPORTING
      i_field_seperator    = l_field_seperator
      i_tab_raw_data       = it_data
    TABLES
      i_tab_converted_data = <gf_itab>.
ENDFORM.                    " UPLOAD_DATA
*&      Form  F4_FOR_p_file
FORM f4_for_p_file CHANGING file.
  DATA:
        l_field_name LIKE  dynpread-fieldname VALUE 'P_FILE'.
  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      program_name  = syst-cprog
      dynpro_number = syst-dynnr
      field_name    = l_field_name
    IMPORTING
      file_name     = p_file.
  file = p_file.
ENDFORM.                    " F4_FOR_p_file </pre>
Thanks,
Venkat.O</font>

Similar Messages

  • Dynamicly creating an internal table with header line

    Hi experts,
    I am trying to do a read on an internal table using field symbols of type any table. To be able to read more than one row at once, I'd like to read it into another internal table (instead of just one line and instead of looping through them one by one).
    So far the following line rendered an error that the target internal table doesn't have a header line
    read table <fs_v_tab> WITH KEY (<fs_comp>) = <fs_param>-low INTO <fs_v_tab>.
    (also attempted using "<fs_v_tab>->*" & "<fs_v_tab>[]" to be silly)
    Based on the following article, I was wondering if it were possible to dynamicly create an internal table with header line.
    [http://help-abap.blogspot.com/2008/09/dynamic-internal-table-creation.html|http://help-abap.blogspot.com/2008/09/dynamic-internal-table-creation.html]
    Any help or tips on how to dynamicly filter an internal table field-symbol is greatly appreciated!

    Just read the online help:
    This statement reads a row from internal table itab.
    Or more exact:
    This statement reads one row from internal table itab.
    Therefore you can not read multiple lines into another table. The header line is needed to put the result in. And this is not what you intended, the result will be in the header line, not in the table itself.
    If the row to be read is not uniquely specified, the first suitable row is read. In the case of index tables, this row has the lowest table index of all matching rows.
    At least you have to do what you dont wanna do: looping.

  • Getting error of Defining an internal table with header line, SELECT-OPTIO

    Hi all,
    i have a coding for my smart form,In this coding i have define an structure which being used,but when i execute it it give me
    error of Defining an internal table with header line, SELECT-OPTIONS, and RANGES is not allowed within a structure.Even tough you can see that in  my coding im not using SELECT-OPTION or RANGES,but can't understand why it gives me this error.
    Following are the code:
      DATA: BEGIN OF traptab OCCURS 50.
            INCLUDE STRUCTURE mseg.
      DATA: vgart LIKE mkpf-vgart,
            blart LIKE mkpf-blart,
            blaum LIKE mkpf-blaum,
            bldat LIKE mkpf-bldat,
            budat LIKE mkpf-budat,
            cpudt LIKE mkpf-cpudt,
            cputm LIKE mkpf-cputm,
            aedat LIKE mkpf-aedat,
            usnam LIKE mkpf-usnam,
            tcode LIKE mkpf-tcode,
            xblnr LIKE mkpf-xblnr,
            bktxt LIKE mkpf-bktxt,
            frath LIKE mkpf-frath,
            frbnr LIKE mkpf-frbnr,
            wever LIKE mkpf-wever,
          END OF traptab. 
    Thanks & Regards,
    sappk25

    thanks

  • BADI cant use an internal table with header line

    hi,
         In BADI, we cant use an internal table with header line, and I am calling a function module which requires internal table as import parameter, now, the table I am passing is without a header line, So how to solve this problem ?

    You can use a type and then create an internal table of that type.
    types :
    begin of t_<example>
    *field list
    end of t_<example>
    data :
    gt_<table> type standard table of t_<example>
    pass this to the FM

  • Passing an internal table WITH HEADER LINE to abap object

    Hi. In another thread, it was explained how to pass an internal table to an abap object method. Is it possible to pass an internal table that has a header line, and RETAIN the header line once the table has been passed?
    My problem is, that I can pass the table, update it, but the read buffer is not populated when returning from the object's method. This is the result of being able to pass a STANDARD TABLE type, but not a STANDARD TABLE WITH HEADER LINE.
    This means that I have to read the table into a work area instead of doing a READ TABLE LKNA1 within the method, which is what I need to do.
    Thanks.

    Please check this sample program, notice that it is modifing the internal table and passing it back modified as well as passing the "work area" or "header line" back thru the exporting parameter.
    report zrich_0001.
    *       CLASS lcl_app DEFINITION
    class lcl_app definition.
      public section.
        types: t_t001 type table of t001.
        class-data: it001 type table of t001.
        class-data: xt001 like line of it001.
        class-methods: change_table
                                    exporting ex_wt001 type t001
                                    changing im_t001 type t_t001.
    endclass.
    data: w_t001 type t001.
    data: a_t001 type table of t001 with header line.
    start-of-selection.
      select * into table a_t001 from t001.
      call method lcl_app=>change_table
                 importing
                     ex_wt001 = w_t001
                 changing
                     im_t001  = a_t001[] .
      check sy-subrc  = 0.
    *       CLASS lcl_app IMPLEMENTATION
    class lcl_app implementation.
      method change_table.
        loop at im_t001 into xt001.
          concatenate xt001-butxt 'Changed'
               into xt001-butxt separated by space.
          modify im_t001 from xt001.
        endloop.
        ex_wt001 = xt001.
      endmethod.
    endclass.
    Regards,
    Rich Heilman

  • How to create an internal table with header line in smartforms

    Hello Guys,
    I need to append the data in my internal table in smartforms by the problem is an error occurred "a table without header line  and therefore no component called tdline"
    i already declared the data under types declaration tab
    types : begin of ts_tline,
             TDFORMAT type tdformat,
             tdline type tdline,
            end of ts_tline.
    types : it_tline type table of ts_tline.
    and declare these in global data
    WA_TLINE type TS_TLINE
    XT_TLINE type IT_TLINE
    my syntax in program lines :
      LOOP AT  gy_lines INTO WA_PROJ.
        SPLIT wa_proj AT  cl_abap_char_utilities=>cr_lf
           INTO table IT_SPLIT.
        LOOP AT IT_SPLIT.
          MOVE it_split-commentext TO xt_TLINE-tdline.
    an error occured at this part ****
         append xt_TLINE.
        ENDLOOP.
      ENDLOOP.
    what is wrong with my code..it cannot append data to xt_tline.
    Please help.Will reward points
    Thanks in advance
    aVaDuDz

    check this link
    this will help u......
    http://www.****************/Tutorials/Smartforms/SFMain.htm
    reward IF..........
    regards
    Anbu

  • Internal table with header line

    Hi All,
         I want to declare a internal table with headerline as page attribute.
         i am having to fields in the internal table ( firstname and lastname ). how to do that?
    helpful answers will be rewarded.
    Regards,
    Azaz Ali.

    Azaz,
    Why do you need a header line?
    Header lines are a no-no in an object context and if you need to loop at the table you can always declare a line type or an field symbol to process the table.
    If you need an table as a page parameter the best way to do it is to create a table type. This is based of a line type (another name for structure ) and this may well be based off a database (transparent) table.
    If you need to do special things to the table I would look at tableview iterators.
    Let me dig out a blog reference for that...
    ... ahh here it is
    <a href="/people/thomas.jung3/blog/2004/06/17/bsp-150-a-developer146s-journal-part-i-introduction View Iterator blog</a>
    HTH,
    N

  • Why does my internal table(with header line) ignore 4 of its fields?

    Hi Gurus,
    I am a newbie to ABAP how has spent far to much of my weekend time trying to solve the following problem;
    when trying to insert data from table cdpos into my internal table, I only get the two object* fields, the other 3 are not even part of the internal table according to the debugger.
    my select code is:
      SELECT  fname tabkey changenr    objectclas objectid
       FROM  cdpos
       INTO CORRESPONDING FIELDS OF i_cd_index
      WHERE tabname = 'XXX'
       AND  fname   = 'XXX'
       AND  chngind = 'U'   
      ENDSELECT.
      IF sy-subrc <> 0.
      ENDIF.
    - If I use a wa like line of i_cd_index the other fields will show up.
    - I have tried with including 'TABLE' in the INTO statement, same result.
    Please help out, getting very frustrated here....
    /Mike

    Hi Magdic,
    I have completely coded for but i have taken as parameters rather direct values (XXXX). Under stand the code and select statement you will get it. Program which i have shown is working fine.
    Do one thing first go the table CDPOS take one entry of Objectid, Tabname, fname and chngind and then enter in the selection and find whether the values are fetched correctly or not.
    To my knowledge there might be no data in your table.
    Anyhow try the below code.
    TABLES: CDPOS.
    DATA: ITAB LIKE CDPOS OCCURS 0 WITH HEADER LINE.
    parameters: p_CHGID like CDPOS-chngind,
                p_TAB like CDPOS-TABNAME,
                P_FNAM LIKE CDPOS-FNAME.
    SELECT OBJECTID TABNAME FNAME CHNGIND FROM CDPOS INTO CORRESPONDING FIELDS OF ITAB WHERE OBJECTID = P_CHGID
                                                                                    AND TABNAME = P_TAB
                                                                                    AND FNAME = P_FNAM.
    APPEND ITAB.
    ENDSELECT.
    WRITE: ITAB-OBJECTID, ITAB-TABNAME, ITAB-FNAME, ITAB-CHNGIND.
    Cheers!!
    Balu

  • How to move field symbol internal table to internal table with header line?

    Dear all,
    hi...hereby i would like to ask how i can move field symbol internal table to a internal table?
    as i know field symbol internal table is without header line..
    so, may i know how to do this....to move field symbol internal table to internal table which consist of header line and field and record will same as field symbol internal table...in additional, my field symbol internal table is dynamic table mean everytime will have flexible columns..?
    Please advise...
    Thanks
    Regard,
    ToToRo.
    Edited by: @ToToRo@ on Aug 20, 2009 6:16 AM

    Hello,
    Try this way:
    If both the type of internal tables are same then you can directly assign dynamic internal table to static internal table.
    itab = <itab>.
    Suppose you have field symbol internal table <itab> which is different in structure from ITAB.
    Now, you can create <wa> as follow:
    FIELD-SYMBOLS <wa>.
    DATA wa TYPE REF TO DATA.
    CREATE DATA wa TYPE LINE OF <itab>.
    ASSIGN wa->* to <wa>.
    This way your work area is read.
    Using [ASSIGN COMPONENT|http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3923358411d1829f0000e829fbfe/content.htm] syntax you can read required component of <wa>.
    Finally you can use that value to load static internal table.
    You can also refer to my thread on [Dynamic table|Re: Creating Dynamic table].
    Hope this helps!
    Thanks,
    Augustin.
    Edited by: Augustarian on Aug 20, 2009 10:06 AM

  • Internal table with header line and work area.

    data:itab like LIKE bapimepoheader.
    DATA : BEGIN OF it_po_items OCCURS 0.
            INCLUDE STRUCTURE bapimepoitem.
    DATA : END OF it_po_items.
    DATA:it_input         TYPE STANDARD TABLE OF typ_input,
          wa_input         TYPE typ_input,
    LOOP AT it_input INTO wa_input WHERE poind = 'H'.
    CLEAR wa_po_header.
      wa_po_header-doc_type  = wa_input-bsart.
      wa_po_header-comp_code = wa_input-bukrs.
      wa_po_header-vendor    = wa_input-lifnr.
    CLEAR it_po_items.
      it_po_items-po_item = v_itemcount * 10.
      it_po_items-acctasscat = wa_input-knttp.
      it_po_items-material   = wa_input-matnr.
      it_po_items-plant      = wa_input-werks.
      it_po_items-quantity   = wa_input-menge.
      it_po_items-net_price  = wa_input-netpr.
      it_po_items-po_unit    = wa_input-meins.
      it_po_items-free_item  = wa_input-umson.
      it_po_items-tax_code   = wa_input-mwskz.
      it_po_items-gr_ind     = wa_input-wepos.
      it_po_items-gr_non_val = wa_input-weunb.
      it_po_items-incoterms1 = wa_input-inco1.
      it_po_items-incoterms2 = wa_input-inco2.
      it_po_items-vend_mat   = wa_input-idnlf.
      it_po_items-taxjurcode = wa_input-txjcd.
      it_po_items-item_cat   = wa_input-pstyp.
      APPEND it_po_items.
    here my doubt is whether i can move data from work area to internal table in this way?
    whether this is the correct approach or not?

    hii,
    u can define structure and make workarea ,internal table using that structure.
    for example
    types:begin of struct,
             declare all fields,
             end of struct.
    data:wa type struct,
           int_tab type standard table of struct.
    hope this will help u.

  • Error: Tables with Header line No longer Supported In WD-ABAP

    Hi folks,
               I am working on WD4A functionality.I have to use Abap code to retrive data from database and i am doing it by declaring internal table with header line in one of the Methods.I have to do manipulation on table before i can bind table to result node.I can do manipulation in Header in ABAP,but now it is no longer supported in WD4A.What can i do for this?
    Nirad.

    hi nirad.
    The example is not of much sense
    but explains the funtionality. Hope this is what you are searching for.
    data:
             lt_flights    type table of sflight.
    data:
             ls_flight     type sflight.
    select * from sflight
    into corresponding fields of table lt_flights.
    loop at lt_flights into ls_flight.
      ls_flight-price = 1000.
      modify lt_flights from ls_flight.
    endloop.
    Cheers,
    Sascha

  • Moving data into internal table without header line

    Hello experts.
    i have two internal tables . itab1 without headerline and itab2 with headerline. itab1 has 10 fields and itab2 has 2 fields.
    BEGIN OF itab,
            lifnr LIKE lfa1-lifnr,
            ktokk LIKE lfa1-ktokk,
            name1 LIKE lfa1-name1,
            sortl LIKE lfa1-sortl,
            pstlz LIKE lfa1-pstlz,
            ort01 LIKE lfa1-ort01,
            land1 LIKE lfa1-land1,
           j_1ipanno LIKE j_1imovend,
    end of itab.
    DATA: itab1 TYPE STANDARD TABLE OF itab.
    data: begin of itab2 occurs 0,                             
          lifnr like j_1imovend-lifnr,
          j_1ipanno like j_1imovend-j_1ipanno,
      end of itab2.
    now i want to move the data from itab2-j_1ipanno into itab1-j_1ipanno. so pls tell me how to do that. lifnr in both the tables are the same.
    thanks for all the replies.

    Hi Shiva,
    In with out header line,
    You declare header line & body separately like
    data: IT_MARA type standard table of MARA,
    WA_MARA like line of IT_MARA.
    Advantages:
    1. Clear differentiation of header line over body
    2. It is must in the ABAP Objects to have separate header line & body
    3. Use ful in Nested Internal tables
    Disadvantages:
    1. Long syntax
    for example: Loop at IT_MARA into WA_MARA.
    In with header line
    Data ITAB like MARA occurs 0 with header line.
    Advantages:
    1. Simple to use & declare over without header line.
    Also,
    With Header line:
    codedata : itab like <dbtable> occurs 0 with header line.
    Data: begin of itab occurs 0,
    f1 type f1,
    f2 type f2,
    end of itab.[/code]
    Without Header line.
    codeTypes: begin of ty_tab,
    f1 type f1,
    f2 type f2,
    end of ty_tab.
    Data: itab type table of ty_tab, " Internal Table
    wa type ty_tab. " Work Area[/code]
    at any point of time use internal table without header line,it will be good performance as well OO ABAP will allow only internal table without header line.
    Just use one simple example :
    create one simple program with header line,use get run time field.
    create one simple program without header line,use get run time field.
    see the results ,here time will be micro seconds,so take 1000 records to internal table and do calculate the time.
    While adding or retrieving records to / from internal table we have to keep the record temporarily.
    The area where this record is kept is called as work area for the internal table. The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.
    Header line is a implicit work area for the internal table. It depends on how the internal table is declared that the itab will have the header line or not.
    e.g.
    data: begin of itab occurs 10,
    ab type c,
    cd type i,
    end of itab. " this table will have the header line.
    data: wa_itab like itab. " explicit work area for itab
    data: itab1 like itab occurs 10. " table is without header line.
    The header line is a field string with the same structure as a row of the body, but it can only hold a single row.
    It is a buffer used to hold each record before it is added or each record as it is retrieved from the internal table. It is the default work area for the internal table.
    kindly reward if found helpful.
    cheers,
    Hema.

  • Downloading the internal table with header to FTP folder

    Hi All,
    I have one requirement in downloading the internal table details with the fixed header line to FTP folder. The header line having the fixed text of 425 characters length.
    Note: We are not suppose to use WS_DOWNLOAD and GUI_DOWNLOAD function modules.
    Thanks in advance for your reply.
    Regards
    Kamini.

    Hi,
    I can download the internal table details successfully to FTP folder using the FTP function modules like(FTP_CONNECT, FTP_COMMAND , FTP_R/3_TO_SERVER and FTP_DISCONNECT). Here my problem is I am unable to download the internation table with some header text.
    You can see the format (example) of file to be download.
    Here I can successfully download the below details without the header. But I am unable to download with header line. Could you please suggest me.
    seq_no|record_action|trans_date|sku|description|
    1|N|2008-01-03 07:52:31|TTASA5025CBO     
    2|N|2008-01-03 10:28:33|411014        
    3|N|2008-01-03 10:01:03|TTASA6030CBO  
    4|N|2008-01-03 10:01:15|TTASA6630CBO
    5|N|2008-01-03 10:01:25|TTASA7035CBO 
    6|N|2008-01-08 16:57:39|TT6G       
    Regards
    Kamini.

  • Dynamic creation of internal table based on alv layout

    Hi experts!!
    I have the following request from my client:
    I am displaying an alv report and i need to download it in txt format based on the columns showed in the current layout (i.e. if the user chooses to hide some columns, then they should not appear in the txt file ). In the alv i am using the Function Modules of the alv and not ABAP Objects.
    I thought of dynamically creating the internal table, but i am not sure how to do it.
    I also thaught of creating an internal table with only one field with the maximum length, but how can i check which fields are diplayed, and how can i get their values??
    Please Help!!
    Thank u in advance!!!
    Please - no duplicate posts
    Edited by: Rob Burbank on Feb 24, 2009 2:16 PM

    After call the above said function module you will get the exporting table for field catalog ie
              call function 'REUSE_ALV_GRID_LAYOUT_INFO_GET'
                importing
                  es_layout     = ls_slis_layo
                  et_fieldcat   = lt_slis_fcat
    if you check the lt_slis_fcat internal table if the field are hide in the layout by the user then in this internal table check for field NO_OUT will X.
    Take the fields where NO_OUT ne X 
    then for creating dynamic internal table
      field-symbols :  <ptab>  type standard table.
      call method cl_alv_table_create=>create_dynamic_table
        exporting
          it_fieldcatalog =  lt_slis_fcat
        importing
          ep_table        = i_content.
      if sy-subrc = 0.
        assign i_content->* to <ptab>.
      else.
        write: 'Error creating internal table'.
        stop.
      endif.
    Here  is the dynamic internal table

  • Dynamic creation of internal tables

    Hi all,
    i very urgently need a sample code which will help me to create an internal table dynamically at the click of a pushbutton using alv.Awaiting reply shortly .
    thank you.
    Regards,
    Lailu Philip

    Hi,
    Check this.I got it from SDN.
    REPORT zmaschl_create_data_dynamic .
    TYPE-POOLS: slis.
    DATA: it_fcat TYPE slis_t_fieldcat_alv,
          is_fcat LIKE LINE OF it_fcat.
    DATA: it_fieldcat TYPE lvc_t_fcat,
          is_fieldcat LIKE LINE OF it_fieldcat.
    DATA: new_table TYPE REF TO data.
    DATA: new_line  TYPE REF TO data.
    FIELD-SYMBOLS: <l_table> TYPE ANY TABLE,
                   <l_line>  TYPE ANY,
                   <l_field> TYPE ANY.
    Build fieldcat
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
               i_structure_name = 'SYST'
           CHANGING
               ct_fieldcat      = it_fcat[].
       LOOP AT it_fcat INTO is_fcat WHERE NOT reptext_ddic IS initial.
            MOVE-CORRESPONDING is_fcat TO is_fieldcat.
            is_fieldcat-fieldname = is_fcat-fieldname.
            is_fieldcat-ref_field = is_fcat-fieldname.
            is_fieldcat-ref_table = is_fcat-ref_tabname.
            APPEND is_fieldcat TO it_fieldcat.
       ENDLOOP.
    Create a new Table
    CALL METHOD cl_alv_table_create=>create_dynamic_table
           EXPORTING
            it_fieldcatalog = it_fieldcat
           IMPORTING
            ep_table        = new_table.
    Create a new Line with the same structure of the table.
    ASSIGN new_table->* TO <l_table>.
    CREATE DATA new_line LIKE LINE OF <l_table>.
    ASSIGN new_line->* TO <l_line>.
    Test it...
       DO 30 TIMES.
          ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.
          <l_field> = sy-index.
          INSERT <l_line> INTO TABLE <l_table>.
       ENDDO.
       LOOP AT <l_table> ASSIGNING <l_line>.
          ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.
          WRITE <l_field>.
       ENDLOOP.

Maybe you are looking for