天天看点

how to create BRF application via code

使用如下代码自动创建新的BRF application:

REPORT zceate_application.

DEFINE write_errors.

 IF &1 IS NOT INITIAL.

 LOOP AT &1 ASSIGNING .

 WRITE: -text.

 ENDLOOP.

 RETURN.

 ENDIF.

END-OF-DEFINITION.

START-OF-SELECTION.

 DATA: lo_factory     TYPE REF TO if_fdt_factory,

       lo_application TYPE REF TO if_fdt_application,

       lt_message     TYPE if_fdt_types=>t_message,

       lv_boolean     TYPE abap_bool.

 FIELD-SYMBOLS: TYPE if_fdt_types=>s_message.

 lo_factory = cl_fdt_factory=>if_fdt_factory~get_instance( ).

 lo_application = lo_factory->get_application( ).

 lo_application->if_fdt_transaction~enqueue( ).

 lo_application->set_development_package( '$TMP' ).

 lo_application->if_fdt_admin_data~set_name( 'PRICING' ).

 lo_application->if_fdt_admin_data~set_texts(

 iv_short_text = 'Pricing' ).

 lo_application->if_fdt_transaction~activate(

     IMPORTING et_message           = lt_message

               ev_activation_failed = lv_boolean ).

 write_errors lt_message.

 lo_application->if_fdt_transaction~save( ).

 lo_application->if_fdt_transaction~dequeue( ).

 lo_factory = cl_fdt_factory=>if_fdt_factory~get_instance(

 iv_application_id = lo_application->mv_id ).

 BREAK-POINT.

 WRITE:/ lo_application->mv_id.

记下输出的application id: FA163E8EAB031EE48B80D14409724BFF

使用BRF+ tcode打开BRF work bench:

利用如下搜索条件查找刚刚创建好的application:

how to create BRF application via code

找到匹配的application. 点击expand button查看header信息:

how to create BRF application via code

ID和report里输出一致,证明这就是report里刚刚创建的application:

how to create BRF application via code

继续阅读