cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a Dynamic internal table structure based on ROWS & COLUMNS

VELUS
Discoverer
0 Kudos
265

HI Experts,

I have a rquirement to read the Dynamic Application server file.txt() having rows, columns and values like below

(ROW 1 COLUMN 1 A,

ROW 1 COLUMN 2 B,

ROW 1 COLUMN 3 C,

ROW 2 COLUMN 1 D,

ROW 2 COLUMN 2 E,

ROW 2 COLUMN 3 F)

Now i want it this data into an column wise like below:

(ROW 1 A B C,

ROW 2 D E F) in an Excel format.

With header lines,

i made the internal table data from the values of the application server txt.file by using the string functions.

That is cleared now i want to get this internal data in the Excel file. For that I used the below code in my object.

 

TYPES BEGIN OF ty_head,
            text1(256TYPE c,
          END OF ty_head.

  DATAlit_head TYPE STANDARD TABLE OF ty_head WITH HEADER LINE,

lt_tab_str TYPE TABLE OF string. .

  lit_head-text1 |{ TEXT-t01 } { TEXT-t02 } { TEXT-t03 } |.
  LOOP AT lt_tab_s INTO DATA(ls_tab_s).
    lit_head-text1 |{ lit_head-text1 } { ls_tab_s-fieldname } |.
  ENDLOOP.
  lit_head-text1 |{ lit_head-text1 } { TEXT-t04 } { TEXT-t05 } { TEXT-t06 } { TEXT-t07 } { TEXT-t08 } { TEXT-t09 } { TEXT-t10 }|.
  APPEND lit_head.
  CALL METHOD cl_gui_frontend_services=>gui_download
    EXPORTING
      filename                lv_filename
      filetype                 =  'DAT'
      fieldnames              lit_head[]
    CHANGING
      data_tab                lt_tab_str
    EXCEPTIONS
      file_write_error        1
      no_batch                2
      gui_refuse_filetransfer 3
      invalid_type            4
      no_authority            5
      unknown_error           6
      header_not_allowed      7
      separator_not_allowed   8
      filesize_not_allowed    9
      header_too_long         10
      dp_error_create         11
      dp_error_send           12
      dp_error_write          13
      unknown_dp_error        14
      access_denied           15
      dp_out_of_memory        16
      disk_full               17
      dp_timeout              18
      file_not_found          19
      dataprovider_exception  20
      control_flush_error     21
      not_supported_by_gui    22
      error_no_gui            23
      OTHERS                  24.

But am not getting the header values in the download excel file. I got the file without header values of data. Can you please suggest any solution for this? 

Any one please suggest here.

Accepted Solutions (0)

Answers (0)