How to handle exception thrown in standard bo method in the workflow design

Hi Experts
    how to handle exception thrown from standard bo method in the workflow design. For example, bo BUS2032, METHOD confirm. If the user cancel it, it will throw exception. In the workflow, how to catch this exception and add corresponding steps in the workflow.

@jrockman li
Try to implement the logic that what ever you are performing in the BO mehtod in a FM and in the FM you have tab with name EXECPTIONS define the execption in that tab.Now in the BO method you call this FM  and if the exception occurs by using RAISE you can raise the exception in the FM and based on the number of exceptions your sy-subrc value will be set
so when sys-subrc is not eq 0 then pass a value back t the workflow container., I think this will work.
a sample Snippet for understanding purpose
CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    filename         = <path>
    filetype         = 'ASC'
  IMPORTING
    filelength       = lv_len
  TABLES
    data_tab         = l_txt_tab
  EXCEPTIONS
    file_write_error = 1          " If this Exception occurs
    invalid_type     = 2
    no_authority     = 3
    unknown_error    = 4
    OTHERS           = 10.
CASE sy-subrc.
  WHEN 1. " SY-SUBRC value will be 1 then,
      " Pass or set the value back to the workflow conatiner element
ENDCASE.

Similar Messages

  • How to handle exceptions thrown by event

    Hi all,
    i have this slight problem, i'm trying to handle accessing a databse from a button click, i'm trying to simulate somebody logging on to a network. the code is as follows;
    *@author James Taylor
    *@version 30-11-2003
    *Logon gui
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.sql.*;
    public class LogonUI extends JFrame {
         //instance variables
         private JLabel userNameL;
         private JPasswordField password;
         private JButton logon;
         ButtonHandler handler;
         Connection con;
         Statement stmt;
          *Constructor initialises and creates UI, adds functionality to the button.
         public LogonUI() throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException{
              super("Employee Logon");
              Container c = getContentPane();
              c.setLayout(new FlowLayout() );
              //handles what happens when user presses the button
               handler = new ButtonHandler();
              userNameL = new JLabel("Please Enter Password:");
              c.add(userNameL);
              password = new JPasswordField(15);
              c.add(password);
              logon = new JButton( "Logon" );
              //anonymous inner class that is created once the button is pressed.
              //it connects to database to validate user
              logon.addActionListener( handler );
              c.add(logon);
              c.setBackground( Color.pink );
              setDefaultCloseOperation(DISPOSE_ON_CLOSE);
              setSize(250,150);
              setVisible(true);
          *class that opens connection to validate user
         private class ButtonHandler implements ActionListener {
              public void actionPerformed(ActionEvent ae)throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException{
                   try{
                        boolean isValidUser = false;
                        //Load mysql driver
                         Class.forName("com.mysql.jdbc.Driver").newInstance();
                         //make a connection
                        String url = "jdbc:mysql://localhost/flight";
                        con = DriverManager.getConnection(url)
                        //Create and instantiate a statement obj
                        stmt = con.createStatement();
                        //get a result set
                        ResultSet rs = stmt.executeQuery("SELECT Password FROM employees");
                        //Iterate through the result set
                        while ( rs.next() ){     
                             String savedPassword = rs.getString("Password");
                             if (password.getText().equals(savedPassword) ){
                                  isValidUser = true;
                                  JOptionPane.showMessageDialog(null,"Yipeeeee");
                        if (isValidUser == false){
                             JOptionPane.showMessageDialog(null,"Invalid Password");     
                        stmt.close();
                        con.close();
                   }catch(Exception e){ e.printStackTrace();}
              public static void main (String[] args) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException{
              LogonUI testAirApp = new LogonUI();
    }When the user presses the button the app tries to validate the user.
    I have not been able to test the code due to SQL Exceptions thrown in the handler class, and when i try and throw them up from here i get;
    LogonUI.java:52: actionPerformed(java.awt.event.ActionEvent) in LogonUI.ButtonHandler cannot implement actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener; overridden method does not throw java.lang.InstantiationExceptionAny ideas on my code and how to handle these exceptions will be very appreciated. Regards, James

    Turn your checked exceptions into unchecked exceptions and retrieve the cause later:
    RuntimeException unchecked = new RuntimeException(checked);
    Throwable t = unchecked.getCause();Stephen

  • How webDynpro handles exception thrown by adaptive web service

    Hi people,
    in design time, webdynpro can handle web service's exception by defining return structure based on the <b>Fault </b>which is the exception defined in the web service. But in the runtime, when web service throws exception, webDynpro can not handle it, WD framework will throw nullPointerException.
    The reason behind it might be: let me assume a WS <b>getEmployeeNumber</b>, the WS returns employee number as a element <b><EmployeeNumber></b>12345<b></EmployeeNumber></b> in the return SOAP document. I think WD always expects the element <b><EmployeeNumber></b> in the SOAP document, but in case of exception, web service throws exception and will not provide employee number in the return SOAP which is logical, thus the element <EmployeeNumber> will not be available in the SOAP document, therefore causes WD framework to raise <b>nullPointerException</b>.
    So any of you have any suggestion to make webDynpro working in case an exception is thorwn in the web service?
    Thanks for your infor
    Jayson

    To encourage people, I include the text of the xml response from the test of Web Service Navigator window :
    HTTP/1.1 500 Internal Server Error
    Connection: close
    Server: SAP J2EE Engine/6.40
    Content-Type: text/xml; charset=UTF-8
    Set-Cookie: <value is hidden>
    Date: Mon, 27 Mar 2006 09:30:50 GMT
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
    <SOAP-ENV:Body>
    <SOAP-ENV:Fault>
    <faultcode>SOAP-ENV:Client</faultcode>
    <faultstring>Hi, I'm the new exception</faultstring>
    <detail>
    <ns1:throwException_com.sap.demo.testexception.TestException xmlns:ns1='urn:TestExceptionServiceWsd/TestExceptionServiceVi' xmlns:pns='urn:com.sap.demo.testexception'>
    <pns:message>Hi, I'm the new exception</pns:message>
    </ns1:throwException_com.sap.demo.testexception.TestException>
    </detail>
    </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    I've found too a strange workaround :
    The fact seems that you have to design your session bean without throwing custom exceptions, then generates the VI and after that, adding the custom exceptions throws.
    Or if you don't want to modify the bussiness methods.
    The point is to eliminate the exceptions (faults) sections from the VI and WS deployment descriptor.
    You have to access from Package Explorer, and edit with a Text Editor the following files :
    *.videf from the package, and remove <Function.Faults> sections
    ws-deployments-descriptor.xml in META-INF, and remove <fault> sections
    After that, the WS Configurations will give an error, so delete the configuration and remake it. Now, the VI stills looks bad, so close the project, close NetViewer and reopen it to flush whatever cache it seems to keep.
    Now, your VI will looks better without exceptions, and you'll get their messages when you catch them in the WebDynpro applicattion.
    So, now the question is: Could anybody explain me why ?

  • Handling Exceptions thrown by EDT Thread?

    Hi,
    How to handle exceptions thrown by EDT Thread?. If anybody can give any link or any example, then it really helpful.
    Thanks

    System.setProperty( "sun.awt.exception.handler", EventThreadExceptionHandler.class.getName() );

  • How to handle exceptions in web dyn pro

    Hi Frndz....
                     Can any one kindly xplain how to handle exceptions in web dyn pro..like we hav exceptionhandling in java ....so is there any for NWDS
    THANKS & REGARDS
    Rajesh

    Hi,
    Web Dynpro Java is basically java only.i.e You program in java. Hence exceptions are supported in the same way as in java i.e. via try,catch and finally block.
    Additionally,
    In 04/04s if you create a method in any controller in web dynpro you cann't specify exception that can be thrown in the method. This is now possible in new programming web dynpro model in CE.
    Hence when creating a method you can also specify custom or core java (lib)excetions.
    Regards,
    Ashwani Kr Sharma

  • How RMI handle exception in RMI kernel ?

    hi everyone.
    How RMI handle exception in RMI kernel ?
    That is , when RMI catch an exception ,
    what RMI should do to handle the exception?
    best regards.

    it throws an exception (some derived class of RemoteException) which is transmitted to, rethrown at, and must be caught at, the client.

  • How to handle screen resolution in bdc session method.

    hi all,
    how to handle screen resolution in bdc session method.

    Hello,
    Why do need that for? Is it to add rows on a table control??
    If it does, add new rows by using the add button instead of adding into the table control directly to each row.
    Bye
    Gabriel.

  • How to handle table control in lsmw recording method

    hi expert please tell me the procedure for how to handle table control in lsmw recording method
    Locked for same reason as how to upload data for me01 using LSMW BDC METHOD
    Edited by: Matt on May 9, 2011 8:52 AM

    Sri,
    just search in SDN search box by giving table control in lsmw you will get hell lot of threads for same.
    Amit.

  • How to perform system copy using standard sap method (sapinst)

    Hi guys
    pls tel how to perform system copy using standard sap method (sapinst) and to perform enterprise portal RESTORSTION.
    thanks
    kamal

    Hi Kamal,
    I have done a system copy of the production portal to a sandpit system before. The system copy export import method works very well, and is easy. For my portal, the whole procedure took me less than 6 hours.
    1. Go to this page: System Copy and Migration
    2. See the videos "Demo: How to Perform a System Copy Export" and "Demo: How to Perform a System Copy Import".
    This should give you the basic idea.
    I did a systemcopy using sapinst. If I remember right, this is the steps I performed:
    1. On target host, Installed a new Central services.
    2. On source host: Ran sapinst system copy export for Central Instance and Database instance. This created two export files (depending on your database size).
    3. Used the export files created in previous step to run the import step in target host.
    4. Some post processing steps, like configuring sso, creating systems in system landscapes, configuring WD JCos etc.
    Let me know if you need more help.
    Cheers
    Rishi

  • How do I send single notifications to multiple people in the workflow?

    HI
    As I see you can send notification to one person at a time.
    For example, the approval notification goes to a approver once someone submits a expense report or po approval.
    How do I send single notifications to multiple people in the workflow?
    Any idea?
    Thanks in advance.

    Hi,
    You need to send the notification to a role, which can comprise one or more than one users. If you check the "Expand roles" checkbox, then a different copy of the notification will be sent to each member of the role; otherwise one notification is sent which can be viewed by all holders of the role.
    You should always send a notification to a role rather than a user, anyway - roles do not go on holiday, get sick or leave the company; users do.
    HTH,
    Matt
    WorkflowFAQ.com - the ONLY independent resource for Oracle Workflow development
    Alpha review chapters from my book "Developing With Oracle Workflow" are available via my website http://www.workflowfaq.com
    Have you read the blog at http://thoughts.workflowfaq.com ?
    WorkflowFAQ support forum: http://forum.workflowfaq.com

  • How to properly handle Exception thrown in a .tag file?

    I've got a .jsp file that makes use of some custom tags, each defined in their own .tag file, and located in WEB-INF/tags. I'm having a lot of trouble with the scenario of cleanly dealing with an exception raised by scriptlets in either a .jsp file, and a .tag file. I'm using both Java and Tomcat 6....
    Originally, I wanted to use .tag files in order to componentize common elements that were present in .jsp pages, as well as move ugly scriptlets out of .jsp pages, and isolate them in tag files with their associated page elements.
    Things started getting hairy when I started exploring what happens when an exception is thrown (bought not handled) in a scriptlet in a .tag file. Basically, my app is a servlet that forwards the user to various .jsp pages based on given request parameters. The forwarding to the relevant .jsp page is done by calls to the following method:
    servletContext.getRequestDispatcher("/" + pageName).forward(request, response);
    Where 'pageName' is a String with the name of the .jsp I want to go to...
    Calls to this method are enclosed in a try block, as it throws both a ServletException, and IOException...
    When either my .jsp, or .tag throw an exception in a scriptlet, the exception is wrapped in a JSPException, which is then wrapped in a ServletException.
    I can catch this exception in my servlet... but then what? I want to forward to an error page, however, in the catch block, I can't forward in response to this exception, as that results in an IllegalStateException, as the response has already been committed. So what do I do? How do I get from this point, to my "error.jsp" page?
    It was suggested to me that I use the <% @ page isErrorPage="true" %> directive in my error.jsp,
    and the in my real .jsp, use <%page errorPage="/error.jsp" %>.
    This works great when the exception is thrown in my .jsp.... But when the exception is thrown in the .tag file... not so much...
    My .jsp page was rendered up until the point where the <my:mytag/> (the tag with the offending raised exception) was encountered. Then, instead of forwarding to the error page when the error in the tag is encountered, the error page is rendered as the CONTENT of of my TAG. The rest of the .jsp is then NEVER rendered. I checked the page source, and there is no markup from the original .jsp that lay below the my tag. So this doesn't work at all. I don't want to render the error page WITHIN the half of the .jsp that did render... Why doesn't it take me away from the .jsp with the offending tag altogether and bring me to the error.jsp?
    Then it was suggested to me that I get rid of those page directives, and instead define error handling in the web.xml using the following construct:
    <error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>/error</location>
    </error-page>
    <error-page>
    <error-code>404</error-code>
    <location>/error</location>
    </error-page>
    For this, I created a new servlet called ErrorServlet, and mapped it to /error
    Now I could mangle the end of the URL, which causes a 404, and I get redirected to the ErrorServlet. Yay.
    However, exceptions being thrown in either a .jsp or .tag still don't direct me to the ErrorServlet. Apparently this error handling mechanism doesn't work for .jsp pages reached via servletContext.getRequestDispatcher("/" + pageName).forward(request, response) ????
    So I'm just at a total loss now. I know the short answer is "don't throw exceptions in a .jsp or .tag" but frankly, that seems a pretty weak answer that doesn't really address my problem... I mean, it would really be nice to have some kind of exception handler for runtime exceptions thrown in a scriptlet in .tag file, that allows me to forward to a page with detailed stacktrace output, etc, if anything for debugging purposes during development...
    If anyone has a few cents to spare on this, I'd be ever so grateful..
    Thanks!!
    Jeff

    What causes the exception?
    What sort of exception are you raising from the tag files?
    Have you got an example of a tag file that you can share, and a jsp that invokes it so people can duplicate the issue without thinking too much / spending too much time?
    My first instinct would be that the buffer is being flushed, and response committed before your Exception is raised.
    What you describe is pretty much standard functionality for Tomcat in such cases.

  • How to handle exception CX_SY_REF_IS_INITIAL

    hi experts,
    im working on a test scenario for abap mapping in SAP XI im getting this error
    An exception with the type CX_SY_REF_IS_INITIAL occurred, but was neither handled locally, nor declared in a RAISING clause Dereferencing of the NULL reference
    i understand that i need to catch this exception in the abap coding but i'm not familiar with oops concepts
    can any one please suggest me how to handle this exception for the following code...
    method IF_MAPPING~EXECUTE.
      break x1149.
    * initialize iXML
      TYPE-POOLS: ixml.
      class cl_ixml definition load.
    ** Instances & Variable declaration =======================
    * instance main factory
      TYPES: BEGIN OF t_xml_line,
              data(256) TYPE x,
            END OF t_xml_line.
      DATA: l_ixml TYPE REF TO if_ixml,
    * instance input stream factory
       l_streamfactory TYPE REF TO if_ixml_stream_factory,
    * instance input stream
      l_istream  TYPE REF TO if_ixml_istream,
    * instance input document
      l_document TYPE REF TO if_ixml_document,
    * instance parse input document
      l_parser TYPE REF TO if_ixml_parser,
    * instance for elements within the nodes
      node      TYPE REF TO if_ixml_node,
    *instance of nodemap
      nodemap   TYPE REF TO if_ixml_named_node_map,
    * instance for iterator
      iterator  TYPE REF TO if_ixml_node_iterator,
      name      TYPE string,
      value     TYPE string,
    * instance main factory
       o_ixml   TYPE REF TO if_ixml,
    * instance output document
       o_document TYPE REF TO if_ixml_document,
    * instance output stream
      o_istream  TYPE REF TO if_ixml_ostream,
    * instance parse output document
      o_parser  TYPE REF TO if_ixml_parser,
    * instance fot renderer
      renderer type ref to if_ixml_renderer,
      irc type i,
      l_xml_size   TYPE i,
    *ROOT ELEMENT
    l_element_MT_DEMANDTEC_COST TYPE REF TO if_ixml_element,
    *NEXT CHILD ELEMENT FROM THE ABOVE PARENT
    l_element_DT_DEMANDTEC TYPE REF TO if_ixml_element,
    *CHILDREN1 ELEMENT FOR DT_DEMANDTEC
    l_element_DT_WHSE  TYPE REF TO if_ixml_element,
    *CHILDREN2 ELEMENT FOR DT_DEMANDTEC
    l_element_DT_DC    TYPE REF TO if_ixml_element,
    *CHILDREN3 ELEMENT FOR DT_DEMANDTEC
    l_element_DT_PLANT    TYPE REF TO if_ixml_element,
    *CHILDREN4 ELEMENT FOR DT_DEMANDTEC
    l_element_DT_QTY    TYPE REF TO if_ixml_element.
    *saving the xml document
      DATA: l_xml_table       TYPE TABLE OF t_xml_line.
      types: begin of t_source,
              whse(5),
              dc(4) ,
              plant(4),
              qty    type i,
             end of t_source.
      types: tt_source TYPE STANDARD TABLE OF t_source.
      data:  wa_source type t_source.
      data: it_source TYPE  tt_source,
            ivalue type string.
    * Procedures and business logic =======================================
    *   Creating the main iXML factory
      l_ixml = cl_ixml=>create( ).
    *   Creating a stream factory
      l_streamfactory = l_ixml->create_stream_factory( ).
    * create input stream
      l_istream = l_streamfactory->create_istream_xstring( source ).
    *  initialize input document
      l_document = l_ixml->create_document( ).
    *  Create a Parser
      l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
                                          istream        = l_istream
                                          document       = l_document ).
    * parse input document
      l_parser->parse( ).
    *   Validate a document
      l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
    *   Parse the stream
      IF l_parser->parse( ) NE 0.
        IF l_parser->num_errors( ) NE 0.
          DATA: parseerror TYPE REF TO if_ixml_parse_error,
                str        TYPE string,
                i          TYPE i,
                count      TYPE i,
                index      TYPE i.
          count = l_parser->num_errors( ).
          WRITE: count, ' parse errors have occured:'.
          index = 0.
          WHILE index < count.
            parseerror = l_parser->get_error( index = index ).
            i = parseerror->get_line( ).
            WRITE: 'line: ', i.
            i = parseerror->get_column( ).
            WRITE: 'column: ', i.
            str = parseerror->get_reason( ).
            WRITE: str.
            index = index + 1.
          ENDWHILE.
        ENDIF.
      ENDIF.
    *   Process the document
      IF l_parser->is_dom_generating( ) EQ 'X'.
        refresh : it_source.
        node ?= l_document.
        CHECK NOT node IS INITIAL.
    *   create a node iterator
        iterator  = node->create_iterator( ).
    *   get current node
        node = iterator->get_next( ).
    *   loop over all nodes
        WHILE NOT node IS INITIAL.
          CASE node->get_type( ).
            WHEN if_ixml_node=>co_node_element.
    *         element node
              name    = node->get_name( ).
              nodemap = node->get_attributes( ).
            WHEN if_ixml_node=>co_node_text.
    *         text node
              value  = node->get_value( ).
              if name eq 'DT_WHSE'.
                wa_source-whse = value.
              ELSEIF name eq 'DT_DC'.
                wa_source-DC = value.
              ELSEIF name eq 'DT_PLANT'.
                wa_source-PLANT = value.
              ELSEIF name eq 'DT_QTY'.
                wa_source-QTY = value.
                COLLECT wa_source INto it_source.
                CLEAR   wa_source.
              ENDIF.
          endcase.
          node = iterator->get_next( ).
        endwhile.
      ENDIF.
      loop at it_source into wa_source .
        at first.
    *       Creating a ixml factory
          o_ixml = cl_ixml=>create( ).
    *       Creating the dom object model
          o_document = l_ixml->create_document( ).
        endat.
    *       Build and Fill  root node MT_DEMANDTEC_COST
        AT FIRST.
          l_element_MT_DEMANDTEC_COST    =
    O_document->create_simple_element(
                                  name   = 'MT_DEMANDTEC_COST'
                                  parent = o_document ).
        ENDAT.
    *      Build and Fill  Child node DT_DEMANDTEC for parent
    *                                                  MT_DEMANDTEC_COST
        l_element_DT_DEMANDTEC    = O_document->create_simple_element(
                                     name   = 'DT_DEMANDTEC'
                                     parent = l_element_MT_DEMANDTEC_COST ).
    *      Build and Fill  Child node1 DT_WHSE for parent DT_DEMANDTEC
        ivalue              = wa_source-WHSE.
        l_element_DT_WHSE    = O_document->create_simple_element(
                                         name   = 'DT_WHSE'
                                         VALUE  = ivalue
                                         parent = l_element_DT_DEMANDTEC  ).
    *      Build and Fill  Child node2 DT_WHSE for parent DT_DEMANDTEC
        ivalue              = wa_source-DC.
        l_element_DT_DC   = O_document->create_simple_element(
                                             name   = 'DT_DC'
                                              VALUE  = ivalue
                                    parent = l_element_DT_DEMANDTEC ).
    *      Build and Fill  Child node3 DT_WHSE for parent DT_DEMANDTEC
        ivalue              = wa_source-PLANT.
        l_element_DT_PLANT   = O_document->create_simple_element(
                                                 name   = 'DT_PLANT'
                                                  VALUE  = ivalue
                                   parent = l_element_DT_DEMANDTEC  ).
    *      Build and Fill  Child node4 DT_QTY for parent DT_DEMANDTEC
        ivalue              = wa_source-QTY.
        l_element_DT_QTY     = O_document->create_simple_element(
                                                 name   = 'DT_QTY'
                                                  VALUE  = ivalue
                                   parent = l_element_DT_DEMANDTEC  ).
      endloop.
    * render document ======================================================
    * create output stream
      o_istream  = l_streamfactory->create_ostream_xstring( result ).
    *   Connect internal XML table to stream factory
      o_istream  = l_streamfactory->create_ostream_itable( table =
    l_xml_table ).
      renderer = o_ixml->create_renderer( ostream = o_istream
                                              document = o_document ).
      irc = renderer->render( ).
    * how do i catch the exception for type CX_SY_REF_IS_INITIAL ...?
    endmethod.
    full reward points for answers.
    Thanks & Regards,
    Uday Kumar.
    Edited by: UDAY on May 6, 2008 9:32 PM

    Hi Uday,
    Its occurs because you're trying to access a objects with null reference. Or you forgot to create an instance or an error occurs during the instance creation. So You should put all your "Procedures and business logic" inside a Try/catch block. as follow.
    " Define a class exception object to get error message......
    DATA o_exception TYPE REF TO cx_sy_ref_is_initial.
    "// Use the statment Try block to catch the error.
    TRY.
    *   Creating the main iXML factory
      l_ixml = cl_ixml=>create( ).
    *   Creating a stream factory
      l_streamfactory = l_ixml->create_stream_factory( ).
    * create input stream
      l_istream = l_streamfactory->create_istream_xstring( source ).
    *  initialize input document
      l_document = l_ixml->create_document( ).
    *  Create a Parser
      l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
                                          istream        = l_istream
                                          document       = l_document ).
    * parse input document
      l_parser->parse( ).
    *   Validate a document
      l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
    *   Parse the stream
      IF l_parser->parse( ) NE 0.
        IF l_parser->num_errors( ) NE 0.
          DATA: parseerror TYPE REF TO if_ixml_parse_error,
                str        TYPE string,
                i          TYPE i,
                count      TYPE i,
                index      TYPE i.
          count = l_parser->num_errors( ).
          WRITE: count, ' parse errors have occured:'.
          index = 0.
          WHILE index < count.
            parseerror = l_parser->get_error( index = index ).
            i = parseerror->get_line( ).
            WRITE: 'line: ', i.
            i = parseerror->get_column( ).
            WRITE: 'column: ', i.
            str = parseerror->get_reason( ).
            WRITE: str.
            index = index + 1.
          ENDWHILE.
        ENDIF.
      ENDIF.
    *   Process the document
      IF l_parser->is_dom_generating( ) EQ 'X'.
        refresh : it_source.
        node ?= l_document.
        CHECK NOT node IS INITIAL.
    *   create a node iterator
        iterator  = node->create_iterator( ).
    *   get current node
        node = iterator->get_next( ).
    *   loop over all nodes
        WHILE NOT node IS INITIAL.
          CASE node->get_type( ).
            WHEN if_ixml_node=>co_node_element.
    *         element node
              name    = node->get_name( ).
              nodemap = node->get_attributes( ).
            WHEN if_ixml_node=>co_node_text.
    *         text node
              value  = node->get_value( ).
              if name eq 'DT_WHSE'.
                wa_source-whse = value.
              ELSEIF name eq 'DT_DC'.
                wa_source-DC = value.
              ELSEIF name eq 'DT_PLANT'.
                wa_source-PLANT = value.
              ELSEIF name eq 'DT_QTY'.
                wa_source-QTY = value.
                COLLECT wa_source INto it_source.
                CLEAR   wa_source.
              ENDIF.
          endcase.
          node = iterator->get_next( ).
        endwhile.
      ENDIF.
      loop at it_source into wa_source .
        at first.
    *       Creating a ixml factory
          o_ixml = cl_ixml=>create( ).
    *       Creating the dom object model
          o_document = l_ixml->create_document( ).
        endat.
    *       Build and Fill  root node MT_DEMANDTEC_COST
        AT FIRST.
          l_element_MT_DEMANDTEC_COST    =
    O_document->create_simple_element(
                                  name   = 'MT_DEMANDTEC_COST'
                                  parent = o_document ).
        ENDAT.
    *      Build and Fill  Child node DT_DEMANDTEC for parent
    *                                                  MT_DEMANDTEC_COST
        l_element_DT_DEMANDTEC    = O_document->create_simple_element(
                                     name   = 'DT_DEMANDTEC'
                                     parent = l_element_MT_DEMANDTEC_COST ).
    *      Build and Fill  Child node1 DT_WHSE for parent DT_DEMANDTEC
        ivalue              = wa_source-WHSE.
        l_element_DT_WHSE    = O_document->create_simple_element(
                                         name   = 'DT_WHSE'
                                         VALUE  = ivalue
                                         parent = l_element_DT_DEMANDTEC  ).
    *      Build and Fill  Child node2 DT_WHSE for parent DT_DEMANDTEC
        ivalue              = wa_source-DC.
        l_element_DT_DC   = O_document->create_simple_element(
                                             name   = 'DT_DC'
                                              VALUE  = ivalue
                                    parent = l_element_DT_DEMANDTEC ).
    *      Build and Fill  Child node3 DT_WHSE for parent DT_DEMANDTEC
        ivalue              = wa_source-PLANT.
        l_element_DT_PLANT   = O_document->create_simple_element(
                                                 name   = 'DT_PLANT'
                                                  VALUE  = ivalue
                                   parent = l_element_DT_DEMANDTEC  ).
    *      Build and Fill  Child node4 DT_QTY for parent DT_DEMANDTEC
        ivalue              = wa_source-QTY.
        l_element_DT_QTY     = O_document->create_simple_element(
                                                 name   = 'DT_QTY'
                                                  VALUE  = ivalue
                                   parent = l_element_DT_DEMANDTEC  ).
      endloop.
    * render document ======================================================
    * create output stream
      o_istream  = l_streamfactory->create_ostream_xstring( result ).
    *   Connect internal XML table to stream factory
      o_istream  = l_streamfactory->create_ostream_itable( table =
    l_xml_table ).
      renderer = o_ixml->create_renderer( ostream = o_istream
                                              document = o_document ).
      irc = renderer->render( ).
    "   The Statement CATCH define a block that catches the exceptions of the
    "   exception class cx_sy_ref_is_initial
        CATCH cx_sy_ref_is_initial INTO o_exception.
    " If you need to get the error message text do as follow
    DATA errorMsg type string.
    " Get the message text
      errorMsg = o_exception->GET_TEXT( ).
    " Display the error information
      MESSAGE errorMsg TYPE 'I'.
      ENDTRY.
    The TRY block defines a guarded area whose class-based exceptions can be caught in the subsequent CATCH blocks. If no exception occurs in the TRY block and it reaches its end, the system continues the processing after ENDTRY. If a class-based exception occurs in the TRY block, the system searches for an exception handler in the same or an external TRY control structure.
    Font: SAP Help
    You can see a how to create and use an exception in this example [ ABAP Objects - Defining a Class-based exceptions|https://wiki.sdn.sap.com/wiki/x/19w] .
    Best Regards.
    Marcelo Ramos

  • Handling exception thrown by parseEscapedXML function

    Hi,
    I am using parseEscapedXML function to parse an xml string in the below format .
    <parameters><item id="" value=""/><item id="" value=""/></parameters>
    The exception thrown when input is in incorrect xml format is not caught using catchAll.
    Kindly check if anyone have any idea about this.

    Hi,
    Ideally your BAPI shouldn't raise exceptions - it is much better to use the RETURN table from your BAPI with any relevant messages - have a look at the majority of standard SAP BAPI's in transaction BAPI.
    This way, the only exceptions your try... catch block needs to handle are those related to the actual calling of your BAPI, not it's functionality.
    Also, if you can successfully run the BAPI in SE37 but it fails when called from your WD application, try using the FBGENDAT functionality to capture what data is being passed to SAP from your Web Dynpro application.  All it takes is a simple mistake in setting up your contexts or logic and you won't be calling your BAPI correctly.
    Hope this helps,
    Gareth.

  • How to handle Exception in Forms??

    Hi,
    We have a customer facing application...self-service kinda things actually with self registration, forgot password/ username and edit profile. We are using SIM forms for all of these. Now as per requirement we need to call some web services as backend validation in the forms. we want that if any exception is generated while calling these web services or general exceptions that SIM thrown (like xpress exception etc..) ....the user should redirected to other page containg some custom message because actual exception message is completely useless for user. i tried to use try/catch in jsp and other fundas of exception handling in java but nothing works. If anyone has any suggestion or any prior experience please share. Any pointer will be helpful.
    We are using SIM-SPE 7.1 . if someone has experience about exception handling in SPE it will be great otherwise SIM forms exception handling will also work. we can corellate the things in SPE!!!
    Thanks in advance!

    Bhavna,
    create a when-custom-item-event handler on the Forms Bean Container
    example:
    DECLARE
         eventName varchar2(30) := :system.custom_item_event;
         eventValues ParamList;
         eventValueType number;
         tempString varchar2(100);
    BEGIN
    IF (eventName=BEAN_ERROR_EVENT') THEN eventValues := get_parameter_list(:system.custom_item_event_parameters);
                   get_parameter_attr(eventValues,'ERROR_MESSAGE',eventValueType, tempString);          MsgBox.Show(MsgBox.STOP_ALERT,tempString);
    END IF;
    END;
    This looks for an event named BEAN_ERROR_EVENT and there for a message ERROR_MESSAGE.
    In the Bean add the following code:
    public static final ID pErrorMessage = ID.registerProperty("ERROR_MESSAGE");
    public static final ID eErrorEvent = ID.registerProperty("BEAN_ERROR_EVENT");
    private void dispatchErrors(String message)
    log(message);
    try{
    CustomEvent ce = new CustomEvent(m_handler, eErrorEvent);
    m_handler.setProperty(pRwAuthMessage,pErrorMessage);
    dispatchCustomEvent(ce);
    catch (Exception e)
    e.printStackTrace();
    To handle Bean errors:
    try{
    catch (Exception e){
    dispatchErrors(e.getMessage());
    finally {
    This know publishes the error message to Forms where you can handle it the way you want.
    Fran

  • How to handle exceptions of rfc in web dydnpro

    hi all,
    i want to handle exceptions of Remote function module in webdynpro.how can we do that one.are there any variables in model class for those exceptions.
    regards
    Naidu

    Hi,
    Hope the following snippet answers ur query
    IWDMessageManager manager = wdComponentAPI.getMessageManager();
                   try{
                        wdContext.currentB_Quotation_Createfromdata_InpElement().modelObject().execute();
                        wdContext.nodeOutputQuotation().invalidate();
                   } catch(WDDynamicRFCExecuteException ce) {
                        manager.reportException(ce.getMessage(), false);

Maybe you are looking for