2007 Feb 09 5:38 AM
how to handle exceptions in subroutine, give me the loginc
can we use RAICE statement in subroutines.
if we can use RAICE statement in subroutine. tell me How can we use?
2007 Feb 09 5:42 AM
in subroutine you can only pass using < value addition> changing < value addition> and table option no exception option is there RAISE is on ly pass the value for exception. so in subroutine you cant do raise.
regards
shiba dutta
2007 Feb 09 6:29 AM
2007 Feb 09 6:40 AM
what are you asking means you want to do some validation i.e. by raising exception we are just getting the value of sy-subrc in our program and using validation.
just pass the value to subroutine and check the value.
if sy-subrc ne 0.
message i001(zspd).
endif.
just you have to assign the sy-subrc value and show the message as per needed.
in subroutine you have to do at your own validation and sy-subrc checking and display thae message there.
regards
shiba dutta
2007 Feb 09 5:49 AM
Rajesh,
DATA FIELD(10).
MOVE 'ABCB' TO FIELD.
REPLACE 'B' WITH 'string' INTO field.
Pls. Maek for all useful answers
2007 Feb 09 5:49 AM
Hi Rajesh,
No exceptions are raised in a Subroutine as in a Function Module.
Subroutines are procedures that you can define in any ABAP program and also call from any program. Subroutines are normally called internally, that is, they contain sections of code or algorithms that are used frequently locally. If you want a function to be reusable throughout the system, use a function module.
A subroutine is a block of code introduced by FORM and concluded by ENDFORM.
FORM <subr> [USING ... [VALUE(]<pi>[)] [TYPE <t>|LIKE <f>]... ]
[CHANGING... [VALUE(]<pi>[)] [TYPE <t>|LIKE <f>]... ].
...
ENDFORM.
<subr> is the name of the subroutine. The optional additions USING and CHANGING define the parameter interface. Like any other processing block, subroutines cannot be nested. You should therefore place your subroutine definitions at the end of the program, especially for executable programs (type 1). In this way, you eliminate the risk of accidentally ending an event block in the wrong place by inserting a FORM...ENDFORM block.
You call subroutines using the statement
PERFORM... [USING ... <pi>... ]
[CHANGING... <pi>... ].
Subroutines can call other subroutines (nested calls) and may also call themselves (recursive calls). Once a subroutine has finished running, the calling program carries on processing after the PERFORM statement. You can use the USING and CHANGING additions to supply values to the parameter interface of the subroutine.
Regards,
Priyanka.
2007 Feb 09 5:50 AM
2007 Feb 09 5:52 AM
Hi Rajesh ,
You cannot raise execptions in subroutines , if you want to do it then you can either create a FM containing the same logic or create a class and create methods containg your logc and trigger an event when an error occus( instead of exceptions ).
Rehards
Arun
2007 Feb 09 6:03 AM
HI,
RAISE exception is not possible in subroutine.
U pass a FLAG variable in changing parameter of the subroutine.
After the subroutine, u can check the flag variable.
e.g.
DATA FLG_ERROR type flag.
PERFORM f100_check_validity changing FLG_ERROR.
if FLG_ERROR = 'X'.
logic
endif.
Rgds,
Prakash