10 Replies Latest reply: Feb 6, 2013 4:01 AM by Jenny_Gomez RSS

    parameters to execute vo

    Jenny_Gomez
      hello everyone,

      when i am trying to pass a single date parameter i am able to get the vo executed and the data gets displayed on the required items defined, following is the code written in my AM.java:

      public void payslipsummary(OAPageContext pageContext){

      //Getting value runtime employee person id
      int personid = pageContext.getEmployeeId();

      //getting user search payslip month and year (payslip date) at runtime

      String paydate1 = pageContext.getParameter("paydate"); // "paydate" is Id of paydate item

      /* Creating the YY_PAYSLIP_SUMMARY_VO View Object method and pass this parameter in the where clause parameter */

      YY_PAYSLIP_SUMMARY_VOImpl vo = getYY_PAYSLIP_SUMMARY_VO1();
      vo.setWhereClauseParam(0,personid); //passign person_id parameter

      if (paydate1!=null &&!paydate1.equals("")){
      vo.setWhereClauseParam(1,paydate1); //Passing search payroll date as parameter

      }

      //now execute the Query
      vo.executeQuery();
      //Data setting in local variable
      vo.reset();
      //Query first result setting
      OARow paysum = (OARow)vo.first();
      //Checking data is return or not. If it is not the system must throw a token message.
      if (paysum!=null){

           //capture total earinging attribute value to string variable
      String YYtotalear = paysum.getAttribute("TotalEarnings")+"";

           //capture total deduction attribute value to string variable
      String YYtotaldedu = paysum.getAttribute("TotalDeductions")+"";
      //capture net salary attribute value to string variable
      String YYnetsal = paysum.getAttribute("NetSalary")+"";

      //this TotalEarnings attribute value putting session variable in stotalear this we can use in second page

      pageContext.putSessionValue("stotalear",YYtotalear);
      //this TotalDeductions attribute value putting session variable in stotaldedu this we can use in second page
      pageContext.putSessionValue("stotaldedu",YYtotaldedu);
      //this NetSalary attribute value putting session variable in snetsal this we can use in second page
      pageContext.putSessionValue("snetsal",YYnetsal);
      System.out.println("Total earnings test "+YYtotalear);
      System.out.println("Total deductions test "+YYtotaldedu);
      System.out.println("Total netsalary test "+YYnetsal);

      }
      else
      //If not return data through message
      {
      MessageToken[]Token=null;
      throw new OAException("PER","ONLINE_PAYSLIP_MESSAGE",Token,OAException.INFORMATION,null);

      }
      }


      BUT.....

      When i am trying to add two more parameters currency and payroll action then i am unable to see an output INSTEAD the code goes and execute the else condition
      else
      //If not return data through message
      {
      MessageToken[]Token=null;
      throw new OAException("PER","ONLINE_PAYSLIP_MESSAGE",Token,OAException.INFORMATION,null);

      }
      }

      Following is my code in the AM.java :

      public void payslipsummary(OAPageContext pageContext){

      //Getting value runtime employee person id
      int personid = pageContext.getEmployeeId();

      //getting user search payslip month and year (payslip date) at runtime

      String paydate1 = pageContext.getParameter("paydate"); // "paydate" is Id of paydate item
      String currency1 = pageContext.getParameter("currency"); // "currency" is Id of currency item
      String payaction1 = pageContext.getParameter("payaction"); // "payaction" is Id of payaction item

      /* Creating the YY_PAYSLIP_SUMMARY_VO View Object method and pass this parameter in the where clause parameter */

      YY_PAYSLIP_SUMMARY_VOImpl vo = getYY_PAYSLIP_SUMMARY_VO1();
      vo.setWhereClauseParam(0,personid); //passign person_id parameter

      if (paydate1!=null &&!paydate1.equals("")){
      vo.setWhereClauseParam(1,paydate1); //Passing search payroll date as parameter
      vo.setWhereClauseParam(2,currency1);
      vo.setWhereClauseParam(3,payaction1);
      System.out.println("paysummary vo is data return as of PARAM 1 "+paydate1);
      System.out.println("paysummary vo is data return as of PARAM 2 "+currency1);
      System.out.println("paysummary vo is data return as of PARAM 3 "+payaction1);
      }

      //now execute the Query
      vo.executeQuery();
      //Data setting in local variable
      vo.reset();
      //Query first result setting
      OARow paysum = (OARow)vo.first();
      //Checking data is return or not. If it is not the system must throw a token message.
      if (paysum!=null){
      System.out.println("paysummary vo data returned as of Period "+paydate1);
      System.out.println("paysummary vo data returned as of Currency "+currency1);
      System.out.println("paysummary vo data returned as of Pay ACTION "+payaction1);

           //capture total earinging attribute value to string variable
      String YYtotalear = paysum.getAttribute("TotalEarnings")+"";

           //capture total deduction attribute value to string variable
      String YYtotaldedu = paysum.getAttribute("TotalDeductions")+"";
      //capture net salary attribute value to string variable
      String YYnetsal = paysum.getAttribute("NetSalary")+"";

      //this TotalEarnings attribute value putting session variable in stotalear this we can use in second page

      pageContext.putSessionValue("stotalear",YYtotalear);
      //this TotalDeductions attribute value putting session variable in stotaldedu this we can use in second page
      pageContext.putSessionValue("stotaldedu",YYtotaldedu);
      //this NetSalary attribute value putting session variable in snetsal this we can use in second page
      pageContext.putSessionValue("snetsal",YYnetsal);
      System.out.println("Total earnings test "+YYtotalear);
      System.out.println("Total deductions test "+YYtotaldedu);
      System.out.println("Total netsalary test "+YYnetsal);

      }
      else
      //If not return data through message
      {
      MessageToken[]Token=null;
      throw new OAException("PER","ONLINE_PAYSLIP_MESSAGE",Token,OAException.INFORMATION,null);

      }
      }


      I am not able to understand why the vo does not execute and display the data...

      please help!

      Brgds,

      Jenny

      Edited by: Jenny_Gomez on Jan 24, 2013 12:14 PM
        • 1. Re: parameters to execute vo
          Sushant Sharma
          Hi,

          Instead of writing if (paydate1!=null &&!paydate1.equals("")){, try using this:

          if(!("".equals(paydate1.trim()))) {
          // your code here
          vo.setWhereClauseParam(1,paydate1); //Passing search payroll date as parameter
          vo.setWhereClauseParam(2,currency1);
          vo.setWhereClauseParam(3,payaction1);


          --Sushant                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
          • 2. Re: parameters to execute vo
            keerthioaf
            Hi Jenny ,

            Try this code to set where clause (2 parameters )



            public void standardsexecutequery(String codeexe, String actexe)
            {
            System.out.println("The value of code in STANDARD EXE QUERY IS"+codeexe);
            System.out.println("- - - - - - - - - - - - - - - - - - - - - - - - - - ");
            System.out.println("The value of action in STANDARD EXE QUERY IS"+actexe);

            sdaStandardsUpdateVOImpl pacelineStd = (sdaStandardsUpdateVOImpl)getsdaStandardsUpdateVO1();

            pacelineStd.setWhereClause(null);
            pacelineStd.setWhereClauseParams(null);
            pacelineStd.setWhereClause("CODE=:1 AND ACTION=:2");
            pacelineStd.setWhereClauseParam(0,codeexe);
            pacelineStd.setWhereClauseParam(1,actexe);
            pacelineStd.executeQuery();
            throw new OAException("Record Updated Successfully", OAException.INFORMATION);

            }

            Alternate way : repeated bind parameters in where clause of ViewLink in OAF in R12 insta

            Note : Please make sure that by passing two parameter in where clause you are able to get the result set from back end (data base ) .

            Keerthi
            • 3. Re: parameters to execute vo
              Jenny_Gomez
              I tried the way sushant mentioned it did not work Sushant. if you have some other way please do share it.

              Hi Keerthi,

              Note : Please make sure that by passing two parameter in where clause you are able to get the result set from back end (data base ) .

              I am able to get the output by passing the same parameters in the same sequence in my TOAD. I am able to see the parameters getting passed when i enter my parameters from front end and then click on the Go button i can see the parameters are shown (appear as same value as stored in the view) in Running: Embedded OC4J Server . But the record does not get displayed on the page for my items...

              Also, If you were going to modify the below code based on your suggestion then how will you modify the below part of the code [i.e. for (OAPageContext pageContext) ] please advise...

              public void payslipsummary(OAPageContext pageContext){

              //Getting value runtime employee person id
              int personid = pageContext.getEmployeeId();

              //getting user search payslip month and year (payslip date) at runtime

              String paydate1 = pageContext.getParameter("paydate"); // "paydate" is Id of paydate item
              String currency1 = pageContext.getParameter("currency"); // "currency" is Id of currency item
              String payaction1 = pageContext.getParameter("payaction"); // "payaction" is Id of payaction item

              /* Creating the YY_PAYSLIP_SUMMARY_VO View Object method and pass this parameter in the where clause parameter */

              YY_PAYSLIP_SUMMARY_VOImpl vo = getYY_PAYSLIP_SUMMARY_VO1();
              vo.setWhereClauseParam(0,personid); //passign person_id parameter

              if (paydate1!=null &&!paydate1.equals("")){
              vo.setWhereClauseParam(1,paydate1); //Passing search payroll date as parameter
              vo.setWhereClauseParam(2,currency1);
              vo.setWhereClauseParam(3,payaction1);
              System.out.println("paysummary vo is data return as of PARAM 1 "+paydate1);
              System.out.println("paysummary vo is data return as of PARAM 2 "+currency1);
              System.out.println("paysummary vo is data return as of PARAM 3 "+payaction1);
              }

              //now execute the Query
              vo.executeQuery();
              //Data setting in local variable
              vo.reset();
              //Query first result setting
              OARow paysum = (OARow)vo.first();
              //Checking data is return or not. If it is not the system must throw a token message.
              if (paysum!=null){
              System.out.println("paysummary vo data returned as of Period "+paydate1);
              System.out.println("paysummary vo data returned as of Currency "+currency1);
              System.out.println("paysummary vo data returned as of Pay ACTION "+payaction1);

              //capture total earinging attribute value to string variable
              String YYtotalear = paysum.getAttribute("TotalEarnings")+"";

              //capture total deduction attribute value to string variable
              String YYtotaldedu = paysum.getAttribute("TotalDeductions")+"";
              //capture net salary attribute value to string variable
              String YYnetsal = paysum.getAttribute("NetSalary")+"";

              //this TotalEarnings attribute value putting session variable in stotalear this we can use in second page

              pageContext.putSessionValue("stotalear",YYtotalear);
              //this TotalDeductions attribute value putting session variable in stotaldedu this we can use in second page
              pageContext.putSessionValue("stotaldedu",YYtotaldedu);
              //this NetSalary attribute value putting session variable in snetsal this we can use in second page
              pageContext.putSessionValue("snetsal",YYnetsal);
              System.out.println("Total earnings test "+YYtotalear);
              System.out.println("Total deductions test "+YYtotaldedu);
              System.out.println("Total netsalary test "+YYnetsal);

              }
              else
              //If not return data through message
              {
              MessageToken[]Token=null;
              throw new OAException("PER","ONLINE_PAYSLIP_MESSAGE",Token,OAException.INFORMATION,null);

              }
              }


              Appreciate all your help/assistance.

              Brgds,

              Jenny

              Edited by: Jenny_Gomez on Jan 24, 2013 12:23 PM

              Edited by: Jenny_Gomez on Jan 24, 2013 2:15 PM
              • 4. Re: parameters to execute vo
                Jenny_Gomez
                I am able to get the output by passing the same parameters in the same sequence in my query on TOAD.

                when i run the .xml file from Jdev there ... I am able to see the parameters getting passed when i enter my parameters from front end (messageChoice ...Date, Currency and Payroll Action) and then when i click on the Go button i can see the parameters appear same as stored in the view (this is visible on JDEV when i view the "Running: Embedded OC4J Server" ).
                But the record does not get displayed on the page for my items... INSTEAD the system executes the following

                else
                //If not return data through message
                {
                MessageToken[]Token=null;
                throw new OAException("PER","ONLINE_PAYSLIP_MESSAGE",Token,OAException.INFORMATION,null);

                }
                }

                Also, If i have to modify the below code based on your suggestion then how will you modify it [i.e. for (OAPageContext pageContext) ]

                Will it be as follows???

                *public void payslipsummary(OAPageContext pageContext){*

                pacelineStd.setWhereClause(null);
                pacelineStd.setWhereClauseParams(null);
                pacelineStd.setWhereClause("CODE=:1 AND ACTION=:2");
                pacelineStd.setWhereClauseParam(0,codeexe);
                pacelineStd.setWhereClauseParam(1,actexe);
                pacelineStd.executeQuery();

                *}*

                please advise...
                • 5. Re: parameters to execute vo
                  keerthioaf
                  Hi Jenny ,

                  Code should go in your AMImpl.java

                  if (paydate1!=null &&!paydate1.equals("")){

                  Make sure your parameter values are not null , then

                  EmployeesVOImpl empVO = getEmployeesVO3();//get your vo Instance
                  empVO.setWhereClause("EMP_SSN = :1 AND EMP_NAME = :2");
                  // here EMP_SSN and EMP_NAME are VO based attributes , now you need to replace then with your vo attributes for paydate1,currency1 etc ...

                  vo.setWhereClauseParam(0,paydate1); //Passing search payroll date as parameter
                  vo.setWhereClauseParam(1,currency1);
                  vo.setWhereClauseParam(2,payaction1);
                  vo.executeQuery()

                  Keerthi

                  }
                  • 6. Re: parameters to execute vo
                    Jenny_Gomez
                    Hi keerthi,

                    on the View Object Editor"

                    should i pass the Attribute Name or Alias ?

                    Brgds,

                    Jenny
                    • 7. Re: parameters to execute vo
                      Jenny_Gomez
                      Hi keerthi,

                      on the View Object Editor should i pass the Attribute Name or Alias ?

                      i.e. Attribute Name = AccountNumber
                      Alias = ACCOUNT_NUMBER

                      Which one should i pass from the above?


                      One more question please...

                      In case of my database view i have Payslip Date as 31-JAN-2013 (payroll month end date) and I have Payroll Date as January 2013 (Concatenated in one column in my db view)

                      Now for paydate item in Jdev Property Inspector i am setting the property as :

                      Picklist Display Attribute = PayrollDate

                      Picklist Value Attribute = PayslipDate

                      THEN how should i pass the parameters for the example you showed me earlier:

                      empVO.setWhereClause("EMP_SSN = :1 AND EMP_NAME = :2");
                      +// here EMP_SSN and EMP_NAME are VO based attributes , now you need to replace then with your vo attributes for paydate1,currency1 etc ...+


                      really appreciate all your help!


                      Brgds,

                      Jenny
                      • 8. Re: parameters to execute vo
                        keerthioaf
                        Hi Jenny ,

                        Use Columns alias name , for the 2nd question i will get back to you later .

                        If possible please document your requirement along with the screen shot and mail me in detail .

                        Keerthi
                        • 9. Re: parameters to execute vo
                          Jenny_Gomez
                          hi keerthi,

                          plz share ur email id.

                          Brgrds,

                          Jenny
                          • 10. Re: parameters to execute vo
                            Jenny_Gomez
                            hi Keerthi,
                            thanx dear!

                            manage to resolve

                            Brgds,

                            Jenny