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

File issue in ABAP

Hi,

I am writting the data in to a file using OPEN DATASET. When I opened the file if I press right arrow button at the end of the record it is going to the next line eventhough the there is no data in the second line.As per my requirement cursor should not go to second line if there is no data in it.

My Code is

OPEN DATASET lv_file FOR OUTPUT IN TEXT MODE
ENCODING DEFAULT
WITH SMART LINEFEED.
IF sy-subrc = 0.
LOOP AT gt_tab INTO lw_tab.
TRANSFER lw_tab TO lv_file LENGTH 517.
CLEAR lw_tab.
ENDLOOP.
*--Close the file opened.
CLOSE DATASET lv_file.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Apr 23, 2012 at 11:26 AM

    Dear Shoban Babu,

    Did you try without the addition, "WITH SMART LINEFEED".

    Upon using the addition "WITH SMART LINEFEED", the line end markers are set to "LF" and "CRLF". so untill the cursor encounters these line end markers, the whole data is considered to be on the same line.

    Hope this solves. Thank you.

    Regards.

    kartik

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 23, 2012 at 11:34 AM

    Hi shoban,

    the problem is the gt_tab internal table you are reading will be having blank records that is the reason for you ending up with blank lines in your file.

    try deleting blank entries in the internal table gt_tab before you loop on gt_tab, this might solve your problem.

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Shoban,

      I understood what you are trying to say,

      the problem is the file that is already preset, that you see in al11 already has blank lines in it, hence when you download it and move cursor it moves to next line rather than staying in the same line and blink.

      to avoid this when you upload a file using CG3Y make sure file does not have blank lines in it, if it does have blank lines then it will show up when you download the same file.

      The file you are trying to download, go to AL11 and double click on it and open it and see if it has more than one # symbol after the data ended if it does then it will contain blank lines when you download it.

  • Posted on May 03, 2012 at 08:24 AM

    See the following example:

    DATA: file TYPE string VALUE `test.dat`,
    result TYPE string.

    OPEN DATASET file FOR OUTPUT IN TEXT MODE
    ENCODING DEFAULT
    WITH SMART LINEFEED.
    TRANSFER `1234567890` TO file.
    CLOSE DATASET file.

    OPEN DATASET file FOR UPDATE IN TEXT MODE
    ENCODING DEFAULT
    WITH SMART LINEFEED
    AT POSITION 2.
    TRANSFER `ABCD` TO file.
    CLOSE DATASET file.

    OPEN DATASET file FOR INPUT IN TEXT MODE
    ENCODING DEFAULT
    WITH SMART LINEFEED.
    WHILE sy-subrc = 0.
    READ DATASET file INTO result.
    WRITE / result.
    ENDWHILE.
    CLOSE DATASET file.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 03, 2012 at 08:29 AM

    Hi,

    Don't understand why this thread is still opened!

    The correct answer has been given: Handle the CR/LF manually and use the option NO END OF LINE with your OPEN DATASET statement. The issue you are facing comes from transaction CG3Y which does not use this option (NO END OF LINE) while opening and transferring the file.

    http://scn.sap.com/message/13203818#13203818

    Manu.

    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.