Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

GUI_DOWNLOAD adding a blank line after every actual internal table line in the txt file.

sh4il3sh
Participant
0 Kudos

I have a file in char Internal Table as :

Header:
Item:
Item:
Header:

But when I download it as a txt file in GUI_DOWNLOAD I am getting the file as:

Header:

Item:

Item:

Header:

ie. with a blank line after every internal table line.
Does anyone have an idea why is this happening?
The same code was working fine before:

*** Download internal table to path selected in selection screen
    IF gt_input IS NOT INITIAL.
      CONCATENATE p_infile <ls_file_tbl>-name INTO lv_filename SEPARATED BY '\'.
      IF lv_filename CS '.txt' OR lv_filename CS '.TXT'.
      ELSE.
        CONCATENATE lv_filename '.txt'(005) INTO lv_filename.
      ENDIF.

      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = lv_filename
        TABLES
          data_tab                = gt_input
        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
          OTHERS                  = 22.
      IF sy-subrc <> 0.
        CLEAR gt_input.
      ENDIF.
    ENDIF.

Thank You in advance.

Regards,
Shailesh

9 REPLIES 9

aoyang
Contributor
0 Kudos

Hi, can you share screenshot of the data in gt_input, just before GUI_DOWNLOAD? Can you also share the downloaded file in question?

By the way, it is good practice to have "WRITE_FIELD_SEPARATOR = 'X'" in GUI_DOWNLOAD. Otherwise the data is one single data string in the text file.

Sandra_Rossi
Active Contributor

Probably you incorrectly handle end of line characters (CR and LF). Maybe GT_INPUT contains them also? Only you can check that. NB: for helping developers understand your program, you should add parameter format 'ASC' (text) or 'BIN' so that it's more explicit.

raymond_giuseppi
Active Contributor
0 Kudos

Look at the downloaded file with a tool such as notepad++ and in the option display the end of line character (CRLF for windows vs LF for Unix) check also for display option for wide text (trailing blank displayed in a following line)

Else youi could also look (debug) for the internal table table content (already some end of line characters)

sh4il3sh
Participant
0 Kudos

aocheng I agree with the good practice but it isn't my program.
Besides, It used to work perfectly 2 days ago.
Below the screenshot of data in GT_INPUT:

Below The Screenshot of Generated File



Thanks!

sh4il3sh
Participant
0 Kudos

raymond.giuseppi Do you mean something like this?


sandra.rossi I think the contents of Internal table are fine, and I am hesitant to debug GUI_DOWNLOAD. Noted the parameter advice, thanks!

raymond_giuseppi
Active Contributor

The CRLF (end of line Windows) was appended by GUI_DOWNLOAD

  • Does the single CR comes from your internal table?

Could you display GT_INPUT in hex values in debug to disambiguate the # values.

  • I suppose most # are horizontal tab characters (0x09) and that the last one is a carriage return (0x0D) ?

sh4il3sh
Participant
0 Kudos

raymond.giuseppi Yes the CR are from internal table, and # are Horizontal tab chars and last one are (0x0D)

Do you mean this below by GT_INPUT in hex values?



I have a point to add, I tried to download today with CG3Y and now the file has 4 lines gaps.



Although the transfer format was BIN.
Tried again with ASC and everything looked fine and dandy.

I am going to try by copying the program and with different options in GUI_DOWNLOAD over the weeknd.
I would also share my observations.

raymond_giuseppi
Active Contributor

In your picture, content of the itab is displayed as text, click on

(Basically your internal table contains only one field and this field contain a CR, GUI_DOWNLOAD in text (ASC) mode add a CRLF by default, so 2 line breaks, try to pass WRITE_LF as space)

sh4il3sh
Participant
0 Kudos

raymond.giuseppi Please see below.
I tried with adding Write field separator and FileType ASC and BIN both.

We know filetype is ASC by default anyway, still added ASC and same results.
and Bizzare results with BIN.

Also, the file was uploaded to application server in BIN format by me using CG3Z fm.


ANSWER Chronology:
The program uploads a huge txt file(300000 lines) to application server in BIN format.
Then the program reads the huge file if it has more than 25k lines, it tries to split them into smaller parts.
Actually while splitting the file program adds an Additional '#' to the split file. This error was resolved by adding statement 'SMART LINEFEED' to OPEN DATASET statement.
After the unwanted '#' is gone, GUI_DOWNLOAD works fine!!

Thanks a lot to everyone.