cancel
Showing results for 
Search instead for 
Did you mean: 

BRF+ issues with result in function call

dominik_ee
Advisor
Advisor
0 Kudos

Hello Community,

I'm having some problems with my brf+ function.

My function takes two Data Objects as input and processes some rules. The rules check if the input data have the right values and then calls a formula. The function should then provide the result of this calculation in the result data object.

Here the Context:

By simulating my function the rules and calculation work proper, but I get the following result in the end:

Why is my function not returning the value of ZRESULT and instead returning the value of my input data MAXVALUE?

I'm calling the function from abap with the following LoC and want to retrieve the calculated result:

TRY .

* Get BRFplus function

lo_fuction ?= cl_fdt_factory=>if_fdt_factory~get_instance( )->get_function( 'XXXXXXXXXXX' ).

lo_context = lo_fuction->get_process_context( ).

lo_context->set_value( iv_name = 'MAXVALUE' ia_value = norm_rel_val ).

lo_context->set_value( iv_name = 'WEIGHTEDRELEVANCE' ia_value = norm_rel_ovd ).

lo_fuction->process( EXPORTING io_context = lo_context

IMPORTING eo_result = lo_result ).

lo_result->get_value( IMPORTING ea_value = calc_result ).

WRITE calc_result.

CATCH cx_fdt INTO lo_message.

ENDTRY.

Do you have any hints, why my function does not return the result of the calculation? And am I retrieving the result from the function right with this code?

Thanks & Regards,

Dominik

View Entire Topic
christianlechne
Active Contributor
0 Kudos

Hi,

concerning your result in simulation mode: Can you check the results displayed in the upper part of the simulation mode screen (section above the section "processing steps"). There you should see your result data ZRESULT with the value you calculated as according to your screenshot all values are set corrrectly,

Concerning the mapping of your result data object: Do you do some manipulation of the object in the ruleset after callling the formula expression?

Concerning the call in ABAP: Please use the code template that you can create in the BRFplus workbench on function level -> Detail section -> Create Code Template

Your call  is an old way to call a function and has performance drawbacks

Hope that helps

Cheers

Christian

dominik_ee
Advisor
Advisor
0 Kudos

Hi Christian,

Im not manipuliating any Data Objects in this example. The rulesets checks if one of the input Data Objects are not initial and sets them to 0 if they are. In this example their values are 0,001089 and 1, so nothing will be changed before the calculation. Rule for changing the ZRESULT Data Object is:

IF ZRESULT is initial

THEN Change ZRESULT after processing RELEVANCE_CALCULATION

After executing this rule the function returns without any changes.

I also used the debugger to have a look at which points the values are changed. Every Rule and Calculation works proper, exept the last step when returning the function. The function changes its value to the input-value although the Result Data Object has the right value.

Thanks for the hint with the creation of code templates, but in my Details-section there are only the Simulation und Debugger Buttons.

-EDIT- Found it. Had to change to expert mode. Thanks again!

Regards,

Dominik

christianlechne
Active Contributor
0 Kudos

Hi Dominik,

for the code template button you have to change the personalization and switch to "Expert mode". You are running in "simple mode" and the button is not visible.

Concerning the result value: the screenshot you attached shows the right value in the result data object:

So the workbench/simulation itself shows the right results. I would therefore say that the problem is in your ABAP code and this should be solved when using the code delivered by the code template.

BR

Christian

dominik_ee
Advisor
Advisor
0 Kudos

Hi Christian,

Thanks for your fast reply. You were right. The problem was in my ABAP code as running the programm with the code template returned the right results.

Thanks a lot for you help!

Cheers,

Dominik