Wednesday, 6 January 2016

If Line Exists...

New to ABAP 740 (okay, that's well old, but new to me) this blog describes how to use the itab function "if line_exists"


Looks really useful!

Monday, 23 November 2015

CTRL-N

Opens a new session... Just like Word, Outlook, Chrome, Notebook etc etc.

Press Ctrl-N in GUI. Now triggers new session. Useful. 3 of my colleagues hadn't heard about this, so thought it worth broadcasting! SAP starts to behave a bit like other software. Good.

Wednesday, 11 November 2015

WSDL Loading

So my third party gave me a WSDL that needs to be consumed. I was using the wizard in SE80, when I get the following error : 

"Proxy Generation : Error Occurred" Incorrect Value: Entity (1/0) Unexpected End of file.

Okay.

Now the WSDL was a text file that was sent to me via e-mail. I'd just saved it from Outlook onto my desktop...

I was able to double check the WSDL using this website:

https://www.wsdl-analyzer.com/service/service/1118547868?version=1

which took a copy of the file and gave me a natty little report on how well formed the file was. It didn't much like my WSDL, and told me the same thing that SAP did... not happy!

I then cut and pasted WSDL content into Eclipse in a new WSDL file, saved that to my desktop. Eclipse seemed to like it. Once that had been saved to the DT, it passed the SAP and WSDL Analyser.

My only summation is that there must be something in notepad / outlook that messes up the WSDL definition...

Wednesday, 4 November 2015

Creating data on the fly... just like Javascript and Visual Basic!

This blog from Horst (hero!) describes one of the "new" features of the ABAP editor.

http://scn.sap.com/community/abap/blog/2013/05/23/abap-news-for-release-740--inline-declarations

This is ace! No more jumping up to the data declarations or local variable declarations. Just do them on the fly!

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.

data: i_call type CRMT_OBJECT_ID VALUE '7000000941'.

data: ls_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.


Friday, 23 October 2015

UI5 Product Locator App


Was just putting this baby to bed and realised that I'd not blogged it yet!




Anyway, it was a stack of fun to develop, and if anyone wants something like this on their SAP system, get in touch with EdenhouseSolutions!

Wednesday, 21 October 2015

CRM Add Partner to Incident

The following function can be used to add bespoke partner functions to SAP CRM Incidents - in this case, a "Requester".
The bit that threw me was the need for a BAPI-Commit after the CRM_ORDER_SAVE; it seems SAP have added another layer of flexibility / complexity


FUNCTION 
ZSHA_ORDER_MAINTAIN_ADD.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(I_CALL) TYPE  CRMT_OBJECT_ID
*"     REFERENCE(I_REQUESTER) TYPE  CRMT_PARTNER_NO
*"     REFERENCE(I_SOLD_TO) TYPE  CRMT_PARTNER_NO
*"----------------------------------------------------------------------

data: ls_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.

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

READ TABLE lt_guid into ls_guid INDEX 1.

ls_partner-ref_guid = ls_guid.
ls_partner-ref_kind = 'A'.
ls_partner-ref_partner_handle = '0001'.
ls_partner-kind_of_entry = 'C'.
ls_partner-partner_fct = 'Z0000015'.
ls_partner-partner_no = i_requester.
if ls_partner-partner_no(4) ne '0000'.
  CONCATENATE '0000' ls_partner-partner_no into ls_partner-partner_no.
endif.

ls_partner-display_type = 'BP'.
ls_partner-no_type = 'BP'.


append ls_partner to lt_partner.

*ls_input_fields-REF_HANDLE
ls_input_fields-REF_GUID     = ls_guid.
ls_input_fields-REF_KIND     = 'A'.
ls_input_fields-OBJECTNAME   = 'PARTNER'.
ls_input_fields-LOGICAL_KEY  = '0001'.



ls_field_names-fieldname = 'DISPLAY_TYPE'.
INSERT ls_field_names INto table ls_input_fields-FIELD_NAMES.
ls_field_names-fieldname = 'KIND_OF_ENTRY'.
INSERT ls_field_names INto table ls_input_fields-FIELD_NAMES.
ls_field_names-fieldname = 'NO_TYPE'.
INSERT ls_field_names INto table ls_input_fields-FIELD_NAMES.
ls_field_names-fieldname = 'PARTNER_FCT'.
INSERT ls_field_names INto table ls_input_fields-FIELD_NAMES.
ls_field_names-fieldname = 'PARTNER_NO'.
INSERT ls_field_names INto table ls_input_fields-FIELD_NAMES.

append ls_input_fields to lt_input_fields.



*ls_orderadm_h-guid = ls_guid.
*append ls_orderadm_h to lt_orderadm_h.


  CALL FUNCTION 'CRM_ORDER_MAINTAIN'
    EXPORTING
*      it_activity_h               = lt_activity_h
*      it_appointment              = lt_appointment
*     it_text                      = lt_text
      it_partner                  = lt_partner
*      it_service_os               = lt_service_os
*      it_status                   = lt_status
*      it_sales                    = lt_sales
*      it_service_h                = lt_service_h
  IMPORTING
      ET_EXCEPTION                  = lt_exception
    CHANGING
*      ct_orderadm_h                = lt_orderadm_h
      ct_input_fields              = lt_input_fields
**    CV_LOG_HANDLE                =
**    CT_PARTNER_ATTRIBUTES        =
**    CT_DOC_FLOW                  =
    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
*   IV_UPDATE_TASK_LOCAL         = FALSE
*   IV_SAVE_FRAME_LOG            = FALSE
*   IV_NO_BDOC_SEND              = FALSE
*   IT_ACTIVE_SWITCH             =
* IMPORTING
*   ET_SAVED_OBJECTS             =
*   ET_EXCEPTION                 =
*   ET_OBJECTS_NOT_SAVED         =
* CHANGING
*   CV_LOG_HANDLE                =
*   CT_NOCHECK_BEFORE_SAVE       =
 EXCEPTIONS
   DOCUMENT_NOT_SAVED           = 1
   OTHERS                       = 2
          .
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.


commit work and wait.

ENDFUNCTION.