8 Replies Latest reply: Aug 31, 2013 12:39 AM by 929913 RSS

    Need to click on submit button twice to execute Procedure in OAF

    929913

      hi,

      I have defined a procedure in AM, and calling the same in Controller. I am able to achieve expected functionality but the problem is i need to click on submit button twice to execute procedure. Please help..

       

      My controller code is:

        public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)

        {

          super.processFormRequest(pageContext, webBean);

          OAApplicationModule am = pageContext.getApplicationModule(webBean);

                   if (pageContext.getParameter("Save") != null)

                        {    

                am.invokeMethod("generaterepayscheduleProcedure");

                            System.out.println(" Procedure called");

                am.invokeMethod("Save");

                System.out.println("record saved");

           String message = "Record Updated Successfully !!";

            throw new OAException(message, OAException.INFORMATION);

            }

       

      And my AM code is:

       

           public void generaterepayscheduleProcedure() {

          OADBTransaction txn = (OADBTransaction)getDBTransaction();

          CallableStatement callableStatement =

          txn.createCallableStatement("begin omx_create_repay(OMX_SEC_LOAN_ID.currval);  end;",OADBTransaction.DEFAULT);

           try {

           String outParamValue = null;

           callableStatement.execute();

             System.out.println("procedure in AM executed");

           callableStatement.close();

           }

            catch (SQLException sqle) {

                      callableStatement.close();

                    }

           }

       

       

      Please help, thanks in advance..

        • 1. Re: Need to click on submit button twice to execute Procedure in OAF
          Sushant Sharma

          Hi,

           

          Are you getting SOP messages on first click as well or only when pressed second time ?

           

          --Sushant

          • 2. Re: Need to click on submit button twice to execute Procedure in OAF
            929913

            hi,

            When i am clicking of submit button for the first time, i am getting below message:

             

            13/08/30 12:48:52  Procedure called

            13/08/30 12:48:52 record saved

             

             

            when i am clicking for the second time, i am getting below message:

            13/08/30 12:49:16 procedure in AM executed

            13/08/30 12:49:16  Procedure called

            13/08/30 12:49:16 record saved

            • 3. Re: Need to click on submit button twice to execute Procedure in OAF
              keerthioaf

                                    Hi there ,

               

                                     Any fire action / partial fire action been set on page ??

               

                                    Regards ,

                                    Keerthi

              • 4. Re: Need to click on submit button twice to execute Procedure in OAF
                929913

                Hi,

                No fire action/Partial fire action is set.

                its a record creation page where a single record is created in one table and a procedure is called which in turn creates multiple records in other table on a click of  Save Button.

                 

                Regards,

                Mohit

                • 5. Re: Need to click on submit button twice to execute Procedure in OAF
                  keerthioaf

                                Hi there ,

                   

                                Can you share this method definition - am.invokeMethod("Save"); ??

                   

                                --Keerthi

                  • 6. Re: Need to click on submit button twice to execute Procedure in OAF
                    929913

                    hi,

                    Please find below :

                         public void Save()

                         {

                           getTransaction().commit();

                            // String userContent = pageContext.getParameter("Record Saved Successfully");

                          //   String message = "Record Saved Successfully !!";

                          //   throw new OAException(message, OAException.INFORMATION);

                          }

                     

                    Code for calling procedure:

                     

                         public void generaterepayscheduleProcedure() { 

                        OADBTransaction txn = (OADBTransaction)getDBTransaction(); 

                        CallableStatement callableStatement = 

                        txn.createCallableStatement("begin omx_create_repay(OMX_SEC_LOAN_ID.currval);  end;",OADBTransaction.DEFAULT);

                         try {

                         String outParamValue = null;

                         callableStatement.execute();

                           System.out.println("procedure in AM executed");

                         callableStatement.close(); 

                         }

                          catch (SQLException sqle) { 

                                    callableStatement.close(); 

                                  } 

                         }

                    • 7. Re: Need to click on submit button twice to execute Procedure in OAF
                      Mahesh112

                      Hi,

                       

                      The below code is a working code, just check and change in your code:

                      OADBTransaction oadbtransaction = getOADBTransaction();

                                String s1 ="BEGIN APPS.QCC_REQ_FCPA_SOURCING_INS_PKG.QC_REQ_ITEM_UPDATE(?,?,?,?,?,?); END;";

                                CallableStatement callablestatement=null;

                                 try

                                    { 

                                       callablestatement = oadbtransaction.createCallableStatement(s1, 1);

                                       callablestatement.setString(1,reqNumber);

                                       callablestatement.setString(2,Answer1value);

                                       callablestatement.setString(3,Answer2value);

                                       callablestatement.setString(4,Answer3value);

                                       callablestatement.setString(5,Answer4value);

                                       callablestatement.setString(6,user_name);

                                    }

                                  catch(Exception e)

                                      {  

                                       oadbtransaction1.writeDiagnostics(this,"Error in calling package l",1);

                                      }

                                  try

                                     {

                                   

                                       callablestatement.execute();

                                   

                                     }

                                   catch(Exception e)

                                     {

                                       e.printStackTrace();

                                     }

                       

                      Regards

                      Mahesh

                      • 8. Re: Need to click on submit button twice to execute Procedure in OAF
                        929913

                        hi all,

                        Thank for your help...!!

                        Problem has been resolved..

                        i have reverse the sequence of function calling in controller i.e. first i am calling save method and then procedure method and its working fine.

                         

                          public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)

                          {

                            super.processFormRequest(pageContext, webBean);

                              OAApplicationModule am = pageContext.getApplicationModule(webBean);

                               if (pageContext.getParameter("Save") != null)

                                          {     

                                             am.invokeMethod("Save");

                                  am.invokeMethod("generaterepayscheduleProcedure"); 

                                              System.out.println(" Procedure called");

                                   System.out.println("record saved");

                             String message = "Record Updated Successfully !!";

                              throw new OAException(message, OAException.INFORMATION);

                             

                                         }