3 Replies Latest reply: Mar 12, 2013 1:10 PM by siebelD RSS

    Set output property set on business service

    siebelD
      hi experts

      My siebel version is 7.8

      I am confused about property set for any escript.
      I wanted to set some of fields values on Outputs property set..

      My code is below
      function UpdateDfiScreen(Inputs, Outputs)
      {
       var oDfiBO = null;
       var oDfiBC = null;
       var SapDealNum=null;
       var sEarliestDFIStartDate = "";
       var sLatestDFIEndDate = "";
       var retVal = false
       try
       {
        oDfiBO = TheApplication().GetBusObject("WHV DFI Recon");
        oDfiBC = oDfiBO.GetBusComp("WHV DFI Recon HDR");
        Outputs = TheApplication().NewPropertySet();
      
        with(oDfiBC)
        {
         SetViewMode(AllView); 
         ActivateField("Transaction Source");
         ActivateField("Presidium Promo Id");
         ActivateField("SAP Deal Number");
         ActivateField("Presidium Promo Name");
         ActivateField("Transaction Status");
         
         ClearToQuery();
         //SetSearchSpec("Transaction Source","SAP");
         //SetSearchSpec("Presidium Promo Id",null);
         SetSearchSpec("Id","1120");
         ExecuteQuery(ForwardOnly);
         if (FirstRecord())
         {
            if ( GetFieldValue("SAP Deal Number") != "IS NULL" )
          {
            SapDealNum=GetFieldValue("SAP Deal Number");
            retVal = PullPromo(SapDealNum, Outputs); 
            if (retVal == true)
            {
               SetFieldValue("Presidium Promo Name", Outputs.GetProperty("PromoName"));
            }
            else
               SetFieldValue("Transaction Status","Failed");
         }
         }// End of FirstRecord()
      } //End of with
      }// End of try block
      
      catch(e)
              {
              throw e;
              }
      /*catch(e)
      {
        Outputs.SetProperty("Status", "FAILED");
      }*/
       
      finally
      {
        oDfiBO = null;
        oDfiBC = null;
       }
      }
      function PullPromo(dealno,Outputs)
         {
         var oPromotionBO = null;
         var oPromotionBC = null;
         var sPromoNumber = "";
         var retval=false;
         var sPromoName="";
         var sBUId="";
          
          try
         {
           oPromotionBO = TheApplication().GetBusObject("WHV Promotion");
           oPromotionBC = oPromotionBO.GetBusComp("CPG Plan Account Promotion");
          with(oPromotionBC)
          {
         SetViewMode(AllView);
         ActivateField("Plan Account Promotion Name");
         ActivateField("WHV SAP Deal Number");
         ActivateField("Organization Id");
         ActivateField("WHV Commitment Number");
         ClearToQuery();
         SetSearchSpec("WHV SAP Deal Number", dealno);
         ExecuteQuery(ForwardOnly);
         if (FirstRecord())
         {
           retval = true;
           sPromoName = GetFieldValue("Plan Account Promotion Name");
           sPromoName = sPromoName.substring(0, 39);
           Outputs.SetProperty("PromoName",sPromoName);
           Outputs.SetProperty("FLAG",retval); 
      
           Outputs.SetProperty("PromoNum",GetFieldValue("WHV Commitment Number"));
      
           sBUId = GetFieldValue("Organization Id")
           if ( sBUId == "1-7BY04" )
          {
           Outputs.SetProperty("BU", "2403");
          }
          else
          {
           Outputs.SetProperty("BU", "2500");
          }
          
          //  sEarliestDFIStartDate = GetEarliestDFIStartDate (sPromoId, Outputs);
          //  sLatestDFIEndDate = GetLatestDFIEndDate (sPromoId, Outputs);
          //  Outputs.SetProperty("PromoStartDate", sEarliestDFIStartDate);
          //  Outputs.SetProperty("PromoEndDate", sLatestDFIEndDate);
      
           }//end of if (FirstRecord())
              
          }//end of with(oPromotionBC
      
      }//end of try block
      
      catch(e)
      {
        Outputs.SetProperty("Status", "FAILED");
      } 
      finally
      {
        oPromotionBO = null;
        oPromotionBC = null;
        return(retval);
      
       }
      }//end of main function
      This code is working perfectly ...but when I am trying to simulate business service ..I am getting only one output property set value ..not all 4 values....
      Can I set output property set as array and can paas this on function .....and can return whole 5-6 values return ?

      Please let me know if requirment is not clear ..

      Thanks
        • 1. Re: Set output property set on business service
          user9354442
          I suspect what is happening is when you finish looping, only the last record is available in the output property as it overrides the value set earlier. You can create a new property set to store set property and try AddChildAt(loop counter) while adding to output property.
          • 2. Re: Set output property set on business service
            user9354442
            Ignore my answer. I thought you were looping through the records. Dunno why your code is not setting property set for all 4 variables. Please share if you were able to figure it out.
            • 3. Re: Set output property set on business service
              siebelD
              Yes ...I got answer of my this question ..actually on simulator ..output window ..MVG exists which shows all values ....I was not aware about this MVG and thought only on value is visible but for same requirement still I am stuck ....I am calling on function from main function ....during debut I checked code is entering on the called function but not going on code inside of try .....I know ..it would be very silly mistake ..But I am not able to figure out ....

              this is updated code for same requirement
                function UpdateDfiScreen(Inputs, Outputs)
              {
               var oDfiBO = null;
               var oDfiBC = null;
               var sSapDealNum=null;
               var sEarliestDFIStartDate = "";
               var sLatestDFIEndDate = "";
               var bretValH =null;
               //var bretValL =null;
               var sSearchExpr="";
               try
               {
                oDfiBO = TheApplication().GetBusObject("WHV DFI Recon");
                oDfiBC = oDfiBO.GetBusComp("WHV DFI Recon HDR");
                //Outputs = TheApplication().NewPropertySet();
               
                with(oDfiBC)
                {
                 SetViewMode(AllView); 
                // ActivateField("Transaction Source");
                 ActivateField("Presidium Promo Id");
                 ActivateField("SAP Deal Number");
                //ActivateField("Presidium Promo Name");
                 ActivateField("Transaction Status");
              
                 ClearToQuery();   
                 SetSearchSpec("Id","1120");
                // SetSearchExpr(sSearchExpr);
                 ExecuteQuery(ForwardOnly);
                 var bRecExists = FirstRecord();
                 while(bRecExists)
                 {
                   bRecExists = NextRecord();
                
                   if (GetFieldValue("SAP Deal Number")!="" && GetFieldValue("SAP Deal Number")!=null)
                  {
                    
                    var sRowId=GetFieldValue("Id");
                    Outputs.SetProperty("row_id", sRowId);
                    sSapDealNum=GetFieldValue("SAP Deal Number");
                    Outputs.SetProperty("deal_num", sSapDealNum); 
                  //  bretValH = MatchRcnHdr(sSapDealNum, Outputs);
                   var bretValL = MatchRcnLine(sRowId,Outputs);       
                    if (bretValH == false)
                    {
                       SetFieldValue("Transaction Status","Failed");          
                    }
                    if (bretValL == false)
                    {
                       SetFieldValue("Transaction Status","Failed");          
                    }
                 }// End of If
              } //End of while
              }// End of with
              }//end of try
               
              
              catch(e)
              {
                Outputs.SetProperty("Status", "FAILED");
              }
              
              finally
              {
                oDfiBO = null;
                oDfiBC = null;
               }
              }  
               function MatchRcnLine(sRowId,Outputs)
              {
              
                 var oDfiBO=null;
                 var oDfiChildBC=null;
                 var oPromoChildBc=null;
                 var oPromotionBO=null;
                 var sSegment="";
                 var sExpr="";
                 var bretValL;
               
                   try
                   {
                   oDfiBO = TheApplication().GetBusObject("WHV DFI Recon");
                   oDfiChildBC = oDfiBO.GetBusComp("WHV DFI Recon Line");
                   oPromotionBO = TheApplication().GetBusObject("WHV Promotion");
                   oDealBC = oPromotionBO.GetBusComp("WHV Alternate Promotion Deal");
                   with(oDfiChildBC)
                   {
                     ActivateField("Recon Hdr Row Id");       
                     ActivateField("SAP SKU Num");      
                     ClearToQuery();       
                     SetSearchSpec("Recon Hdr Row Id", sRowId);
                     ExecuteQuery(ForwardOnly);
                    var bRecordExists=FirstRecord();
                     Outputs.SetProperty("bRecord" , bRecordExists);     
                     while(bRecordExists)
                     {
                        bRecordExists=NextRecord();
                        var sMatNo=GetFieldValue("SAP SKU Num");
                        Outputs.SetProperty("SAP SKU",sMatNo);
                        var sPriceCond=GetFieldValue("SAP Pricing Condition");
                        Outputs.SetProperty("Pricing Condition",sPriceCond);
                        if (GetFieldValue("SAP Pricing Condition") == "ZPRD")
                          sSegment="NAT";
                        else if (GetFieldValue("SAP Pricing Condition") == "ZMDF") 
                          sSegment="CDF"; //or "Sales"
                        else if (GetFieldValue("SAP Pricing Condition") == "ZPFD") 
                          sSegment="PFP";
                        Outputs.SetProperty("sSegment",sSegment);
              
                        with(oDealBC)
                        {
                          
                       if (sSegment == "CDF")
                       {
                         sExpr = "[WHV Material Number] = '"+sMatNo+"' AND ([Mdf Segment] = 'CDF' OR [Mdf Segment] = 'Sales)";
                       }
                // SetSearchExpr("[Plan Account Promo Prod Id] = '"+sPrdRowID+"' AND [WHV Tactic] = 'DFI' AND [Status] <> 'Cancelled'");
                       else
                       {
                         sExpr = "[WHV Material Number] = '"+sMatNo+"' AND [Mdf Segment] = '"+sSegment+"'";
                       } 
                          
                          ActivateField("WHV Start Date");       
                          ActivateField("WHV End Date");
                          ClearToQuery();
                          SetSearchExpr(sExpr);
              
                          ExecuteQuery(ForwardOnly);
                          if (FirstRecord())
                          {
                            bretValL=true;
                            oDfiChildBC.SetFieldValue("Presidium SKU Num",sMatNo);
                            oDfiChildBC.SetFieldValue("Presidium Deal Id",oDealBC.GetFieldValue("Id"));
                            oDfiChildBC.SetFieldValue("Presidium Start Date",oDealBC.GetFieldValue("WHV Start Date"));
                            oDfiChildBC.SetFieldValue("Presidium Deal End Date",oDealBC.GetFieldValue("WHV End Date"));
                          }
                         }//end of with 
                       } //end of while
                     }//end of main with
                    return(bretValL);
                    }//end of try
              
              
              } //end of function 
              here on called function ...code is not going inside try block

              if anyone can help out on this ..
              thanks