1. bgRFC 的配置T-code
使用bgRFC时,主要会用到以下的事务代码:
- SBGRFCCONF - bgRFC Configuration
- SBGRFCMON - bgRFC Monitor
- SBGRFCPERFMON - bgRFC Performance Monitor
2. Inbound与Outbound的配置
bgRFC可以分为Inbound与Outbound两种类型。
- 当系统A不需要与远程系统交互,仅是与本流程解耦合,使用inbound bgRFC
- 当系统A需要向系统B发送信息,并需要与本流程解耦合,使用outbound bgRFC
使用inbound bgRFC时,需要在SBGRFCCONF的Define Inbound Dest中定义Destination,并且定义Prefix。
此处定义的inbound destination类似于指定一个业务场景,此destination并不需要定义在SM59中。但此destination会在调用inbound bgRFC时使用,也即在代码中调用inbound bgRFC时,需要指定在SBGRFCCONF定义的这个inbound destination。
使用outbound bgRFC时,需要在SBGRFCCONF的Scheduler中定义Destination,这个destination也即是远程系统的Destination,也需要定义在SM59中,并且在SM59的Special Options中开启bgRFC的传输协议。
3. type t与type q
bgRFC有两种类型,也即t类型和q类型,分别对应于传统的t-RFC和q-RFC。bgRFC是传统t-RFC和q-RFC的继承和增强。
4. 示例代码
4.1 t 类型的inbound bgRFC
DATA:
lo_inb_dest TYPE REF TO if_bgrfc_destination_inbound,
lo_inb_unit TYPE REF TO if_trfc_unit_inbound,
lv_dest_name TYPE bgrfc_dest_name_inbound.
lv_dest_name = 'SDBL_PROC_BGRFC'. " you defined in SBGRFCCONF >> Define Inbound Dest
lo_inb_dest = cl_bgrfc_destination_inbound=>create( lv_dest_name ).
lo_inb_unit = lo_inb_dest->create_trfc_unit( ).
lo_inb_unit->disable_commit_checks( ). " configure bgRFC unit as what you need
CALL FUNCTION 'RFC_FUNCTION_1' IN BACKGROUND UNIT lo_inb_unit.
COMMIT WORK. " execute bgRFC when commit
4.2 q 类型的inbound bgRFC
DATA:
lo_inb_dest TYPE REF TO if_bgrfc_destination_inbound,
lo_inb_unit TYPE REF TO if_qrfc_unit_inbound,
lv_dest_name TYPE bgrfc_dest_name_inbound,
lv_qname TYPE qrfc_queue_name.
lv_dest_name = 'SDBL_PROC_BGRFC'. " you defined in SBGRFCCONF >> Define Inbound Dest
lv_qname = 'SDBL_PROC' && 'SRCCLNT002' && '1800000000'.
lo_inb_dest = cl_bgrfc_destination_inbound=>create( lv_dest_name ).
lo_inb_unit = lo_inb_dest->create_qrfc_unit( ).
lo_inb_unit->disable_commit_checks( ). " configure bgRFC unit as what you need
lo_inb_unit->add_queue_name_outbound( queue_name = lv_qname ).
CALL FUNCTION 'RFC_FUNCTION_1' IN BACKGROUND UNIT lo_inb_unit.
COMMIT WORK. " execute bgRFC when commit
4.3 t 类型的outbound bgRFC
DATA:
lo_outb_dest TYPE REF TO if_bgrfc_destination_outbound,
lo_outb_unit TYPE REF TO if_trfc_unit_outbound,
lv_dest_name TYPE bgrfc_dest_name_outbound.
lv_dest_name = 'SRCCLNT002_BGRFC'. " you defined in SBGRFCCONF >> Scheduler: Destination
lo_outb_dest = cl_bgrfc_destination_outbound=>create( lv_dest_name ).
lo_outb_unit = lo_outb_dest->create_trfc_unit( ).
lo_outb_unit->disable_commit_checks( ). " configure bgRFC unit as what you need
CALL FUNCTION 'RFC_FUNCTION_1' IN BACKGROUND UNIT lo_outb_unit.
COMMIT WORK. " execute bgRFC when commit
4.4 q 类型的outbound bgRFC
DATA:
lo_outb_dest TYPE REF TO if_bgrfc_destination_outbound,
lo_outb_unit TYPE REF TO if_qrfc_unit_outbound,
lv_dest_name TYPE bgrfc_dest_name_outbound,
lv_qname TYPE qrfc_queue_name.
lv_dest_name = 'SRCCLNT002_BGRFC'. " you defined in SBGRFCCONF >> Scheduler: Destination
lv_qname = 'PRIFIX' && 'SRCCLNT002' && '1800000000'.
lo_outb_dest = cl_bgrfc_destination_outbound=>create( lv_dest_name ).
lo_outb_unit = lo_outb_dest->create_qrfc_unit( ).
lo_outb_unit->disable_commit_checks( ). " configure bgRFC unit as what you need
lo_outb_unit->add_queue_name_outbound( queue_name = lv_qname ).
CALL FUNCTION 'RFC_FUNCTION_1' IN BACKGROUND UNIT lo_outb_unit.
COMMIT WORK. " execute bgRFC when commit
本博客专注于技术分享,干货满满,持续更新。
欢迎关注❤️、点赞👍、转发📣!