· 

SAP BW: Keyfigure to Account Model

In my current project we have a lots of source systems which delivers our data in a key figure model. In a normal case is this not a problem. But we need the values of the key figures in a hierarchy. So there are two ways to realize it. First way would be we build a structure with restricted key figures and get our hierarchy. Here is the problem, the customer will need different queries to realize his needs. If there is a change, we need to adjust different queries (each has a light different hierarchy) and the maintainace is immense.

Query Hierarchy Structure
Query Hierarchy Structure

Another way is to use an account model. Here is your first Problem, we only get a key figure model and it is not so easy to use rule groups or a simply routine, because we get around 100 key figures. So it isn't easy as Denis wrote in his post (this post is in German). But I found, really I can't belive I found an article on the former SCN. This post decribes how to transform a key figure based model to an account based model with some ABAP coding and an expert routine. So I think that must be the answer to my problem, but it isn't so well writen that I could use it. But the start was done. I need a Z-Table and some ABAP. First I created my Z-Table with four fields:

  • MANDT
  • AREA
  • SOURCE_KF
  • ACCOUNTPOSITION

AREA is necessary to use this table in different deparments, SOURCE_KF represents the source key figure for example /BIC/ZGROSSVAL and the ACCOUNTPOSITION is the technical key of the account model, for example 15.

Z-Table for Mapping Keyfigure to Account
Z-Table for Mapping Keyfigure to Account

This was the easy part. Now I need some ABAP and here I had some struggle.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
Data: lt_account        type HASHED TABLE OF z_account WITH UNIQUE KEY source_kf,
      ls_account        like LINE OF lt_account.

FIELD-SYMBOLS: <fv_source> type any.

Select * from z_account into table lt_account WHERE area = 'SOMETHING'.

LOOP AT SOURCE_PACKAGE ASSIGNING <source_fields>.
  MOVE-CORRESPONDING <source_fields> to RESULT_FIELDS.
  Loop at lt_account into ls_account.
    RESULT_FIELDS-/BIC/VF0CBPOS = ls_account-berichtsposition.
    ASSIGN COMPONENT ls_account-source_kf of STRUCTURE <source_fields> to <fv_source>.
    RESULT_FIELDS-/bic/vf0kbehw = <fv_source>.
    Append RESULT_FIELDS TO RESULT_PACKAGE.
  Endloop.
Endloop.

The Problem was the ASSIGN COMPONENT part, which I didn't know how to work, but a colleague helped me here. So that's it. The Z-Table can be modified to fulfill your needs, but the basic code should help you to realize a solution.

author.


I am Tobias, I write this blog since 2014, you can find me on twitter and youtube. If you want you can leave me a paypal coffee donation. You can also contact me directly if you want.

SAP Analysis for Office - The Comprehensive Guide
The book SAP Analysis for Office - The Comprehensive Guide by Tobias Meyer is a pdf book about SAP Analysis for Office. It is based on Analysis for Office 2.8 and contains 346 Pages.
45,00 €
SAP Analysis for Office - The Comprehensive Guide
SAP Analysis for Office - The Comprehensive Guide is a pdf book about SAP BusinessObjects Analysis for Office. It is based on Analysis for Office 2.7 and contains 299 Pages.
37,00 €
SAP Analysis for Office - The Comprehensive Guide
SAP Analysis for Office - The Comprehensive Guide is a pdf book about SAP BusinessObjects Analysis for Office. It is based on Analysis for Office 2.6 and contains 272 Pages.
27,00 €

Write a comment

Comments: 5
  • #1

    Morten Lindenfalk (Monday, 28 September 2020 17:36)

    Could I ask you a question?

  • #2

    Tobias (Monday, 28 September 2020 19:55)

    Sure :)

  • #3

    Morten Lindenfalk (Tuesday, 29 September 2020 09:39)

    Is RESULT_FIELDS-/BIC/VF0CBPOS your account in the RESULT_PACKAGE? For instance in my case it will be 0GL_ACCOUNT.

    Then what is RESULT_FIELDS-/bic/vf0kbehw where you assign <fv_source>? In my case I will have 0AMOUNT as key figure in the RESULT_PACKAGE I would like to assign the value from e.g. /BIC/ZGROSSVAL.

  • #4

    Tobias (Wednesday, 30 September 2020 08:28)

    HI,

    yes RESULT_FIELDS-/BIC/VF0CBPOS is my account position and RESULT_FIELDS-/bic/vf0kbehw is my amount . I hope this clear things up.

  • #5

    Morten Lindenfalk (Wednesday, 30 September 2020 09:55)

    Got it solved. Thanks for sharing your knowledge :-)