Build and run a BTP ABAP program calling RFC FM of OnPrem S/4 system

CLASS zcl_system_info_rfc_000 DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_system_info_rfc_000 IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
TRY.
DATA msg TYPE c LENGTH 255.
DATA(lo_destination) = cl_rfc_destination_provider=>create_by_comm_arrangement(
comm_scenario = 'Z_OUTBOUND_RFC_000_CSCEN' " Communication scenario
service_id = 'Z_OUTBOUND_RFC_000_SRFC' " Outbound service
comm_system_id = 'Z_OUTBOUND_RFC_CSYS_000' " Communication system
).
DATA(lv_destination) = lo_destination->get_destination_name( ).
out->write( lv_destination ).
DATA lv_result TYPE c LENGTH 200.
DATA lv_result1 TYPE c LENGTH 1.
CALL FUNCTION 'RFC_SYSTEM_INFO'
DESTINATION lv_destination
IMPORTING
"RFCSI_EXPORT = lv_result
s4_hana = lv_result1
EXCEPTIONS
system_failure = 1 MESSAGE msg
communication_failure = 2 MESSAGE msg
OTHERS = 3.
CASE sy-subrc.
WHEN 0.
out->write( lv_result1 ).
WHEN 1.
out->write( | EXCEPTION SYSTEM_FAILURE | && msg ).
WHEN 2.
out->write( | EXCEPTION COMMUNICATION_FAILURE | && msg ).
WHEN 3.
out->write( | EXCEPTION OTHERS | ).
ENDCASE.
out->write( lv_result1 ).
CATCH cx_root INTO DATA(lx_root).
out->write( lx_root->get_text( ) ).
ENDTRY.
ENDMETHOD.
ENDCLASS.
PreviousSetup Communication Arrangement for S/4HANA systemNextSubscribe and Administer BTP Landscape Portal Application
Last updated