(极力推荐)BW:How to load and generate a custom hierarchy in SAP Business Warehouse (SAP BW) without using flat files

2023-05-16

这篇文章,真是救了哥,所以非常感谢这位作者。你看,人家也是201123号才写的,量身打造,多好的人,刚好赶上我了。

   

PS:前段时间设计的文本抽取方式被否,为了去R3重建数据源,我找到了这篇文章,方法果然精辟,而且里面的内容价值很高,荐!

   

by Dirk Francis [ Senior SAP Business Warehouse Architect ]

Thursday, February 03, 2011

   

Introduction

Often reports need to show data in a tree-like structure. This is enabled via characteristic hierarchies in SAP BW. High level data is displayed using the top nodes of the hierarchy. More detailed data can be visualized by drilling down to the lower nodes of the hierarchy.

Consider an example hierarchy 'Customer Contacts Hierarchy' that is used to qualify the telephone calls a telecommunications call center receives.

   

Image 1: Customer Contacts Hierarchy

   

Standard mechanisms for loading hierarchies

There are several possibilities to supply the hierarchy with data in SAP BW:

  • Hierarchies can be maintained manually in SAP BW, however, doing this for large or frequently changing hierarchies is of course time consuming.
  • Hierarchies can be fetched automatically from all types of source systems. SAP delivers numerous BI Content datasources to extract standard data from SAP source systems for all kinds of industries and modules. This is also the case for lots of standard hierarchies, like profit center, organizational unit However, very often the hierarchy data is available in custom tables in the source system. SAP does not allow for custom hierarchies to be extracted with a generic datasource.
  • Hierarchies can also be extracted from external systems (non-SAP) using staging BAPI's (Business Application Programming Interface) or flat files, which can be generated automatically via a program and then loaded into the hierarchy InfoObject. When automating this procedure a problem is introduced that is not always easy to overcome; the physical flat file that is to be uploaded should be placed on the SAP BW server. This is not always possible for several reasons.
  • Last option to load a hierarchy is the data mart interface which allows loading data from within a SAP BW system or from another SAP BW system. The problem is that the hierarchy is not (yet) available in a SAP BW system. However, this option will prove to be very useful to enable a custom hierarchy extraction.

If you want to load a standard SAP hierarchy or a hierarchy based on a flat file, you can use one of the above mechanisms to fetch the data. However, when loading non-standard SAP hierarchies or hierarchies from other sources, you are facing one big problem. SAP BW only allows standard hierarchy datasources or flat file based hierarchy datasources and one thing is for sure, loading any type of hierarchy requires a datasource of type hierarchy to insert the data into the corresponding InfoObject tables! So there is no standardized way to load a custom hierarchy from a source system.

How can we work around this problem?

In short, the solution is to get the data into a DataStore Object (DSO) [1], make sure the InfoObject has the correct properties [2], load a dummy hierarchy (using the data mart interface) [3] and enhance this extraction in order to replace the dummy hierarchy with the data from the DSO [4]. This procedure will be explained in more detail below.

   

Image 2: Solution overview

   

1. DSO containing the Hierarchy Data

The first step is to get the hierarchy data into a DSO. We can use a transactional datasource for this purpose. A combination of the node ID and its parent node ID is enough to build a simple hierarchy.

   

Image 3: DSO ZDSOCUST

   

It is important to note that we do not need a hierarchy datasource. No matter what source of data and type of extractor, SAP allows various procedures to fetch the "transactional" data.

The DSO ZDSOCUST used in this example was populated with a simple flat file.

Contact;Description;Parent Contact

1001;Commercial;

1002;Technical Support;

1003;Change Contract;1001

1004;End Contract;1001

1005;New Contract;1001

1006;TV;1002

1007;Telephone;1002

1008;Internet;1002

1009;Up-sell;1003

1010;Down-sell;1003

1011;Side-sell;1003

1012;End;1004

1013;New;1005

1014;Digital TV;1006

1015;Analog TV;1006

1016;Mobile;1007

1017;Fixed;1007

2. Hierarchy InfoObject

