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

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.

VELUS
Discoverer
0 Kudos
I have a option to get the Dynamic fields name with data type. That details i have stored in one internal table. PFB data 00010001CAC1 00010002A888 00010003CA 00010004A001 0001000547 00010006IN 000100072 0001000910 0001001201.06.2023 0001001331.05.2035 00010014I 00020001CAC1 00020002A888 00020003CA 00020004A001 0002000548 00020006IN 000200072 0002000910 0002001201.06.2023 0002001331.05.2035 00020014I i want this allign with the above field names in one internal table
Sandra_Rossi
Active Contributor
0 Kudos

Header Lines in ABAP are obsolete. I guess you mean a header line in your .txt file.

Your examples are not clear. Could you please attach real source and expected files, and explain the rules?

Accepted Solutions (0)

Answers (0)