SAP ERP, SAP BW/4HANA

How to map SAP ERP fields to SAP BW/4HANA InfoObjects?

Introduction

It could be cumbersome for BW developers while trying to find appropriate InfoObjects to use in InfoProviders. BW developers often ask themselves if there are any standard InfoObjects that they can use for mapping with SAP ERP fields and therefore, use in the InfoProviders such as DSO.

In this blog post, I’m going to teach a way to find the mappings of SAP ERP fields with SAP BW/4HANA InfoObjects. The process I will talk about works also on SAP BW classic (3.X and 7.x).

At the end of this blog post, you’ll know how to find the standard InfoObject (if there are any) mappped with a SAP field and use in your InfoProvider.

Solution

In SAP BW classic versions, it was easier to find the right mapping for ERP fields, thanks to tables such as:

  • Table RSTRFIELDSH (Shadow table: Transfer Structure Fields)
  • Table RSOSFIELDMAP (Mapping Between OLTP Source Fields and InfoObjects)
  • Table RSTSFIELD (Transfer structure fields)

Since these tables don’t exist anymore in SAP BW/4HANA, I started thinking about utilizing the assignment rules in BI Content Transformations. These help us to find out what InfoObjects are used to be mapped with the source fields in the standard transformations.

I created a Program named ZMAP_FIELD_INFOOBJECT for this purpose. Create the same in your SAP BW/4HANA system. I suggest that you execute this program once in background and insert the output in a table for easier and faster access.

Based on the output of my Program, I designed a helper report. You can do the same for yourself or write your email for me in comments, if you want me to send this excel report to you.
To explain how this report works, I’m giving you an example. Let’s take MATNR for instance. Here, we see that the InfoObject 0MATERIAL is used 119 times in transformation rules to be mapped with MATNR.

Source of Program:

*&---------------------------------------------------------------------*
*& Report ZMAP_FIELD_INFOOBJECT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZMAP_FIELD_INFOOBJECT.

TABLES: RSTRAN, RSTRANRULE, RSTRANFIELD.

TYPES: BEGIN OF ST_RESULT,
         ZFIELDNM      TYPE RSFIELDNM, 
         ZIOBJNM       TYPE RSIOBJNM, 
         SOURCETYPE    TYPE RSO_TLOGO_SUBTYPE,
         SOURCENAME    TYPE SOBJ_NAME,
         TARGETTYPE    TYPE RSTLOGO,
         TARGETNAME    TYPE SOBJ_NAME,
         TRANID        TYPE RSTRANID,
         OBJVERS       TYPE RSOBJVERS,
         RULEID        TYPE RSTRAN_RULEID,
         SEQNR         TYPE RSTRAN_SEQNR,
         GROUPID       TYPE RSTRAN_GROUPID,
         GROUPTYPE     TYPE RSTRAN_GROUPTYPE,
         RULETYPE      TYPE RSTRAN_RULETYPE,
         SEGID         TYPE RSTRAN_SEGID,
         STEPID        TYPE RSTRAN_STEPID,
         PARAMTYPE     TYPE RSTRAN_PARAMTYPE,
         PARAMNM       TYPE RSFIELDNM,
         FIELDTYPE     TYPE RSTRAN_FIELDTYPE,
         RULEPOSIT     TYPE RSPOSIT,
         ZSOURCE_POSIT TYPE RSPOSIT,
         ZTARGET_POSIT TYPE RSPOSIT,
       END OF ST_RESULT.

DATA: WA_RESULT  TYPE ST_RESULT,
      WA_RESULT1 TYPE ST_RESULT,
      WA_RESULT2 TYPE ST_RESULT,
      IT_RESULT  TYPE TABLE OF ST_RESULT,
      IT_RESULT1 TYPE TABLE OF ST_RESULT,
      IT_RESULT2 TYPE TABLE OF ST_RESULT,
      LV_COUNT   TYPE I,
      GR_TABLE   TYPE REF TO CL_SALV_TABLE.

