‎2006 Aug 15 4:40 PM
Hi,
I have a code which calls standard function module. The standard function module outputs messages using the message statement. So, if an error occurs in the function module, it does not return me back anything through the program, but just gives out an error message, which I would not be aware of through my program.
Is there a way to activate any memory log, so that whenever such error/ warning messages happen in the standard function module, then message will be sent to the log, and when the control returns to my program, I can read the message log, and call the appropriate handler from my code.
Thanks,
Juwin
‎2006 Aug 15 6:55 PM
I solved the problem myself. Luckily the function module was RFC enabled. So I called the function in a separate task, so the function module when throws error, will not effect my screen and I will get the sy-subrc value changed after the call.
‎2006 Aug 15 4:45 PM
which standard function module are you calling in your ABAP ?
‎2006 Aug 15 4:52 PM
L_TO_CREATE_SINGLE is the function module. But the solution should not be this function module specific. I have come across this situation with other function modules also.
‎2006 Aug 15 5:10 PM
THe function module raise exception with message for errors. After function call try the following code or use the system variables in code to get message.
data: v_msg(255).
if sy-subrc ne 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
into v_msg.
endif.
Regards
Sridhar
‎2006 Aug 15 5:05 PM
Can you please send the code u have written ?
I guess you have not uncommented the Exceptions in the function modules .
Regards
Yogesh
‎2006 Aug 15 6:30 PM
The function module just does not throw any exception. It gives out an error message and stops right there. I would rather prefer the function module to throw an exception and let me handle the error in my own way.
The code I am using is:
FORM create_to .
CLEAR v_tanum.
CALL FUNCTION 'L_TO_CREATE_SINGLE'
EXPORTING
i_lgnum = v_0200data-lgnum
i_bwlvs = v_0200data-bwlvs
i_matnr = v_0200data-matnr
i_werks = v_0200data-werks
i_lgort = v_0200data-lgort
i_anfme = v_0200data-qnty
i_altme = v_0200data-uom
i_squit = 'X'
i_wempf = v_0200data-recipient
i_vlenr = v_storageunit
i_nltyp = v_0200data-sttype
i_nlpla = v_0200data-destbin
i_update_task = 'X'
i_commit_work = space
IMPORTING
e_tanum = v_tanum
EXCEPTIONS
no_to_created = 1
bwlvs_wrong = 2
betyp_wrong = 3
benum_missing = 4
betyp_missing = 5
foreign_lock = 6
vltyp_wrong = 7
vlpla_wrong = 8
vltyp_missing = 9
nltyp_wrong = 10
nlpla_wrong = 11
nltyp_missing = 12
rltyp_wrong = 13
rlpla_wrong = 14
rltyp_missing = 15
squit_forbidden = 16
manual_to_forbidden = 17
letyp_wrong = 18
vlpla_missing = 19
nlpla_missing = 20
sobkz_wrong = 21
sobkz_missing = 22
sonum_missing = 23
bestq_wrong = 24
lgber_wrong = 25
xfeld_wrong = 26
date_wrong = 27
drukz_wrong = 28
ldest_wrong = 29
update_without_commit = 30
no_authority = 31
material_not_found = 32
lenum_wrong = 33
OTHERS = 34.
IF sy-subrc <> 0.
PERFORM err_message USING 7.
ELSE.
IF v_tanum IS NOT INITIAL.
COMMIT WORK AND WAIT.
PERFORM err_message USING 8.
ENDIF.
ENDIF.
LEAVE TO TRANSACTION sy-tcode.
ENDFORM. " create_to
‎2006 Aug 15 6:48 PM
If function module fails because of any case failure, it will raise an exception.
After FUNCTION CALL, check SY-SUBRC value. It should vary between 1 - 34 based upon corresponding exceptions.
In your code, add a check to see the SY_SUBRC value and populate error message accordingly.
IF sy-subrc <> 0.
case sy-subrc.
when 1.
when 2.
.
.
.
.
endcase.
endif.
‎2006 Aug 15 6:59 PM
For those of you who thought that sy-subrc value will change on error, do the following. Create a simple function module, which does not have any importing, exporting parameters, and will throw an exception, say ABC.
Write the following statement inside the function module.
message e398(00).
Call this function module from your Program, and see what happens. Your program will be stuck up after the function module throws the error and you will not be able to do anything about it. Since after the error, the program execution stops, the flow will not come to the statement "IF SY-SUBRC NE 0." statement at all.
‎2006 Aug 15 6:55 PM
I solved the problem myself. Luckily the function module was RFC enabled. So I called the function in a separate task, so the function module when throws error, will not effect my screen and I will get the sy-subrc value changed after the call.
‎2006 Aug 15 8:41 PM
Dude :
Its very simple , just add the line ERROR_MESSAGE = 32 under your exceptions, you will get the control back to your program.
I had encountered the same earlier.
Let me know if you still find dofficulty.
Mah
‎2006 Aug 16 1:53 PM
Yep.. abaper_user is great... That was, what I was looking for.
‎2009 Dec 10 8:56 PM
Hi ABAPUser,
Its kind of interesting what you have said. We faced the same issue discussed in this thread and after a lot of struggle found a relief through your answer... Now the control comes back to the calling program and also we can handle the exception.
But the question is, what is the significance of adding ERROR_MESSAGE = 32 in our exceptions? How that works...
Thanks again...