Skip to Content

Objective: When we are working on BW to HANA migration projects, we may convert existing Multiprovider to Composite provider however comparison is always difficult job to check all mappings are correct between MultiProvider and Composite Provider, because in HANA there is no standard table  for Composite Provider mapping table (as we have for MultiProvider RSDICMULTIIOBJ) hence written below program to compare mapping between MultiProvider and Composite Provider and give results either mapping is correct or incorrect.

Sample Program Output

Program

*&----------------  -----------------------------------------------------*
*& Report ZBW_MP_CP_MAPPING_COMPARE
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZBW_MP_CP_MAPPING_COMPARE.


PARAMETERS: W_MP   TYPE RSOHCPRNM OBLIGATORY,
            W_MP_I TYPE RSOHCPRNM OBLIGATORY,
            W_CP   TYPE RSOHCPRNM OBLIGATORY,
            W_CP_I TYPE RSOHCPRNM OBLIGATORY.

*Declartions:

*Types
TYPES: BEGIN OF TY_FDISP,
         MPSQNO        TYPE I,
         MPNAME(30)    TYPE C,
         MPPNAME(30)   TYPE C,
         MPINAME(30)   TYPE C,
         MPMAPNAME(30) TYPE C,
         CPNAME(30)    TYPE C,
         CPPNAME(30)   TYPE C,
         CPINAME(30)   TYPE C,
         CPMAPNAME(30) TYPE C,
         RESULT(10)    TYPE C,
       END OF  TY_FDISP.


TYPES: BEGIN OF TY_CP,
         INFOPROVIDER TYPE RSDODSOBJECT,
         TARGET       TYPE RSOHCPRCOLNM,
         SOURCE       TYPE RSDIOBJNM,
       END OF TY_CP.


DATA: IT_FIELDCAT    TYPE SLIS_T_FIELDCAT_ALV,
      WA_FIELDCAT    TYPE SLIS_FIELDCAT_ALV,
      WA_FIELDLAYOUT TYPE SLIS_LAYOUT_ALV,
      W_REPID        TYPE SY-REPID,
      V_HCPR_XML_DEF TYPE XSTRING,
      T_MP_D         TYPE STANDARD TABLE OF RSDICMULTIIOBJ,
      LT_XML_INFO    TYPE STANDARD TABLE OF SMUM_XMLTB,
      LT_CP          TYPE STANDARD TABLE OF TY_CP,
      LT_RETURN      TYPE STANDARD TABLE OF BAPIRET2,
      LT_FDISP       TYPE STANDARD TABLE OF TY_FDISP,
      WA_FDISP       TYPE TY_FDISP,
      WA_CP          TYPE TY_CP,
      L_CVALUE       TYPE CHAR255,
      L_OFFSET       TYPE I,
      L_CP           TYPE TY_CP.


FIELD-SYMBOLS: <FS_XML_INFO> TYPE SMUM_XMLTB,
               <T_MP_D>      TYPE RSDICMULTIIOBJ.


START-OF-SELECTION.
  W_REPID = SY-REPID.

  PERFORM GET_MP_DETAILS.
  PERFORM GET_CP_DETAILS.
  PERFORM GET_COMP_MP_CP.
  PERFORM SET_BUILD_CATALOG.
  PERFORM SET_DISP_RESULT.


*----------------------------
*FORMS

FORM GET_MP_DETAILS.
  SELECT * FROM RSDICMULTIIOBJ INTO TABLE T_MP_D
    WHERE INFOCUBE = W_MP AND
    PARTCUBE = W_MP_I AND
    OBJVERS = 'A'.

ENDFORM.

FORM GET_CP_DETAILS.
  SELECT SINGLE XML_UI
    FROM RSOHCPR
    INTO V_HCPR_XML_DEF
    WHERE HCPRNM = W_CP
    AND OBJVERS = 'A'.


* Parse XML string to XML table
  CALL FUNCTION 'SMUM_XML_PARSE'
    EXPORTING
      XML_INPUT = V_HCPR_XML_DEF
    TABLES
      XML_TABLE = LT_XML_INFO
      RETURN    = LT_RETURN.