SELECT-OPTIONS: P_FIELD     FOR RSTRANFIELD-FIELDNM.


SELECT RSTRAN~TRANID
       RSTRAN~OBJVERS
       RSTRAN~SOURCETYPE
       RSTRAN~SOURCENAME
       RSTRAN~TARGETTYPE
       RSTRAN~TARGETNAME
       RSTRANRULE~RULEID
       RSTRANRULE~SEQNR
       RSTRANRULE~GROUPID
       RSTRANRULE~GROUPTYPE
       RSTRANRULE~RULETYPE
       RSTRANFIELD~SEGID
       RSTRANFIELD~STEPID
       RSTRANFIELD~PARAMTYPE "0=Importing - 1=Exporting
       RSTRANFIELD~PARAMNM
       RSTRANFIELD~FIELDTYPE "F=Field - I=InfoObject
       RSTRANFIELD~RULEPOSIT
  INTO CORRESPONDING FIELDS OF TABLE IT_RESULT1
  FROM RSTRAN
  INNER JOIN RSTRANRULE  ON RSTRAN~TRANID      = RSTRANRULE~TRANID
                        AND RSTRAN~OBJVERS     = RSTRANRULE~OBJVERS
  INNER JOIN RSTRANFIELD ON RSTRANRULE~TRANID  = RSTRANFIELD~TRANID
                        AND RSTRANRULE~OBJVERS = RSTRANFIELD~OBJVERS
                        AND RSTRANRULE~RULEID  = RSTRANFIELD~RULEID
  WHERE RSTRAN~OBJVERS      = 'D' "Content
    AND RSTRAN~SOURCETYPE   = 'RSDS' "DataSource
    AND RSTRANRULE~RULETYPE IN ('DIRECT' , 'TIME').


APPEND LINES OF IT_RESULT1 TO IT_RESULT.
DELETE IT_RESULT WHERE PARAMNM   NOT IN P_FIELD.
DELETE IT_RESULT WHERE PARAMTYPE NE 0
                   AND FIELDTYPE NE 'F'.
SORT IT_RESULT BY TRANID RULEID.


CLEAR: WA_RESULT.
LOOP AT IT_RESULT INTO WA_RESULT.
  WA_RESULT-ZSOURCE_POSIT = WA_RESULT-RULEPOSIT.
  WA_RESULT-ZFIELDNM = WA_RESULT-PARAMNM.

  CLEAR: WA_RESULT1, LV_COUNT, IT_RESULT2.
  LOOP AT IT_RESULT1 INTO WA_RESULT1 WHERE TRANID = WA_RESULT-TRANID
                                       AND RULEID = WA_RESULT-RULEID
                                       AND PARAMTYPE = 1
                                       AND FIELDTYPE = 'I'.
    APPEND WA_RESULT1 TO IT_RESULT2.
  ENDLOOP.

  IF SY-SUBRC NE 0.
  ENDIF.

  DESCRIBE TABLE IT_RESULT2 LINES LV_COUNT.
  IF LV_COUNT = 1.
    WA_RESULT-ZTARGET_POSIT = WA_RESULT1-RULEPOSIT.
    WA_RESULT-ZIOBJNM = WA_RESULT1-PARAMNM.
  ENDIF.

  MODIFY IT_RESULT FROM WA_RESULT.
ENDLOOP.

DELETE IT_RESULT WHERE ZIOBJNM IS INITIAL.
SORT IT_RESULT BY ZFIELDNM ZIOBJNM SOURCETYPE TARGETTYPE SOURCENAME TARGETNAME.


CALL METHOD CL_SALV_TABLE=>FACTORY
  IMPORTING
    R_SALV_TABLE = GR_TABLE
  CHANGING
    T_TABLE      = IT_RESULT.

CALL METHOD GR_TABLE->DISPLAY.