cancel
Showing results for 
Search instead for 
Did you mean: 

File upload is failing after upgrade to 7.31

Former Member
0 Kudos

Hi

Recently we upgraded a 7.1 WD Java application to 7.31 NWDS.

We're facing issue in file upload functionality in the upgraded application. When we upload a new PDF file, the content could not be opened in backend as the binary charecters in PDF are not stored exactly as uploaded. We're wondering if this is a problem in server side charecter encoding (does it perform automatically?) when sending the file to backend ECC (6.0).

We're able to read all existing (already uploaded) PDF files from ECC.

The issue is also only during upload and for binary file (all text files are working fine) formats.

We also set the "file.encoding" to "UTF-8" in Java server side but it did not help.

Please help with any pointers if you have come across similar issue (or what is changed in 7.31).

(Note: the same application still works if deployed with 7.1).

Cheers

Senthil

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I assume you are using the FileUpload UI element? Once uploaded to the WDJ application, is there any post processing being done? The binary file is stored in the WD context as XSTRING, to convert it to binary post processing is required. How is that post processing done? How are you storing the uploaded file from the WDJ application to the backend system? Maybe the problem is not really with the uploading but what happens after that. You could confirm by trying to directly open the file from the WDJ application using FileDownload once uploaded.

Former Member
0 Kudos

Yes, I'm using the FileUpload element. Once uploaded, the content is sent to ECC for storing via a BAPI.

However, when I send a txt content, I could get the content uploaded/download working fine.

Only the binary content (PDF files) is affected. I beleive when the WDJ sends it to ECC, the charecter set is getting changed.


Former Member
0 Kudos

Which BAPI? You have to share the implementation details in order for people to be able to help. Please also confirm whether uploading and downloading the PDF within the WDJ application works, without sending it to the backend system.

Former Member
0 Kudos

Sure, here is a code snippet and hope it can explained:

                                                                                                                                 Ztsac_Attachment attchTab =new Ztsac_Attachment(form_model);

attchTab.setAtt_Name(addrFileName);

form_data.addT_Attachment(attchTab);

InputStream fileStream =

addrResource.read(false);

SAC_AttachNewModel attn4 = new SAC_AttachNewModel();

Zmmsac_Upload_Attachment_New_Input attachNew_Input =

                                   new Zmmsac_Upload_Attachment_New_Input(attn4);

attachNew_Input.setFile(addrFileName);                                                                                                                             attachNew_Input.setObject_Key(wdContext.currentOutput_ToFormElement().getLong_Messg());

int fileSize = 0;

byte[] lineContents = new byte[1022];

int numBytesRead = 0;

do {

                                                                                                                                               numBytesRead =

                                                                                                                                                                fileStream.read(lineContents);

                                                                                                                                                if (numBytesRead > 0) {

                                                                                                                                                                fileSize += numBytesRead;

                       Bapiconten binNew = Bapiconten(attn4);

                       binNew.setLine(lineContents);

                  attachNew_Input.addI_File_Content(binNew);

   // Make sure the last loop sends the EOF charecter                                                                                                                                                          Arrays.fill(lineContents, (byte) 0);

                                                             }

        } while (numBytesRead > 0);

                                              

//send it to FM ECC                                                                                                                                 attachNew_Input.execute();

                                                                                                                               fileStream.close();

                                                                              }

The "BAPICONTEN" is a structure, but has a field of tyoe RAW of size 1022, so that's why you see the loop for 1022 byte size.

Note: Uploading / downloading within WDJ works perfectly fine.

Former Member
0 Kudos

Hi Experts

Would appreciate any inputs, we're struggling on this small piece of code. please let me know if you have any questions..

Note that the same code works fine in previous version (7.1).. what's wrong with 7.31?

Former Member
0 Kudos

Since uploading and then downloading from WDJ works something must be broken with the way you split the binary and pass to the custom remote enabled function module or even the custom function module itself. To further narrow it down, inside your onActionUploadFile method store the PDF as a binary file on the file system of the application server and try to open it. If you can't open the file, the implementation of onActionUploadFile is to blame. See for a working implementation.

Former Member
0 Kudos

Samuli, I have the recent version of the file you sent, so did not help much. Because, we're only struggling with the charecter format. The upgraded WDJ is not sending (or even reading) the charecters as such. So this is where the problem is lying.

Please also note that upload /download is working in previous version. As such it is working even for ascii / text files. So the issue is not upload ; but upload of binary files (specifically PDF format)

Cheers

Former Member
0 Kudos

Experts - please, would appreciate any inputs

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Senthil, please  follow the newest Web Dynpro Java tutorial on FileUpload/Download that was published by the Web Dynpro Java Runtime experts in 2010 (to my knowledge) that can be found in the Web Dynpro for Java Demo Kit - Web Dynpro Java - SCN Wiki

How To Upload and Download Files in an Web Dynpro for Java Application

The FileUpload/Download functions applied in this tutorial should also work in SAP NetWeaver 7.31.

Regards, Bertram

Former Member
0 Kudos

I could get this fixed by adding a ByteArrayOutputStream in the middle and send this BO to BAPI and it worked fine. Thanks a lot for all your inputs.

Answers (0)