(极力推荐)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 的相关文章

  • 从 C# 项目的资源区域加载图像

    我的项目中有一张图像存储在 Resources myimage jpg 中 如何动态将此图像加载到 Bitmap 对象中 您使用的是 Windows 窗体吗 如果您使用 属性 资源 UI 添加了图像 则可以从生成的代码访问该图像 因此您可以
  • 从groovy脚本加载脚本

    文件1 groovy def method println test 文件2 groovy method 我想在运行时加载 包含 File1 groovy 中的函数 方法 相当于 ruby s rake 的加载 它们位于两个不同的目录中 如
  • %CPU 列和负载在顶部

    我的一个 C 应用程序在顶部显示非常高的 CPU 但负载却相当低 myapp 总是占用 30 左右 显示在 top 命令的最顶部 但负载总是像 0 00 所以我很困惑负载和 CPU 列之间有什么区别 top 14 09 54 up 62 d
  • 在 R 中保存并重新加载“列表”对象

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

    在 MainActivity 中 我创建了 DownloadTask 它填充模型类 然后通过 CustomListAdapter 类填充列表视图 但我创建了函数来识别滚动结束 并且我想将更多项目加载到列表视图中 我正在互联网上阅读和查看代码
  • 将文本文件加载到 RichTextBox 的最快方法是什么?

    我使用 OpenFIleDialog 将文本文件加载到 RichTextBox 中 但是 当大量文本 例如大约 50 70 行的歌曲文本 并且我单击 打开 时 程序会挂起几秒钟 3 5 秒 正常吗 也许有一些更快的方法或组件来加载文本文件
  • 如何调试“无法加载文件或程序集”运行时错误?

    我有一个使用 Java 库转换的项目IKVM http www ikvm net 我添加了创建的 DLL 以及所有可能的 IKVM DLL 作为对我的项目的引用 但是当我运行它时 出现以下运行时错误 System IO FileNotFou
  • iPhone异步文件加载?

    有没有办法异步加载iPhone中的本地文件 我使用以下方法为我的 uitableview 加载 uiimages NSData imageData NSData alloc initWithContentsOfFile fileName U
  • Node.js Express 模块未正确加载

    Geos Mac hone georgiana npm list Users georgiana local hone email protected cdn cgi l email protection email protected c
  • Unity3D 构建后加载资源

    我有很多组图像 PNG 它们放置在Resources项目的 Assets 文件夹中 使用编辑器时 我可以毫无问题地从不同的子文件夹加载图像 只需简单地使用Resources Load 命令并提供我尝试加载的特定图像的路径 例如 firstL
  • 将页面加载设置为黑色而不是白色背景?

    网站链接 http www ideagang co home php http www ideagang co home php 从一页点击到另一页时是否可以将背景设置为黑色 现在 网站以黑色背景完美加载 只是当我从一个页面导航到另一个页面
  • 加载后 JavaScript 不会执行

    我的网站包含链接 当我点击一次时 目标 HTML 内容会使用 JQuery 加载到 div 中 到目前为止没有问题 我的问题是 当第三次加载下面的搜索页面时 脚本将不会执行 h1 span Search span h1 p class bi
  • 如何在 C++ 中加载共享对象?

    我有一个共享对象 so Windows dll 的 Linux 等效项 我想将其导入并与我的测试代码一起使用 我确信这不是那么简单 但这就是我想做的事情 include headerforClassFromBlah h int main l
  • 是否可以使用 JavaScript 更改 document.readyState ?

    我正在通过网站上的 iframe 加载 HTML 正在加载的 HTML 应该等待父文档加载完成后才加载某些内容 document readyState interactive document readyState complete 问题在
  • 如何在 C# 中获取每个核心的 CPU 负载?

    如何在 C 中获取每个核心 四核 cpu 的 CPU 负载 谢谢 您可以使用 WMI 或 System Diagnostics 命名空间 从那里您可以获取任何您想要的性能计数器 但是需要一秒钟 1 1 5秒 来初始化这些计数器 读取值是可以
  • 导入 Python 模块时 __package__ 为 None

    我想通过以下方式动态导入模块 我创建一个名为 pkg 的文件夹 其结构如下 pkg init py foo py 在头 init py 添加此代码片段 pkgpath os path dirname pkg file for module
  • Jquery应用css加载div

    我在使用 css 将 css 动态应用到加载的 div 时遇到问题load 功能 找到正在加载的 html 并将其插入 我可以使用关闭命令 但是我尝试应用的 CSS 没有被注册 除去动态 CSS 之外 一切似乎都工作正常 我想我这里可能有问
  • 为什么当某些内容已加载时 jQuery 会丢失“事件”(点击)?

    当我在侧边栏上选择页面时 我尝试使用下一个脚本加载内容 该脚本运行没有问题 if Modernizr history var newHash wrapperTag main content contentTag main content i
  • 双击打开 Excel 工作簿时,Excel 2010 AddIn 未加载

    我为 Excel 2010 编写了一个加载项 如果我从 开始 菜单打开 Excel 它可以正常工作 但是 如果我双击 Excel 工作簿 则无法加载 AddIn 我签入了ThisAddIn cs 方法InternalStartup 没有参与
  • LC3 LEA指令和存储的值

    我对这个问题感到困惑 指令后寄存器0中存储的值是多少 LEA R0 A 被处决了吗 为什么答案是x370C 我认为应该将A的地址加载到R0中 如果是这样我们怎么知道地址 有人可以帮忙吗 非常感谢 ORIG X3700 LEA R0 A LD

