8 Replies Latest reply: Jan 16, 2011 5:15 PM by Davin Fifield-Oracle RSS

    Multiple result values to attribute

    user85712
      We have a requirement where we want to find multiple disk(c)ount rate for a given condition.

      Conditions are Customer name and Effective Dates.

      For a customer there can be multiple disk(c)ount rates applicable.

      eg

      Customer Name Effective Date Disk(c)ount perc
      CUST-A JAN-MAR 20 %
      CUST-A JAN-MAR 15%
      CUST-A JAN-DEC 10 %
      CUST-A MAR-DEC 5%


      And this way there could be multiple disk(c)ount rates for given transaction date. If the transaction date is say in FEB then we have three disk(c)ounts 20, 15% and 10%. If the transaction is in MAR then we have four lines 20, 15, 10 and 5. It can be potentially be any number of disk(c)ount rate lines effective for a given date. We want to show all these disk(c)ount lines in invoice lines.

      How to model it so that I get all effective disk(c)ount lines?

      If I am using excel for modelling the rule
      a. I wont be able to compile if same conditions are repeated. eg:-
      Customer Name Effective Date Disk(c)ount perc
      CUST-A JAN-MAR 20 %
      CUST-A JAN-MAR 15%

      b. Also the result would be only one value.

      c. I cant have multiple conclusion attributes as columns because that way I am restricting number of applicable disk(c)ounts design time.

      Appreciate your response.

      -- Sreeram.H

      * strange spelling for disk(c)ount due to spam filter set for the forum.
        • 1. Re: Multiple result values to attribute
          Stephen French-Oracle
          Wow that spam filter is ridiculous. Diskount it is then.

          Rather than hardcoding the diskounts in the rules, you could define an entity called "the customer diskounts" with a separate instance for each diskount.

          You can then add a condition to each diskounts that indicates whether that particular diskounts is applicable to the current assessment:
          the customer diskounts is applicable if
          ...the customer name for the customer diskount = the customer name and
          ...the transaction date >= the customer diskount start date and
          ...the transaction date <= the customer diskount end date
          You can then use the various Instance*If() functions to perform any calculations. For example, to sum up the diskounts you could use:
          the transaction diskount = InstanceSumIf(the customer diskounts, the percentage of the customer diskount, the customer diskount is applicable)
          • 2. Re: Multiple result values to attribute
            user85712
            Thanks a lot for the quick response. Sounds like we must put this logic in Word. However we have 1000's of records like this and it would be nice if we can use Excle for it. Can we do something similar in Excel?
            • 3. Re: Multiple result values to attribute
              user85712
              Can you please tell me whether your solution will work by defining diskount rate table in excel (more than 1000 records) and refer back to excel
              • 4. Re: Multiple result values to attribute
                Stephen French-Oracle
                My suggestion is not to store the 1000s of records in Excel or Word, but to instead store them as entity instances and pre-populate any requests with the information about what diskounts are available, effectively as reference data.
                • 5. Re: Multiple result values to attribute
                  user85712
                  Thanks once again. However I still need more information. Are you suggesting that we store these 1000s of records somewhere else like Oracle table and then while accessing the rule session, create entity instances for diskounts and populate diskount values only for eligible diskounts. Please enlighten me.

                  -- Sreeram.H
                  • 6. Re: Multiple result values to attribute
                    Stephen French-Oracle
                    Yes that's basically what I'm suggesting.

                    Of course there's no reason you couldn't store these in, for example, a CSV file (editable by Excel, to fit your initial request) and then prepopulate your request data with this information.
                    • 7. Re: Multiple result values to attribute
                      Stephen French-Oracle
                      Just to elaborate one possible way to do this. You could have a software engineer create an inferencing listener and implement the beginInferencing() method to ensure the available diskounts are preloaded in every session. The data could be loaded from a CSV file as described above (which allows it to be edited in Excel) and created as entity instances.

                      Refer to the OPA developer help for more information on inferencing listeners - there is no example for this particular situation however it should be feasible. This documentation also explains how to package up the inferencing listener code with the rulebase so that it will automatically load in the regression tester, but note that you need to produce code suitable for the platform you are using (either .NET or Java).

                      The one difficulty here is loading the CSV from the inferencing listener code. There's no easy way to do locate it from the inferencing listener itself, so you may just have to decide on a reliable place to locate the file. Something we need to improve in a future version!
                      • 8. Re: Multiple result values to attribute
                        Davin Fifield-Oracle
                        Another way to do this in OPA 10.2 is to create an extension for Determinations Server that handles the OnMapDataEvent. You can load whatever reference data you need within your handler for that event. There will be a video available that shows how to do this, shortly.

                        Davin.