ABAP中bgRFC的用法与示例

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
          

本博客专注于技术分享,干货满满,持续更新。
欢迎关注❤️、点赞👍、转发📣!

  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

十年铸器

给作者赏杯咖啡

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值