Thursday, 29 October 2015

ICT_SERVICE_DESK_API : CRM - Solution Manager - Categorise an Incident without Catalog / CodeGroup / Code combo...

Fully geeking out on CRM at the moment. Present remit is to integrate a third party helpdesk system with our SAP Solution Manager helpdesk... The SAP provided ICT interface is pretty good, but as ever you need to call your friendly neighbourhood ABAPer to finesse it into exactly what you want!

Right now, our config guys have told me that they're reluctant to tie together the Categories to the Catalog / CodeGroup / Code that ICT expects, so I'm having to use an enhancement point to update the Categories on our Helpdesk incidents...

Here's my stub program...

REPORT  YPD_INCIDENT_CATEGORISE.

datai_call type CRMT_OBJECT_ID VALUE '7000000941'.

datals_partner type CRMT_PARTNER_COM,
      lt_partner type CRMT_PARTNER_COMt,
      lt_guid type CRMT_OBJECT_GUID_TAB,
      ls_guid type CRMT_OBJECT_GUID,
      lt_input_fields type CRMT_INPUT_FIELD_TAB,
      ls_input_fields type CRMT_INPUT_FIELD,
      ls_field_names type CRMT_INPUT_FIELD_NAMES,
      lt_field_names TYPE CRMT_INPUT_FIELD_NAMES_TAB,
      lt_orderadm_h TYPE CRMT_ORDERADM_H_COMT,
      ls_orderadm_h type crmt_orderadm_h_com,
      lt_exception type CRMT_EXCEPTION_T,
      lt_sales type CRMT_SALES_COMT,
      ls_sales type CRMT_SALES_COM,
      lt_service_os type CRMT_SRV_OSSET_COMT,
      ls_service_os type CRMT_SRV_OSSET_COM,
      ls_osset type CRMT_SRV_OSSET_COM1,
      ls_subject type CRMT_SRV_SUBJECT_COM,
      LS_GUID16 TYPE guid_16.

CALL FUNCTION 'CRM_ORDERADM_H_GUID_GET_DB'
  EXPORTING
    IV_OBJECT_ID           i_call
  IMPORTING
    ET_GUID                lt_guid
 EXCEPTIONS
   RECORD_NOT_FOUND       1
   OTHERS                 2.

READ TABLE lt_guid into ls_guid INDEX 1.

check ls_guid is not INITIAL.



"Trying to Categorise the call....
ls_service_os-ref_guid ls_guid.
ls_service_os-ref_kind 'A'.

CALL FUNCTION 'GUID_CREATE'
 IMPORTING
    EV_GUID_16       ls_guid16.

ls_subject-ref_guid ls_guid16.
ls_subject-asp_id 'EDENHOUSE SOLUTIONS'.
ls_subject-cat_id 'AIC_CAT01_03_06'.
ls_subject-katalog_type 'D'.

INSERT ls_subject into table ls_osset-subject.

CALL FUNCTION 'GUID_CREATE'
 IMPORTING
    EV_GUID_16       ls_guid16.

ls_osset-ref_guid ls_guid16.
ls_osset-profile_type 'A'.

insert ls_osset  into TABLE ls_service_os-osset.

insert ls_service_os INTO TABLE lt_service_os.

"Do the input fields too...


*ls_input_fields-REF_HANDLE
ls_input_fields-REF_GUID     ls_service_os-ref_guid.
ls_input_fields-REF_KIND     'A'.
ls_input_fields-OBJECTNAME   'SERVICE_OS'.









ls_field_names-fieldname 'ASP_ID'.
INSERT ls_field_names INto table ls_input_fields-FIELD_NAMES.
ls_field_names-fieldname 'CAT_ID'.
INSERT ls_field_names INto table ls_input_fields-FIELD_NAMES.
ls_field_names-fieldname 'CODE'.
INSERT ls_field_names INto table ls_input_fields-FIELD_NAMES.
ls_field_names-fieldname 'CODEGRUPPE'.
INSERT ls_field_names INto table ls_input_fields-FIELD_NAMES.
ls_field_names-fieldname 'KATALOGART'.
INSERT ls_field_names INto table ls_input_fields-FIELD_NAMES.
ls_field_names-fieldname 'MODE'.
INSERT ls_field_names INto table ls_input_fields-FIELD_NAMES.
ls_field_names-fieldname 'REF_GUID'.
INSERT ls_field_names INto table ls_input_fields-FIELD_NAMES.


insert ls_input_fields into TABLE lt_input_fields.

  CALL FUNCTION 'CRM_ORDER_MAINTAIN'
    EXPORTING
*      it_partner                  = lt_partner
       it_service_os               lt_service_os
*      it_sales                    = lt_sales
*      it_service_h                = lt_service_h
  IMPORTING
      ET_EXCEPTION                  lt_exception
    CHANGING
      ct_input_fields              lt_input_fields
    EXCEPTIONS
      error_occurred               1
      document_locked              2
      no_change_allowed            3
      no_authority                 4
      OTHERS                       5.



CALL FUNCTION 'CRM_ORDER_SAVE'
  EXPORTING
    IT_OBJECTS_TO_SAVE           lt_guid
 EXCEPTIONS
   DOCUMENT_NOT_SAVED           1
   OTHERS                       2
          .
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.


commit work and wait.


No comments:

Post a Comment