Image 4: InfoObject Customer Contact

   

Using transaction code RSD1, maintain the InfoObject as an 'InfoSource with Direct Update'.

Choose an Application Component after enabling the corresponding checkbox. Depending on the InfoObject properties, this will allow loading attribute, text and hierarchy data for the characteristic.

Mark the characteristic as an InfoProvider by assigning it to an InfoArea. The InfoObject will then be displayed in the InfoProvider tree in the Data Warehousing Workbench.

Enable the characteristic as an export data source. This allows the extraction of the InfoObject data using the data mart interface.

Image 5 InfoObject Properties

   

源文档 <http://www.element61.be/e/resourc-detail.asp?ResourceId=189>

   

   

Obviously you will also need to specify that the InfoObject contains hierarchies. The exact settings, like time-dependent and versions, affect the tables being generated and this will in turn require specific coding in the datasource enhancement afterwards.

   

Image 6 InfoObject with hierarchies

   

3. Dummy Hierarchy Extraction

Now the InfoObject is correctly maintained and activated, we can build a dummy hierarchy, which we will use afterwards as a starting point for the data extraction. This manual process needs to be done only once (per SAP BW system in your landscape). Use the button 'Maintain Hierarchies' in order to create the dummy hierarchy.

   

Image 7 Creating a dummy hierarchy

   

Adding one (dummy) node to this hierarchy is sufficient to activate the hierarchy. A text node is the easiest to add.

Image 8 Using a dummy node

   

Image 9 Dummy hierarchy

   

The next step is generating an export datasource. This will in fact generate a data mart for extracting attributes (M), texts (T) and hierarchies (H), depending on the InfoObject settings. Go to the 'Data Warehousing Workbench' (transaction code RSA1) and right-click on the InfoObject. In the context menu, choose 'Additional Functions' > 'Generate Export DataSource'. The datasource typically gets the technical name 8 <'M', 'T' or 'H'> and can be found in the application component called 'Data Marts Master Data' (DM-IO) after replicating this application component in the datasources area of the Data Warehousing Workbench (remember to check the BW system itself as a source system on the top left of the screen). If this specific application component is not yet activate in your BW system, the new datasource can be found in the application component 'Unassigned Nodes' (NODESNOTCONNECTED).

Now we have a hierarchy datasource and we can link it to our InfoObject hierarchy via transfer rules. Hierarchy datasources are not yet supported using SAP Netweaver 2004s/7.0 technology and therefore we still need to use a SAP BW 3.5 datasource and transfer rules to build the connection. In fact we connect the InfoObject to itself. In order to create transfer rules, right-click on the hierarchy and use the context menu to go to 'Additional Functions' > 'Create transfer rules'. Next we need to select the correct source system. As we want to employ the export datasource we created earlier, select the same SAP BW system as the one you are logged on to. A list of all available datasources for that source system will pop up. Select the export datasource we created earlier. It should have the name 8 <'H'>. The transfer rules are generated automatically and in fact they establish the link between the export datasource and the InfoObject hierarchy.

Create a new Infopackage for the hierarchy datasource by right-clicking on the datasource and selecting 'Create Infopackage'. Give the Infopackage a descriptive name and refresh the 'available hierarchies from OLTP'. This will load all hierarchies that are available in the source. As we only created one dummy hierarchy, this will be the only hierarchy we can extract. Select this dummy hierarchy and save the Infopackage. It is advisable to rename the target hierarchy.

Image 10 InfoPackage

4. Extraction Enhancement

So far we have built a data flow that allows the extraction of a dummy hierarchy into a new hierarchy that is an exact copy of the original one. Now we still need to insert the hierarchy data that is currently residing in the DSO. This can be done in a user exit, an enhancement of the generated hierarchy datasource.

Image 11 Hierarchy dataflow

   

Hierarchy datasources can be enhanced like any other type of datasource. Each type has its own function module, within the enhancement "RSAP0001 - Customer function calls in the service API" that is called automatically during extraction:

  • EXIT_SAPLRSAP_001: Transactional data
  • EXIT_SAPLRSAP_002: Master data attributes or texts
  • EXIT_SAPLRSAP_004: Hierarchies

