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: 

Line length with WS_DOWNLOAD

Former Member
0 Kudos

Hello,

I am using WS_DOWNLOAD to save a file to my PC.

the line length has to be a fixed length of 160, the structure that i send over i 160 but the FM ignores the last 6 spaces at the end.

Does anyone know how to make the FM not cut off spaces so the line length will come out with 160.

Best regards

Lisa M Simonsen

8 REPLIES 8

Former Member
0 Kudos

Hi!

Could you post the code? It will be easier to see what's happening.

Regards,

Pablo

0 Kudos

Hello,

As i cannot paste the original code i have created a simple test code:

DATA: BEGIN OF wk_txt OCCURS 0,

text_lines(10),

END OF wk_txt.

wk_txt-text_lines(5) = 'testx'.

wk_txt-text_lines+5(5) = ' '.

Append wk_txt to wk_txt.

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

filename = 'D:/test file.txt'

filetype = 'ASC'

TABLES

data_tab = wk_txt

EXCEPTIONS

file_open_error = 1

file_write_error = 2

invalid_filesize = 3

invalid_type = 4

no_batch = 5

unknown_error = 6

invalid_table_width = 7

gui_refuse_filetransfer = 8

customer_error = 9

OTHERS = 10.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

If you test this code and open the file and use your curser to count the number of chars you will notice that when the cursor gets to X it jumps down onto the next line, But i specified the line to be 10 long not 5.

So this means it cuts spaces off, and i dont want this to do that.

I am aware of that this FM also has two Importing parameters that could indicated that i can specifiy the line length but filling these still doesent make it work.

Best regards

Lisa M Simonsen

PS: OMG this fourm also cuts spaces >.< SAP must really hate spaces.... there are 5 spaces between '&' in the line wk_txt-text_lines+5(5) = ' '.

Edited by: Lisa Marie Simonsen on Feb 14, 2008 1:55 PM

0 Kudos

Lisa, use method GUI_DOWNLOAD. Just send space in parameter trunc_trailing_blanks_eol.

Sample code:

DATA: BEGIN OF wk_txt OCCURS 0,
text_lines(10),
END OF wk_txt.

wk_txt-text_lines(5) = 'testx'.
*wk_txt-text_lines+5(5) = ' '.
APPEND wk_txt TO wk_txt.

CALL METHOD cl_gui_frontend_services=>gui_download
  EXPORTING
    filename                  = 'C:/test_file.txt'
    trunc_trailing_blanks_eol = ' '
  CHANGING
    data_tab                  = wk_txt[]
  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.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

I hope it helps, <REMOVED BY MODERATOR>

Regards,

Pablo

Edited by: Alvaro Tejada Galindo on Feb 14, 2008 9:46 AM

0 Kudos

Hi,

Thanks for that but i am still having the problem.

Any other ideas?

Best regards

Lisa M Simonsen

0 Kudos

Hi,

Try changing file type to 'DAT'. If you are downloading the file in txt format and opening in notepad thn you should be able to get it.

Note: If you open your file in excel than you cannot have blank spaces. Its a property of excel.

Regards,

Siddhesh S.Tawate

0 Kudos

Hi,

I am still having problems with the spaces after each line anybody have some tips other than the above mentioned?

Best regards

Lisa M Simonsen

Former Member
0 Kudos

Remember to put the importing parameter WRITE_LF of GUI_DOWNLOAD to space.

Then it will work

0 Kudos

Hi Lisa,

I have a similar requirement (download a fixed length file).

My internal table has multiple rows. If I set the WRITE_LF parameter to space, all the rows are being appended and are displayed in a single line on the downloaded file, instead of giving me separate rows. Each row in the internal table should have a corresponding row in the file.

Can you please suggest a solution for this?

Your help is greatly appreciated.

Thanks!

Sandeep