*&---------------------------------------------------------------------*
*& Report ZTS_QRFC_CALL
*&---------------------------------------------------------------------*
*&SBGRFCCONF bgRFC 配置
*SBGRFCMON bgRFC 监控器
*&---------------------------------------------------------------------*
REPORT zts_bgrfc_call.
PARAMETERS: p_sec TYPE i DEFAULT 10,
rfcdest LIKE rfcdes-rfcdest DEFAULT 'NONE',
p_uname TYPE bgrfc_dest_name_inbound DEFAULT 'ZTS_BGRFC_IN', "执行前,必须要先注册
p_qname TYPE qrfc_queue_name DEFAULT 'MY_QUEUE'.
PARAMETERS: p_tin RADIOBUTTON GROUP ra1,
p_tout RADIOBUTTON GROUP ra1,
p_qin RADIOBUTTON GROUP ra1,
p_qout RADIOBUTTON GROUP ra1.
INITIALIZATION.
%_p_sec_%_app_%-text = '等待时间(秒)'.
%_rfcdest_%_app_%-text = '远程调用目标'.
%_p_uname_%_app_%-text = '目标名称'.
%_p_qname_%_app_%-text = '队列名称'.
%_p_tin_%_app_%-text = 'TRFC入站'.
%_p_tout_%_app_%-text = 'TRFC出站'.
%_p_qin_%_app_%-text = 'QRFC入站'.
%_p_qout_%_app_%-text = 'QRFC出站'.
START-OF-SELECTION.
CASE 'X'.
WHEN p_tin."通过trfc inbound方式调用bgRFC
PERFORM frm_bgrfc_tin.
WHEN p_tout."通过trfc outbound方式调用bgRFC
PERFORM frm_bgrfc_tout.
WHEN p_qin. "通过qRFC inbound 方式调用bgRFC
PERFORM frm_bgrfc_qin.
WHEN p_qout. "通过qRFC outbound 方式调用bgRFC
PERFORM frm_bgrfc_qout. "
ENDCASE.
*&---------------------------------------------------------------------*
FORM frm_bgrfc_tin .
DATA lo_destination TYPE REF TO if_bgrfc_destination_inbound.
DATA lo_trfc_unit TYPE REF TO if_trfc_unit_inbound.
DATA lc_bgrfc_dest_name TYPE bgrfc_dest_name_inbound .
lc_bgrfc_dest_name = p_uname.
DATA myref TYPE REF TO cx_bgrfc_invalid_destination .
DATA err_text TYPE string.
DATA result TYPE i.
TRY.
lo_destination = cl_bgrfc_destination_inbound=>create( lc_bgrfc_dest_name ).
CATCH cx_bgrfc_invalid_destination INTO myref.
err_text = myref->get_text( ).
MESSAGE s001(00) WITH err_text.
EXIT.
ENDTRY.
lo_trfc_unit = lo_destination->create_trfc_unit( ).
* lo_trfc_unit->disable_commit_checks( ).
CALL FUNCTION 'Z_BC_TEST_BGRFC' IN BACKGROUND UNIT lo_trfc_unit
EXPORTING
iv_wait = p_sec.
CALL FUNCTION 'START_OF_BACKGROUNDTASK'
EXPORTING
startdate = sy-datum
starttime = sy-uzeit
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 1.
EXIT.
ENDIF.
COMMIT WORK. "提交才会写入队列
ENDFORM.
FORM frm_bgrfc_tout .
DATA lo_destination TYPE REF TO if_bgrfc_destination_outbound.
DATA lo_trfc_unit TYPE REF TO if_trfc_unit_outbound.
DATA lc_bgrfc_dest_name TYPE bgrfc_dest_name_outbound .
lc_bgrfc_dest_name = p_uname.
lo_destination = cl_bgrfc_destination_outbound=>create( lc_bgrfc_dest_name ).
lo_trfc_unit = lo_destination->create_trfc_unit( ).
* lo_trfc_unit->disable_commit_checks( ).
CALL FUNCTION 'Z_BC_TEST_BGRFC' IN BACKGROUND UNIT lo_trfc_unit
EXPORTING
iv_wait = p_sec.
CALL FUNCTION 'START_OF_BACKGROUNDTASK'
EXPORTING
startdate = sy-datum
starttime = sy-uzeit
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 1.
EXIT.
ENDIF.
COMMIT WORK. "提交才会写入队列
ENDFORM.
FORM frm_bgrfc_qin .
DATA lo_destination TYPE REF TO if_bgrfc_destination_inbound.
DATA lo_qinrfc_unit TYPE REF TO if_qrfc_unit_inbound.
DATA lc_bgrfc_dest_name TYPE bgrfc_dest_name_inbound .
lc_bgrfc_dest_name = p_uname.
lo_destination = cl_bgrfc_destination_inbound=>create( lc_bgrfc_dest_name ).
lo_qinrfc_unit = lo_destination->create_qrfc_unit( ).
*TRY.
CALL METHOD lo_qinrfc_unit->add_queue_name_inbound
EXPORTING
queue_name = p_qname
* ignore_duplicates = ABAP_FALSE
.
* CATCH cx_bgrfc_invalid_unit .
* CATCH cx_qrfc_duplicate_queue_name .
* CATCH cx_qrfc_invalid_queue_name .
*ENDTRY.
* lo_trfc_unit->disable_commit_checks( ).
TRY.
CALL METHOD lo_qinrfc_unit->add_queue_name_inbound
EXPORTING
queue_name = p_qname.
CATCH cx_bgrfc_invalid_unit .
CATCH cx_qrfc_duplicate_queue_name .
CATCH cx_qrfc_invalid_queue_name .
ENDTRY.
CALL FUNCTION 'Z_BC_TEST_BGRFC' IN BACKGROUND UNIT lo_qinrfc_unit
EXPORTING
iv_wait = p_sec.
CALL FUNCTION 'START_OF_BACKGROUNDTASK'
EXPORTING
startdate = sy-datum
starttime = sy-uzeit
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 1.
EXIT.
ENDIF.
COMMIT WORK. "提交才会写入队列
ENDFORM.
FORM frm_bgrfc_qout .
DATA lo_destination TYPE REF TO if_bgrfc_destination_outbound.
DATA lo_qoutrfc_unit TYPE REF TO if_qrfc_unit_outbound.
DATA lc_bgrfc_dest_name TYPE bgrfc_dest_name_outbound .
lc_bgrfc_dest_name = p_uname.
lo_destination = cl_bgrfc_destination_outbound=>create( lc_bgrfc_dest_name ).
lo_qoutrfc_unit = lo_destination->create_qrfc_unit( ).
* lo_trfc_unit->disable_commit_checks( ).
CALL FUNCTION 'Z_BC_TEST_BGRFC' IN BACKGROUND UNIT lo_qoutrfc_unit
EXPORTING
iv_wait = p_sec.
CALL FUNCTION 'START_OF_BACKGROUNDTASK'
EXPORTING
startdate = sy-datum
starttime = sy-uzeit
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 1.
EXIT.
ENDIF.
COMMIT WORK. "提交才会写入队列
ENDFORM.