* Find the mapping objects like target and source
  LOOP AT LT_XML_INFO ASSIGNING <FS_XML_INFO>.

    IF <FS_XML_INFO>-CNAME = 'entity'.
      L_CVALUE = <FS_XML_INFO>-CVALUE.
      SEARCH L_CVALUE FOR 'composite'.
      L_OFFSET = SY-FDPOS.
      L_OFFSET = L_OFFSET - 1.
      TRY.
          L_CP-INFOPROVIDER = <FS_XML_INFO>-CVALUE(L_OFFSET).
        CATCH CX_SY_RANGE_OUT_OF_BOUNDS.
          L_CP-INFOPROVIDER = <FS_XML_INFO>-CVALUE.
      ENDTRY.
    ELSEIF
     <FS_XML_INFO>-CNAME = 'targetName'.
      L_CP-TARGET = <FS_XML_INFO>-CVALUE.
    ELSEIF
      <FS_XML_INFO>-CNAME = 'sourceName'.
      L_CP-SOURCE = <FS_XML_INFO>-CVALUE.
      APPEND L_CP TO LT_CP.
    ENDIF.

    IF <FS_XML_INFO>-CNAME = 'infoObjectName' AND
       <FS_XML_INFO>-CVALUE CP '*__*'.
      L_CP-SOURCE = <FS_XML_INFO>-CVALUE.
      L_CP-TARGET = <FS_XML_INFO>-CVALUE.
      APPEND L_CP TO LT_CP.
    ENDIF.

  ENDLOOP.

ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  GET_COMP_MP_CP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_COMP_MP_CP .

  SORT T_MP_D BY IOBJNM.
  SORT LT_CP BY INFOPROVIDER TARGET.
  LOOP AT T_MP_D ASSIGNING <T_MP_D>.
    CLEAR: WA_FDISP.

    WA_FDISP-MPSQNO  = SY-TABIX.
    WA_FDISP-MPNAME = <T_MP_D>-INFOCUBE.
    WA_FDISP-MPPNAME = <T_MP_D>-PARTCUBE.
    WA_FDISP-MPINAME = <T_MP_D>-IOBJNM.
    WA_FDISP-MPMAPNAME = <T_MP_D>-PARTIOBJ.

    READ TABLE LT_CP INTO WA_CP WITH KEY
       INFOPROVIDER = W_CP_I
       TARGET =  <T_MP_D>-IOBJNM BINARY SEARCH.
    IF SY-SUBRC EQ 0.
      WA_FDISP-CPNAME = W_CP.
      WA_FDISP-CPPNAME = WA_CP-INFOPROVIDER.
      WA_FDISP-CPINAME = WA_CP-TARGET.
      WA_FDISP-CPMAPNAME = WA_CP-SOURCE.

      IF <T_MP_D>-PARTIOBJ = WA_CP-SOURCE.
        WA_FDISP-RESULT = ICON_CHECKED.
      ELSE.
        WA_FDISP-RESULT = ICON_INCOMPLETE.
      ENDIF.
      APPEND WA_FDISP TO LT_FDISP.

    ELSE.

      IF <T_MP_D>-IOBJNM CP '*__*'.
        READ TABLE LT_CP INTO WA_CP WITH KEY
        INFOPROVIDER = ''
        TARGET =  <T_MP_D>-IOBJNM BINARY SEARCH.
        IF SY-SUBRC EQ 0.
          WA_FDISP-CPNAME = W_CP.
          WA_FDISP-CPPNAME = W_CP.
          WA_FDISP-CPINAME = WA_CP-TARGET.
          WA_FDISP-CPMAPNAME = WA_CP-SOURCE.

          IF <T_MP_D>-PARTIOBJ = WA_CP-SOURCE.
            WA_FDISP-RESULT = ICON_CHECKED.
          ELSE.
            WA_FDISP-RESULT = ICON_INCOMPLETE.
          ENDIF.
          APPEND WA_FDISP TO LT_FDISP.

        ELSE.
          WA_FDISP-CPNAME = W_CP.
          WA_FDISP-CPPNAME = WA_CP-INFOPROVIDER.
          WA_FDISP-CPINAME = 'InfoObject missing'.
          WA_FDISP-CPMAPNAME = 'InfoObject missing'.
          WA_FDISP-RESULT = ICON_INCOMPLETE.
          APPEND WA_FDISP TO LT_FDISP.
        ENDIF.
      ELSE.
        WA_FDISP-CPNAME = W_CP.
        WA_FDISP-CPPNAME = WA_CP-INFOPROVIDER.
        WA_FDISP-CPINAME = 'InfoObject missing'.
        WA_FDISP-CPMAPNAME = 'InfoObject missing'.
        WA_FDISP-RESULT = ICON_INCOMPLETE.
        APPEND WA_FDISP TO LT_FDISP.

      ENDIF.

    ENDIF.
  ENDLOOP.
ENDFORM.

