Inserting new line to the output using WS_Download in ABAP

First of all, don't use WS_DOWNLOAD as this function module is obsolete and deprecated in modern ABAP development.

Using cl_abap_char_utilities for Line Breaks

You can use a character type field and set it to cl_abap_char_utilities=>cr_lf. This utility class provides constants for various character operations, including carriage return and line feed combinations. Now use this field at places where you want to insert the new line.

Example

Here's how to implement line breaks when downloading data using modern ABAP approaches ?

DATA: lv_string TYPE string,
      lv_newline TYPE string.

" Set the newline character
lv_newline = cl_abap_char_utilities=>cr_lf.

" Build your output string with line breaks
lv_string = 'First Line' && lv_newline && 
            'Second Line' && lv_newline && 
            'Third Line'.

" Use GUI_DOWNLOAD instead of WS_DOWNLOAD
CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    filename = 'C:\temp\output.txt'
    filetype = 'ASC'
  TABLES
    data_tab = lt_output_table
  EXCEPTIONS
    file_write_error = 1
    OTHERS = 2.

Alternative Characters

The cl_abap_char_utilities class also provides other useful constants for formatting ?

  • cl_abap_char_utilities=>cr_lf ? Carriage return + Line feed (Windows style)
  • cl_abap_char_utilities=>newline ? System-specific newline character
  • cl_abap_char_utilities=>horizontal_tab ? Tab character for formatting

Conclusion

Replace obsolete WS_DOWNLOAD with GUI_DOWNLOAD and use cl_abap_char_utilities=>cr_lf for proper line break formatting in your output files.

Updated on: 2026-03-13T18:33:31+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements