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)
Thank you very much sir for posting such a fantastic blog ,
i am a new bee to BW, Sir i did as you mentioned but i got error and my control table is also not filled can you help me please
short dump details:
message i168(rsmpc) with p_rnr
l_s_cubes-infocube
l_dtp_rnr l_dtp_sid.
continue.
endif.
endloop.
loop at l_t_cubes into l_s_cubes.
l_idx = sy-tabix.
select * from rsmonicdp into table l_h_icdp where
icube = l_s_cubes-infocube.
loop at p_t_datapakid into l_s_datapakid.
read table l_h_icdp into l_s_icdp with table key
icube = l_s_cubes-infocube
rnr = p_rnr
dp_nr = l_s_datapakid-low.
if sy-subrc = 0 and
l_s_icdp-status(3) = icon_green_light(3) ).
if l_s_icdp-aufrufer <> '66'.
delete l_t_cubes index l_idx.
exit.
endif.
endif.
endloop.
endloop.
break luxm. "#EC NOBREAK
l_s_minfo-t_infocube[] = l_t_cubes[].
if l_t_cubes[] is initial and
l_s_minfo-type = 'D'.
>>>> message x000.
else.
*** OSS 935625
perform fill_reprocess_tables using p_rnr
l_t_cubes[]
l_t_datapakid[].
***
call function 'RSAR_REQUEST_INTERPRETER_1'
exporting
i_request = p_rnr
i_t_datapakid = p_t_datapakid
* I_DATAPAKID =
* I_IDOC_DOCNUM =
i_s_minfo = l_s_minfo
i_parallel_procs = l_par_procs
* TABLES
* L_T_TABU_TRANS =
changing
c_t_idocstate = l_t_idocstate
c_subrc = l_subrc
Screen Shot:
Hi Vamshi,
The shortdump shows standard SAP coding but it's not clear for me what you have done to trigger the shortdump. Is it during the execution of a DTP?
It's difficult for me to check what you have done and might have forgotten. Let me give the right order of activities:
Please check if all development objects are correct and created in the right order. Please also check the guidelines mentioned in my blog Mapping Services - Inbound Mapping of DataSource Fields to InfoObjects.
Best regards,
Sander
yes sir ,
i loaded data to PSA when i load data from PSA to info cube i am getting this error. i created transformation in that i added expert routine as you mentioned but i have a doubt that i didn't map the source columns to target infocube(becoz i used expert routine so i can't map it ) and you mentioned that it will get the mapping information from control table which i created but i created control table which doesn't hold any data(ofcourse it's newly created table).step 7 is missing(so i think i need to fill the control table with source and target columns initiallly then transformation will pick from the control tables but filling for all the data sources is also a time consuming job i guess).instead of that can we fetch the details from RSOSFIELDMAP table( by providing OLTP SOURCE = 2LIS_11_VAITM )and map it to the respective colums and fill the TARGET_PACKAGE.can you please help me?
Hi Vamshi,
Step 7 (Fill the Mapping Control Table with mapping rules) is essential. The program will dynamically map source fields (i.e. DataSource fields) with target fields (e.g. InfoSource) based on the information found in the Mapping Control Table. If your DataSource is 2LIS_11_VAITM, then you should create mapping rules for all source fields (many fields in this case, around 300 fields if I remember correctly).
The maintenance of the Mapping Control Table can be time-consuming. That's why I came up with the idea of so-called Data Warehouse InfoObjects. Please see my blog Introducing Data Warehouse InfoObjects - Part 1: Conceptual Overview for the concept. In addtion to that, I created another add-on to generate those Data Warehouse InfoObjects in an automated way. Please refer to my blog Generating Data Warehouse InfoObjects - Part 1: Introduction. As a bonus, it will also fill the Mapping Control Table in an automated way.
Bottom-line is that both add-ons are complementary. You do not have to use them together but it certainly pays off and can lead to a significant efficiency improvement in populating your Data Warehouse layer.
Best regards,
Sander
Hi Sir ,
I Created all the components on BI as well as ECC side and only one error i am getting i checked and even added type groups in class RSD,RSSB even still i am getting the error like below.
Hi Vamshi,
I wonder on what BW release (and SP level) you are working. It might be lower than release 7.3. In my system (BW 7.31 SP 10) I can find the constant in Type Group RSD. It looks as follows:
CONSTANTS:
BEGIN OF rsd_c_bexfl,
false TYPE rsdbexfl VALUE ' ',
reporting TYPE rsdbexfl VALUE ' ',
true TYPE rsdbexfl VALUE 'X',
activation TYPE rsdbexfl VALUE 'X',
never TYPE rsdbexfl VALUE 'N',
END OF rsd_c_bexfl.
If in your system the above coding cannot be found in Type Group RSD, then I suggest as a work-around to write similar coding in the Class.
Best regards,
Sander
Now everything working fine, last question can i move this to production or not?
hi Sir i am extracting 2LIS_02_ITM My Unit Key figure catalog is not filling
But in DSO i can able to see key figures related to units
this is my application log details
even after activating DSO and creating transformation from DSO to Info cube it is not providing mapping for relevant fields automatically.why?
Hi Vamshi,
Let's continue with a new reply since the window is becoming too small.
Best regards,
Sander
it's really great.thank you sir and thank you scn.
Hi Vamshi,
Re. your questions of Jan 15, 2015 I would like to react as follows.
Q: Now everything working fine, last question can i move this to production or not?
A: Please make sure that everything is complete and working fine. Solve any error messages you find in the logs. Use the Transport Connection to collect all objects and create appropriate transport requests.
For the records in the control table (e.g. YBWMAPPING), it depends how to transport them. If you created a Table Maintenance view using t/code SE54 with a "transportable" setting, then a transport request is automatically proposed. Otherwise you have to create a transport request manually (R3TR TABU).
Q: My Unit Key figure catalog is not filling
A: I expect that your Unit InfoObject Catalog is not created in a proper way. The system probably has stored the Units in the "not assigned" InfoObject Catalog 0UNINOTASSIGNED.
You cannot create a Unit InfoObject Catalog the normal way (only Characteristic and Key Figure are allowed). Please use a work-around the copy function using t/code SE16. Table RSDIOBC. Make a copy of InfoObject Catalog 0UNINOTASSIGNED and choose an appropriate name and InfoArea. Go back to t/code RSA1, Modeling view > InfoObjects and activate the InfoObject Catalog from here. Please make sure to update the corresponding parameter in table YBWADMIN accordingly.
Q: ... this is my application log details
A: Please have a close look at the error messages and solve them. Please refer to my blog Generating Data Warehouse InfoObjects - Part 4: Optimizing Results for some common cases.
Q: even after activating DSO and creating transformation from DSO to Info cube it is not providing mapping for relevant fields automatically.why?
A: Please solve first all errors and make sure your transport requests are complete (do not forget to also transport the table contents of the Mapping Table).
Please note that you have to write a small piece of coding in the Expert Routine as explained in my blog Mapping Services - Inbound Mapping of DataSource Fields to InfoObjects.
Last but not least, please try to post questions in the appropriate blog or document. Although there is a relation between the various Add-ons, it is becoming a bit hard to follow. Alternatively and maybe even a better approach, create a new Discussion in SAP Business Warehouse. Thanks in advance.
Best regards,
Sander
Hi Sander,
are the attachments available only for a limited time.
I also did not found the IOBJ generation codes.
Are there any other sources that might provide a backup or could you send me a copy.
Thanks Dirk
Hi Sander,
cool post! Could you please share source codes. They are any more available after migration to new scn portal ?
radek.herskovic@seznam.cz
Radek
Hi,
The attachments were lost during migration and cannot be added anymore in the blog.
Please have a look at Q&A https://answers.sap.com/questions/183690/where-can-i-find-attachments-of-blog-implementing-10.html to download the attachments.
Best regards,
Sander
Hi Sander,
Even though this was written five years ago it is still GOLD. Thank you for your posting.
Regards,
Owen