FORM SET_BUILD_CATALOG.

  WA_FIELDCAT-FIELDNAME  = 'MPSQNO'.
  WA_FIELDCAT-SELTEXT_M  = 'Sq No'.
  WA_FIELDCAT-OUTPUTLEN  = 30.
  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  WA_FIELDCAT-FIELDNAME  = 'MPNAME'.
  WA_FIELDCAT-SELTEXT_M  = 'MultiProvider '.
  WA_FIELDCAT-OUTPUTLEN  = 30.
  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  WA_FIELDCAT-FIELDNAME  = 'MPINAME'.
  WA_FIELDCAT-SELTEXT_M  = 'InfoObject'.
  WA_FIELDCAT-OUTPUTLEN  = 30.
  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  WA_FIELDCAT-FIELDNAME  = 'MPPNAME'.
  WA_FIELDCAT-SELTEXT_M  = 'MP Part InfoProvider'.
  WA_FIELDCAT-OUTPUTLEN  = 30.
  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  WA_FIELDCAT-FIELDNAME  = 'MPMAPNAME'.
  WA_FIELDCAT-SELTEXT_M  = 'Part Infoobject'.
  WA_FIELDCAT-OUTPUTLEN  = 30.
  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  WA_FIELDCAT-FIELDNAME  = 'CPNAME'.
  WA_FIELDCAT-SELTEXT_M  = 'Composite Provider'.
  WA_FIELDCAT-OUTPUTLEN  = 30.
  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  WA_FIELDCAT-FIELDNAME  = 'CPINAME'.
  WA_FIELDCAT-SELTEXT_M  = 'InfoObject'.
  WA_FIELDCAT-OUTPUTLEN  = 30.
  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  WA_FIELDCAT-FIELDNAME  = 'CPPNAME'.
  WA_FIELDCAT-SELTEXT_M  = 'CP Part InfoProvider'.
  WA_FIELDCAT-OUTPUTLEN  = 30.
  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  WA_FIELDCAT-FIELDNAME  = 'CPMAPNAME'.
  WA_FIELDCAT-SELTEXT_M  = 'Part InfoObject'.
  WA_FIELDCAT-OUTPUTLEN  = 30.
  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  WA_FIELDCAT-FIELDNAME  = 'RESULT'.
  WA_FIELDCAT-SELTEXT_M  = 'Mapping Status'.
  APPEND WA_FIELDCAT TO IT_FIELDCAT.

  WA_FIELDLAYOUT-COLWIDTH_OPTIMIZE = 'X'.
  WA_FIELDLAYOUT-INFO_FIELDNAME    = 'LINE_COLOR'.
  WA_FIELDLAYOUT-ZEBRA             = 'X'.
ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  GET_DISP_RESULT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM SET_DISP_RESULT .


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      IT_FIELDCAT        = IT_FIELDCAT
      IS_LAYOUT          = WA_FIELDLAYOUT
      I_CALLBACK_PROGRAM = W_REPID
    TABLES
      T_OUTTAB           = LT_FDISP
    EXCEPTIONS
      PROGRAM_ERROR      = 1
      OTHERS             = 2.

ENDFORM.
To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Matthew Billingham

    I’m sure your program is quite useful – it looks it to me – but if I may make a few comments.

    When you post code, it’s better to use the {;} button in the editor to paste it. Then it looks like this:

    PARAMETERS: W_MP   TYPE RSOHCPRNM OBLIGATORY,
                W_MP_I TYPE RSOHCPRNM OBLIGATORY,
                W_CP   TYPE RSOHCPRNM OBLIGATORY,
                W_CP_I TYPE RSOHCPRNM OBLIGATORY.

    Which, I’m sure you’ll agree is much easier to read and understand.

    PERFORM is an obsolete ABAP keyword. You should really use classes and methods. In this case, a simple local class would be sufficient.

    Finally, rather than use REUSE_ALV_GRID_DISPLAY, with all that tedious playing with the field catalog, which not use CL_SALV_TABLE. It requires less coding (at its simplest, just two lines of code) and produces excellent results.

    DATA alv TYPE REF TO cl_salv_table.
    
    cl_salv_table=>factory( IMPORTING r_salv_table = alv CHANGING t_table = LT_FDISP ).
    alv->display( ).

    See here for a richer example: https://blogs.sap.com/2013/05/08/using-new-abap-stuff-method-chaining-and-clsalvtable/

    Do you think you might take on my comments, and edit your blog with these improvments?

    (0) 
    1. Nanda Anantha Post author

      Thanks for your comment and suggestions.

      In fact initially I used cl_salv_table however output column headlines are displaying blank because those are all custom columns not standard ones.

      Anyway when I get sometime I will make changes.

      (1) 
      1. Matthew Billingham
        DATA col TYPE REF TO cl_salv_column_table.
        col ?= alv->get_columns( )->get_column( 'MY_COLUMN' ).
        col->set_short_text( 'Short' ).
        col->set_medium_text( 'Medium' ).
        col->set_long_text( 'Long' ).

        Easy!

        (0) 

Leave a Reply