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

transfering 0 byte file

prasad_reddy9
Explorer
0 Likes
879

I need to transfer a 0 byte file.

for that I am using the following code.

<b><i>begin of i_zero occurs 0,

dummy,

end of i_zero,

move '' to i_zero-dummy.

append i_zero.

open dataset v_file for output in binary mode.

if sy-subrc eq 0.

loop at i_zero.

transfer i_zero-dummy to v_file.

endloop.

close dataset v_file.</i></b>

but the above code is giving me a 1 byte size file. is there anyway around this to be able to transfer a 0 byte file?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
816

Hi Prasad

May be you can just open a file and don't transfer anything and close the file.

Something like this,

<b>open dataset v_file for output in binary mode.

close dataset v_file.</b>

Rewards points for all useful answers !!

~Ranganath

I need to transfer a 0 byte file.

for that I am using the following code.

<b><i>begin of i_zero occurs 0,

dummy,

end of i_zero,

move '' to i_zero-dummy.

append i_zero.

open dataset v_file for output in binary mode.

if sy-subrc eq 0.

loop at i_zero.

transfer i_zero-dummy to v_file.

endloop.

close dataset v_file.</i></b>

but the above code is giving me a 1 byte size file. is there anyway around this to be able to transfer a 0 byte file?

4 REPLIES 4
Read only

Former Member
0 Likes
817

Hi Prasad

May be you can just open a file and don't transfer anything and close the file.

Something like this,

<b>open dataset v_file for output in binary mode.

close dataset v_file.</b>

Rewards points for all useful answers !!

~Ranganath

Read only

Former Member
0 Likes
816

Hi Prasad,

I believe, though you are writing a space into dummy it would be occufying 1 byte.

Why don't you just open and close the file. It will create file with 0 bytes.

Try this.

Regards

Surya.

Read only

Sougata
Active Contributor
0 Likes
816

Try this:

OPEN DATASET v_file FOR OUTPUT IN BINARY MODE.
IF sy-subrc <> 0.
  MESSAGE e001(VL) WITH 'File open error'.
ENDIF.

CLOSE DATASET v_file.

Don't forget to reward points.

Cheers,

Sougata.

Read only

former_member196280
Active Contributor
0 Likes
816

IF you want to create a file with 0 bytes then why do you want to transfer empty space to your file.

Do it like this...

open dataset v_file for output in binary mode.

if sy-subrc eq 0.

**File opened successfully.

endif.

close dataset v_file.

Regards,

Sairam