使用ABAP调用BRF+ function

针对如下的BRF+ function:

使用ABAP调用BRF+ function

基于如下输入,根据rule的规则,计算出的final price应等于 10 / ( 1 + 0.12 ) = 8.93
使用ABAP调用BRF+ function

可以使用如下的report来将上述输入传入brf+的API,通过ABAP 代码来调用function的执行:

REPORT zcall_function.
 
DATA: lo_function TYPE REF TO if_fdt_function,
      lo_context  TYPE REF TO if_fdt_context,
      lo_result   TYPE REF TO if_fdt_result,
      lx_fdt      TYPE REF TO cx_fdt,
      lv_string   TYPE string.
FIELD-SYMBOLS <ls_message> TYPE if_fdt_types=>s_message.
lo_function =
cl_fdt_factory=>if_fdt_factory~get_instance(
)->get_function( iv_id = 'FA163E8EAB031EE48B847ADC6A96D5F0' ).
TRY.
    lo_context = lo_function->get_process_context( ).
    lo_context->set_value( iv_name = 'CUSTOMER'
    ia_value = 'sap' ).
    lo_context->set_value( iv_name = 'ITEM' ia_value = 'pencil' ).
    lo_context->set_value( iv_name = 'PROMOTION' ia_value = space ).
    lo_context->set_value( iv_name = 'SHELF_PRICE'
    ia_value = '10' ).
    lo_function->process( EXPORTING io_context = lo_context
    IMPORTING eo_result = lo_result ).
    lo_result->get_value( IMPORTING ea_value = lv_string ).
    WRITE lv_string .
  CATCH cx_fdt INTO lx_fdt.
    LOOP AT lx_fdt->mt_message ASSIGNING <ls_message>.
      WRITE / <ls_message>-text.
    ENDLOOP.
ENDTRY.

report输出和在BRF+ workbench里得到的结果一致:
使用ABAP调用BRF+ function

上一篇:Linux 内核:设备树中的特殊节点


下一篇:CGB2110-Day18-完成Linux项目部署