Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
syam_yalamati
Product and Topic Expert
Product and Topic Expert

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.

Prerequisites:

To execute the supported integration scenarios between SSAM and SAP FSM, the following prerequisites must be met and assuming that the Proaxia FSM connector will be configured and set up to replicate the data between the SAP backend and SAP FSM system.
    • Proaxia FSM connector is configured and set-up to replicate data b/w SAP & FSM system
    • Enable 'External Id' flag under FSM connector Company definition section.
    • Implement BAdi methods to provide ID mapping between SAM & FSM.

Implementation Details:

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:

Enable 'External Id' flag under FSM connector Company definition settings

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

Implement BAdi methods to provide ID mapping between SSAM & FSM:

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.

  • Add local method GET_COMPID to determine the FSM company Id. This method required for the GET_EMPLOYEE_IDS BADI method in Step2. This method returns the following data:

    Import Parameter:  iv_account TYPE /pacg/ecm_cloudaccount.                                            Return Parameter: rv_compid TYPE /pacg/ecm_compid.
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.​
  • Implement BAdi method /MERP/IF_CA_FSM_CROSSREF_BADI~GET_EMPLOYEE_IDS:

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:

  1. ET_OBLNK: Object link table that has the unique Object IDs in Field Service Management for all the Personnel numbers specified in IT_PERNR with the following fields populated:
  2. OBJECT_KEY: Personnel number in the back end (LOW property in the range table)
  3. EXT_OBJECT_KEY: Object Id of the Employee/Person in Field Service Management.
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. ​

 

 

  • Implement the method /MERP/IF_CA_FSM_CROSSREF_BADI~GET_ACTIVITY_ID:

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.

 

Use the importing parameter IO_ACI_SERVICE to execute a service call to Field Service Management for retrieving the ID based on the code. See the following code example for more details.

 

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. ​
  • Implement the method /MERP/IF_CA_FSM_CROSSREF_BADI~GET_SERV_ASSIGN_ID:

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.​
  • Implement the method /MERP/IF_CA_FSM_CROSSREF_BADI~GET~GET_SERV_ASSIGN_STATUS_ID:

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.​

Known Issues:

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

Summary:

With the Integration Scenario explained above, SAP Service and Asset Manager (SSAM) can now be able to integrate with SAP Field Service Management (FSM). SSAM integrates directly with SAP FSM via MAIF from backend 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) etc., are replicated by the Proaxia connector. To support this direct integration from SAP SAM to SAP FSM, we provided dedicated BAdi options to ID mapping, to determine the cross-referencing of key fields between the FSM connector and FSM.

Please provide your feedback to improve the product features. Also, encourage you to follow the Mobile Application Integration Framework post and answer questions (https://answers.sap.com/tags/6baf0d27-c212-4154-85a9-71ed13c7b1ab), and read other posts on the topic for MAIF (https://blogs.sap.com/tags/6baf0d27-c212-4154-85a9-71ed13c7b1ab/) and SAP SAM (https://blogs.sap.com/tags/73555000100800000639/).

SAP Service and Asset Manager application metadata is available on the SAP Support Portal Software Center and the mobile client may be downloaded from the Apple App Store and Google Play Store. The Windows 1.0 application is available for customers and partners from the SAP Download Center, navigate to SAP SERVICE AND ASSET MANAGER > MOB SERVICE ASSET MANAGER WIN > MOB SVC ASSET MANAGER WIN 1.0 > MOB SVC ASSET MANAGER WIN 1.0.

We look forward to your comments. Stay up to date with latest news and post your questions or feedback about SAP Mobile in the Q&A area. Start by visiting our SAP Mobile Experience community page and click “follow”. We’ll be publishing more informative blog posts. Want to be notified? Check your #communications to ensure you have your notifications activated.
5 Comments
gonzalo_reyna
Participant
0 Kudos
Hi Syam,

Thank you very much for your valuable post.

I have a question regarding the integration at database tables level. When integrating SSAM with FSM, the order assignment type is similar to the one used with MRS (assignment type A)? By reading capacity requirements through table KBED?

Best regards,

Gonzalo.
syam_yalamati
Product and Topic Expert
Product and Topic Expert
Hi Gonzalo,

Thank you, the assignment type used for SSAM to FSM integration is via assignment type '2' - Operational level personnel number assignment. Since FSM dispatch work to technicians at activity level which is nothing but order operation, we need to set this configuration from SSAM application.

Thanks

Syam
mara_sol
Participant
0 Kudos
Hi Syam! Very valuable information.

Are "supporting technicians" assigned in FSM somehow shown in SAP Service and Asset Manager?

Example: In FSM Work Order X/Operation 10 is assigned to Person P1, and 2 supporting technicians (P2 and P3) are added.

When Person P1 receives Work Order X/Operation 10 in SAP Service and Asset Manager, does he know that P2 and P3 are supporting technicians for the job? Will he be able to declare time confirmation on behalf of P2 and P3?

Thanks!

Maria

 
syam_yalamati
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hi Maria,

Sorry for the delayed response, somehow it is missed from my inbox. Currently, SAP Service and Asset Manager does not support this feature, we will deliver supporting technicians in the coming releases.

Thanks

Syam
mara_sol
Participant
0 Kudos
Thanks Syam!!