4 Replies Latest reply: Feb 20, 2013 9:16 AM by 852496 RSS

    Fast Formula Doubt

    983218
      Hi,

      For understanding purpose, I have created simple FF(below)

      ----------------------------------------------------------------------------------------------------------------------
      DEFAULT FOR DIST IS 45
      INPUTS ARE DIST
      TRAVEL_PAYMENT = DIST * TEST_RATE
      RETURN TRAVEL_PAYMENT
      ----------------------------------------------------------------------------------------------------------------------
      Where TEST_RATE is global value whose value is 2.


      And I execute the same formula from the backend using below code:
      ----------------------------------------------------------------------------------------------------------------------
      declare
      l_formula_id number default 66217; --Formula ID which I created
      l_inputs ff_exec.inputs_t;
      l_outputs ff_exec.outputs_t;
      l_user_message varchar2(20);
      Begin

      ff_exec.init_formula (p_formula_id => l_formula_id ,p_effective_date => sysdate,p_inputs=> l_inputs,p_outputs=> l_outputs);
      for i_input in l_inputs.first..l_inputs.last
      loop
      if l_inputs(i_input).name = 'DISTANCE' then
      l_inputs(i_input).value := 20;
      end if;
      end loop;
      ff_exec.run_formula(l_inputs, l_outputs);
      for i_output in l_outputs.first..l_outputs.last
      loop
      if l_outputs(i_output).name = 'TRAVEL_PAYMENT' then
      l_user_message := l_outputs(i_output).value;
           dbms_output.put_line(':'|| l_outputs(i_output).value);
      end if;
      end loop;
      dbms_output.put_line(':'||l_user_message||'Chk Value');
      End;

      ----------------------------------------------------------------------------------------------------------------------

      But when I executes, getting NULL value for 'l_user_message'
      I couldn't figure out where I 'm doing mistake.

      Please help.

      Thanks in advance.

      Regards,
      Naresh
        • 1. Re: Fast Formula Doubt
          clive_t
          Hi

          I am guessing that the database item representing the global TEST_RATE needs a business group for a context value. To prove that, modify your formula to use a hard-coded value of 2 instead of the global

          I'm not 100% sure this will work, but you could try setting a value for business group id by adding the following prior to the formula execution:

          if l_inputs(i_input).name = 'BUSINESS_GROUP_ID' then
          l_inputs(i_input).value := <your business group id value>;
          end if;


          Clive
          • 2. Re: Fast Formula Doubt
            983218
            Hi Clive,

            Thanks for your response.
            I tried you suggestion. But no luck!
            Getting the same error. Still not able access global variable.

            Naresh
            • 3. Re: Fast Formula Doubt
              clive_t
              It might be that you need to do a call to fnd_global.apps_initialize prior to running the formula - maybe that will set the business group context for you.

              How did you get on with a hard-coded value in place of the global value in the formula?
              • 4. Re: Fast Formula Doubt
                852496
                Hi Naresh,

                From the definition for the inputs table.

                type inputs_r is record
                (
                name varchar2(240),
                datatype varchar2(6), -- 'DATE', 'NUMBER', 'TEXT'
                class varchar2(7), -- 'CONTEXT' or 'INPUT'.
                value varchar2(255) -- NOTE: match FF_BIND_LEN
                );

                If Business group ID is the context used by your global, you may have to classify it with the class variable as a 'CONTEXT.

                i.e. following Clive's suggestion above,

                if l_inputs(i_input).name = 'BUSINESS_GROUP_ID' then
                l_inputs(i_input).value := <your business group id value>;
                l_inputs(i_input).class := 'CONTEXT';
                end if;

                You can try if this works.

                Thanks.
                Anitha