How to throw custom errors?
Hi Friends
How to throw custom errors in APEX?
For example if I violate a datatype instead of the oracle error i need to get a custom error.
Thanks
Nav
Use raise_application_error - Its built-into the database and not really an APEX specific thing. Google it for more info
Like so:
declare
v_num number;
begin
v_num := 1/0;
exception
when zero_divide then
raise_application_error(-20001, 'You tried dividing by zero - luckily I caught it just in time!');
end;
Similar Messages
-
How to throw Custom Error message in Portal
Hi Experts !
I am working on CRM 5.0 and using BADI CRM_ORDER_STATUS for LEAD transaction.
This BADI is checking the userid when user is trying to change the status of a lead. if userid is not correct than it is throwing an Error Message in GUI but this message is reflecting in Portal as an Exception but what I need here is a custom Message similar to GUI.
Pls suggest .
With Thanks & Regards
NavneetHi Experts !
I am working on CRM 5.0 and using BADI CRM_ORDER_STATUS for LEAD transaction.
This BADI is checking the userid when user is trying to change the status of a lead. if userid is not correct than it is throwing an Error Message in GUI but this message is reflecting in Portal as an Exception but what I need here is a custom Message similar to GUI.
Pls suggest .
With Thanks & Regards
Navneet -
How to show custom error message in WebADI Excel template?
Hi,
I've created a custom Web ADI integrator and associated it with a 'Procedure' based custom interface.
WebADI Interface API Returns is set to "Error Message".
I'm using raise_application_error(-20001, "Actual Error Message") for invalid rows,but custom error message from PL/SQL is not populated on the excel template.
Instead it is showing "SQL exception occurred during PL/SQL upload".
Am I missing anything? How to show custom error message from Pl/SQL procedure to WebADI Excel template?
TIA
NarasimhaThe custom API errors are visible in the BNE log but not on the Excel.
BNE Log=>
12/10/13 2:52 PM Web ADI Upload Job 13008 ERROR BnePLSQLUpload.doUpload: Exception while uploading to PL/SQL API. Error Code: 20001, Message: ORA-20001: -Please enter CONTAINER_ID - Enter PO_NO -
ORA-06512: at "APPS.XXPO_COSTFACTS_WEBADI_PKG", line 264
ORA-06512: at line 1
12/10/13 2:52 PM Web ADI Upload Job 13008 ERROR BnePLSQLUpload.doUpload: Stack trace: java.sql.SQLException: ORA-20001: -Please enter CONTAINER_ID - Enter PO_NO -
ORA-06512: at "APPS.XXPO_COSTFACTS_WEBADI_PKG", line 264
ORA-06512: at line 1
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:202)
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1005)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1307)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3449)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3550)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4710)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1374)
at oracle.apps.bne.integrator.upload.BnePLSQLUpload.doUpload(BnePLSQLUpload.java:284)
at oracle.apps.bne.integrator.upload.BneSAXUploader.processDeepestLevel(BneSAXUploader.java:2346)
at oracle.apps.bne.integrator.upload.BneSAXUploader.startElement(BneSAXUploader.java:1182)
at oracle.xml.parser.v2.XMLContentHandler.startElement(XMLContentHandler.java:181)
at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1288)
at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:336)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:303)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:234)
at oracle.apps.bne.integrator.upload.BneUploader.processUpload(BneUploader.java:301)
at oracle.apps.bne.integrator.upload.BneAbstractUploader.processUpload(BneAbstractUploader.java:114)
at oracle.apps.bne.integrator.upload.async.BneAsyncUploadThread.run(BneAsyncUploadThread.java:140)
12/10/13 2:52 PM AJPRequestHandler-HTTPThreadGroup-5 WARNING BneOracleWebAppsContext.getTimeZone CLIENT_TIMEZONE_ID has not been set
12/10/13 2:52 PM AJPRequestHandler-HTTPThreadGroup-5 ERROR BneOracleWebAppsContext.getExtraJDBCConnection recieved the same connection as the base connection. There may be transaction problems.
How to show the same error in the excel template?
Here is the package:
CREATE OR REPLACE PACKAGE BODY APPS.XXPO_COSTFACTS_WEBADI_PKG
AS
PROCEDURE upload_data (
P_CONTAINER_ID IN VARCHAR2
, P_SAIL_DATE IN DATE
, P_PO_NO IN VARCHAR2
) IS
--declare
lv_err_msg VARCHAR2(240);
lf_err_flag NUMBER := 0;
ln_temp NUMBER;
BEGIN
--------------------- checking for mandatory parameters---------------------------
IF (P_CONTAINER_ID IS NULL) THEN
lf_err_flag := 1;
lv_err_msg := lv_err_msg||'-'||'Please enter CONTAINER_ID - ';
END IF;
-------------Validation for Sail Date Format----------------------
IF (P_SAIL_DATE IS NULL) THEN
lf_err_flag := 1;
lv_err_msg := lv_err_msg || ' ' || 'Enter Sail Date - ';
ELSE
BEGIN
SELECT 1
INTO ln_temp
FROM DUAL
WHERE P_SAIL_DATE = TO_DATE (TO_CHAR (P_SAIL_DATE, 'DD-MON-YYYY'), 'DD-MM-YYYY');
EXCEPTION
WHEN NO_DATA_FOUND THEN
lf_err_flag := 1;
lv_err_msg := lv_err_msg || ' Enter Sail date in DD-MON-YYYY Format';
WHEN OTHERS THEN
lf_err_flag := 1;
lv_err_msg := lv_err_msg || ' Enter Sail date in DD-MON-YYYY Format'|| SQLERRM;
END;
END IF;
-------------Validation for PO_Number----------------------
IF (P_PO_NO IS NULL) THEN
lf_err_flag := 1;
lv_err_msg := lv_err_msg || ' ' || 'Enter PO_NO - ';
ELSE
BEGIN
SELECT count(1)
INTO ln_temp
FROM PO_HEADERS
WHERE Attribute4 = P_PO_NO;
EXCEPTION
WHEN NO_DATA_FOUND THEN
lf_err_flag := 1;
lv_err_msg := lv_err_msg || ' No Oracle PO for Biceps PO#'||P_PO_NO;
WHEN OTHERS THEN
lf_err_flag := 1;
lv_err_msg := lv_err_msg || ' Error getting the Oracle PO for Bicpes PO#'||P_PO_NO||' Error-' || SQLERRM;
END;
END IF;
-----------------------Insert Record----------------------------
IF lv_err_msg is NULL THEN
BEGIN
INSERT
INTO XXP2P_HW_COST_FACTORS_STG
CONTAINER_ID
,SAIL_DATE
,PO_NO
, ERROR_FLAG
, ERROR_MSG
,CREATED_BY
,CREATION_DATE
,LAST_UPDATED_BY
,LAST_UPDATE_DATE
,LAST_UPDATE_LOGIN
VALUES
P_CONTAINER_ID
,P_SAIL_DATE
,P_PO_NO
,lf_err_flag
,lv_err_msg
,FND_GLOBAL.USER_ID
, trunc (sysdate)
,FND_GLOBAL.USER_ID
, trunc (sysdate)
,FND_GLOBAL.LOGIN_ID
-- commit;
DBMS_OUTPUT.put_line
'-' || 'After ap_invoices_interface'
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
lf_err_flag := 1;
lv_err_msg := lv_err_msg || ' ' || 'error loading CONTAINER_ID-' || P_CONTAINER_ID || SQLERRM;
raise_application_error(-20001, lv_err_msg);
END;
ELSE
raise_application_error(-20001, lv_err_msg);
END IF;
END upload_data;
END XXPO_COSTFACTS_WEBADI_PKG; -
Best way to throw custom error from SubVI
Hi
I was wondering how best to throw error messages from a SubVI.
Say I have a toplvl VI called Caller.vi which calls Sub.vi. The toplvl vi whishes to use the Sub.vi's error out cluster to determine what to do - e.g. halt execution of the toplvl vi if the Sub.vi throws an error. Easy enough if the Sub.vi just have to pass errors from build in LabView functions and VI's, but how to do it if the sub vi has to throw a custom error upon some condition?
Say the sub vi takes a certain number of inputs and that the inputs need validation before executing what ever the sub vi does. E.g. a certain algorithm implemented is only meaningfull if a>10.
My own thought is this: Simply select between an empty/no-error error cluster and an error-cluster containing the wanted custom errorcode and description. The area circled in blue is the interesting part:
Is that the worst idea you've iever seen implemented?
The only other real suggestion I've been able to find (which originally adresses another issue, but shows a method for "throwing an error") is a VI posted in this thread: http://forums.ni.com/t5/LabVIEW/Throw-an-error/m-p/882575 which looks like:
Please help me out guys How to throw a custom error which is not intended for the end-user, but intended to ease the life of a develper calling the sub-vi if he/she wishes to.
Best regards
WuhtzuThank you tbob. (EDIT: and thank you blawson)
I know all about volunteering and having jobs to do - I participate in quite a few fora. I just thought that my topic was lost since after only 2 days it was on page 3 of the forum - but if page 3 isn't forgotten I will remember that next time and also if 2 days isn't patient I will also remember that
To you answer: The error code should be negative, shouldn't it? Even though an indicator wired to error-out of a build in labview function will actually display error codes as positive... maybe it's diffrent form labview version to labview version. My v2010 manual reads:
"You can define custom error codes in the range of -8999 through -8000, 5000 through 9999 or 500,000 through 599,999"
So say I want to throw an error with error code 5687 - should I then wire -5687 or +5687 to the cluster?
Thanks - Wuhtzu -
ICI - How to display custom error messages in SAP CRM
Hello,
we are working on a custom Contact Center which interfaces with SAP CRM Version 7 with Enhancement Package over ICI.
The basic call functions like accepting, hanging up, holding and retrieving are fully implemented and are working already.
Our goal is to display error messages in the CRM so that clients know there is something wrong, for example why he can't be log in successfully (e.g. the telephony server isn't reachable).
We already found the ICI Documentation file which provides us the CRM SOAP error codes and tried to send SOAP Fault messages, but never got
them to screen.
Please find an attached example screenshot what we mean exactly, reproduced by trying to make a call with CRM user while BCM CDT isn't
running in the background.
Regarding to this topic we've the following questions:
- Is it possible to display custom error messages on the CRM or is this functionality limited to SAP?
- Could you provide us some further information on how to use this feature exactly (implementation details?) and how the SOAP XML should look like to get it work?
Thank you in advance!
Best regards
René HolyNewUser7 wrote:
Please correct me if I am wrong
I need to create an entity adapter and attach an error handler with the adapter? or can i handle that in the event handler itself. I coulnt find any api for handling errorsYou can do it both ways but since we are talking about event handler now, then in 9.x you need to extend com.thortech.xl.client.events.tcBaseEvent class for creating a event handler. In tcBaseEvent class there are various flavors of handleError method. So use that as per my note earlier and you should be good.
HTH -
How to display custom error message in custom page
Hi,
I would like to show the exception details of custom component in my custom idoc page. Please let me know how to get the exception which is cached in Custom component in page.
ThanksHi,
Do they get a 404 error? If it is the case, you can customize error pages : [Custom Error Pages|http://help.sap.com/saphelp_nw70/helpdata/en/ec/1273b2c413b2449e554eb7b910bce7/frameset.htm].
Regards,
Pierre -
How to create Custom error message in SharePoint 2013
Hi,
I have created one document library.On uploading the same file SharePoint throws error as"server error.The same file exit".
But my requirement is not to show the SharePoint default message.I wanted to create custom message and show the pop up for the same file upload.
Is there any way to create any custom error page or can I manipulate SharePoint default error page?
Any help?
Thank youHi,
You can create an event receiver to set the validation error messages. One such post to redirect the custom error page is as follows
https://social.msdn.microsoft.com/Forums/office/en-US/2bc851f6-e04b-4550-b87f-9b874a290482/sharepoint-event-receivers-and-custom-error-messages?forum=sharepointdevelopmentlegacy
Create custom error page for SharePoint event receiver
Please mark it answered, if your problem resolved or helpful. -
How to display custom error message in Job log for batch processing
Hi All,
I am rexecuting one R/3 report in batch mode and i want to display all the custom error i have handled in job log when its executed from SM36,SM37. The custom error are like 'Delovery/Shipmet doe not exits' or others which we can display in online mode like message e100(ZFI) or any other way and accordingly we can handle the program control like come out of the program ro leave to transaction'Zxxx' or anything. But i want my program to be executed completely and accumulate all the error in job log of batch processing.
Can anyone tell me how can i do so...
Thanks,
AmritaHi,
Thats what i have done from the begining. I have written message like this:
Message i100(ZFI).
I was hoping to see this message in the log. But i cant see. Can you help me pleae... -
Editable ALV - how to throw an error message for a specific line & field
Hi all,
I've implemented an editable ALV and also the ON_DATA_CHECK event to check the values, entered in the ALV. So this works fine and I can check the values.
But now, I want to throw an error message corresponding to the field in the ALV, where the error occured.
How can I throw this error message corresponding to a specific line/field in the ALV?
I was using REPORT_ATTRIBUTE_ERROR_MESSAGE and REPORT_ELEMENT_ERROR_MESSAGE but without success.
I'm also using a loop over the "CHANGES" in the ALV and within this loop, I use
elem_alv = node_alv->get_element( index = <change>-element_index )
to get the element for the message.
CALL METHOD lo_message_manager->REPORT_ELEMENT_ERROR_MESSAGE
EXPORTING
MESSAGE_TEXT = 'my message'
ELEMENT = elem_alv
* ATTRIBUTES =
* PARAMS =
* MSG_USER_DATA =
* IS_PERMANENT = ABAP_FALSE
* SCOPE_PERMANENT_MSG = CO_MSG_SCOPE_CTXT_ELEMENT
* MSG_INDEX =
* CANCEL_NAVIGATION =
* IS_VALIDATION_INDEPENDENT = ABAP_FALSE.
2.) is it right, that for an editable ALV, I can't use the WDDOBEFOREACTION to do the checks?
If I try to use this, I can't get the values of my ALV table to check it.
Thanks,
AndreasHi Andreas,
I have tried to replicate your problem and I am getting the desired output. I have a row by name TEMP_NEW in my ALV and I want to throw an error message whenever the user enters a value of 4 for that particular field. Please find my coding as below. The important thing is where we perform the actual comparison between the r_value and 4. r_value is defined in SALV_WD_S_TABLE_MOD_CELL as reference to type DATA. So suppose the user enters a value of say 3 in the TEMP_NEW field of the ALV then r_value would contain 3 but if you observe its type in debugging mode it would be as TYPE REF TO I and not TYPE I. So you cannot directly say something like:
"if ls_modified_cells-r_value = 3" as this would lead to a syntax error. Define a field-symbol say <temp> and then use it to get the actual value into it by saying like:
ASSIGN ls_modified_cells-r_value->* TO <temp>.
Then you can use this <temp> for comparison in your IF statement like:
IF <temp> = 3.
Find the entire coding as below:
METHOD check_data.
DATA: lr_node TYPE REF TO if_wd_context_node,
lr_element TYPE REF TO if_wd_context_element,
ls_modified_cells TYPE salv_wd_s_table_mod_cell.
FIELD-SYMBOLS <temp> TYPE data.
" get message manager
DATA lo_api_controller TYPE REF TO if_wd_controller.
DATA lo_message_manager TYPE REF TO if_wd_message_manager.
lo_api_controller ?= wd_this->wd_get_api( ).
CALL METHOD lo_api_controller->get_message_manager
RECEIVING
message_manager = lo_message_manager.
lr_node = wd_context->get_child_node( name = 'NODE' ).
LOOP AT r_param->t_modified_cells INTO ls_modified_cells.
lr_element = lr_node->get_element( index = ls_modified_cells-index ).
IF ls_modified_cells-attribute = 'TEMP_NEW'.
" Get the value extracted into the field symbol from the reference variable
ASSIGN ls_modified_cells-r_value->* TO <temp>.
" Use the value present in this field-symbol for your comparison
IF <temp> = 4.
" report message
CALL METHOD lo_message_manager->report_attribute_error_message
EXPORTING
message_text = 'Sample message text'
element = lr_element
attribute_name = ls_modified_cells-attribute.
ENDIF.
ENDIF.
ENDLOOP.
ENDMETHOD.
Hope this helps resolve your problem.
Regards,
Uday -
How to display custom error message if the Required field is not entered?
Hi,
I have made one input field as required field in a view.
I want to display one custom error message ,if the required input field is not entered.
Please help me regarding this.
Thanks,
Deepikahi deepika....
First go to message pool under webdynpro components.
Create a new message there..of type error.
Enter your text.
Now to avoid null pointer exception , in wdDoInit(), initialise the value
wdContext.currentDateTimeElement().setDate("");
now create an action for submission of data. If field is empty, then within the button write:
msg = wdComponentAPI.getComponent().getMessageManager();
if(wdContext.currentDateTimeElement().getDate().equals(""))
msg.raiseMessage(IMessageCompTodatDateTime.ERROR,new Object[]{""},true) ;
between begin others put:
regards,
pinki
IWDMessageManager msg = null; -
How to configure custom error page in WebServer 6.1 if instance is down
Hi ,
I have deployed an application on port 82.
If the instance is down, want to configure custom error page in Sun One Webserver 6.1 so that the it displays a customised message rather than browser displaying its custom DNS error page.
In web.xml, configured the 404/500 error messages, but if the instance is down, my web application does not receive the request. So it should be defined at the root level.Where to configure the same?
Thanks for the help in advance.You can use Error function "send-error" http://docs.sun.com/source/817-1834-10/crobjsaf.html#wp20007
It has an example
Error fn=send-error code=401 path=/sun/server61/docs/errors/401.html -
EBS 12.1.3: Unable to throw custom error messages back to Excel document
Hi Gurus,
We are on 12.1.3 using Desktop Integration Framework.
I created a API Procedure based custom Integrator.
In the PLSQL procedure, I have raise_application_error(-20009, ‘Custom Error’) but this message never comes through.
It always shows a ‘SQL exception occurred during PL/SQL upload’.
When it is a success, it shows a green smiley which is fine.
But when there is a explicit raise_application_error in plsql proc, I would like the error message to flow all the way back to Excel document.
1.) What should I be using 'API Procedure or API Function' in the Custom Integrator,
2.) Should it return Error Message or FND Message?
Has it worked for anyone in 12.1.3?
Please let me know.
Thanks
Vinodhi ,Vinod
Please check the 'API Returns' is setted with 'FND Message Code' in Interfaces define(Step 2 of 5).
Regards,
leno -
How to add custom error message in standard application log of change doc.
Hi,
While saving chnage document I need to add raise an error on specific condition. As Error messages is being shown in application log I added custom message in include LCRM_1O_UIF15 by using BAL_LOG_MSG_ADD FM however it is not showing in the screen. What could be the reason? Can anybody please explain?
Rgds
SudhanshuMuhammed,
Have you tried throwing a JboException in your AM code?
John -
How to throw custom exception from sessionbean
I define an AppException generalize from EJBException.
public class AppException extends EJBException{
when error occurs in sessionbean,I throw AppException, Container perform rollback operation. but at client. I only get EJBException, Why? and How can I get AppException from sessionbean?AppException extends RuntimeException
-
IDOC_INPUT_ORDER - How manage the custom error message ?
Hello,
on EXIT_SAPLVEDA_002 and EXIT_SAPLVEDA_003 I done some custom check, (I would show some custom message as a result of these check).
My question is: How to show these custom message on the standardc idoc spool (WE02) ??
There's DERRTAB internal table to manage the error, but is not available on there exit ...(EXIT_SAPLVEDA_002 and 3)
Any idea ??
thank youHello,
question is if you want to raise an error, which makes sense only if the document is not posted or just an information message.
Please consider that you can put messages into the idoc only connected with a status. If you set status 51 thge Idoc is reprocessible, if you set status 53 it is successfully processed.
In error case you can raise exception USER_ERROR. in exit EXIT_SAPLVEDA_002. Set SY-MSGTY, SY-MSGID, SY-MSGNO, etc before. In exit EXIT_SAPLVEDA_003 you can set changing parameter ok to space. Then SAP will add an error message.
/Michael
Maybe you are looking for
-
Problem-Report generation using shell script
Hi We have the Production database and the Reporting database (copy of Production database), both on Oracle 9.2.0.5 and Solaris 5.8. There is a package inside the Oracle database, which extracts some data from inside the database, and would generate
-
I just had my macbook pro checked out and all of it's systems restarted to solve its beeping and freezing problem. However, it is still shutting itself down when I close the lid and becoming very hot. When I open the lid again the screen is black an
-
Can't get EE and SE to play nicely with deploytool
Hi, I have tried the following combinations of installations: j2se 1.4.x / j2ee 1.4.x (beta) j2se 1.4.x / j2ee 1.3.1 j2se 1.3.1 / j2ee 1.4.x (beta) With all of these combinations, the deploytool utility which comes with the j2ee bundle crashes on me
-
How do you get Airdrop to always work?
I have Airdrop on my two macbooks, both running Mavericks. Sometimes it works. Sometimes it doesn't. Today, I logged in and out of my Macbook Pro and it worked to connect to the Airdrop of my Macbook Air. When I tried it again, it did not work.
-
I've backed up my iPhone 5 using iCloud where can I find my pictures?
Every week I back up my iphone 5 I go to my my icloud settings and back up everything however when I log into icloud online I can't seem to see my photos how can I make sure there being backed up?