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

Problem reading in binary file

Former Member
0 Likes
1,404

I'm sending a zip file that I receive from ISA to a 3rd party archiving system (IXOS). When I test this on my local pc using WS_UPLOAD to upload the file it works. The arcived zip file is fine and I am able to view it.

When I read in the zip file from the network using the "OPEN Dataset" statement the resulting archived document cannot be opened.

I read in the data to the table pass it to the function module and also specify a length ( received from ISA as an input parameter to my function module).

The archiving function module takes a parameter table where the data is in char format.

In this case when I try to look at the archived document it tells me the file is not a valid zip file and I can't view it.

I've tried reading the file into an internal table where the data is in "RAW" format - that didn't work.

I am also geting different numbers for the length of the file. The java passes in a number that is different than I get when count the bytes in the reading in of the file.

Can anybody guide me in the right direction on how to handle binary files?

Thanks,

Brent

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
968

Brent,

Normally the reason for not able to open the file after uploading from a network using 'Open dataset' is to do with the file size not correctly being derived.

For files uploaded as binary I use the following code;

open dataset file for input.

if sy-subrc = 0.

do.

read dataset file into att_cont length len.

append att_cont. clear att_cont.

if sy-subrc <> 0. exit. endif. "--> SAPnote# 564796

enddo.

endif.

close dataset file.

Using the above mentioned way of upload will give you the right size of the file in the len field. The reason why the check is moved after append is in the note.

Thanks.

3 REPLIES 3
Read only

Former Member
0 Likes
969

Brent,

Normally the reason for not able to open the file after uploading from a network using 'Open dataset' is to do with the file size not correctly being derived.

For files uploaded as binary I use the following code;

open dataset file for input.

if sy-subrc = 0.

do.

read dataset file into att_cont length len.

append att_cont. clear att_cont.

if sy-subrc <> 0. exit. endif. "--> SAPnote# 564796

enddo.

endif.

close dataset file.

Using the above mentioned way of upload will give you the right size of the file in the len field. The reason why the check is moved after append is in the note.

Thanks.

Read only

0 Likes
968

Thanks for the help. In looking at your code sample, I found that my problem was that I had my append statement AFTER the check of the return code in the read statement.

Apparently, this was leaving my file table without that last partial row of data.

Thanks again

Brent

Read only

Former Member
0 Likes
968

Are you using OPEN DATASET dsn IN BINARY MODE?