‎2008 Jul 07 2:02 PM
Hi experts,
I wrote a function and i'm using RAISE EE_FILE_NOT_FOUND if the selection was failed, and no records found in the dba.
After the function there is an automatic check when I'm calling my own function:
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
This check is giving a dump and says that the type cannot be " ". It should be A, E, I, W, S or X .
How can I correct this error? Why is it that the message type is not handled in my case?
‎2008 Jul 07 2:06 PM
Maintain this exception EE_FILE_NOT_FOUND in Exceptions tab of the FM. Only then u can avoid the dump.
Regards,
Joy.
‎2008 Jul 07 2:08 PM
‎2008 Jul 07 2:14 PM
When calling the FM u have to uncomment the exception part from FM interface.
Ex:
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Pl. see this documentation.
Syntax
RAISE exception.
Effect
The statement triggers the non class-based exception exception. It is only useful during processing of methods and function modules in which the exception exception is defined. After the exception exception is triggered, the system proceeds as follows:
If the exception is triggered in a method or function module whose caller assigns a return value to the exception, then the procedure ends immediately, the system returns to the calling position, and the system field sy-subrc is set according to the assignments.
If the exception is triggered in a method or function module whose caller does not assign a return value to the exception, a runtime error is then triggered whose short dump contains the name of the exception.
If the exception is triggered in a subprogram, the system searches for the first function module in the procedures for the preceding call hierarchy. If it finds such a function module and the exception is defined in it, the system acts as though the exception was triggered in this function module. Otherwise, a runtime error will occur.
In all other processing blocks, the triggering of a non class-based exception causes a runtime error that immediately ends all further program execution.
Regards,
Joy.
‎2008 Jul 07 2:07 PM
If you only
RAISE ERROR_CODEthen there is no error message explicitly sent to caller. (fields SY-MSGxx are initial) If you want to get a message you have to sent it before using
MESSAGE E001 RAISING ERROR_CODE. " with every optionsor if you don't want to change the FM, then send the message in the caller
CASE sy-subrc.
WHEN 0.
WHEN 1.
MESSAGE e000(xx).
WHEN 2.
MESSAGE e001(xx).
ENDCASE.Regards
‎2008 Jul 07 2:07 PM
hi White,
Define your own exception message
IF sy-subrc 0.
RAISE ERROR.
ENDIF.
‎2008 Jul 07 2:07 PM
Hi,
Instead of,
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
use your own message.
if sy-subrc <> 0.
message e035(zf) with 'File not found'.
endif.
Regards,
Subramanian
‎2008 Jul 07 2:10 PM
Yes, I know that I can use my own message, but I want to know why it is not working with the automatically generated sy-subrc check:
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
the dump says: Message type " " is unknown.
Only message types A, E, I, W, S and X are allowed.
‎2008 Jul 07 2:13 PM
What Raymond wrote is the information you need
>
> If you only
RAISE ERROR_CODEthen there is no error message explicitly sent to caller. IF you want to get a message you have to sent it before using
MESSAGE E001 RAISING ERROR_CODE.or send the message in the caller
CASE sy-subrc. > WHEN 0. > WHEN 1. > MESSAGE e000(xx). > WHEN 2. > MESSAGE e001(xx). > ENDCASE.Regards
Because you are using RAISE rather than MESSAGE .. RAISING..., sy-msgty is NOT set, so you get a dump.
matt
‎2008 Jul 07 2:22 PM
Hi,
U r getting this dump because when u try to display the message using statement MESSAGE.... the message type(Sy-msgtyp) is not getting populated which is mandatory to display the message.
So when u raise it in FM u have to specify which type it should be.
eg: MESSAGE ID zv TYPE 'E' NUMBER 001 RAISING EE_FILE_NOT_FOUND.
Put above syntax in ur FM it works fine.
To check it just place a break point in calling program at statement IF sy-subrc NE 0. Here try to change sy-msgtyp = E in debug mode and execute u will get ur error message.
Thanks,
Vinod.
‎2008 Jul 07 2:08 PM
Hi Stripes,
Make the IF statement as IF sy-subrc ne 0. and check .
Regards,
Swapna.
‎2008 Jul 07 2:18 PM
Hello,
U just maintain in ur FM like below instead of RAISE ERROR_OPEN_ERROR.
MESSAGE ID 'FES' TYPE 'E' NUMBER '000' RAISING FILE_OPEN_ERROR.
Then sy-subrc set to ur wish and all the variables will be set accordingly.
Regards,
Subbu
‎2008 Jul 07 2:18 PM
Hi
The system variables of the message should be filled as soon as the fm raises the exception, so it means in the fm should be a code like this:
MESSAGE ID <ID> TYPE <TYPE> NUMBER <NR>
WITH <TEXT1> <TEXT2> <TEXT3> <TEXT4> RAISING EE_FILE_NOT_FOUND MESSAGE.In this way after calling the fm if the exception is raised the system will fill SY-MSGID, SY-MSGTY, SY-MSGNO, SY-MSGV1, SY-MSGV2, SY-MSGV3 and SY-MSGV4.
But in your case u have only
RAISE EE_FILE_NOT_FOUNDHere no message is called so the system variable won't have any value, the following code:
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.will generate a dump as every system variables has no values.
If u want to avaoid a dump u should force the error message has to be triggered:
IF sy-subrc <> 0.
MESSAGE ID '000' TYPE 'E' NUMBER '208' WITH 'No file was founded'.
ENDIF.Max
Max
‎2008 Jul 07 2:19 PM