Creation of bgRFC and calling in a program
What is bgRFC.
1. What is bgRFC?
The bgRFC allows application to record data that is received later by a called
application. When the data is received, we must ensure that the data was transferred to
the receiver either once only in any order(transactional) or once only in the order of
2. bgRFC Configuration?
Creation of supervisor Destination.
This is a mandatory step because the bgRFC can only function if a supervisor
destination has been define for bgRFC processing. For creation of supervisor
destination the t-code is SBGRFCCONF.
Need to verify the supervisor destination as an RFC destination using the transaction
SM59. This destination must be defined as either an ABAP connection or a logical
A user, password, and client must be entered for both connection types. Please refer
the attached screenshot.
ABAP Connection :
No load balancing can be defined.
No system number can be entered.
No server can be entered.
Creation of destination:
We have to create inbound/outbound destination name based on the requirement.
Creation of Inbound Destination:
On the define inbound Dest. Tab page in the transaction SBGRFCCONF, we can
maintain a separate inbound destination for each application. This is also mandatory
step to create any inbound bgRFC.
Logon/Server group can be defined using transaction RZ12.
All the settings and activities related to the transaction SBGRFCCONF is BASIS related
activity so before creating/configuring any bgRFC please consult with BASIS team.
Creation of outbound destination:
We can create outbound destination using transaction SM59. Creation of outbound
destination in SM59 is normal like any of the destination creation. Please refer the
below screenshot for reference.
We have to created outbound destination under ABAP Connections. For this destination
we have to maintain the necessary target destination IP, system no etc. Please refer all
the below screenshots for detailed setting in each tab.
After creation of the outbound destination in SM59 we have to maintain this destination
in SBGRFCCONF transaction. We have to maintain the destination in Scheduler
Destination tab of transaction SBGRFCCONF. Please refer the below screenshot.
3. bgRFC Programming
After the entire configuration now let’s talk about the programming.
Creation of unit:
We have to create one bgRFC unit by taking the reference from the configured
inbound/outbound destination name. Destination objects can be requested using the
class methods from the class CL_BGRFC_DESTINATION_OUTBIUND for the
outbound and the class CL_BGRFC_DESTINATION_INBOUND for the inbound. We
have to use method create of the above mentioned class to create a destination object.
Please see the below example of how to create an inbound destination object.
Pass any of the configured inbound destination name in the below mentioned variable.
Call the below mentioned method to create reference of inbound destination.
If the inbound/outbound destine is invalid the program is going to dump.
Please refer the blow screen shot for your reference.
For handling the runtime error we need to use exception class
CX_BGRFC_INVALID_DESTINATION. Please refer the below screenshot for your
After creation of the destination object it is time to create a bgRFC unit. bgRFC unite
can be two types like tRFC and qRFC. We have to use method CREATE_TRFC_UNIT
to create a tRFC unit and method CREATE_QRFC_UNIT to create a qRFC unit. Please
refer the below screenshot.
To create a qRFC unit we just have to call CREATE_QRFC_UNIT method instead of
Calling a function module:
After creation of the unit we have to call any function module in background. The new
syntax for calling a function module for background processing is as follows.
CALL FUNTION ‘function_name’
IN BACKGROUND UNIT unit
Inside the calling function module we have to write our required logic which we want to
process in background (e.g Update a table). Please refer below screenshot for calling of
a function module.
In the above example the function module is called in background using the created
unit. In the exporting parameter we can define whatever we want to send in the function
module. If we want to send some table also we can define it in the calling module and
we can send it.
The above screenshot shows complete program to call bgRFC.
RFC Function module:
The function module must be RFC enabled function module.
Here one thing need to remembered, calling the function module will happen once
program does the COMMIT WORK. If we want to create bgRFC from our custom
program like report in that case we have to do external COMMIT WORK but if we are
trying to create bgRFC from any BADI/USER EXIT/Enhancement Spot in that case we
do not need to apply external COMMIT WORK. Once standard SAP do the COMMIT
WORK bgRFC unit will be Created.
4. bgRFC Monitoring:
bgRFC monitor typically required to check if any unit is failed or there are any issue in
any particular unit.
We have to use transaction SBGRFCMON to monitor bgrfc unit. In the selection screen
we have option to monitor Inbound/Outbound unit along with tRFC unit or qRFC unit.
Also there are several options in the selection screen. Please refer the below screen shot.
After execution the transaction we will be able to monitor all the erroneous units in the
system. We have to remember if any unit is created successfully and if there are no
data issue or any connection issue in that case it will be executed and we will not able
to see it in this transaction. Only erroneous and warning units will be displayed here.
Please refer the below screenshot.
Background Remote Funtion Call (bgRFC) is a technology in SAP that allow for
asynchronous (qRFC) and synchronously (tRFC) communication between different
systems. It is used to enable background processing of distributed system in a secure
and reliable manner.
With bgRFC, developers can create and schedule processes to run in the background
of SAP system, which helps reduce the workload on the front-end and improve system
performance. The technology ensure that all data is transmitted securely and can
handle large volumes of data efficiently.
I would like to hear your thoughts and feedback on this post and promoting relevant
community resources in the SAP community.
Other Blogs for related bgRFC:
Thank you for reading my content on SCN blog! If you enjoyed what you read and
would like to see more, I encourage you to follow my profile.