If enhancement RSAP0001 is not yet active in your system, it can simply be activated and assigned to a project.

The function module 'EXIT_SAPLRSAP_004' is called every time a hierarchy datasource is executed. It is part of the function group 'XRSA - Customer Exits in the Service API'. This function module contains an include called 'ZXRSAU04'. This include can be enhanced using ABAP coding to fetch the data from the DSO we loaded earlier. The most important table in this exit is table C_T_HIENODE which should be filled with the actual hierarchy data. This table has the type RSAP_T_HIENODE which is defined like the structure ROSHIENODE.

Image 12 Structure ROSHIENODE

Note that not all fields are required in order to successfully build your hierarchy. Depending on the hierarchy properties in the InfoObject settings, other fields and even other tables can become required.

The above example hierarchy is quite straight-forward and therefore it is sufficient to populate only a selection of fields of the table C_T_HIENODE; NODEID, IOBJNM, NODENAME, TLEVEL and PARENTID.

Let's have a more detailed look at these fields. The field NODEID has to be uniquely defined. The field IOBJNM should be filled with the InfoObject name 'ZCUSTCONT' or the value '0HIER_NODE' if you want to load a text node. The field NODENAME should be filled with the actual value (InfoObject value or the description of the text node). Compounded InfoObjects can also be used, but then we need to specify the compounded value as well. Imagine that our InfoObject ZCUSTCONT is compounded with country. If we fill the field NODENAME with the value "BE 1003", this value will be automatically split into the country "BE" and the Customer Contact "1003".

The next field is called TLEVEL and contains the hierarchy level of the node. If the hierarchy level of a node is not equal to the sum of the hierarchy level of its parents and 1, this will generate an error when loading the hierarchy. The top node of a hierarchy is called a root and multiple roots are allowed in a single hierarchy. This root node always has hierarchy level 1. PARENTID contains the node id of the parent.

Table 1 Populating C_T_HIENODE

According to your hierarchy properties, other fields and/or tables will be required. For example, if you have a time-dependent hierarchy, the fields DATEFROM and DATETO should be filled as well.

The field NODENAME has to be unique, except when the field LINK contains the value 'X' (in capitals!) which allows for one hierarchy node to be included several times in the hierarchy (at different hierarchy branches). In other words, one NODENAME can have multiple parent nodes. When using these duplicate hierarchy nodes in a report, the key figure value for that InfoObject value will be displayed multiple times in the hierarchy. Of course this key figure value will only be taken into account once in the result rows! When using intervals, you will also have to fill the table C_T_HIEINTV.

If we have a DSO that only contains the node id and its parent node id, we have enough information to build our hierarchy. However we need to calculate the hierarchy level manually. Best practice is to start with the root(s) and find its children, then find the children of those children and so on. Note that each root should of course be listed separately as well.

Let's take a closer look at the coding. As the include 'ZXRSAU04' is executed each time a hierarchy datasource is executed, it is recommended to make a distinction between the datasources.

This procedure makes sure that your coding is not executed when other hierarchy datasources are executed.

The first thing to do in the ABAP program is to delete the dummy hierarchy data from the internal table C_T_HIENODE.

Now we can set the hierarchy description 'Customer Contacts'.

Next we need to fetch the hierarchy data from the DSO into an internal table.

For each node we need to find out the hierarchy level and the node ID of its parent. Make sure all relevant fields are filled. As mentioned earlier, this varies according to the InfoObject properties. The easiest way is to work top-down and start with the root(s). A root is a node that does not have a parent. A hierarchy can consist of multiple roots. Once we have identified the roots, we can search for its children. Then we need to search for the children of the children. Every record is saved in the table C_T_HIENODE. We continue this process until every record is processed.

Now that we have completed the datasource enhancement, the last step is executing the Infopackage. This will populate the hierarchy based on the dataset that we previously loaded into a DSO. The complete loading procedure can be automated by implementing a process chain.

