cancel
Showing results for 
Search instead for 
Did you mean: 

Get BRF+ function parameters dynamically?

marspark
Participant

Hi experts,

We created many BRF+ formula expressions. In a custom program, users can choose one of them to calculate price. The requirement is when a BRF+ formular is selected, custom program should display operands in formular, which are parameters of BRF+ function. Then users will know the things they should input.

I know if it is an abap function or abap method, with RTTS I can get its parameters dynimacally. But how to get BRF+ function parameters by ID?

Accepted Solutions (0)

Answers (1)

Answers (1)

marspark
Participant

I have found a solution.

Class CL_FDT_CONTEXT has a private attribute, MT_NAME_VALUE. I found parameters in this attribute.

Create a class enhancement to add new method for this class,

  methods GET_MT_NAME_VALUES
    exporting
      value(ET_NAME_VALUE) type HASHED TABLE .

Assign MT_NAME_VALUE to the exporting parameter,

METHOD get_mt_name_values .

  et_name_value = me->mt_name_value.

ENDMETHOD.

Then call GET_MT_NAME_VALUES in the program,

TYPES:
  BEGIN OF s_name_id_value,
    id               TYPE if_fdt_types=>id,
    name             TYPE abap_parmname,
    data_object_type TYPE if_fdt_types=>data_object_type,
    value            TYPE REF TO data,
    value_set        TYPE abap_bool,
  END OF s_name_id_value .
TYPES:
  t_name_id_value TYPE HASHED TABLE OF s_name_id_value
                  WITH UNIQUE KEY name .

DATA: t_name TYPE t_name_id_value.

DATA(lo_fuction) = cl_fdt_factory=>if_fdt_factory~get_instance(
  )->get_function( '005056A4CCA61ED8A8924F0F3F4F1D98' ).
*

DATA(lo_context) = CAST cl_fdt_context( lo_fuction->get_process_context( ) ).

lo_context->get_mt_name_values( IMPORTING et_name_value = t_name ).

That's all.

pokrakam
Active Contributor
0 Kudos

Nice! Thanks for sharing the answer.