
SAP Service and Asset Manager (SSAM) Mobile Application integrates with SAP Field Service Management (FSM) as part of Field Service Technician persona using Proaxia connector. This scenario talks about ECC or S/4HANA Customer Service use case only, if you are looking for S/4HANA Service use case then please refer to my other blog: Integration of SAP Service and Asset Manager(SSAM) with SAP FSM to support S/4HANA Service Processes.
SAP SAM is now integrated with SAP FSM planning board and show the current status of orders and tracks technician’s location to facilitate scheduling and dispatching. As part of this Integration, SAP SSAM also supports FSM Smartforms and allows the SAM mobile application to download, modify and upload FSM Smartforms assigned to an activity/operation.
Process flow for SAP SAM Integration with SAP FSM
SAP SAM integrated directly with SAP FSM using the Service and Data APIs provided by SAP FSM. However, the underlying objects that need to be updated, (e.g. Service Orders (Service Calls in FSM), Operations (Activities in FSM), Employees (Persons in FSM) are created by the Proaxia connector. Therefore, the following pre-requisites must be implemented for the end-to-end scenarios to work.
The following sections will explain the details on how to implement these prerequisites.
Make sure Proaxia FSM connector is configured and set-up in your environment to replicate data b/w SAP & FSM system. For more details about Proaxia connector, refer to the following documentation:
From SAP backend system, use menu option of FSM Connector, Customizing --> Objects --> Company --> Company Definition (Transaction Code: /PACG/ECM_COMP).
FSM Connector Company Definition
By enabling the External Id flag, you can switch on sending the External Id from the FSM connector to FSM.
Enable External Id from FSM Connector settings
Mobile Application Integration Framework (MAIF), which supports SAM backend integration features, provides different BAdi options to determine cross-referencing of key fields between FSM Connector and FSM Cloud system. The Badi /MERP/CA_FSM_CROSSREF_BADI is delivered for both ERP & S/4HANA system to support this feature with following interface methods.
BAdi Interface for FSM Id mapping
The following code samples are an example, you may need to make additional adjustments for your environment.
METHOD get_compid. DATA: lv_string1 TYPE string, lv_string2 TYPE string, lv_account TYPE string, lv_fsmaccount TYPE /pacg/ecm_cloudaccount, lv_fsmcompany TYPE /pacg/ecm_cloudid, lv_compid TYPE /pacg/ecm_compid, ls_cacc TYPE /pacg/ecm_cacc. lv_account = iv_account. SPLIT lv_account AT '&account=' INTO lv_string1 lv_string2. SPLIT lv_string2 AT '&company=' INTO lv_string1 lv_string2. lv_fsmaccount = lv_string1. lv_fsmcompany = lv_string2. ls_cacc = /pacg/ecm_cl_d_access=>get_cloudcomp_definition( iv_cloudaccount = lv_fsmaccount iv_cloudid = lv_fsmcompany ). rv_compid = ls_cacc-compid. ENDMETHOD.
This method is a prerequisite for saving geolocations captured from SAP SAM to the SAP FSM planning and scheduling board.The method must return the FSM internal Employee ID(s) (Field id of the Field Service Management Person entity) based on the personnel number(s) provided.Use the importing parameter IO_ACI_SERVICE to execute a service call to Field Service Management for retrieving the id based on the code in the following code example.
NOTE: The assumption is that the ExternalId field for the ‘Person’ entity in FSM is populated with the internal format of the Personnel number in SAP. If this is not the case, then the lv_cloud_name may need to be used to query the ExternalId.
This method returns the following data:
METHOD /merp/if_ca_fsm_crossref_badi~get_employee_ids. TYPES: BEGIN OF ty_error, error TYPE string, END OF ty_error. TYPES: BEGIN OF ty_fsmitem, id TYPE string, externalid TYPE string, username TYPE string, END OF ty_fsmitem. TYPES: BEGIN OF ty_persondata, person TYPE ty_fsmitem, END OF ty_persondata. DATA: lv_pernr_query TYPE string, ls_oblnk TYPE /smfnd/sync_d_oblnk_h_upd_str, lv_id TYPE /smfnd/sync_object_key_dte, lv_url TYPE string, lv_char_code TYPE n LENGTH 3, lt_persondata TYPE STANDARD TABLE OF ty_persondata, ls_persondata LIKE LINE OF lt_persondata, lt_error TYPE STANDARD TABLE OF ty_error, ls_error LIKE LINE OF lt_error, lv_status_code TYPE i, lv_reason TYPE string, lv_result TYPE string, lv_raw_data TYPE xstring, lv_compid TYPE /pacg/ecm_compid, lv_cloud_uname TYPE /pacg/ecm_cloud_uname, ls_pernr LIKE LINE OF it_pernr. TYPES: BEGIN OF ty_personresp, data LIKE lt_persondata, END OF ty_personresp. DATA: ls_personresp TYPE ty_personresp. IF io_aci_service IS BOUND. IF it_pernr IS INITIAL. RETURN. ENDIF. lv_compid = get_compid( iv_account ). LOOP AT it_pernr INTO ls_pernr. CLEAR lv_pernr_query. IF ls_pernr-low IS NOT INITIAL. TRY. lv_cloud_uname = /pacg/ecm_cl_x_util=>build_cloud_uname( iv_pernr = ls_pernr-low iv_compid = lv_compid ). CATCH /pacg/ecm_cx_main. "No FSM user exists CONTINUE. ENDTRY. CONCATENATE lv_pernr_query 'externalId="' ls_pernr-low '"' INTO lv_pernr_query. ENDIF. IF lv_pernr_query IS NOT INITIAL. CONCATENATE '/api/data/v4/Person?dtos=Person.24' '&query=' lv_pernr_query '&fields=id,externalId,userName' iv_account INTO lv_url. CALL METHOD io_aci_service->call_service EXPORTING iv_request_uri = lv_url iv_request_method = 'GET' it_headers = it_headers IMPORTING ev_status_code = lv_status_code ev_reason = lv_reason ev_result = lv_result ev_raw_data = lv_raw_data. lv_char_code = lv_status_code. IF lv_char_code CP '4*'. ls_error-error = lv_result. APPEND ls_error TO lt_error. ELSE. /aci/cl_util_json_handler=>deserialize( EXPORTING json = lv_result CHANGING data = ls_personresp ). LOOP AT ls_personresp-data INTO ls_persondata. lv_id = ls_persondata-person-id. ls_oblnk-object_type = 'EMPLOYEE'. ls_oblnk-object_key = ls_pernr-low. ls_oblnk-ext_object_type = 'PERSON'. ls_oblnk-ext_object_key = lv_id. ls_oblnk-sys_comp = 'SAM_FSM'. ls_oblnk-mobile_app = iv_mapp. APPEND ls_oblnk TO et_oblnk. CLEAR ls_oblnk. ENDLOOP. ENDIF. ENDIF. ENDLOOP. ENDIF. ENDMETHOD.
This method is a prerequisite for implementing the relevant status updates from SAP SAM to the SAP FSM planning and scheduling board. This method must return the Field Service Management internal activity ID (the id field of the Field Service Management Activity entity) based on the order and operation number provided.
METHOD /merp/if_ca_fsm_crossref_badi~get_activity_id. TYPES: BEGIN OF ty_fsmitem, id TYPE string, externalid TYPE string, END OF ty_fsmitem. TYPES: BEGIN OF ty_error, error TYPE string, END OF ty_error. TYPES: BEGIN OF ty_actdata, activity TYPE ty_fsmitem, END OF ty_actdata. DATA: lv_act_query TYPE string, lv_id TYPE /smfnd/sync_object_key_dte, lv_url TYPE string, lv_char_code TYPE n LENGTH 3, lt_actnr TYPE STANDARD TABLE OF /pacg/ecm_actnr, lv_actnr TYPE /pacg/ecm_actnr, lv_object_key TYPE /smfnd/sync_object_key_dte, lt_error TYPE STANDARD TABLE OF ty_error, ls_error LIKE LINE OF lt_error, lt_actdata TYPE STANDARD TABLE OF ty_actdata, ls_actdata LIKE LINE OF lt_actdata, lv_status_code TYPE i, lv_reason TYPE string, lv_result TYPE string, lv_raw_data TYPE xstring, lv_aufnr_len TYPE i, lo_descr TYPE REF TO cl_abap_elemdescr, ls_aufnr_dfies TYPE dfies. TYPES: BEGIN OF ty_actresp, data LIKE lt_actdata, END OF ty_actresp. DATA: ls_actresp TYPE ty_actresp. IF io_aci_service IS BOUND. IF iv_aufnr IS INITIAL OR iv_vornr IS INITIAL. RETURN. ENDIF. lv_object_key = iv_aufnr. lo_descr ?= cl_abap_elemdescr=>describe_by_data( iv_aufnr ). ls_aufnr_dfies = lo_descr->get_ddic_field( ). lv_aufnr_len = ls_aufnr_dfies-leng. lv_object_key+lv_aufnr_len = iv_vornr. "Get all activitties for order operation SELECT actnr INTO TABLE lt_actnr FROM /pacg/ecm_acti WHERE aufnr = iv_aufnr AND vornr = iv_vornr. "Get the newest activity SORT lt_actnr DESCENDING. READ TABLE lt_actnr INTO lv_actnr INDEX 1. IF sy-subrc IS NOT INITIAL. RETURN. ENDIF. CONCATENATE lv_act_query 'externalId="' lv_actnr '"' INTO lv_act_query. IF lv_actnr IS NOT INITIAL. CONCATENATE '/api/data/v4/Activity?dtos=Activity.39' '&query=' lv_act_query '&fields=id,externalId' iv_account INTO lv_url. CALL METHOD io_aci_service->call_service EXPORTING iv_request_uri = lv_url iv_request_method = 'GET' it_headers = it_headers IMPORTING ev_status_code = lv_status_code ev_reason = lv_reason ev_result = lv_result ev_raw_data = lv_raw_data. lv_char_code = lv_status_code. IF lv_char_code CP '4*'. ls_error-error = lv_result. APPEND ls_error TO lt_error. ELSE. /aci/cl_util_json_handler=>deserialize( EXPORTING json = lv_result CHANGING data = ls_actresp ). LOOP AT ls_actresp-data INTO ls_actdata. lv_id = ls_actdata-activity-id. es_oblnk-object_type = 'OPERATION'. es_oblnk-object_key = lv_object_key. es_oblnk-ext_object_type = 'ACTIVITY'. es_oblnk-ext_object_key = lv_id. es_oblnk-sys_comp = 'SAM_FSM'. es_oblnk-mobile_app = iv_mapp. ev_id = ls_actdata-activity-id. EXIT. ENDLOOP. ENDIF. ENDIF. ENDIF. ENDMETHOD.
This method is a prerequisite for implementing relevant status updates from SAP SAM to the SAP FSM planning and scheduling board. The method must return the FSM internal activity ID (the idfield of the Field Service Management Activity entry) based on the order and operation number provided.Use the QUERY_FSM_SERVICEASSIGN method from the /MERP/CL_CA_FSM_INTEGRATION class to get this value based on the following code example.
METHOD /merp/if_ca_fsm_crossref_badi~get_serv_assign_id. DATA lref_fsm_integration TYPE REF TO /merp/cl_ca_fsm_integration. TRY. " Create FSM object CREATE OBJECT lref_fsm_integration EXPORTING iv_mapp = iv_mapp. CATCH /merp/cx_core_exception_gen INTO DATA(lref_badi_exception). RETURN. ENDTRY. " Fetch Service Assignment from FSM if it exists lref_fsm_integration->query_fsm_serviceassign( EXPORTING iv_aufnr = iv_aufnr iv_vornr = iv_vornr iv_activity_id = iv_activity_id IMPORTING ev_id = ev_id ev_activity_id = ev_activity_id es_oblnk = es_oblnk ). ENDMETHOD.
This method is a prerequisite for implementing relevant status updates from SAP SAM to the SAP FSM planning and scheduling board. Use the QUERY_FSM_SERVICEASSIGNSTATUS method from the /MERP/CL_CA_FSM_INTEGRATION class to get this value based on the following code example.
METHOD /merp/if_ca_fsm_crossref_badi~get_serv_assign_status_id. DATA lref_fsm_integration TYPE REF TO /merp/cl_ca_fsm_integration. TRY. " Create FSM object CREATE OBJECT lref_fsm_integration EXPORTING iv_mapp = iv_mapp. CATCH /merp/cx_core_exception_gen INTO DATA(lref_badi_exception). RETURN. ENDTRY. lref_fsm_integration->query_fsm_serviceassignstatus( EXPORTING iv_aufnr = iv_aufnr iv_vornr = iv_vornr iv_activity_id = iv_activity_id IMPORTING ev_id = ev_id es_oblnk = es_oblnk ). ENDMETHOD.
During initial sync in SAP Service & Asset Manager 2210 application, no FSM Smartforms are downloaded onto the mobile client. This is because while downloading the FSM Smartforms Instance the associated activity IDs mapping can not be found. Following SAP Notes will fix these issues:
3308616 - FSM Smartform Instances cannot find associated activity ID - SAP ONE Support Launchpad
3311163 - All controls in an FSM Smart Form are read-only in SAP Service & Asset Manager
3312313 - Changes to FSM Smart Forms on mobile don't get reflected on FSM Planning Board UI
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
2 | |
2 | |
2 |