That's it! The hierarchy is ready for use in the SAP BW reports.

Conclusion

Using SAP NetWeaver BW 7.1 (or prior), there is no standardized way to load a custom hierarchy. Hierarchies can only be loaded using the BW 3.x data flow and datasource migration is impossible. The procedure described in this insight is a good workaround to enable an automated custom hierarchy extraction. With the brand new hierarchy framework that is delivered with SAP NetWeaver BW 7.30 , this will become easier as any type of datasource can be used.

   

源文档 <http://www.element61.be/e/resourc-detail.asp?ResourceId=189>

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

(极力推荐)BW:How to load and generate a custom hierarchy in SAP Business Warehouse (SAP BW) without using flat files 的相关文章

  • Objective C:向视图控制器添加加载视图

    在我的应用程序中 我的许多页面都需要一个加载屏幕 如何创建与下面的屏幕截图类似的加载效果 检查 MBProgressHUD https github com jk MBProgressHUD https github com jk MBPr
  • 如何在Flutter移动应用程序中加载和查询本地json数据

    这是我的核心价值配对本地 json 我需要加载 稍后我需要用于查询 那么 如何在Flutter移动应用中加载和查询本地json数据呢 currency 01 United State USD currency 17 British Poun
  • 在 R 中保存并重新加载“列表”对象

    我正在尝试将我手动创建的列表对象保存到以下内容中list我可以很快参考的格式 保存的对象应该能够作为list not df或任何东西 下面是我的列表对象的一部分 citations lt list as integer c 1 2 3 4
  • 如何只获取一次脚本

    所以这是一个简化的问题 我将其用作参考 以使这个问题变得简单 如果超过 x 像素 则使用 resize 来 getScript jQuery https stackoverflow com questions 11388247 using
  • 如何在运行时加载Assembly并创建类实例?

    我有一个集会 在这个程序集中我有一个类和接口 我需要在运行时加载此程序集 并想要创建该类的对象 并且还想使用该接口 Assembly MyDALL Assembly Load DALL DALL is name of my dll Type
  • AttributeError:模块“spacy”没有属性“load”

    import spacy nlp spacy load en core web sm Error Traceback most recent call last File C Users PavanKumar spyder py3 Exce
  • 在 Python 中跟踪文件加载进度

    我使用的许多模块都会将整个文件导入内存或在处理文件时将文件的内容滴入其中 我想知道是否有任何方法可以跟踪这种加载进度 可能是一个需要回调的包装类 我会通过确定文件的大小 然后简单地将总数除以读取的字节数来实现这一点 像这样 import o
  • Maui Android 无法从捆绑包加载

    我有一个毛伊岛 Android 应用程序一直在运行 但突然在启动过程中崩溃了 查看输出窗口日志 似乎无法从捆绑包中提取 dll 我已经包含来自输 出窗口的日志 也许这会帮助某人识别问题 我不得不稍微修剪一下日志 因为它太长而无法发布 For
  • jQuery 在网站/内容加载后淡入淡出?

    是否有任何教程或插件可以在网站正确加载后淡入视图 以限制任何不和谐等 使内容基本上顺利显示 我想如果它只是一个特定区域会更容易 因为页眉或页脚已经被缓存 从以前的页面 例如 带有各种缩略图的作品集页面 它们只有在准备好后才会顺利显示 这可以
  • onPageFinished() 从未调用过(webview)!

    我想在网络视图完全加载时显示一个祝酒词 但吐司从未出现 我不知道为什么 这是我的代码 public class WebViewSignUp extends Activity WebView mWebView Override public
  • 为什么 addEventListener 加载会阻止代码工作?

    Update 我原本有 document addEventListener DOMContentLoaded and链接到 HTML 文档头部的 JS 文件 结果是 另一个 js 脚本的某些部分无法正常工作 然后我将 DOMContentL
  • 如何将ListView分成多个部分并加载?

    我想知道我该如何划分我的ListView分成几部分 当用户启动我的应用程序时仅显示其中的一部分 并在用户按下名为 加载更多项目 的按钮时显示其他部分 我有一个包含 500 多个项目的大列表 并考虑将其分成几个部分 以便可以快速加载 我想要类
  • 是否可以使用 JavaScript 更改 document.readyState ?

    我正在通过网站上的 iframe 加载 HTML 正在加载的 HTML 应该等待父文档加载完成后才加载某些内容 document readyState interactive document readyState complete 问题在
  • Javascript 在 window.open 之后调用函数

    我试图在 window open 函数完全加载后调用一个函数 然而 使用 onload 函数调用得太早了 所点击的 URL 将打开一个 Excel 电子表格 下载可能需要 2 秒到 1 分钟 一旦 window open 函数被调用 onl
  • Jquery应用css加载div

    我在使用 css 将 css 动态应用到加载的 div 时遇到问题load 功能 找到正在加载的 html 并将其插入 我可以使用关闭命令 但是我尝试应用的 CSS 没有被注册 除去动态 CSS 之外 一切似乎都工作正常 我想我这里可能有问
  • 延迟加载插件 (jQuery)

    a lightbox hover function if jQuery lightbox required otherwise lightbox js will be loaded on hover each time a lightbox
  • 如何加载之前存储的svm分类器?

    我正在 Visual Studio 中使用 openCV SVM OpenCV 2 4 4 0 我训练它 mySVM train trainingDataMat labelsMat Mat Mat params 已保存 mySVM save
  • 将数据加载到 R 的最佳文件类型(速度方面)?

    我正在运行一些分析 得到了很多 2 3G 之间的数据集 现在 我将其另存为 RData文件类型 然后 稍后我加载这些文件以继续工作 这需要一些时间来加载 我的问题是 保存然后加载这些文件为 csv 会更快吗 是data table读取 cs
  • 将 sharepoint 2007 webpart 加载到 microsoft online emea?

    我在我的 Visual Studio 2007 中实现了 Web 部件 Hello World 项目中有 webpart cs webpart xml 和 webpart webpart 文件 我构建了洞项目 并尝试加载webpart we
  • 在页面加载之前运行 JavaScript 函数(设置适当大小的背景)

    我有一个图像背景 无论用户的分辨率是多少 我都希望其内容始终可见 因此 我希望能够在一开始就在页面加载之前确定分辨率并设置适当的背景图像文件 有可能吗 您可以运行可访问 DOM 的 Javascript 函数 无需等待页面加载 的最早点是放

