Application Development and Automation 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: 
Read only

Missing CRLF in file created on application server

mrio_espinheira
Participant
0 Likes
1,185

Hello,

We have a requisite to create a file on the Application Server (AS/400) with CRLF at the end of every record. The records are stored in this structure:

- OUTPUT: CHAR655, text to export;

- LENGTH: NUMC4, length of the record (text to export).

To create the file I have the following code:


  open dataset lv_filename
    for output in text mode
    encoding default
    with windows linefeed.

  loop at pt_output into ls_output.
    try.
        clear lv_length.
        lv_length = ls_output-length.
        transfer ls_output-output to lv_filename
          length lv_length.
      catch cx_root into gv_oref.
*    TODO
    endtry.
  endloop.

I have two problems:

1º When I open the file in Notepad++ the records should have 500 caracters (lv_length = 500), but it has 502;

2º Only LF appears, not CRLF.

Can anyone help me please?

Regards.

Hello,

We have a requisite to create a file on the Application Server (AS/400) with CRLF at the end of every record. The records are stored in this structure:

- OUTPUT: CHAR655, text to export;

- LENGTH: NUMC4, length of the record (text to export).

To create the file I have the following code:


  open dataset lv_filename
    for output in text mode
    encoding default
    with windows linefeed.

  loop at pt_output into ls_output.
    try.
        clear lv_length.
        lv_length = ls_output-length.
        transfer ls_output-output to lv_filename
          length lv_length.
      catch cx_root into gv_oref.
*    TODO
    endtry.
  endloop.

I have two problems:

1º When I open the file in Notepad++ the records should have 500 caracters (lv_length = 500), but it has 502;

2º Only LF appears, not CRLF.

Can anyone help me please?

Regards.

3 REPLIES 3
Read only

mrio_espinheira
Participant
0 Likes
802

Hello,

Strangest thing, when I test it with 255 characters it works fine (CR+LF):


        clear lv_string.
        ls_output-output+254(1) = cl_abap_char_utilities=>cr_lf.
        lv_string = ls_output-output+0(255).
        transfer lv_string to lv_filename
          length 255.

When I try with 256 characters it doesn't work, at the end of each record I can only find LF:


        clear lv_string.
        ls_output-output+255(1) = cl_abap_char_utilities=>cr_lf.
        lv_string = ls_output-output+0(256).
        transfer lv_string to lv_filename
          length 256.

Don't understand why...

Regards.

Read only

0 Likes
802

You'lll notice in your reference to CR_LF that the result is 2 bytes.....look again at your cl_abap_char_utilities definition. In NotePad, I would not expect to see the CRLF on the end of the row.

Read only

mrio_espinheira
Participant
0 Likes
802

The mentioned code was working, the problem was using FM EPS_FTP_PUT after.

Regards,

Mário Espinheira