You are on page 1of 14

Extraction of Hierarchy into Flat

File from R/3 and Loading in BW


System

Applies to:
This article applies to SAP R/3 (any version) and SAP B/W (any version).For more information, visit the
Business Intelligence homepage.

Summary
This document discusses the R/3 Tables involved in Extracting Hierarchies (mainly covered Cost Center
Group Hierarchy and Cost Element Group Hierarchy), dump the hierarchy in Flat File in required BW
structure and Load the same to BW.
Author: Anil Suryavansi
Company: Patni Computer Systems
Created on: 15 September 2009

Author Bio

Anil Suryavansi is presently working with Patni Computers Systems Ltd. He has worked
extensively on SAP BIW 3.5, BI 7.0, different versions of R/3 and is mainly responsible for
various BW and R/3 developments.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 1
Extraction of Hierarchy into Flat File from R/3 and Loading in BW System

Table of Contents
Introduction ......................................................................................................................................................... 3
Cost Element Group Hierarchy in R/3 ................................................................................................................ 3
R/3 Tables Involved ..................................................................................................................................................... 4
Code to Extract the Hierarchy:............................................................................................................................ 6
How Hierarchy is shown at BW Reports:.......................................................................................................... 12
Related Content ................................................................................................................................................ 13
Related Content ................................................................................................................................................ 13
Disclaimer and Liability Notice .......................................................................................................................... 14

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 2
Extraction of Hierarchy into Flat File from R/3 and Loading in BW System

Introduction
In SAP R/3 for a Group (Ex: Cost Center Group or Cost Element Group), if any of Header node / Sub Node /
Base Node is entered, hierarchy for that node appears. The same functionality can be achieved in B/W by
loading a Single Hierarchy and with maintaining proper Link for an Organizational Unit. There are many
scenarios in which it is required to Extract Hierarchies from R/3 tables, dump Hierarchy in Flat File and
Load into B/W. Using same logic and code All the Group Hierarchies present in R/3 can be Extracted.
For Example:
 Cost Center Group Hierarchy
 Cost Element Group Hierarchy

Cost Element Group Hierarchy in R/3


We can check Cost Element Group in R/3 by T-code KAH3.
For an example, we consider a group KG-ALLCOST:

Now if we check for K585ADEPRE:

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 3
Extraction of Hierarchy into Flat File from R/3 and Loading in BW System

Now if we check for K585AFIXDP:

By above example it is possible to check hierarchy of KG-ALLCOST, K585ADEPRE and K585AFIXDP, as all
these entries are maintained in SETHEADER table.

R/3 Tables Involved


Mainly 3 tables are involved to extract hierarchy:
 SETHEADER
The value of field Set class represents that the hierarchy is related to which field, as value
0102 is for Cost Element Group, 0101 is for Cost Center Group.

If we check Set ID KG-ALLCOST (Higher Node) entry is available in this table.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 4
Extraction of Hierarchy into Flat File from R/3 and Loading in BW System

 SETNODE
If we check table SETNODE with Set ID KG-ALLCOST, there are 12 Subset Ids available.

If we now take any Subset ID ex. K585ADEPRE and check this as Set ID, there are two Subset
IDs for this.

Now if we take a Subset ID K585AFIXDP and check this as Set ID, there are no entries available
in SETNODE table as it’s a leaf node.
 SETLEAF
If we take K585AFIXDP and check this as Set ID in table SETLEAF, it contains values of Cost
Elements assigned to the node.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 5
Extraction of Hierarchy into Flat File from R/3 and Loading in BW System

Code to Extract the Hierarchy:

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 6
Extraction of Hierarchy into Flat File from R/3 and Loading in BW System

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 7
Extraction of Hierarchy into Flat File from R/3 and Loading in BW System

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 8
Extraction of Hierarchy into Flat File from R/3 and Loading in BW System

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 9
Extraction of Hierarchy into Flat File from R/3 and Loading in BW System

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 10
Extraction of Hierarchy into Flat File from R/3 and Loading in BW System

The above code will generate the file, which is compatible to load in BW in Master Hierarchy Object.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 11
Extraction of Hierarchy into Flat File from R/3 and Loading in BW System

How Hierarchy is shown at BW Reports:


Now we can Load this extracted Hierarchy in Cost Element Object and create a Hierarchy Node variable
at query level for this hierarchy. In Selection Screen Hierarchy is available to select at different nodes.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 12
Extraction of Hierarchy into Flat File from R/3 and Loading in BW System

Related Content
Relation between SETNODE, SETLEAF and SETHEADER
Structure of a Flat Hierarchy File for Loading via IDoc
Hierarchy Nodes
Link Nodes
For more information, visit the Business Intelligence homepage.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 13
Extraction of Hierarchy into Flat File from R/3 and Loading in BW System

Disclaimer and Liability Notice


This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not
supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.
SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document,
and anyone using these methods does so at his/her own risk.
SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or
code sample, including any liability resulting from incompatibility between the content within this document and the materials and
services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this
document.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com


© 2009 SAP AG 14

You might also like