cancel
Showing results for 
Search instead for 
Did you mean: 

How to Read Java Byte Array back into SAP xstring Table?

Former Member
0 Kudos

Hi Guys,

I have a situation whereby a user can upload a document in a WebDynpro Java Application. This needs to be saved. I am trying to see if I can make the location of this file that is being saved to be on our SAP AS. I have written a SAP RFC that is imported into the Java Application for use.

The RFC is expecting a table of type TBL1024 which is basically a table of xstring values. The Java proxy interprets this SAP table as a byte array. This is my problem... I cannot seem to "break" up the Byte array into lines of 1024 lengt and send it back to SAP. All that is happening currently is that the byte array creates a singe line in the TBL1024 that consists of only the first 1024 bytes in the array... This means that only the first 1024 bytes of my document is being saved - making it corrupt.

Please advise,

Kind regards,

Christiaan

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Loop it...


File file = new File("java.pdf"); 
FileInputStream fis = new FileInputStream(file);
byte[] buf = new byte[1024];
        try {
            for (int readNum; (readNum = fis.read(buf)) != -1;) {
                // Here populate the RFC table                
            }
        } catch (IOException ex) {
            
        }