随机推荐

  • c语言宏定义一个MAX函数

    1 span class token macro property span class token directive hash span span class token directive keyword define span sp
  • C++ -- 异常:try、throw、catch

    异常 申请内存的时候 xff0c 内存不够用 空间配置器申请失败 xff0c 不做处理 拷贝时内存错误 除数分母不能为0 等情况 会抛出异常 try throw catch 1 使用示例 1 xff09 除数为零 xff0c 情况 未处理情
  • C++ -- 笔试题

    1 下列对派生类的描述中错误的说法是 D A 派生类至少有一个基类 B 派生类可作为另一个派生类的基类 C 派生类除了包含它直接定义的成员外 xff0c 还包含其基类的成员 D 派生类所继承的基类成员的访问权限保持不变 2 当派生类中有和基
  • Linux 用户切换、修改用户名、修改密码

    一 用户切换 34 34 xff1a 普通用户提示符 34 34 xff1a root用户提示符 1 普通用户到root 方式一 xff1a 命令 xff1a su 然后输入root密码 此种方式只是切换了root身份 xff0c 但She
  • C++中的.和::和:和->的区别

    在学习C 43 43 的过程中我们经常会用到 和 和 xff1a 和 gt xff0c 在此整理一下这些常用符号的区别 1 A B则A为对象或者结构体 xff1b 2 A gt B则A为指针 xff0c gt 是成员提取 xff0c A g
  • AirSim学习日志 5-LQR实现无人机轨迹跟踪

    1 LQR控制器算法原理推导 1 1 状态反馈控制 连续线性系统的状态空间表示为 x
  • 英语常用短语

    1 xff0e 经济的快速发展 the rapid development of economy 2 xff0e 人民生活水平的显著提高 稳步增长 the remarkable improvement steady growth of pe
  • PX4进入系统控制台以及运行程序

    这里提供进入控制台两种办法 1 运行 Tools mavlink shell py dev ttyACM0 是我进入Px4系统控制台的命令 xff0c 进入之后应该是这样 Pixhawk src Firmware Tools mavlink
  • 哈哈,终于知道CSDN怎么改头像了

    话说之前一直郁闷 xff0c 说改头像的功能还没修好 xff0c 一直说服务器错误 今天偶尔发现 xff0c 右上角有个设置 xff0c 原来在这里可以改 我还发了几封邮件给CSDN的admin xff0c 居然只知道道歉 xff0c 不告
  • Hello Sky! pixhawk第一个例程学习解读

    学习px4的第一个程序 xff0c 这个例子作为官方给出解释的例程 xff0c 对于新手上手来说 xff0c 是很好的范例 接下来我对照程序源码 xff08 已经经过自己的修改和添加注释 xff09 进行讲解 1 PX4 INFO是标准的L
  • ShadowSSDT Hook

    ShadowSSDT表的获取 这里的ShadowSSDT表的获取是通过函数KeAddSystemServiceTable来获取的 使用这个函数的原因 xff1a 1 这个函数是已经导出的 xff0c 可以在代码中直接使用 2 这个函数里面使
  • 2013&2014

    2013总结 2013 毕业了 xff0c 算是正式工作半年 xff0c 2013年7月开始 xff0c 算是我的生活 xff0c 工作之外的时间都是自己的 一 收获 1 压力测试 差不多算是一个月的时间 xff0c 疯狂的一个月 xff0
  • BCTF总结

    缘由 上周 xff0c 我们小组Sigma参加了 百度杯 BCTF比赛 xff0c 经历了难忘的双休 xff0c 这次的BCTF跟以前参加的国内类似的安全比赛有些不同 xff0c 时间只有48小时 xff0c 题目不多 xff0c 但难度大
  • BCTF_海报探秘(300)

    这个题目来自上周的BCTF比赛 xff0c 题目是海报探秘 xff08 300 xff09 xff0c 一张png图片中隐藏了KEY xff0c 解出KEY xff0c 具体报告 xff0c 请下载 xff1a http download
  • 博客转移

    最近好久不来CSDN了 xff0c 自己搭建了一个博客 欢迎各位去新博客留言 http www l0g1n cn 以前学习汇编的博客 http www asmedu net blog user usermain jsp neighborId
  • 《Windows程序设计》之BLOKOUT1

    LRESULT CALLBACK WndProc HWND hwnd UINT message WPARAM wParam LPARAM lParam static BOOL fBlocking fValidBox static POINT
  • 天猫抢红包小工具源码

    时间很仓促 xff0c 写的很乱 xff0c 也就能用明天一天了 主要还是学习这个过程 include lt Windows h gt include lt stdio h gt include lt iostream gt include
  • vs2010开发qt程序debug正常,release出错

    在debug模式下 xff0c 配置的动态链接库是qtmaind lib QtGuid4 lib QtCored4 lib 这些链接库 xff0c 在release模式下是不适用的 xff0c 进入到qt的目录下 xff0c 发现了有一些不
  • cout与wcout

    一直以来只知道有cout用来输出 xff0c 今天用cout输出wchar时出现问题了 xff0c 输出结果是一段地址 xff0c 才发现了wcout的存在 使用wcout输出中文时 xff0c 又出现问题 xff0c 中文输出不了 xff
  • (极力推荐)BW:How to load and generate a custom hierarchy in SAP Business Warehouse (SAP BW) without using flat files

    这篇文章 xff0c 真是救了哥 xff0c 所以非常感谢这位作者 你看 xff0c 人家也是 2011 年 2 月 3 号才写的 xff0c 量身打造 xff0c 多好的人 xff0c 刚好赶上我了 PS xff1a 前段时间设计的文本抽