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

GUI_UPLOAD Exception

Former Member
0 Likes
1,573

Hi,

I'm using the GUI_UPLOAD function to read a file and found that there are lot of exception defined in this FM. How can catch it and display a proper error to user?? Is it possible to handle it without specifically define which exception hit??

Pls give me some reference code.

Regards,

Kit

3 REPLIES 3
Read only

Former Member
0 Likes
814

HI

if you want to catch it then try this coding

TRY/CATCH it's not applicable in case of Function Module, to use TRY you need class-based exceptions.

Use only CATCH:

CATCH.

CALL FUNCTION "Function_1".

IF sy-subrc NE 0.

do_something.

ENDIF.

ENDCATCH.

However, you can add the "EXCEPTIONS" statement to the first CALL FUNCTION, catching a particular value of sy-subrc, like this:

EXCEPTIONS others = 20.

Then, check subrc:

CATCH.

CALL FUNCTION "Function_1"

EXCEPTIONS others = 20.

IF sy-subrc = 20.

do_something.

ENDIF.

ENDCATCH.

<b>Rewar if usefull</b>

Read only

Former Member
0 Likes
814

Hi Kit,

At the end of the FM try using case statements to catch the SY-SUBRC value. If you want to specific processing then you can do so by defining a soubroutine. If you want to display only an error message you can go ahead with 'WRITE' Statement or 'Message' Statement.

Take a look at the code below:

CASE sy-subrc.

WHEN '1'.

WRITE : 'error opening file'.

WHEN '2'.

WRITE : 'file read error'.

WHEN '3'.

PERFORM displayerrormessage.

ENDCASE.

Hope this is of help to you.

Thanks,

pavithra

Read only

Former Member
0 Likes
814

Hi Kit,

All corresponding error code will be stored in SY-SUBRC in following exceptions..

either you can use IF statement or CASE structure to display appropriate message to user...


* EXCEPTIONS
*   FILE_OPEN_ERROR               = 1
*   FILE_READ_ERROR               = 2
*   NO_BATCH                      = 3
*   GUI_REFUSE_FILETRANSFER       = 4
*   INVALID_TYPE                  = 5
*   NO_AUTHORITY                  = 6
*   UNKNOWN_ERROR                 = 7
*   BAD_DATA_FORMAT               = 8
*   HEADER_NOT_ALLOWED            = 9
*   SEPARATOR_NOT_ALLOWED         = 10
*   HEADER_TOO_LONG               = 11
*   UNKNOWN_DP_ERROR              = 12
*   ACCESS_DENIED                 = 13
*   DP_OUT_OF_MEMORY              = 14
*   DISK_FULL                     = 15
*   DP_TIMEOUT                    = 16
*   OTHERS                        = 17