随机推荐

  • 明朝开国第一重臣李善长长子李祺之长子李芳后裔在松滋

    明朝开国第一重臣李善长长子李祺之长子李芳后裔在松滋 李善长 xff0c 何许人也 肩比汉代丞相萧何 xff1b 功臣里排位第一 xff0c 比刘伯温 徐达 汤和 常遇春 蓝玉 李文忠地位高 xff1b 太师 xff0c 左丞相 xff0c
  • 程序员很少上《非诚勿扰》电视节目相亲之分析

    程序员很少上 非诚勿扰 电视节目相亲之分析 偶观看有线电视32 频道的江苏卫视 非诚勿扰 电视相亲节目 xff0c 半年有余 问题 为什么程序员很少上 非诚勿扰 节目进行相亲呢 xff1f 难道是程序员当中 xff0c 很少有大龄的剩男剩女
  • 2018年CSDN博客排名第一名,花落谁家?

    截止2018年10月9日 https blog csdn net stpeace 小虎问题 xff1a 通过搜索引擎例如 xff1a 百度 搜狗 Bing等 如何快速搜索 xff0c 定位谁是CSDN博客的第几名 xff1f 想知道谁CSD
  • 客家刘开七、刘广传刘氏七律族诗赏析V2.0

    七律 刘氏族诗 南宋 刘广传 骏马骑行各出疆 xff0c 任从随地立纲常 年深外境皆吾境 xff0c 日久他乡即故乡 早晚勿忘亲命语 xff0c 晨昏须顾祖炉香 苍天佑我卯金氏 xff0c 八七男儿共炽昌 一 平仄性赏析 除了 卯 字 xf
  • 系统mysql、sqlserver数据库兼容方案

    一 技术选型 springboot2 4 43 mybatisplus3 4 43 mysql5 7 43 redis3 0 43 二 编写目的 如果产品开发默认数据库采用mysql xff0c 但是当客户提出数据库需要采用Sqlserve
  • eclipse maven plugin 插件 安装 和 配置

    离线插件 点击下载离线安装包 xff1a eclipse maven plugin zip for eclipse helios or higher 解压缩到任意目录 xff08 如这里的plugins目录 xff09 xff1a 目录路径
  • Android 使用View Binding来代替频繁findViewById来得到view

    从 Android Studio 3 6 开始 xff0c 视图绑定能够通过生成绑定对象来替代 findViewById xff0c 从而可以帮您简化代码 移除 bug xff0c 并且从 findViewById 的模版代码中解脱出来 在
  • 李开复辞职前后的故事

    这些故事出自即将发售的 世界因你不同 xff1a 李开复自传 一书 xff0c 由李开复本人和北京青年报记者范海涛合写而成 以下为故事部分节选 xff1a 今天 xff0c 我开得很慢 xff0c 仿佛是让自己的心情在辽阔的天空下能够更加安
  • 哈哈,终于知道CSDN怎么改头像了

    话说之前一直郁闷 xff0c 说改头像的功能还没修好 xff0c 一直说服务器错误 今天偶尔发现 xff0c 右上角有个设置 xff0c 原来在这里可以改 我还发了几封邮件给CSDN的admin xff0c 居然只知道道歉 xff0c 不告
  • tail -f 在串口中查看日志文件

    tail f opt log log mi tail follow opt log log mi 如果想从串口中查看日志文件 用tail 命令就可以了
  • 10-WorkManager

    WorkManager 文章目录 WorkManager概览使用入门将WorkManager添加到项目中创建后台任务配置运行任务的方式和时间将任务提交给系统后续步骤 方法指南定义WorkRequest工作约束初始延迟重试和退避政策定义任务的
  • 11-保存状态

    保存状态 文章目录 保存状态用户预期和系统行为用户发起的界面状态解除系统发起的界面状态解除 用于保留界面状态的选项使用 ViewModel 处理配置更改使用 onSaveInstanceState 作为后备方法来处理系统发起的进程终止针对复
  • 12 - ViewModel的已保存状态模块

    ViewModel的已保存状态模块 文章目录 ViewModel的已保存状态模块设置和使用存储和检索值可接受的类其他资源Codelab ViewModel 对象可以处理配置更改 xff0c 因此您无需担心旋转时或其他情况下的状态 但是 xf
  • 13 - 将Kotlin协程与架构组件一起使用

    将Kotlin协程与架构组件一起使用 文章目录 将Kotlin协程与架构组件一起使用添加KTX依赖项生命周期感知型协程范围ViewModelScopeLifecycleScope 暂停生命周期感知型协程将协程与LiveData一起使用其他资
  • Android读取Word文档

    附注 xff1a 本文使用的jar包是tm extractors 0 4的jar包 xff08 麻烦自己自行搜索并下载 xff09 xff0c 地址稍后再补上来 读取隐私协议文档内容 64 return private String sho
  • Android studio中“import org.apache.http.Header;”没用?

    Android M 起默认移除了Apache HTTP xff1a https developer android com intl zh cn preview behavior changes html 要使用的话 xff0c 要这么干
  • 解决华为手机不显示Log日志

    1 xff09 进入工程模式 有两种方式可以进入工程模式 xff1a a 在拨号界面输入 2846579 b 若是小米4 0系统 MIUI xff0c 进入 设置 gt 全部设置 gt 原厂设置 gt 工程模式 2 打开Log 1 依次进入
  • 将字符串时间转为毫秒值

    将字符串格式的时间转为毫秒值 64 param dateTime 字符串时间 xff08 格式 xff1a 2015 12 31 23 59 53 xff09 64 return public Long getLongFromString
  • 在Android Studio中使用JUNIT测试

    单元测试 xff08 unit testing xff09 xff0c 是指对软件中的最小可测试单元进行检查和验证 比如一个函数 xff0c 一个方法等 本文概述的内容 xff1a 在Android Studio中初步使用JUNIT测试 步
  • (极力推荐)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 前段时间设计的文本抽