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

regarding empty file.

Former Member
0 Likes
838

hai,

Using open dataset statement i have created text file (refer code snippet)

problem here is,if line does not have value then i get

0 byte text file created.

i want to avoid this empty file. how to do this.

if textfile does not have value then it should not be created.

code snippet.

open dataset file.

Transfer line to file.

close dataset file.

ambichan.

Message was edited by: ambi chan

5 REPLIES 5
Read only

Former Member
0 Likes
682

Hi Hai,

Check whether file[] is initial before going into the code that creates the file:

if not file[] is initial.

code to create file.

endif.

You can also do a describe on the table as well.

Hope this helps,

James.

Read only

athavanraja
Active Contributor
0 Likes
682

check the content of <b>line</b>.

If not line[]/line is initial.

open dataset file.

Transfer line to file.

close dataset file.

endif .

Raja

Read only

Former Member
0 Likes
682

How about checking your LINE before you open your dataset? Once you open the file, regardless of whether you have data, the file will be created. Are you using LINE as an internal table. If so, maybe use the following code:

CHECK NOT LINE[] IS INITIAL.

If there is no data in your table your file logic will be passed. That is assuming that is the remainder of your code for that particular part of your program (FORM).

Good Luck!

Terry

Read only

Former Member
0 Likes
682

Check the number of line if you have an internal table ( describle table itab lines w_line.

check w_lines ne 0.

Or you can check the line you transfer are not equal to 'space'.

You seem to have only one line ( regarding your code ) :

if line ne space

open dataset file.

Transfer line to file.

close dataset file.

endif.

Read only

Former Member
0 Likes
682

Here is what I would so.

<i>for internal table approach (data is in a internal table)</i>

<b>loop at itab.

at first.

open dataset file.

endat.

<u>move itab to line.</u>

transfer line to file.

at last.

close dataset file.

endat.

endloop</b>

<i>no internal table</i>

<b>if not line is initial.

open dataset file.

Transfer line to file.

close dataset file.

endif.</b>

Rishi