Skip to Content
0
Former Member
Nov 24, 2011 at 07:34 AM

How to skip blank line (EOF char) at the end of the file while creating ?

379 Views

Hi,

In my program I have to create a file in Text mode using OPEN DATASET statement. This file is being sent to a third party system for their processing. I came to know while creating the file using OPEN DATASET, one LF character is inserted end of the file resulting a blank line end of the file. Thus if my internal table contains 5 reocrds, in the created text file I can see 6 lines where last is a blank. My question is how to remove this blank line which is causing issue in the thirdparty system.

Here is the Code I have used.

TRY.

  • Write the file in Text Mode

OPEN DATASET lv_outpf FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE

  • WITH SMART LINEFEED

MESSAGE lv_msg.

*

IF lv_msg IS NOT INITIAL.

WRITE / lv_msg.

EXIT.

ENDIF.

LOOP AT itab_new INTO st.

TRANSFER st TO lv_outpf.

ENDLOOP.

CLOSE DATASET lv_outpf.

CATCH cx_root. "#EC No Handler

ENDTRY.