SAP BRF+ 简单调用示例

SAP BRF+ 简单调用示例_第1张图片

*&---------------------------------------------------------------------*
*& Report YTEST_BRF
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ytest_brf.

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.
DATA: lv_amount1           TYPE if_fdt_types=>element_amount.
DATA: lv_amount2           TYPE if_fdt_types=>element_amount.
DATA: lv_amount_result     TYPE if_fdt_types=>element_amount.
FIELD-SYMBOLS  TYPE if_fdt_types=>s_message.
lo_function =
cl_fdt_factory=>if_fdt_factory~get_instance(
)->get_function( iv_id = 'D3DE095E2D301EEE9E9282C35AB0951A' ).
*fill
lv_amount1 = VALUE #( number = '12.23' currency = 'CNY' ).
lv_amount2 = VALUE #( number = '12.00' currency = 'CNY' ).

TRY.
    lo_context = lo_function->get_process_context( ).
    lo_context->set_value( iv_name = 'IV_INPUT1' ia_value = lv_amount1 ).
    lo_context->set_value( iv_name = 'IV_INPUT2' ia_value = lv_amount2 ).
    lo_function->process( EXPORTING io_context = lo_context
    IMPORTING eo_result = lo_result ).

    lo_result->get_value( IMPORTING ea_value = lv_amount_result ).

    WRITE lv_amount_result-number .
    WRITE lv_amount_result-currency .

  CATCH cx_fdt INTO lx_fdt.
    LOOP AT lx_fdt->mt_message ASSIGNING .
      WRITE / -text.
    ENDLOOP.
ENDTRY.

你可能感兴趣的:(BRF+)