Skip to Content
author's profile photo Former Member
Former Member

Eliminating CRLF on final line of file transfer

My vendor is requiring that the CRLF at the end of the final line on our interface file be removed. The CRLF is required at the end of all other lines. I have not been able to determine how to do that. Can someone help? Here is my open and transfer statement:

OPEN DATASET V_UTGFILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. TRANSFER I_FILEBUILD TO V_UTGFILE.

Thanks for your help,

Tracy

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 13, 2008 at 03:45 PM

    Hi Tracy,

    When you are working in Windows NT or unix environment then system will add the marking with 'CRLF' or 'LF' at the end of the file.

    If you want to replace or remove that marking then add below additions.

    OPEN DATASET '/tmp/kishore.txt' FOR OUTPUT IN TEXT MODE

    TYPE ' '

    ENCODING DEFAULT.

    you should specify addition of 'type'.

    If you want replace with empty space.

    TYPE ' '

    Regards,

    Kishore

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member .Subramony A R .Subramony Ramakrishnan

      a®s,

      OK, this is still not working for me. I have added your code exactly and the TYPE ' ' addition is still not preventing the addition of the CRLF to the end of the last line. I am not sure what else I could be doing wrong. Is there any outside parameter(s) that would prevent the TYPE ' ' from working?

      Thanks,

      Tracy

  • Posted on Feb 13, 2008 at 03:02 PM

    You can do that .

    Repace the occurences of CR_LF, that can be done with the following code.

    Replace all occurences of CL_ABAP_CHAR_UTILITIES=>CR_LF in var with ' '.

    Regards

    Vijay

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 13, 2008 at 03:03 PM

    One solution would be to remove the CRLF for the last line

    from I_FILEBUILD.

    describe table I_FILEBUILD lines v_lines.

    read table I_FILEBUILD index v_lines.

    remove the CRLF from I_FILEBUILD and modify I_FILEBUILD ..

    OR if UR filling I_FILEBUILD in a loop ..

    say ..

    Loop at itab.

    at last.

    do not put CRLF as the last char in I_FILEBUILD ..

    endat

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 15, 2008 at 08:47 PM

    I have the same problem, and this solutions doesn´t work.

    For me, this lines works, but they aren´t the best solution.

    ln_long = ( STRLEN( ls_line ) ) - 1.
    
            IF ln_long > 0.
              ls_line = ls_line+0(ln_long).
            ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 11, 2015 at 02:57 PM

    Hi,

    maybe very late reply but someone can still face the same problem.

    I found a solution by adding "no end of line" to the last line of internal table.

    data: lv_lines type i.

    open dataset sftp_fname ignoring conversion errors for output in text mode encoding non-unicode with windows linefeed.

    lv_lines = lines( t_text ).

    loop at t_text into ls_text.

    if sy-tabix ne lv_lines.

    transfer ls_text-line to sftp_fname.

    else.

    transfer ls_text-line to sftp_fname no end of line.

    endif.

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.