Wednesday, August 5, 2015

TIP: Wrong IMG showing in your system

We recently encountered a situation that after an install of SAP EM on an SNC server the SAP Event Management node was missing in the IMG structure (t-code SPRO). A work-around using transaction SIMGH is doable but the permanent fix is shown below...
SAP provided OSS note 2197261 (SPRO Use another SAP Reference IMG) to address this issue.
  1. Create, activate and execute report ZSLA_SHOW_REFERENCE_IMGS
  2. Follow the instructions mentioned in the report
  3. Copy the content of the clipboard into a text file
  4. Start transaction SCUSSEQUENCE
  5. Choose Hierarchy type SAP Reference IMG
  6. Press icon Change (F6)
  7. Enter an ID, which is different to SAP_----- for example Z_IMG
  8. Enter Switch to another IMG in field Description
  9. Enter the 32 digit GUID which came from the field TREE_ID into field Structure GUID (Copied to clipboard in report ZSLA_SHOW_REFERENCE_IMGS)
  10. Press icon Save (Ctrl+S)
  11. Save the changes in package BECU
*&---------------------------------------------------------------------*
*& Report ZSLA_SHOW_REFERENCE_IMGS
*&---------------------------------------------------------------------*
*& Shows different SAP Reference IMG and delivers the
*& corresponding Structure GUID
*&---------------------------------------------------------------------*


REPORT ZSLA_SHOW_REFERENCE_IMGS.
DATA SCUS_HIER_TABLE TYPE STANDARD TABLE OF SCUS_HIER WITH HEADER LINE.
DATA SCUS_HIER_TABLE_CHOOSEN LIKE STANDARD TABLE OF SCUS_HIER.
DATA SCUS_HIER_ROW LIKE SCUS_HIER.
DATA CHOOSEN_TREE_ID LIKE SCUS_HIER-TREE_ID.
DATA FELD(100). "for AT LINE-SELECTION
DATA WERT(100). "for AT LINE-SELECTION
DATA rc type i.
SELECT * FROM SCUS_HIER APPENDING TABLE SCUS_HIER_TABLE
   WHERE TYPE = 'IMGXX'.
SORT SCUS_HIER_TABLE BY TREE_ID.
DELETE ADJACENT DUPLICATES FROM SCUS_HIER_TABLE COMPARING TREE_ID.

NEW-LINE.
WRITE: 'Double-click on the TREE_ID to open the different SAP Reference IMG´s' COLOR 2.
NEW-LINE.
WRITE: 'If you have found the correct SAP Reference IMG, leave the reference ' COLOR 2.
NEW-LINE.
WRITE: 'IMG with Back (F3), and leave the report with Back (F3)' COLOR 2.
NEW-LINE.
WRITE: 'Now you can find the correct reference IMG TREE_ID in your clipboard' COLOR 2.
NEW-LINE.
WRITE: /, 6(20) 'ID' COLOR 5,
                  26(20) 'REPLACES' COLOR 5,
                  46(32) 'TREE_ID' COLOR 5.

NEW-LINE.
* Dataloop at SCUS_HIER_TABLE.
   WRITE: 6(20) SCUS_HIER_TABLE-ID COLOR 3,
                  26(20) SCUS_HIER_TABLE-REPLACES COLOR 3,
                  46(32) SCUS_HIER_TABLE-TREE_ID COLOR 2.
   NEW-LINE.
endloop.

AT LINE-SELECTION.
   READ TABLE SCUS_HIER_TABLE.
   GET CURSOR FIELD FELD.
   GET CURSOR VALUE SCUS_HIER_TABLE.
   CASE FELD.
     WHEN 'SCUS_HIER_TABLE-TREE_ID'.
       IF NOT SCUS_HIER_TABLE-TREE_ID IS INITIAL.
         SCUS_HIER_ROW = SCUS_HIER_TABLE.
         CALL FUNCTION 'STREE_BROWSER_DYNP_HC'
            EXPORTING
               STRUCTURE_ID = SCUS_HIER_TABLE-TREE_ID
               LANGUAGE = SY-LANGU.
       ENDIF.
     ENDCASE.
CLEAR SCUS_HIER_TABLE_CHOOSEN. REFRESH SCUS_HIER_TABLE_CHOOSEN.
APPEND SCUS_HIER_ROW TO SCUS_HIER_TABLE_CHOOSEN.

* Paste SCUS_HIER_TABLE_CHOOSEN to clipboard
CALL METHOD CL_GUI_FRONTEND_SERVICES=>CLIPBOARD_EXPORT
   IMPORTING
     DATA = SCUS_HIER_TABLE_CHOOSEN
   CHANGING
     RC = rc
   EXCEPTIONS
     CNTL_ERROR = 1
     ERROR_NO_GUI = 2
     NOT_SUPPORTED_BY_GUI = 3
     others = 4.
   IF SY-SUBRC <> 0.
     EXIT.
   ENDIF.