SAP雲平台上兩個ABAP系統實例之間的互連

  • 2020 年 3 月 26 日
  • 筆記

場景:SAP雲平台上的兩個ABAP系統實例,一個作為數據的提供者-provision system;另一個作為數據的消費者 – client system,後者從前者讀取數據,並顯示

實現步驟概述:

(1) client System創建outbound communication. (2) 在provision系統創建inbound communication. (3) Create a Service Consumption Model, and save this locally as a $metadata XML file; From this you will create proxy artefacts in the client system, representing the remote service, and use this model to generate an abstract entity. (4) 創建一個remote client proxy (5) 在client System創建一個OData服務,使用Fiori Elements消費並展示從provision系統取回的數據

SAP標準發布的Communication Scenario SAP_COM_0276,提供了SAP Cloud Platform ABAP實例同遠端的ABAP On-Premises系統或者第三方系統集成的可能性。

A communication arrangement specifies the metadata for a specific communication scenario, such as your host system and the authentication method. This metadata is contained in a service key. You can then define one or more specific destinations for this arrangement.

Communication Arrangement為Communication Scenario指定了必須的元數據,包括通訊系統和消息認證方式等資訊,這些元數據以Service key的形式存儲。可以基於Communication Arrangement創建Destination.

在SAP雲平台CloudFoundry環境里創建一個Destination服務實例:

基於這個Destination服務創建一個新的Destination實例:

url欄位維護成provision System的url,確保連接能夠成功建立。

給Destination service創建一個新的service key,將其內容保存在本地:

在client System上打開ABAP service instance的dashboard:

在Communication Arrangement tile里,創建一個新的實例:

從Communication Scenario下拉列表裡,選擇之前介紹的SAP_COM_0276: SAP CP CF Destination Service integration:

選擇好Communication Scenario後,維護Communication Arrangement的名稱,比如OUTBOUND_XXX.

在Communication Arrangement的additional properties里,將service instance name的值從默認值OUTBOUND_XXX改成更便於記憶的值,比如Outbound-For-Tutorials_XXX.

最後一步,在ABAP client System上創建ABAP 實現類:

CLASS ZCL_OUTPUT_HTTP_XXX DEFINITION    PUBLIC    FINAL    CREATE PUBLIC .      PUBLIC SECTION.      INTERFACES if_oo_adt_classrun.    PROTECTED SECTION.    PRIVATE SECTION.  ENDCLASS.    CLASS ZCL_OUTPUT_HTTP_XXX IMPLEMENTATION.    METHOD if_oo_adt_classrun~main.         TRY.            DATA(lo_destination) = cl_http_destination_provider=>create_by_cloud_destination(            i_name                  = 'A4C_ACCESS_XXX_HTTP'            i_service_instance_name = 'Outbound-For-Tutorial-XXX'              i_authn_mode = if_a4c_cp_service=>service_specific ).            DATA(lo_http_client) = cl_web_http_client_manager=>create_by_http_destination( i_destination = lo_destination ).          DATA(lo_request) = lo_http_client->get_http_request( ).            DATA(lo_response) = lo_http_client->execute( i_method = if_web_http_client=>get ).            out->write( lo_response->get_text( ) ).          CATCH cx_root INTO DATA(lx_exception).          out->write( lx_exception->get_text( ) ).          ENDTRY.      ENDMETHOD.    ENDCLASS.

第18行的參數i_name的值,就是之前在SAP Cloud Platform里創建的Destination名稱。

i_service_instance_name, 就是創建的Communication Arrangement additional properties里創建的Service instance name的值。

執行ABAP類,測試結果如下: