3 Replies Latest reply: Jan 8, 2013 12:08 PM by Vijay Nimmakuri RSS

    How to populate the configurator UI using CIO

    Vijay Nimmakuri
      Requirement : Based on the user entered string (Basemodel.Option1.Options2.Optiopn3.Options4.Option5) a free text at sales order line. In case of bad line(meaning any one of the options is invalid) the user hits the configurator button and the valid options need to be populated to the configurator UI. As of now i able to populate one value. I am missing some where when i am trying to populate multiple options. Below is the java code which iam using.

      I tried using ArrayString and by result set but no luck :( , Please let me know if any one came accross this type of requirement.


      //The class CfgExtTest contains two methods, namely displayAttributes and getCountrySelected.
      //The displayAttributes accepts a runtime node as a parameter, through which the connection to the database can be established.
      //Once a connection is established, the getCountrySelected method can be used to obtain the value entered in the DFF for the Order Header Id.
      //The java code also selects the option from an Option Feature which matches the option selected in the DFF.

      import java.sql.Connection;
      import java.sql.PreparedStatement;
      import java.sql.ResultSet;
      import java.sql.SQLException;
      import java.sql.Statement;
      import java.util.StringTokenizer;

      import oracle.apps.cz.cio.IOption;
      import oracle.apps.cz.cio.IRuntimeNode;
      import oracle.apps.cz.cio.LogicalException;
      import oracle.apps.cz.cio.NoSuchChildException;
      import oracle.apps.cz.cio.TransactionException;
      import oracle.apps.cz.utilities.NameValuePairSet;
      import oracle.apps.cz.cio.*;

      public class Configtestui {
      public void displayAttributes(IRuntimeNode irn){
      try{
           
                     Configuration config = irn.getConfiguration();
                     InformationalMessage iMsg1 = new InformationalMessage("config---->"+config, irn);
                     config.addInformationalMessage(iMsg1);
                ConfigTransaction tr = config.beginConfigTransaction();
                InformationalMessage iMsg2 = new InformationalMessage("ConfigTransaction---->"+tr, irn);
                config.addInformationalMessage(iMsg2);
      String country= getCountrySelected(irn);
      InformationalMessage iMsg3 = new InformationalMessage("getCountrySelected---->"+country,irn);
      config.addInformationalMessage(iMsg3);
      try{
                config.commitConfigTransaction(tr);
                IRuntimeNode udcc = irn.getChildByName("Select Monitor");//Select Hard Drive
                IOption option = (IOption)udcc.getChildByName(country);
                option.setState(IState.TRUE);
                     
                }
                
                catch(Exception e)
                {
                Configuration conf = irn.getConfiguration();
                ConfigTransaction trans = conf.beginConfigTransaction();
                     InformationalMessage iMsg = new InformationalMessage("Exception caused while reading property - First", irn);
                     config.addInformationalMessage(iMsg);
                     
                     try{
                          config.commitConfigTransaction(trans);
                     }
                     catch(Exception ee){
                          
                     }}
                }
      catch (Exception le){
           }}
           public String getCountrySelected(IRuntimeNode baseNode)
           {
                Connection conn = baseNode.getConfiguration().getContext().getJDBCConnection();
                PreparedStatement pStmt = null;
                ResultSet rs;
                String UDC=null;
                String sql = "select ATTRIBUTE2 from cz.CZ_CONFIG_ATTRIBUTES" ;//"select attribute2 "+ "from oe_order_headers_all ooha ";//+ "where ooha.header_id ="+orderid;
                try
                {
                pStmt = conn.prepareStatement(sql);
                rs = pStmt.executeQuery();
                if (rs.next())
                     UDC = rs.getString(1);
                
                System.out.println(UDC);
                rs.close();
                pStmt.close();
                }
                          // Close database cursors.
                catch(Exception e){
                     
                }

                return UDC;
           }
           }
        • 1. Re: How to populate the configurator UI using CIO
          Pankaj
          I am not clear what you are trying to achieve, can you elaborate more?

          Also why are you querying cz config attribute table unconditionally? This table will have attributes when you Finish Configurator session, not during active config session. You should revisit your design.

          select ATTRIBUTE2 from cz.CZ_CONFIG_ATTRIBUTES
          • 2. Re: How to populate the configurator UI using CIO
            Vijay Nimmakuri
            Hi Pankaj,

            Thanks a lot for your reply. I am very new to java and configurator extensions.

            There is an option feature "Select hard drive" on UI and 2GB ,10GB , 20GB are my options.

            I am trying to select 2GB on the UI. Iam fetching this value from a table '"Select selection from xxcz.TEST_CONFIG"' using this query.(below is my code)

            <some part of code where iam fetching the question and selecting its option >
            IRuntimeNode udcc = irn.getChildByName("Select Hard Drive");
            IOption option = (IOption)udcc.getChildByName(country);
            option.setState(IState.TRUE);

            My requirement i have multiple options from different questions to select in UI.. Can i select directly option ( as in my example 2GB) ? PLease let me know you thougths on this.



            -------------------------- Entire code ---------------------------------

            import java.sql.Connection;
            import java.sql.PreparedStatement;
            import java.sql.ResultSet;
            import java.sql.SQLException;
            import java.sql.Statement;
            import java.util.StringTokenizer;

            import oracle.apps.cz.cio.IOption;
            import oracle.apps.cz.cio.IRuntimeNode;
            import oracle.apps.cz.cio.LogicalException;
            import oracle.apps.cz.cio.NoSuchChildException;
            import oracle.apps.cz.cio.TransactionException;
            import oracle.apps.cz.utilities.NameValuePairSet;
            import oracle.apps.cz.cio.*;

            public class CreateConfig {

                 
                 public void displayAttributes(IRuntimeNode irn){

                 
                      
                      try{
                 Configuration config = irn.getConfiguration();
                      InformationalMessage iMsg1 = new InformationalMessage("config---->"+config, irn);
                      config.addInformationalMessage(iMsg1);
                      ConfigTransaction tr = config.beginConfigTransaction();
                      InformationalMessage iMsg2 = new InformationalMessage("ConfigTransaction---->"+tr, irn);
                      config.addInformationalMessage(iMsg2);
            String country= getModelOptions(irn);
            InformationalMessage iMsg3 = new InformationalMessage("getCountrySelected---->"+country,irn);
            config.addInformationalMessage(iMsg3);

            try{
                      config.commitConfigTransaction(tr);
                      IRuntimeNode udcc = irn.getChildByName("Select Hard Drive");
                      IOption option = (IOption)udcc.getChildByName(country);
                      option.setState(IState.TRUE);          
                           
                      }
                      
                      catch(Exception e)
                      {
                      Configuration conf = irn.getConfiguration();
                      ConfigTransaction trans = conf.beginConfigTransaction();
                           InformationalMessage iMsg = new InformationalMessage("Exception caused while reading property - First", irn);
                           config.addInformationalMessage(iMsg);
                           
                           try{
                                config.commitConfigTransaction(trans);
                           }
                           catch(Exception ee){
                                
                           }
                           
                      }
                      
                      }
            catch (Exception le){
                 
            }
                      }
                 
            public String getModelOptions(IRuntimeNode baseNode)
                 {
                      Connection conn = baseNode.getConfiguration().getContext().getJDBCConnection();
                      PreparedStatement pStmt = null;
                      ResultSet rs;
                      String UDC=null;
                      String sql = "Select selection from xxcz.TEST_CONFIG" ; // < Here iam getting value 2GB one of the option under 'Select Hard Drive'
                      try
                      {
                      pStmt = conn.prepareStatement(sql);
                      rs = pStmt.executeQuery();
                      if (rs.next())
                      UDC = rs.getString(1);
                      rs.close();
                      pStmt.close();
                      }
                      catch(Exception e){
                           
                      }

                      return UDC;
                 }
            • 3. Re: How to populate the configurator UI using CIO
              Vijay Nimmakuri
              I got the resolution Thanks all.