Exception handling in function module
Hi experts,
when we write the function module in the report program like "CONVERT_TO_LOCAL_CURRENCY" if anything goes wrong in this FM the program goes to dump. So how to handling this exceptions.
if sy-subrc ne 0 then i need to continue with the next statement. will i need to use continue statement.
Please expllain with some example
hello,
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
CLIENT = SY-MANDT
date = itab-date_of_export
foreign_amount = dl_kwert
foreign_currency = itab-waers
local_currency = c_usd
IMPORTING
local_amount = itab-value_of_goods
EXCEPTIONS " un-comment these sections
no_rate_found = 1
overflow = 2
no_factors_found = 3
no_spread_found = 4
derived_2_times = 5
OTHERS = 6.
IF sy-subrc NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO " this is display the system message automatically when ever exp are hit
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
here you can use the case statement like:
case sy-subrc.
when 1.
write your code what you want to do if no rate found
when 2.
what do you want to do in case of overflow.
*similarly handle all the cases of exceptons
endcase.
hope it helps
regards
geeta gupta
Similar Messages
-
Customer 9000AAAE : Exception 7 in function module VIEW_KUAG2
Hi,
Hi all,
When I do the intercompany billing for STO (vf01), I got the system message attached below. The customer 9000AAAE is a ship to party and assigned to the ordering plant. It has the partner function SH. So can anybody kindly tell me where is wrong in the custmer master data or somewhere else according to the following message? Or where to find the VIEW_KUAG2? What does it mean?
Customer 9000AAAE: Exception 7 in function module VIEW_KUAG2
Diagnosis
During the attempt to read customer master record 9000AAAE,
an error occured which is not handled separately.
System Response
The billing document for this business transaction was not
created.
Procedure
If the error occured during a background job, you should try
to create the billing document online. If the error occured
online, the billing document can be created online. In any
case, you should check the customer master record. If you
cannot find any error in the master data, contact SAP.
Technical data
Tech. data details
Client 002
Group Number
Sales Document Number 0080100090
Item Number of the SD Document 000000
Schedule Line Number 0083
Counter in Control Tables 00
Message Identification VF
System Message Number 083
Output Type E
Message Variable 01 9900AAAE
Message Variable 02
Message Variable 03 VIEW_KUAG2
Message Variable 04
Group Type F
In our Intercompany, our ship to party is different from the Sold to, bill to and Payer. The configuration done as follows -
a. Defined Ship to Party as 9000AAAE
b. Define Sold to, Bill to, Payer as 9000AAAA
c. Assignd Ship to Sold to
d. Assigned Ship to customer to plant assignment in STO configuration in MM
e. Assigned internal customer of sales organization as 9000AAAA
Please help in this
Best Regards
GouthamHi,
Thanks for ur reply
I check the partner determination and the settings are as below -
a. Defined new account group for Sold to, Bill to and Payer
b. Defined new account group for Ship to
c. In the Ship to party account group, system only determine the ship to partner function
d. Customer defined in Sold to is assined as interneal customer to sales org
e. Customer defined in Ship to is assigned as customer for plant in Shipping data configure for STO in MM Configuration
Please provide more insights
Best Regards
Goutham -
How to use Exceptions for a function module
Hi folks,
I have created a new function module.Its working fine, but i am not aware of using exceptions for a function module. I hav just declared an exception in the 'exception' tab. Could any body explain me how to use that in my FM source code....Thanks...Hi Shyam,
Have a look at this,
START-OF-SELECTION.
gd_file = p_infile.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = gd_file
has_field_separator = 'X' "file is TAB delimited
TABLES
data_tab = it_record
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.
IF sy-subrc NE 0.
write: 'Error ', sy-subrc, 'returned from GUI_UPLOAD FM'.
skip.
endif.
Regards,
Sai -
Exceptions in the function module
Hi,
I declared exceptions in the function module. But those exceptions not trigger in the abap editor.
Regards
SrinuHi
use RAISE EXCEPTION...
RAISE KEY WORD IT WILL DEFENETELY RAISE THE EXCEPTION..
REWARD IF IT USE FUL -
Customer : Exception 7 in function module VIEW_KUxxV
Hi,
While Billing facing this problem
00 Customer : Exception 7 in function module VIEW_KUxxV
10 The bill-to party could not be determined
10 The payer could not be determined
tx in advance
Bhushan KolteHello Colleague;
Please check the account group assignment to the partner functions in
transaction VOPA click on partner function button then environment
then Account group assignment. Please ensure that this is all configured
correctly for the partners.
Please also review the note
-> 80233 Debit-side settlement: Customizing, error messages
In particular the section:
VF083: 'Customer &: Exception & in function module VIEW_KUAGV'
The error message is generated because of a program error that
has since been corrected. The correct error message is VP304,
'Customer belongs to customer group & and thus cannot be the
sold-to party'.
The partner roles in the customer master are incorrectly set, see
below.
Recommendation: Assign the customer an account group which
already fulfills these criteria. (In the standard system, this is
Account group '0001).
I hope this helps resolve the error.
Regards
Ruy Castro -
Exception 7 in function module VIEW_KUAG2
Hi all,
When I try to process a Billing document in transaction VF04, has an error message "Customer 12334: Exception 7 in function module VIEW_KUAG2".
Could you advise me why I receive this message?
Is it possible that Customer master data it is not maintained propertly?Hi,
When I checked there are only 5 exceptions for this functional module. By the way which version are you in? If you want to find out what the exception 7 is then go to SE37 and display this functional module. There you can find a tab for exceptions. Based on that you can proceed with changes in the customer master.
Its definitely the possibility of not maintaining the customer properly.
Hope this helps.
Thanks
Krishna. -
How do we trap exception inside the function module?
How do we trap exception inside the function module?
Use ABAP Help - CATCH, RAISE for starters. Or take a look at an existing function module, for example.
-
Message handling in function module
Dear All,
I created a function module to create equipment master. but i want to know how to handle message for this function module.
Like if i create an equipment which is already been created then the message should shoe that equipment already exist.
<removed by moderator>
this is my query. so pls kindly tell me how to handle message for this query
Moderator message: please post only relevant code parts, your posts must contain less than 5000 characters to preserve formatting.
Edited by: Thomas Zloch on Apr 14, 2011 10:00 AMHi Prakrita,
Try building below code within the RFC after you have added return structure in your RFC parameters.
IF sy-subrc NE 0.
CLEAR message.
message-msgty = 'E'.
message-msgid = 'ZMI'.
message-msgno = '001'.
message-msgv1 = ID.
PERFORM return_message USING message
CHANGING return.
Endif.
form return_message USING VALUE(P_MESSAGE) LIKE MESSAGE
CHANGING P_RETURN LIKE BAPIRETURN.
CHECK NOT MESSAGE IS INITIAL.
CALL FUNCTION 'BALW_BAPIRETURN_GET'
EXPORTING
TYPE = P_MESSAGE-MSGTY
CL = P_MESSAGE-MSGID
NUMBER = P_MESSAGE-MSGNO
PAR1 = P_MESSAGE-MSGV1
PAR2 = P_MESSAGE-MSGV2
PAR3 = P_MESSAGE-MSGV3
PAR4 = P_MESSAGE-MSGV4
IMPORTING
BAPIRETURN = P_RETURN
EXCEPTIONS
OTHERS = 1.
endform. -
Uncatchable exception: BSP calling Function Module
Hi all,
currently i'm facing a very weird problem. My application class calls function module
HR_INFOTYPE_OPERATION. Normally, in case of an error, the function module gives you back a return parameter. But if i call it from my BSP, the processing doesn't leave the function module. It directly throws an exception ERROR_MESSAGE_STATE instead of writing the message into parameter return.
If i call the function module with the same parameters from a report, it works fine and the error message is written to return parameter without throwing an exception.
What am i doing wrong? I don't want that exception and need to go on with filled parameter result.
Regards
Mark-AndréHi MA,
try using ERROR_MESSAGE in the exceptions list, like this.
CALL FUNCTION 'func_name'
EXPORTING
string = text
pos = position
IMPORTING
string1 = text1
string2 = text2
EXCEPTIONS
string1_too_small = 1
string2_too_small = 2
ERROR_MESSAGE = 3
OTHERS = 4.
Cheers
Graham Robbo -
Exception Raising in Function Module
Hi,
I am having a custom function module that calls a standard function module. Custom function module has following exception defined: manufacture unknown.
Standard function module has enhancement sections that I implement. For a defined condition I have to raise an exception and return from the function module. However, the exception is not defined in function module.
Standard exception OTHERS is available. Is it possible to raise OTHERS exception from the code? I have tried statement Raise OTHERS. But it has syntax errors.
Regards,
Bhavish BhatiaHi,
If you raise an exception not defined at exception's tab, sy-subrc will be returned with the number of exception OTHERS.
Just with the sentece:
RAISE ZEXCEPTION. (Assuming that ZEXCEPTION is not included at exception's tab).
Regards,
Pablo. -
Catch the Exceptions of standard Function Module
Hi Experts,
I am Using Version 4.6C.
I am developing an RFC for creation of commitments into the system for this i have used 'FMFR_CREATE_FROM_DATA' Function Module. But i need to capture the System exception so as to alert the user when it puts in invalid data. However function Module 'FMFR_CREATE_FROM_DATA' is working fine but I am unable to System Exceptions i have tried using Function Module FORMAT_MESSAGE by importing the system variable into it but my program gets append ever time an system exception raised.
Can anyone help in getting it fix.Hi,
Which thrid party system you are configuring check the system destinations propely given or not and in third parthy which type error or any message u r getting or not. Once if it is working find in from R/3 to other it is not RFC problem it may related to u r settings or in third parthy system not set properly.
contact your basis teams
Regards
Ganesh -
Exception while executing Function module - HRXSS_PER_READ_P0006_US
Unable to execute any of the following Function modules(ECC 5)
(Gave the neccesary inputs)
HRXSS_PER_P0006_US
HRXSS_PER_DELETE_P0006_US
HRXSS_PER_EDIT_P0006_US
HRXSS_PER_MODIFY_P0006_US
HRXSS_PER_NEW_P0006_US
HRXSS_PER_READ_P0006_US
Getting an exception
Runtime Errors OBJECTS_OBJREF_NOT_ASSIGNED_NO
Exceptn CX_SY_REF_IS_INITIAL
ShrtText
Access with 'ZERO' object reference not possible.
What happened?
Error in ABAP application program.
The current ABAP program "SAPLHRXSS_PER_MAC" had to be terminated because one of the statements could not be executed.
This is probably due to an error in the ABAP program.
Error analysis
An exception occurred. This exception is dealt with in more detail below . The exception, which is assigned to the class 'CX_SY_REF_IS_INITIAL', was neither caught nor passed along using a RAISING clause, in the procedure "HRXSS_PER_CLEANUP" "(FUNCTION)".
Since the caller of the procedure could not have expected this exception to occur, the running program was terminated.
The reason for the exception is:
There was an attempt to access a component using a 'NULL' object reference (points to nothing).
An object reference must indicate an object (an instance of a class), before it can be used to access components.
Either the reference was never set or it was set to 'NULL' using a CLEAR statement.
Missing RAISING Clause in Interface
Program SAPLHRXSS_PER_MAC
Include LHRXSS_PER_MAC$04
Row 7
Module type (FUNCTION)
Module Name HRXSS_PER_CLEANUP
Trigger Location of Exception
Program SAPLHRXSS_PER_MAC
Include LHRXSS_PER_MACU04
Row 13
Module type (FUNCTION)
Module Name HRXSS_PER_CLEANUP
What could be the reason?
Regards,
SarathHi Sarath,
The problem is caused by a program error in the CRM system.
Solution for this is Import the Support Package or implement the correction instructions as specified in note 742720, there are some corrections attached to the note. Hope this will resolve the issue.
Cheers,
Shyam. -
How to see the exception raised in function module...
DEAR ABAPERS,
how can i see that exception, when iam excuting
Regards,
veerahi Veera,
Based on SY-SUBRC value we can handle those exception in this way ..
if sy-subrc = 1.
raise file_write_error.
elseif sy-subrc = 2.
raise gui_refuse_filetransfer.
elseif sy-subrc = 3.
raise gui_refuse_filetransfer.
Regards,
Santosh -
How to raise the exception in function module
Dear abaper's.
I am creating a Function module .In that in' EXCEPTION' Tab i am giving
3 exception .1.NO_DATA_FOUND 2.NO_PRINTER_FOUND 3.SMARTFORM_INTERFACE_NOT_FOUND.
In my coding if this condtion matches i want to raise this exception.how can i do this in my coding .can any one suggest me..
advance thanks,
Warm regards,
VeeraHi,
if that condition is not satisfied,and u didn't handle that exception while calling function module then in the runtime error u will get the text as the description of the exception in function module definition.
rgds,
bharat. -
Exceptions in Function Modules
Hi
How can I create an Exception in a Function Module and Raise that based on some condition? Plz helpHi Santo,,,,
Look into this link ,, where u will get a clear information on exceptions,,,,,
http://help.sap.com/saphelp_nw70/helpdata/en/9f/db98fc35c111d1829f0000e829fbfe/content.htm
http://abapprogramming.blogspot.com/2007/06/lesson-24-function-groups-and-function.html
In the function module, you can create your own local types and data objects, and call subroutines or other function modules.
You can make a function module trigger exceptions .
To do this, you must first declare the exceptions in the interface definition, that is, assign each one a different name.
In the source code of your function module, you program the statements that trigger an exception under the required condition. At runtime, the function module is terminated when an exception is triggered.
The changes to exporting and changing parameters are the same as in subroutines. There are two statements that you can use to trigger an exception. In the forms given below, stands for the name of an exception that you declared in the interface. The system reacts differently according to whether or not the exception was listed in the function module call:
RAISE .
If the exception is listed in the calling program, the system returns control to it directly. If the exception is not listed, a runtime error occurs.
MESSAGE () RAISING .
If the exception is listed in the calling program, the statement has the same effect as RAISE . If it is not listed, the system sends message from message class with type , and no runtime error occurs.
Function modules differ from subroutines in that you must assume that they will be used by other programmers. For this reason, you should ensure that you complete the steps listed here.
Documentation (can be translated)
You should document both your parameters and exceptions with short texts (and long texts if necessary) and your entire function module. The system provides a text editor for you to do this, containing predefined sections for Functionality, Example Call, Hints, and Further Information.
Work list
When you change an active function module, it acquires the status active (revised). When you save it, another version is created with the status inactive . When you are working on a function module, you can switch between the inactive version and the last version that you activated. When you activate the inactive version, the previous active version is overwritten.
Function test
Once you have activated your function module, you can test it using the built-in test environment in the Function Builder. If an exception is triggered, the test environment displays it, along with any message that you may have specified for it. You can also switch into the Debugger and the Runtime Analysis tool. You can save test data and compare sets of results.
When you insert a function module call in your program, you should use the Pattern function. Then, you only need to enter the name of the function module (input help is available). The system then inserts the call and the exception handling (MESSAGE statement) into your program.
You assign parameters by name. The formal parameters are always on the left-hand side of the expressions:
Exporting parameters are passed by the program. If a parameter is optional, you do not need to pass it. Default values are displayed if they exist.
Importing parameters are received by the program. All importing parameters are optional.
Changing parameters are both passed and received. You do not have to list optional parameters.
Default values are displayed if they exist.
The system assigns a value to each exception, beginning at one, and continuing to number them sequentially in the order they are declared in the function module definition. You can assign a value to all other exceptions that you have not specifically listed using the special exception OTHERS.
If you list the exceptions and one is triggered in the function module, the corresponding value is placed in the return code field sy-subrc. If you did not list the exception in the function call, a runtime error or a message occurs, depending on the statement you used in the function module to trigger the exception.
When you create a function module, you must assign it to a function group. The function group is the main program in which a function module is embedded.
A function group is a program with type F, and is not executable . The entire function group is loaded in a program the first time that you call a function module that belongs to it.
The system also triggers the LOAD-OF-PROGRAM event for the function group.
The function group remains active in the background until the end of the calling program. It is therefore a suitable means of retaining data objects for the entire duration of a program. All of the function modules in a group can access the group's global data.
Please reward if found helpful,,,,,,,,,,,,,,,,
Thanks And Regards ,,,,
Sreekar.Kadiri.
Maybe you are looking for
-
How to transfer my iTunes library from a hard disc to new computer?
Could anybody help me with this issue? I've tried everything I could without any succes... My computer where I had my iTunes library (complete with many info and ratings) crashed and I lost all my archives. Luckly I had a copy of everything in an ext
-
I have a G4 mini connected DVI out to VGA in on my Pioneer Plasma. Works perfectly... except for playing back HD podcasts when it stutters.... but I also have Connect 360 installed & streaming via an XBox360 to an LCD screen (via component) works per
-
When is the next iOS update??
Can anyone please tell me when or what date is the next iOS update as I'm still tying to either downgrade back to ios6
-
Print Preview final adjustments
In CS4 when I went to print using the printer to manage color,[ with a preview ] I had the ability to make changes to brightness contrast ...also to make color changes before printing [ the last step ] in CS5 I seem to have lost the function ... th
-
Image in photoshop transparent and not showing image selected.
My images are appearing in Photoshop as 'transparent' and not as the image selected. This is following a major fault created by hardware supplied to me which caused me to have to re-format my computer.