Standardization is a key aspect of
SAP BW Layered, Scalable Architecture (LSA), SAP’s best practice in Enterprise Data Warehousing. One of the ways to realize standardization in the data staging process is developing generic, reusable ABAP building blocks with a comprehensive interface.
In every data flow we have to deal with the first inbound mapping of DataSource fields to InfoObjects within the transformation. Therefore, it makes sense to identify this process as a modeling pattern and use such a building block to facilitate the process. Let’s call it
Mapping Services.
This document describes how the ABAP Objects classes for Mapping Services were developed, including all necessary ABAP Workbench objects.
Please refer to my blog Mapping Services - Inbound Mapping of DataSource Fields to InfoObjects for a conceptual overview and more information on maintaining the mapping control table and calling Mapping Services in the context of the transformation.
Please have a look
here to download the attachments.
Mapping Services Class
The class
YCL_BW_MAPPING is a reusable building block and facilitates the mapping from DataSource fields to InfoObjects during the first inbound transformation, i.e. in the Data Acquisition Layer the transformation from DataSource to Outbound InfoSource.
This chapter describes how the class is developed.
Use the Class Builder to create the class
YCL_BW_MAPPING. Go here via t/code
SE24 or SAP menu path:
Tools > ABAP Workbench > Development > Class Builder
Source Code of the Implementing Class
Please refer to the attached text document for the source code of the class
YCL_BW_MAPPING.
You can easily copy and paste the source code in the Class Builder. Switch from the "Form-Based" to the "Source Code-Based" maintenance.
Overview of the Attributes
The following attributes are defined:
- P_DATASOURCE - DataSource (OSOA/OSOD);
- P_R_EXCEPTIONS - BW Mapping Exception Class;
- P_R_REQUEST - Interface Between IPRO Admin Tab and Request;
- P_SOURCEOBJECT - Source Object for a DTP;
- P_SOURCESYSTEM - Source System for DataSource;
- P_SOURCETYPE - Type of Source Object for a DTP;
- P_TH_MAPPING - Mapping Table.
Overview of the Methods
The following methods are implemented:
- EXECUTE - Execute Mapping Services (Expert Routine);
- CHECK_MAPPING - Check if Mapping can be Executed;
- GET_SOURCEOBJECT - Determine Source Object (DataSource);
- MAIN_PROCEDURE - Main Procedure to Execute Mapping;
- READ_BW_CONTROL_FROM_DB - Read BW Control Table from Database.
Exception Class
The class YCX_BW_MAPPING is created to facilitate exception handling using the “class-based exception” concept. Most of the implementation is carried out automatically. Below you can find an overview of all necessary additions to the generated proposal.
Use the Class Builder to create the exception class
YCX_BW_MAPPING. Go here via t/code
SE24 or SAP menu path:
Tools > ABAP Workbench > Development > Class Builder
Please note to create the exception class with the option "with message class".
Figure 1: Create Exception Class - Initial Screen
Properties
The Properties should look as follows. Make sure that message class
YBWMAP is specified.
Figure 2: Exception Class - Properties
Interfaces
The Interfaces should look as follows. Make sure that
IF_T100_MESSAGE is present since it's crucialfor maintaining the T100 messages. If it's missing, you can add it manually.
Figure 3: Exception Class - Interfaces
Attributes
Please find below an overview of all attributes which have to be added manually. The automatically generated attributes are not described.
Attribute |
Level |
Visibility |
Read only |
Typing |
Associated type |
Description |
DATASOURCE |
Instance Attribute |
Public |
Yes |
Type |
ROOSOURCER |
DataSource (OSOA/OSOD) |
DSFIELDNAME |
Instance Attribute |
Public |
Yes |
Type |
RSFIELDNM |
DataSource Field name |
SOURCESYSTEM |
Instance Attribute |
Public |
Yes |
Type |
RSDLOGSYS |
Source System for DataSource |
TGTFIELDNAME |
Instance Attribute |
Public |
Yes |
Type |
RSFIELDNM |
Target Field name |
Table 1: Attributes
Texts
Please find below an overview of the custom defined exception texts. As you might have noticed, every message is connected to a corresponding T100 message.
Exception ID |
Text |
T100 Message |
Attributes |
TARGET_FIELD_MISSING |
Target field name &TGTFIELDNAME& is missing in result package |
YBWMAP 003 |
TGTFIELDNAME |
DATASOURCE_FIELD_MISSING |
DataSource field name &DSFIELDNAME& is missing in BW control table |
YBWMAP 002 |
DSFIELDNAME |
MAPPING_TABLE_NO_RECORDS |
No suitable records for DataSource &DATASOURCE& &SOURCESYSTEM& in BW control table |
YBWMAP 001 |
DATASOURCE
SOURCESYSTEM |
SOURCE_OBJECT_FAILED |
Source object determination failed |
YBWMAP 000 |
|
Table 2: Exception Texts
Methods
Next to the automatically generated methods, one additional method has to be created: CREATE_LOG_REC. This method is used to create a record for log object in the context of the expert routine. Please refer to the attached text document for the source code of method
CREATE_LOG_REC.
Other ABAP Workbench Objects
In this chapter, the remaining ABAP workbench objects are discussed. The following objects have to be developed:
- T100 messages;
- Search Helps;
- BW control table.
T100 Messages
A new message class
YBWMAP (Mapping Services) has to be created. This message class contains the various messages used in exception class
YCX_BW_MAPPING.
To create the message class
YBWMAP, use t/code
SE91 or SAP menu path:
Tools > ABAP Workbench > Development > Programming Environment > Messages
Message |
Message Short Text |
Self-expl. |
000 |
Source object determination failed |
Yes |
001 |
No suitable records for DataSource &1 &2 in BW control table |
Yes |
002 |
DataSource field name &1 is missing in BW control table |
Yes |
003 |
Target field name &1 is missing in result package |
Yes |
Table 3: Message Class
Search Helps
Two search helps have to be created:
- YBW_DSFIELD: Search Help for DataSource Fields;
- YBW_IOBJFNM: Search Help InfoObject and Field Name.
To create the search helps, use t/code
SE11 or SAP menu path:
Tools > ABAP Workbench > Development >ABAP Dictionary
Figure 4: Search Help for DataSource Fields
Figure 5: Search Help InfoObject and Field Name
BW Control Table
BW Control Table
YBWMAPPING has to be created. The table should be created as “customizing table” and “table maintenance” enabled. A table maintenance dialog can be generated for this table but is not described any further.
To create the table, use t/code
SE11 or SAP menu path:
Tools > ABAP Workbench > Development >ABAP Dictionary
The delivery and maintenance settings of the BW Control Table are as follows.
Figure 6: BW Control Table - Delivery and Maintenance Settings
Table
YBWMAPPING is used by the class
YCL_BW_MAPPING. This table stores the mapping rules. The configuration of the table looks as follows.
Figure 7: BW Control Table - Fields
Figure 8: BW Control Table - Entry Help/Check
The following foreign key relationships have to be maintained.
Figure 9: BW Control Table - Foreign Key (1)
Figure 10: BW Control Table - Foreign Key (2)
Figure 11: BW Control Table - Foreign Key (3)