Let's follow up this discussion at the Neptune Community

(this forum will be kept in read-only mode)

Error handling with FileUploader

Hi.  I'm using the UI5 FileUploader control to upload files which are then being stored as GOS attachments.  During this process, it's quite possible that GOS will throw errors (due to user authorizations or database issues, for example).  However, I can't come up so far with any way to communicate these issues to the frontend.  

Normally, I either use /NEPTUNE/CL_NAD_SERVER=>API_MESSAGE_CREATE for this purpose or I'll set some oData structures or something like that.  However, I noticed in your code in /NEPTUNE/HTTP_HANDLER that you are not allowing any response data to be passed on in the case that a file upload is being executed.  This being the case, it seems to me that the only way I can communicate that a problem has occurred would be to trigger a short dump in my code, which is less than ideal, but at least then I'd be able to pick up the 500 status.

Any suggestions on how I should be handling errors in this situation?  It's entirely possible that I'm just approaching this from the wrong angle, so any thoughts you have are very welcome.  Thanks!

1 person has this question

Hi Dan,

your analysis is correct.  Unfortunately, there is no nice way on sending data back to the user interface from the FileUploader.upload.

FileUploader object has event uploadComplete.   There you could trigger a new ajax call to the backend where you would fetch a flag or message and bring it back to the UI.


Not the optimal solution but to sum up:

1 - trigger FileUploader.upload()

2 - file upload starts and triggers an AJAX CALL.

3 - ABAP side: perform your validation and store the flag somewhere (IMPORT / EXPORT parameter for example).

4 - uploadComplete event is triggered, then call a getOnlineNewAjaxCall()  statement.

5 - new AJAX call triggers a new piece of logic on the ABAP side, where you fetch the flag/message, and send it back to the UI.


Another approach which I like even less is:

if the Upload call creates a short dump on the ABAP side, the information (error page = 500 status) is received with the update call and can be identified in JavaScript.

I prefer the first approach, but it involves an extra ajax call.

Kind regards,


Any chance you will write your own FileUploader?

Hey Patrick, I ended up not doing anything particularly clever to resolve this issue.  After saving a newly uploaded file, I just performed a read of the available files and wrote a validation to make sure the file I was trying to add was now in the list of files.  Since I was using GOS, I knew that the only likely errors would be due to security role issues, so I just made sure to iron these out as they came up.

Aside from that, my suggestion would be to record an error in an application log so that whenever this happens, you'll have a place to review what went wrong.

You could write your own file upload control, but honestly, you'll likely run into a lot of the same limitations.

thanks for your feedback. Actually i am considering not to use the upload method from FileUploader. Instead using an custom ajax call with a json array of files (base64 encoded) as payload and a json array of file meta data.

What do you think of this workaround? 

Hey Patrick, I just saw your question, and I thought I'd respond since I have been working on something similar in the last couple days.  I basically implemented what you're describing.  I used the SAPUI5 FileUploader control, and in the change event, I just grab the file pointer and append it to a global FormData object.  Then, when you want to make your custom AJAX call, you can just do something like this:

var request = new XMLHttpRequest();

 This will send the data as a multipart request, which you can parse in your handler using the if_http_request->get_multipart( ) method.

Login or Signup to post a comment