02-16-2008 7:01 AM
FUNCTION Y_MODULE4.
*"----
*""Local Interface:*
*" IMPORTING
*" VALUE(IT2)
*" EXPORTING
*" VALUE(IT1)
*" EXCEPTIONS
*" EXCEPTION_A
*" EXCEPTION_B
*" EXCEPTION_C
*"----
write : / ' the global variable g1 =>', g1 color 5 centered.
it1 = g1.
write: / 'it1 = >', it1 color 7 centered.
write: / 'it2 = >', it2 color 6 centered.
case it2.
when 'A'.
raise exception_A.
when 'B'.
raise exception_B.
when 'C'.
raise exception_C.
endcase.
ENDFUNCTION.
REPORT YSUSFUN2.
data getogether(10) .
CALL FUNCTION 'Y_MODULE4'
EXPORTING
IT2 = 'h'
IMPORTING
IT1 = getogether
EXCEPTIONS
EXCEPTION_A = 1
EXCEPTION_B = 2
EXCEPTION_C = 3
OTHERS = 4 .
* values assigned to export parameters are not copied back to the
*calling program
write:/ ' getogether=>', getogether color 7.
IF SY-SUBRC <> 0.
write:/ 'sy-subrc = ', sy-subrc color 7.
ELSE.
write: / 'sy-subrc =', sy-subrc color 7.
ENDIF.
the above program is a functional module and calling program. i am import the it2 as 'H'. it is not compatible with when clause in the functional module. it returns to the calling program and i want to print the others values ie 4 in the sy-subrc . say it is possible. if it is possible .say where i can include the statement.?
02-16-2008 7:17 AM
The foll piece in ur Report defines the sy-subrc value for an exception...
EXCEPTION_A = 1
EXCEPTION_B = 2
EXCEPTION_C = 3
To be more clear....
if EXCEPTION_A is raised by the FM , then sy-subrc = 1 in ur report.
if EXCEPTION_B is raised by the FM , then sy-subrc = 2 in ur report.
if EXCEPTION_C is raised by the FM , then sy-subrc = 3 in ur report.
so u can write like below...
IF SY-SUBRC = 1.
do whatever u want to do when EXCEPTION_A is raised
ELSEif SY-SUBRC = 2.
do whatever u want to do when EXCEPTION_B is raised.
ELSEif SY-SUBRC = 3.
do whatever u want to do when EXCEPTION_C is raised.
ENDIF.
Cheers,
jose.
Edited by: jose on Feb 16, 2008 8:20 AM
02-16-2008 7:28 AM