Sometimes there is a need to forcibly close the RFC connection after calling some RFC module. There can be many reasons, but more importantly, how to do it?
The functional module RFC_CONNECTION_CLOSE will help us with this. Below I will give an example of calling this FM for greater clarity:
1 2 3 4 5 |
CALL FUNCTION 'RFC_CONNECTION_CLOSE' EXPORTING destination = lv_rfc EXCEPTIONS OTHERS = 0. |
We simply call this FM and the RFС closes the connection.
Where lv_rfs is the connection we previously opened, for example using destination lv_rfs.
Close RFC connection example ABAP
I will also give a more complete example with a call to FM through the RFС and the subsequent closing of this connection in SAP system in ABAP program.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
SELECT SINGLE rfcdest INTO @DATA(lv_rfc) FROM smof_erpsh WHERE sitetypeid = 'ERP_SYST'. CALL FUNCTION 'Z_GET_DATA' DESTINATION lv_rfc EXPORTING i_rezerv = 'X' iv_vbeln = lv_vbeln IMPORTING et_data = lt_data. CALL FUNCTION 'RFC_CONNECTION_CLOSE' EXPORTING destination = lv_rfc EXCEPTIONS OTHERS = 0. |