Introduction:- In various requirement , we send SAP BW data to Amazon S3 through IICS ( Informatica Intelligent Cloud Services). There is a challenge in data refresh synchronization between SAP BW and IICS as those two jobs are triggered and run in two different servers. As a work around, we have to trigger the IICS job manually every time after SAP BW data got refreshed. There is no such process automation between those two jobs.
Proposed Solution: – We can communicate with IICS server from SAP through REST APIs. Custom code will use to trigger the IICS job from SAP. This will be an automated process where both SAP job and IICS job execution can be controlled from SAP server.
High level Technical Solution: –
Process flow.
Sample Code snippet: –
Conclusion:
In this blog post, I demonstrated how to communicate IICS server from SAP through REST APIs and trigger IICS task from SAP. Hope this blog post will help BW developers to achieve similar functionality.
Okumaya devam et...
Proposed Solution: – We can communicate with IICS server from SAP through REST APIs. Custom code will use to trigger the IICS job from SAP. This will be an automated process where both SAP job and IICS job execution can be controlled from SAP server.
High level Technical Solution: –
- Use Login API to login to IICS server from SAP and get the session related information.
- Pass IICS job and session related information through job trigger API and trigger the job
- Include this custom code in BW process chain
Process flow.
Sample Code snippet: –
- Post Request for login.
Kod:
DATA: lv_url TYPE string VALUE 'https://***********/v3/login',
lo_http_client TYPE REF TO if_http_client,
lo_rest_client TYPE REF TO cl_rest_http_client,
lo_request TYPE REF TO if_rest_entity.
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = lv_url " URL
* proxy_host = " Logical destination (specified in function call)
* proxy_service = " Port Number
* ssl_id = " SSL Identity
* sap_username = " ABAP System, User Logon Name
* sap_client = " R/3 system (client number from logon)
* proxy_user = " Proxy user
* proxy_passwd = " Proxy password
IMPORTING
client = lo_http_client " HTTP Client Abstraction
EXCEPTIONS
argument_not_found = 1 " Communication Parameters (Host or Service) Not Available
plugin_not_active = 2 " HTTP/HTTPS Communication Not Available
internal_error = 3 " Internal Error (e.g. name too long)
OTHERS = 4.
IF sy-subrc = 0.
lo_http_client->request->set_version( lv_protocol ).
lo_rest_client = NEW #( io_http_client = lo_http_client ).
lo_request = lo_rest_client->if_rest_client~create_request_entity( ).
ENDIF.
lo_rest_client->if_rest_client~set_request_header(
EXPORTING
iv_name = 'ACCEPT'
iv_value = 'APPLICATION/JSON'
).
lo_rest_client->if_rest_client~set_request_header(
EXPORTING
iv_name = 'CONTENT-TYPE'
iv_value = 'APPLICATION/JSON'
).
CONCATENATE '{' '"username"' ':' '"' lv_user '"' ',' '"password"' ':' '"' lv_pwd '"' '}' INTO lv_body.
lo_request->set_string_data( lv_body ).
lo_rest_client->if_rest_resource~post( lo_request ).
- Get request to get the Session ID related information.
Kod:
DATA: lo_response TYPE REF TO if_rest_entity,
lv_response TYPE string.
lo_response = lo_rest_client->if_rest_client~get_response_entity( ).
lv_http_status = lo_response->get_header_field( '~status_code' ).
lv_reason = lo_response->get_header_field( '~status_reason' ).
lv_content_length = lo_response->get_header_field( 'content-length' ).
lv_location = lo_response->get_header_field( 'location' ).
lv_content_type = lo_response->get_header_field( 'conent-type' ).
lv_response = lo_response->get_string_data( ).
IF lv_http_status = lc_status.
CALL METHOD /ui2/cl_json=>deserialize
EXPORTING
json = lv_response " JSON string
pretty_name = /ui2/cl_json=>pretty_mode-user " Pretty Print property names
assoc_arrays = abap_true " Deserialize associative array as tables with unique keys
CHANGING
data = lr_data. " Data to serialize
IF lr_data IS BOUND.
ASSIGN lr_data->* TO <data>.
ASSIGN COMPONENT `PRODUCTS` OF STRUCTURE <data> TO <results>.
ASSIGN <results>->* TO <table>.
LOOP AT <table> ASSIGNING <structure>.
ASSIGN <structure>->* TO <data>.
ASSIGN COMPONENT `BASEAPIURL` OF STRUCTURE <data> TO <field>.
IF <field> IS ASSIGNED.
lr_data1 = <field>.
ASSIGN lr_data1->* TO <field_value>.
ls_final-baseapiurl = <field_value>.
ENDIF.
UNASSIGN: <field> , <field_value>.
APPEND ls_final TO gt_response.
ENDLOOP.
ASSIGN lr_data->* TO <data> .
ASSIGN COMPONENT `USERINFO` OF STRUCTURE <data> TO <results>.
ASSIGN <results>->* TO <data>.
ASSIGN COMPONENT `SESSIONID` OF STRUCTURE <data> TO <field>.
IF <field> IS ASSIGNED.
lr_data = <field>.
ASSIGN lr_data->* TO <field_value>.
ls_final-sessionid = <field_value>.
ENDIF.
UNASSIGN: <field>, <field_value>.
ASSIGN COMPONENT `STATUS` OF STRUCTURE <data> TO <field>.
IF <field> IS ASSIGNED.
lr_data = <field>.
ASSIGN lr_data->* TO <field_value>.
ls_final-status = <field_value>.
ENDIF.
UNASSIGN: <field>, <field_value>.
APPEND ls_final TO gt_response.
ENDIF.
ENDIF.
- Post request for task execution
Kod:
CONCATENATE '{' '"@type"' ':' '"job"' ' ,' '"taskName"' ':' '"' gv_jobname '"' ' ,' '"taskType"' ':' '"MTT"' '}' INTO lv_body .
lo_rest_client->if_rest_client~set_request_header(
EXPORTING
iv_name = 'IcSessionId'
iv_value = im_ssnid
).
lo_request->set_string_data( lv_body ).
lo_rest_client->if_rest_resource~post( lo_request ).
Conclusion:
In this blog post, I demonstrated how to communicate IICS server from SAP through REST APIs and trigger IICS task from SAP. Hope this blog post will help BW developers to achieve similar functionality.
Okumaya devam et...