How to catch error

In my application I want to cathc an error from mysql database.
Does anybody know?
Thanks in advance.

You should be getting an SQLException
But if you are really getting an error you can do
try {
   ... throws an Error
} catch(SQLException e) {
    e.printStackTrace();
} catch (Error e) {
    e.printStackTrace();
}

Similar Messages

  • How to catch errors in calling program when using SUBMIT ... AND RETURN ?

    Hi ,
    I am calling a report using submit and return statement from a function module. The report has select-options field for a date field. If user enters a date in low, which is greater than high, getting error message "Lower limit is greater than upper limit".
    How to catch this error without endup stoping on selection screen of the report?
    In the documentation, I read :
    Programs called with SUBMIT ... AND RETURN or CALL TRANSACTION cannot propagate exceptions to the caller, because exception objects are bound to the internal mode of a program.
    Is there any way to overcome this?
    Also my aim is to write a validation on the date selection-option to have the date range not more than 20 days.
    I am not sure of how to achieve this. 
    Is there a way to do validation of select-options data before submiting to the report ?
    Is there any standard FM to achieve this task?
    Thank you,
    Surya.
    Edited by: Surya on May 24, 2009 6:08 PM

    Hi Surya ,
    In your function module's code validate the date .
    If the low value of the date less than high and date period is not more than 20 then
    call transaction and in else condition raise exception.
    In your FM write like that - -
    IF   date-low LT date-high AND
                           date_difference LE '20' .
    CALL  TRANSACTION   'transaction'.
    ELSE.
    RAISE  ...........  " Raise the invalid date exception
    ENDIF.
    Regards
    Pinaki

  • How to catch error message inside a variable?

    Hi,
    I'm trying to catch the error message inside a variable using this this command below:-
    <%=odiRef.getPrevStepLog("MESSAGE")%>
    Could you please tell me what is the right approach to capture the error message inside a variable.
    Thanks
    Anindya

    Hi Bhabani,
    I have done this and select an oracle schema.But the variables only captures the (null).Please look into this.You must have one step prior to this refresh variable. Then only it can get the status as given below.
    Returns the one-letter code indicating the status with which the previous step terminated. The state R (Running) is never returned.
    D: Done (success)
    E: Error
    Q: Queued
    W: Waiting
    M: Warning
    If you want the complete error details then you will face issues in case of multi line message. For this best option would be jython variable.Could please provide me some idea how to use this jython variable.I will update you on this soon
    Thanks
    Anindya

  • How to catch error records while inserting

    hi all,
    i am trying to insert some records in my function where i need to catch the records that are not inserted due to some data incosistencies. i am using a cursor that has the data. can you please let me how can i accomplish this .below is the part of code which does this but it is not working.
    open c_upd;
    fetch c_upd bulk collect into tbl_rftm_pid_details_upd;
    close c_upd;
    if tbl_rftm_pid_details_upd.count > 0 then
    BEGIN
    FORALL i IN 1.. tbl_rftm_pid_details_upd.COUNT SAVE EXCEPTIONS
         insert into rftm_pid_details
    (pid,project_description ,start_date ,end_date ,cust_name ,end_cust_name ,processing_status,
    pid_status ,effective_date,offshore_onsite ,unit ,sub_unit ,pm_id, pm_name,product ,
    project_location ,rm_id ,rm_name ,pid_release_date ,project_type ,project_type_desc ,
    pid_class_desc ,pa_number ,parent_pid ,ideal_ref_no_zv ,ideal_ref_no_lv ,opp_id ,opp_status ,
    bid_margin ,bpw_version ,bid_vsoe ,est_backlog ,div ,grp ,order_number ,project_exec_type ,
    sow_ol_number ,cd_number ,billable_psd ,non_billable_psd ,total_psd ,ltd_billable_psd ,
    ltd_non_billable_psd ,npr_psd ,cash_cntry ,version_number ,system_date )
    values
    (tbl_rftm_pid_details_upd(i).pid,tbl_rftm_pid_details_upd(i).project_description ,tbl_rftm_pid_details_upd(i).start_date ,tbl_rftm_pid_details_upd(i).end_date ,tbl_rftm_pid_details_upd(i).cust_name ,tbl_rftm_pid_details_upd(i).end_cust_name ,tbl_rftm_pid_details_upd(i).processing_status,
    tbl_rftm_pid_details_upd(i).pid_status ,tbl_rftm_pid_details_upd(i).effective_date,tbl_rftm_pid_details_upd(i).offshore_onsite ,tbl_rftm_pid_details_upd(i).unit ,tbl_rftm_pid_details_upd(i).sub_unit ,tbl_rftm_pid_details_upd(i).pm_id, tbl_rftm_pid_details_upd(i).pm_name,tbl_rftm_pid_details_upd(i).product ,
    tbl_rftm_pid_details_upd(i).project_location ,tbl_rftm_pid_details_upd(i).rm_id ,tbl_rftm_pid_details_upd(i).rm_name ,tbl_rftm_pid_details_upd(i).pid_release_date ,tbl_rftm_pid_details_upd(i).project_type ,tbl_rftm_pid_details_upd(i).project_type_desc ,
    tbl_rftm_pid_details_upd(i).pid_class_desc ,tbl_rftm_pid_details_upd(i).pa_number ,tbl_rftm_pid_details_upd(i).parent_pid ,tbl_rftm_pid_details_upd(i).ideal_ref_no_zv ,tbl_rftm_pid_details_upd(i).ideal_ref_no_lv ,tbl_rftm_pid_details_upd(i).opp_id ,tbl_rftm_pid_details_upd(i).opp_status ,
    tbl_rftm_pid_details_upd(i).bid_margin ,tbl_rftm_pid_details_upd(i).bpw_version ,tbl_rftm_pid_details_upd(i).bid_vsoe ,tbl_rftm_pid_details_upd(i).est_backlog ,tbl_rftm_pid_details_upd(i).div ,tbl_rftm_pid_details_upd(i).grp ,tbl_rftm_pid_details_upd(i).order_number ,tbl_rftm_pid_details_upd(i).project_exec_type ,
    tbl_rftm_pid_details_upd(i).sow_ol_number ,tbl_rftm_pid_details_upd(i).cd_number ,tbl_rftm_pid_details_upd(i).billable_psd ,tbl_rftm_pid_details_upd(i).non_billable_psd ,tbl_rftm_pid_details_upd(i).total_psd ,tbl_rftm_pid_details_upd(i).ltd_billable_psd ,
    tbl_rftm_pid_details_upd(i).ltd_non_billable_psd ,tbl_rftm_pid_details_upd(i).npr_psd ,tbl_rftm_pid_details_upd(i).cash_cntry ,tbl_rftm_pid_details_upd(i).version_number ,tbl_rftm_pid_details_upd(i).system_date);     
    EXCEPTION
    WHEN ex_dml_errors THEN     
    l_exceptions := SQL%BULK_EXCEPTIONS.COUNT;
    FOR i in 1.. l_exceptions LOOP
    l_index := SQL%BULK_EXCEPTIONS(i).error_index;
    l_err_code := SQL%BULK_EXCEPTIONS(i).error_code;
    INSERT INTO rftm_pid_details_exception
         (pid,err_code)
    VALUES
         (tbl_rftm_pid_details_upd(l_index).pid,
         l_err_code);
    END LOOP;
    END;     
    END IF;

    how can i use this DBMS_ERRLOG.CREATE_ERROR_LOG in my function?
    i tried doing this, before the insert command.
    DBMS_ERRLOG.CREATE_ERROR_LOG('rftm_pid_details');
    BEGIN
         FORALL i IN 1.. tbl_rftm_pid_details_upd.COUNT
    INSERT INTO rftm_pid_details
    (pid,project_description ,start_date ,end_date ,cust_name ,end_cust_name ,processing_status,
    pid_status ,effective_date,offshore_onsite ,unit ,sub_unit ,pm_id, pm_name,product ,
    project_location ,rm_id ,rm_name ,pid_release_date ,project_type ,project_type_desc ,
    pid_class_desc ,pa_number ,parent_pid ,ideal_ref_no_zv ,ideal_ref_no_lv ,opp_id ,opp_status ,
    bid_margin ,bpw_version ,bid_vsoe ,est_backlog ,div ,grp ,order_number ,project_exec_type ,
    sow_ol_number ,cd_number ,billable_psd ,non_billable_psd ,total_psd ,ltd_billable_psd ,
    ltd_non_billable_psd ,npr_psd ,cash_cntry ,version_number ,system_date )
    VALUES
    (tbl_rftm_pid_details_upd(i).pid,tbl_rftm_pid_details_upd(i).project_description ,tbl_rftm_pid_details_upd(i).start_date ,
    tbl_rftm_pid_details_upd(i).end_date ,tbl_rftm_pid_details_upd(i).cust_name ,tbl_rftm_pid_details_upd(i).end_cust_name ,
    tbl_rftm_pid_details_upd(i).processing_status,tbl_rftm_pid_details_upd(i).pid_status ,tbl_rftm_pid_details_upd(i).effective_date,
    tbl_rftm_pid_details_upd(i).offshore_onsite ,tbl_rftm_pid_details_upd(i).unit ,tbl_rftm_pid_details_upd(i).sub_unit ,
    tbl_rftm_pid_details_upd(i).pm_id, tbl_rftm_pid_details_upd(i).pm_name,tbl_rftm_pid_details_upd(i).product ,
    tbl_rftm_pid_details_upd(i).project_location ,tbl_rftm_pid_details_upd(i).rm_id ,tbl_rftm_pid_details_upd(i).rm_name ,
    tbl_rftm_pid_details_upd(i).pid_release_date ,tbl_rftm_pid_details_upd(i).project_type ,tbl_rftm_pid_details_upd(i).project_type_desc ,
    tbl_rftm_pid_details_upd(i).pid_class_desc ,tbl_rftm_pid_details_upd(i).pa_number ,tbl_rftm_pid_details_upd(i).parent_pid ,
    tbl_rftm_pid_details_upd(i).ideal_ref_no_zv ,tbl_rftm_pid_details_upd(i).ideal_ref_no_lv ,tbl_rftm_pid_details_upd(i).opp_id ,
    tbl_rftm_pid_details_upd(i).opp_status ,tbl_rftm_pid_details_upd(i).bid_margin ,tbl_rftm_pid_details_upd(i).bpw_version ,
    tbl_rftm_pid_details_upd(i).bid_vsoe ,to_number(tbl_rftm_pid_details_upd(i).est_backlog) ,tbl_rftm_pid_details_upd(i).div ,
    tbl_rftm_pid_details_upd(i).grp ,tbl_rftm_pid_details_upd(i).order_number ,tbl_rftm_pid_details_upd(i).project_exec_type ,
    tbl_rftm_pid_details_upd(i).sow_ol_number ,tbl_rftm_pid_details_upd(i).cd_number ,tbl_rftm_pid_details_upd(i).billable_psd ,
    tbl_rftm_pid_details_upd(i).non_billable_psd ,tbl_rftm_pid_details_upd(i).total_psd ,tbl_rftm_pid_details_upd(i).ltd_billable_psd ,
    tbl_rftm_pid_details_upd(i).ltd_non_billable_psd ,tbl_rftm_pid_details_upd(i).npr_psd ,tbl_rftm_pid_details_upd(i).cash_cntry ,
    tbl_rftm_pid_details_upd(i).version_number ,sysdate)
    LOG ERRORS
    REJECT LIMIT UNLIMITED;
    when i try compiling the function, it is giving an error table not exists for 'rftm_pid_details'.

  • How to catch error or exception for FM JOB_OPEN in code

    Hi,
    i am calling the FM 'JOB_OPEN' in my code to catch the error message when sy-subrc ne 0 but it is giving dump as there is nothing coming in sy-msgid, sy-msgtype. but when i just run this FM in SE37 then I am able to get the error for example when I pass blank for jobname then error comes is 'job missing'  which is fine.
    But this error I am not able to display from ABAP code which is as :
    CALL FUNCTION 'JOB_OPEN'
              EXPORTING
                jobname          = g_jobname
              IMPORTING
                jobcount         = g_jobcount
              EXCEPTIONS
                cant_create_job  = 1
                invalid_job_data = 2
                jobname_missing  = 3.
            IF sy-subrc <> 0.
              MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
            ENDIF.
    Please suggest how to correct it ???
    Thanks,
    Mohan

    try this way
    CALL FUNCTION 'JOB_OPEN'
               EXPORTING
                 jobname          = g_jobname
               IMPORTING
                 jobcount         = g_jobcount
               EXCEPTIONS
                 cant_create_job  = 1
                 invalid_job_data = 2
                 jobname_missing  = 3.
             IF sy-subrc NE 0. 
                if sy-subrc = 1.
                  message 'cant_create_job  '   type 'E'.   "Exxception 1
                elseif sy-subrc = 2.
                  message 'invalid_job_data  '   type 'E'.   "Exxception 2
                else.
                  message ' jobname_missing '   type 'E'.   "Exxception 3
                endif.
           ENDIF.
    Regards,
    Prabhudas

  • How to catch error in the Active Sync process

    Hi, we are using Flat File active sync to update IDM user attribute. Once IDM found matched record, it builts view. However, during this period, the the matched user is locked, for example. Then IDM stop processing this record then go to next record. How can I catch this error? In log file I saw error message but how can use workflow or other way to know the error? How can get ResultItem that contains error message during AS?

    Hi,
    I am doing the following....
    Assume a main workflow which calls many sub workflows ...
    1. Define two global variables as follows
    <Variable name='anyErrorOccured'><Boolean>false</Boolean></Variable>
    <Variable name='allErrorMsg'><s>Error..</s></Variable>
    2. In the all main and sub workflows, add an special 'Action' to check the errors after each Action
    <Action id='1' name='doSomething'>
    </Action>
    <Action id='2' name='checkForErrors'>
    <cond>
    <isTrue><ref>WF_ACTION_ERROR</ref></isTrue>
    set the anyErrorOccured variable to true
    Append a custom error message(hard coded) to allErrorMsg variable - error message may contain workflow name and in which action error occured
    </cond>
    </Action>
    3. Before ending the main workflow, if anyErrorOccured is true, then send an email to IDM administartor with allErrorMsg
    <Activity id='3' name='CheckOverallError'>
    <Transition to='SendOverallErrorNotificationToIDM'>
    <ref>anyErrorOccured</ref>
    </Transition>
    <Transition to='end'/>
    </Activity>
    Hope, this helps.
    Furthermore, I tried to catch the actual error trace from IDM using the following in each 'checkForErrors' Action and append all IDM error messages for email notification.
    <invoke name='getMessage'>
    <get>
    <invoke name='getErrorMessages'>
    <ref>WF_CASE_RESULT</ref>
    </invoke>
    <i>1</i> ???????
    </get>
    </invoke>
    But , it was not successful, as I could not extract the right error mesage at the right place from WF_CASE_RESULT

  • How to catch error executing a preocedure

    Hi All.
    I have done a workflow to execute a oracle procedure who performs DML (truncate table).
    How Can I cacth an error code of procedure in workflow ?
    Thanks,
    Marco

    Hello,
    Have you already tried by catching the errors in you procedure and then as action you enforce the ending of the procedure as error ? In your workflow you are then able to perform a special action if the procedure ended with error or if it was successfull.
    I can't remember the code I used to do that on my previous project but I know that it worked like that.
    Regards,
    Florent

  • How to catch error message and show it in VC?

    I want to catch the error message and show it in VC.For example, if there is no data row in table view queryed from data service, then popup a window to show the message "No Data Found".I don't konw how to implement it!

    Hello Kane
    use expression{disble this after defining erroe messege} box in that popup there u can define your own message as error or warning accordingnly it display message
    I hope it work or Let me know it
    Regards
    ````Satish````

  • How to CATCH error from call to standard SAP Function Module

    Please, is it possible to catch the following error with the TRY CATCH ENDTRY construct?
    From a custom program, am calling CS_BOM_EXPL_MAT_V2.
    Several nested calls in, Form STL_DATEN_HOLEN (LCSS4F1I) calls FM CS_ALT_SELECT_MAT. 
    However, that call is missing the CALL_INVALID Exception. 
    CS_ALT_SELECT_MAT is raising CALL_INVALID, but since it was not included in the FM call, the RAISE_EXCEPTION runtime error is issued.
    I added a TRY CATCH ENDTRY construct around the call in the custom program using CATCH cx_root, but the program is still short dumping.
    All the research I have done has been misleading...some articles indicate all errors should be caught, some indicate only catchable runtime errors can be caught, others are not quite clear.
    So, I would like to find out if, in this scenario, it is even possible to catch this error and avoid the short dump.
    I will open a message to see about having the SAP code fixed as soon as I get authorization to do so, (as well as fix the data causing the issue in the first place), but in the meantime, I would like to handle it in my code if possible.
    ECC 6.0
    Thanks for any information!
    Kind Regards,
    Deb
    Edited by: Debra Garner on Jan 26, 2012 5:19 PM

    Hi Debra,
    You cannot catch non class based exceptions using the TRY/ENDTRY.  You might also find no luck with help from SAP since the FM in question 'CS_BOM_EXPL_MAT_V2' is not released for customer use.  The best bet is to examine why the error is occurring and figure out what needs to be done to fix it and/or avoid it in the future.
    Regards,
    Ryan Crosby

  • How to catch errors watched in sxmb_moni through abap program??

    Dear Gents,
    I have one scenario which is proxy -> xi -> jdbc. Scenario works fine when every thing is good, but if there are any errors in XI usually we catch the exception after calling the proxy as :
    TRY.
        CALL METHOD cl_rfq_sapin->mios_rfq_sapin
          EXPORTING
            output = output
          IMPORTING
            input  = input.
        COMMIT WORK.
      CATCH cx_ai_system_fault INTO cl_system_fault .
        gv_system_fault = 'X'.
      CATCH cx_ai_application_fault INTO cl_application_fault.
        gv_application_fault = 'X'.
    ENDTRY.
    But by this code we are able to know whether it is system error or application error. But we cant get actual error. To see the actual error we need to go to SXMB_MONI in XI. The some sample error in sxmb_moni is as follows :
      <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--  Inbound Message
      -->
    - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="1">
      <SAP:Category>XIAdapterFramework</SAP:Category>
      <SAP:Code area="MESSAGE">GENERAL</SAP:Code>
      <SAP:P1 />
      <SAP:P2 />
      <SAP:P3 />
      <SAP:P4 />
      <SAP:AdditionalText>com.sap.aii.af.ra.ms.api.DeliveryException: Error when attempting to get processing resources: com.sap.aii.af.service.util.concurrent.ResourcePoolException: Unable to create new pooled resource: DriverManagerException: Cannot establish connection to URL 'jdbc:microsoft:sqlserver://10.56.5.79:1433;databaseName=SXD': SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]The requested instance is either invalid or not running.</SAP:AdditionalText>
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack />
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>
    So is there any way we can catch the above error in the abap program ??
    Your responeses were highly appreciated.
    Regards,
    Santhosh

    hi,
    did you try using acknowledgments?
    http://help.sap.com/saphelp_nwpi71/helpdata/en/f4/8620c6b58c422c960c53f3ed71b432/content.htm
    (code at the bottom of this page)
    Regards,
    Michal Krawczyk

  • How to catch error 510 from keithley 7002 Switch System

    I use the PCI-GPIB card to control the Keithley switch system and the multimeter to test the resistance.
    My switch system is munually set to either Pole 2 or Pole 4. When the system is Pole 2, I may use the IBWRT function to send command ":conf:slot1ole 4" to Switch, the instrument shows "error 510" and all the instrution following that will be invalid. But IBWRT won't report any error until you read the data.
    Is there any way to avoid this kind of mistake?

    how could you expect me to use JAVA command without compiling it with Javac??
    I complied the java code using javac and then called(executed ) it using the Java..
    I am using JNI_Create/JavaVM() to create a JVM from CPP file. that works fine. Now, my issue is that I want to capture a couple of exit codes that are returned from the System.exit() of the java code.
    now, guys.. is there any way to capture that exit codes returning by Ssytem.exit() in or using JNI ??
    if yes, please help me with the code snippets.
    Thanks,
    Soujanya.R

  • How to Catch Error in Log in LSMW?

    Hi All,
    I want to Capture all the errors in Log in LSMW without using the GUI_download function Module.
    I am using the below mentioned code. As this code is skipping the records which are not fulfilling my requirement but it is not sending the error message to the Log file.
    IF ZMAT1-MATKL = SPACE.
      WA_ERRORTAB-MSGTY = 'E'.
      WA_ERRORTAB-ID = '/ISDFPS/ROLES'.
      WA_ERRORTAB-MSGNO = 000.
      WA_ERRORTAB-PAR1 = 'Material'.
      WA_ERRORTAB-PAR2 = 'Group'.
      WA_ERRORTAB-PAR3 = 'is'.
      WA_ERRORTAB-PAR4 = 'Missing'.
      INSERT WA_ERRORTAB INTO TABLE G_ERROR_TAB.
      SKIP_RECORD.
      CLEAR WA_ERRORTAB.
    else.
    MM01-MATKL = ZMAT1-MATKL.
    ENDIF.
    Please suggest where I am wrong with proper solution.

    write the error on the screen and download all the errorsusing System->List->Save.

  • How to catch error codes returned from java

    Hi all,
    Is there anyway to capture the exit code that is returned by System.exit() from java. I know a batch file's ERRORLEVEL can do this. However, I want to use c/cpp (JNI) to get this functionality. Please help ..
    Thanks in advance,
    Soujanya.R

    how could you expect me to use JAVA command without compiling it with Javac??
    I complied the java code using javac and then called(executed ) it using the Java..
    I am using JNI_Create/JavaVM() to create a JVM from CPP file. that works fine. Now, my issue is that I want to capture a couple of exit codes that are returned from the System.exit() of the java code.
    now, guys.. is there any way to capture that exit codes returning by Ssytem.exit() in or using JNI ??
    if yes, please help me with the code snippets.
    Thanks,
    Soujanya.R

  • Catching error in call transaction

    Hi,
    Can anyone tell me how to catch errors in call transaction method.
    Please provide step by step guide.
    Thanks,
    Shipra

    Hi Shipra...
    This is the way...
    data : It_MSG type table of BDCMSGCOLL with header line.
    DATA : V_MESSAGE TYPE STRING.
    LOOP AT ITAB.
      PERFORM MAP_BDCDATA.
      CALL Transaction 'MK01'
      USING it_bdcdata
      MODE 'N'
      Messages into IT_MSG.
      if sy-subrc ne 0.  "when the Transaction is unsuccessful
    **Display the Error messages
            LOOP AT IT_MSG WHERE MSGTYP = 'E'.
             CALL FUNCTION 'FORMAT_MESSAGE'
                 EXPORTING
                   msgtyp = it_msg-msgtyp
                   msgno = it_msg-msgnr
                   msgid = it_msg-msgid
                   msgv1 = it_msg-msgv1
                   msgv2 = it_msg-msgv2
                IMPORTING
                   MESSAGE  = V_MESSAGE.
               WRITE:/ V_MESSAGE.
            ENDLOOP.
          REFRESH : IT_BDCDATA, IT_MSG.
    ENDLOOP.
    <b>Reward if Helpful.</b>

  • Catching error in BAPI

    Hi experts,
    I am new to BAPI.
    Can anyone tell me " How to catch error in BAPI ".
    Thanks,
    Shipra

    Hi,
    In the BAPI return internal table you have to check for the Error or ABort message types..
    Ex..
    Check for error or abort messages
    LOOP AT T_RETURN WHERE TYPE = 'E' OR TYPE = 'A'.
      EXIT.
    ENDLOOP.
    IF SY-SUBRC = 0.
      WRITE: / 'Exception occured'.
    ELSE.
       WRITE: / 'Update is successful'.
    ENDIF.
    Thanks
    Naren

Maybe you are looking for