You are on page 1of 16

How to…

Implement a Virtual InfoCube


with Services
BUSINESS INFORMATION WAREHOUSE

ASAP “How to…” Paper

Applicable Releases: BW 3.0B


December 2002

SAP (SAP America, Inc. and SAP AG) assumes no responsibility for errors or omissions in these materials.
These materials are provided “as is” without a warranty of any kind, either express or implied, including but not limited to, the
implied warranties of merchantability, fitness for a particular purpose, or non-infringement.
SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages
that may result from the use of these materials.
SAP does not warrant the accuracy or completeness of the information, text, graphics, links or other items contained within
these materials. SAP has no control over the information that you may access through the use of hot links contained in these
materials and does not endorse your use of third party web pages nor provide any warranty whatsoever relating to third party
web pages.
mySAP BI “How-To” papers are intended to simplify the product implementation. While specific product features and
procedures typically are explained in a practical business context, it is not implied that those features and procedures are the
only approach in solving a specific business problem using mySAP BI. Should you wish to receive additional information,
clarification or support, please refer to SAP Professional Services (Consulting/Remote Consulting).
HOW TO IMPLEMENT A VIRTUAL INFOCUBE WITH SERVICES

1 Business Scenario
The total booking prices for all posted flights are specified in a query. In doing so, only commercial
customers (CUSTTYPE = ‘B’) need to be taken into consideration. The query result has to
correspond to the online entry. The data is stored in the SBOOK table. The BOOKID (Booking
Number), CARRID (Airline Code), CLASS (Class), CONNID (Flight Connection Number), and
FLDATE (Flight Date) characteristics are used to ensure the drilldown.

2 Result
The realization occurs by means of a Virtual InfoCube with services. To do this, a customer function
module (service) has to be created. This selects the necessary data from the table and transfers it to
the Virtual InfoCube interface. A query from the Virtual InfoCube displays the data in the Business
Explorer. The drilldown and the transfer of the filter value are supported by the system.
Query result:

3 The Step-by-Step Solution

3.1 Service Variants


The service variants differ from each other by transfer parameters or types of transfer parameters
from the customer function module (service). In this way, they can be differentiated by various
degrees of functions when the standard BW features are set, or when the customer development has
to be transferred. There are three types of service variants that can be defined by flags in the service
definition.

The types are:


(1) RFC is switched on
(2) SID support is switched on (is used in this example)
(3) SID Support is switched off

You can read more about the different service variants in the BW 3.0B documentation under “Virtual
InfoCubes with Services”.

2002 SAP AMERICA, INC. AND SAP AG 1


HOW TO IMPLEMENT A VIRTUAL INFOCUBE WITH SERVICES

3.2 Realization

1. Definition of a virtual InfoCube with


Service

Administrator Workbench Æ Right


mouseclick on InfoArea Æ Create
InfoCube

Entry screen fields:


InfoCube:
VIRTCUBE1
InfoCube description:
Vitual InfoCube

InfoCube type:
Virtual InfoCube
with Services

Click on Details:

2002 SAP AMERICA, INC. AND SAP AG 2


HOW TO IMPLEMENT A VIRTUAL INFOCUBE WITH SERVICES

2. Fill the input screen with the


following parameters:

Function Module:
Z_VIRT_INFOCUBE_CUBE

Set flags:
- With Navigation Attributes

The interface of the service is


described in the documentation.
Æ F1 on the specific flag

2002 SAP AMERICA, INC. AND SAP AG 3


HOW TO IMPLEMENT A VIRTUAL INFOCUBE WITH SERVICES

3. Define, save, and activate the Characteristics:


InfoCube

Do not forget to assign the


characteristics to dimensions

Key figures:

2002 SAP AMERICA, INC. AND SAP AG 4


HOW TO IMPLEMENT A VIRTUAL INFOCUBE WITH SERVICES

Time characteristics:

2002 SAP AMERICA, INC. AND SAP AG 5


HOW TO IMPLEMENT A VIRTUAL INFOCUBE WITH SERVICES

4. Create the function module with


transaction SE37
Z_VIRT_INFOCUBE_CUBE

5. Attributes of the function module

Create a new function group if none is available.


Transaction SE80 Æ Edit Objects Æ Function Group Æ
Create
6. Importing parameters and types

2002 SAP AMERICA, INC. AND SAP AG 6


HOW TO IMPLEMENT A VIRTUAL INFOCUBE WITH SERVICES

7. Exporting parameters and types

8. No changing parameters

9. Exception parameters

10. Source code: FUNCTION Z_VIRT_INFOCUBE_CUBE.


function module *"-------------------------------------------------
---------------------
*"*"Local interface:
(see comments in the code) *" IMPORTING
*" VALUE(I_INFOPROV) TYPE RSINFOPROV
*" REFERENCE(I_TH_SFC) TYPE RSDRI_TH_SFC
*" REFERENCE(I_TH_SFK) TYPE RSDRI_TH_SFK
*" REFERENCE(I_T_RANGE) TYPE RSDRI_T_RANGE
*" REFERENCE(I_TX_RANGETAB) TYPE
RSDRI_TX_RANGETAB
*" VALUE(I_FIRST_CALL) TYPE RS_BOOL
*" VALUE(I_PACKAGESIZE) TYPE I DEFAULT 1000
*" EXPORTING
*" REFERENCE(E_T_DATA) TYPE STANDARD TABLE
*" REFERENCE(E_END_OF_DATA) TYPE RS_BOOL
*" REFERENCE(E_T_MSG) TYPE RS_T_MSG
*" EXCEPTIONS
*" WRONG_INPUT
*" READ_ACCESS_ERROR
*"-------------------------------------------------
---------------------

* initialize
CLEAR: e_t_data, e_t_msg.

* this is specific to infoprovider VIRTCUBE1


CHECK i_infoprov = 'VIRTCUBE1'.

FIELD-SYMBOLS: <l_s_sbook> TYPE gt_s_sbook,


<l_s_data> TYPE ANY.

DATA: l_t_component TYPE abap_compdescr_tab,

2002 SAP AMERICA, INC. AND SAP AG 7


HOW TO IMPLEMENT A VIRTUAL INFOCUBE WITH SERVICES

i_t_sbook TYPE gt_t_sbook.

* initialize
CLEAR e_t_data.

* Data selection / only Business Customer


select * from sbook
INTO CORRESPONDING FIELDS OF TABLE
i_t_sbook
where custtype = 'B'
and LOCCURKEY <> ''.

if sy-subrc = 0. "
* create a working area
ASSIGN LOCAL COPY OF INITIAL LINE OF e_t_data
TO <l_s_data>.

* get description of components of <L_S_DATA>


PERFORM get_type_components(saplrsdrc)
USING <l_s_data>
CHANGING l_t_component.

* data transformation
* move line by line
LOOP AT i_t_sbook ASSIGNING <l_s_sbook>.

PERFORM move_sbook_to_data
USING <l_s_sbook>
i_th_sfc
i_th_sfk
l_t_component
CHANGING <l_s_data>.
* append to output data
append <l_s_data> to E_T_DATA.
ENDLOOP.
endif.

* all data are selected


E_END_OF_DATA = 'X'.

ENDFUNCTION.

2002 SAP AMERICA, INC. AND SAP AG 8


HOW TO IMPLEMENT A VIRTUAL INFOCUBE WITH SERVICES

*--------------------------------------------------
11. Source code: --------------------*
Perform move_sbook_to_data ***INCLUDE LZVIRTCF02 .
*--------------------------------------------------
--------------------*
*&-------------------------------------------------
(see comments in the code) --------------------*
*& Form move_budget_to_data
*&-------------------------------------------------
--------------------*
* text
*--------------------------------------------------
--------------------*
* -->P_<L_S_BOOK> text
* -->P_I_TH_SFC text
* -->P_I_TH_SFK text
* -->P_L_T_COMPONENT text
* <--P_<L_S_DATA> text
*--------------------------------------------------
--------------------*
FORM move_sbook_to_data
USING i_s_sbook TYPE gt_s_sbook
i_th_sfc TYPE RSDRI_TH_SFC
i_th_sfk TYPE RSDRI_TH_SFK
i_t_component TYPE
abap_compdescr_tab
CHANGING e_s_data TYPE any.

* define FIELD-SYMBOLS
FIELD-SYMBOLS: <l_s_component> TYPE
abap_compdescr,
<l_comp_data> TYPE ANY,
<l_s_sfc> TYPE RSDRI_S_SFC,
<l_s_sfk> TYPE RSDRI_S_SFK.

* Datadeclaration
DATA: l_compno TYPE i,
l_t_component TYPE abap_compdescr_tab,
l_s_sbook TYPE gt_s_sbook.

* initialize
CLEAR e_s_data.
l_s_sbook = i_s_sbook.

* ******* Transformation of all needed SBOOK


Fields ****************

* (1) year ----------------------------------------


------------------
IF NOT i_s_sbook-FLDATE IS INITIAL.
* get alias name from SFC
READ TABLE i_th_sfc ASSIGNING <l_s_sfc>
WITH TABLE KEY chanm = '0CALYEAR'.
IF sy-subrc = 0.
* get number of target column
READ TABLE i_t_component ASSIGNING
<l_s_component>
WITH KEY name = <l_s_sfc>-CHAALIAS.
IF sy-subrc = 0.
* number of target data component
l_compno = sy-tabix.
* get target data component

2002 SAP AMERICA, INC. AND SAP AG 9


HOW TO IMPLEMENT A VIRTUAL INFOCUBE WITH SERVICES

ASSIGN COMPONENT l_compno OF STRUCTURE


e_s_data
TO <l_comp_data>.
move i_s_sbook-FLDATE(4) to <l_comp_data>.
ENDIF.
ENDIF.
ENDIF.

* (2) CALDAY---------------------------------------
---------------------
IF NOT i_s_sbook-FLDATE IS INITIAL.
* get alias name from SFC
READ TABLE i_th_sfc ASSIGNING <l_s_sfc>
WITH TABLE KEY chanm = '0CALDAY'.
IF sy-subrc = 0.
* get number of target column
READ TABLE i_t_component ASSIGNING
<l_s_component>
WITH KEY name = <l_s_sfc>-CHAALIAS.
IF sy-subrc = 0.
* number of target data component
l_compno = sy-tabix.
* get target data component
ASSIGN COMPONENT l_compno OF STRUCTURE
e_s_data
TO <l_comp_data>.
* MOVE
move i_s_sbook-FLDATE to <l_comp_data>.
ENDIF.
ENDIF.
ENDIF.

* (3) calmonth2------------------------------------
---------------------
IF NOT i_s_sbook-FLDATE IS INITIAL.
* get alias name from SFC
READ TABLE i_th_sfc ASSIGNING <l_s_sfc>
WITH TABLE KEY chanm = '0CALMONTH2'.
IF sy-subrc = 0.
* get number of target column
READ TABLE i_t_component ASSIGNING
<l_s_component>
WITH KEY name = <l_s_sfc>-CHAALIAS.
IF sy-subrc = 0.
* number of target data component
l_compno = sy-tabix.
* get target data component
ASSIGN COMPONENT l_compno OF STRUCTURE
e_s_data
TO <l_comp_data>.
* MOVE
move i_s_sbook-FLDATE+4(2) to
<l_comp_data>.
ENDIF.
ENDIF.
ENDIF.

* (4) CARRID---------------------------------------
---------------------
IF NOT i_s_sbook-CARRID IS INITIAL.
* get alias name from SFC
READ TABLE i_th_sfc ASSIGNING <l_s_sfc>

2002 SAP AMERICA, INC. AND SAP AG 10


HOW TO IMPLEMENT A VIRTUAL INFOCUBE WITH SERVICES

WITH TABLE KEY chanm = 'CARRID'.


IF sy-subrc = 0.
* get number of target column
READ TABLE i_t_component ASSIGNING
<l_s_component>
WITH KEY name = <l_s_sfc>-CHAALIAS.
IF sy-subrc = 0.
* number of target data component
l_compno = sy-tabix.
* get target data component
ASSIGN COMPONENT l_compno OF STRUCTURE
e_s_data
TO <l_comp_data>.
* MOVE
move i_s_sbook-CARRID to <l_comp_data>.
ENDIF.
ENDIF.
ENDIF.

* (5) CLASS----------------------------------------
--------------------
IF NOT i_s_sbook-CLASS IS INITIAL.
* get alias name from SFC
READ TABLE i_th_sfc ASSIGNING <l_s_sfc>
WITH TABLE KEY chanm = 'CLASS'.
IF sy-subrc = 0.
* get number of target column
READ TABLE i_t_component ASSIGNING
<l_s_component>
WITH KEY name = <l_s_sfc>-CHAALIAS.
IF sy-subrc = 0.
* number of target data component
l_compno = sy-tabix.
* get target data component
ASSIGN COMPONENT l_compno OF STRUCTURE
e_s_data
TO <l_comp_data>.
* MOVE
move i_s_sbook-CLASS to <l_comp_data>.
ENDIF.
ENDIF.
ENDIF.

* (6) CONNID---------------------------------------
---------------------
IF NOT i_s_sbook-CONNID IS INITIAL.
* get alias name from SFC
READ TABLE i_th_sfc ASSIGNING <l_s_sfc>
WITH TABLE KEY chanm = 'CONNID'.
IF sy-subrc = 0.
* get number of target column
READ TABLE i_t_component ASSIGNING
<l_s_component>
WITH KEY name = <l_s_sfc>-CHAALIAS.
IF sy-subrc = 0.
* number of target data component
l_compno = sy-tabix.
* get target data component
ASSIGN COMPONENT l_compno OF STRUCTURE
e_s_data
TO <l_comp_data>.
* MOVE

2002 SAP AMERICA, INC. AND SAP AG 11


HOW TO IMPLEMENT A VIRTUAL INFOCUBE WITH SERVICES

move i_s_sbook-CONNID to <l_comp_data>.


ENDIF.
ENDIF.
ENDIF.

* (7) BOOKID---------------------------------------
---------------------
IF NOT i_s_sbook-bookid IS INITIAL.
* get alias name from SFC
READ TABLE i_th_sfc ASSIGNING <l_s_sfc>
WITH TABLE KEY chanm = 'BOOKID'.
IF sy-subrc = 0.
* get number of target column
READ TABLE i_t_component ASSIGNING
<l_s_component>
WITH KEY name = <l_s_sfc>-CHAALIAS.
IF sy-subrc = 0.
* number of target data component
l_compno = sy-tabix.
* get target data component
ASSIGN COMPONENT l_compno OF STRUCTURE
e_s_data
TO <l_comp_data>.
* MOVE
move i_s_sbook-BOOKID to <l_comp_data>.
ENDIF.
ENDIF.
ENDIF.

* (8) LOCCURKEY------------------------------------
---------------------
IF NOT i_s_sbook-LOCCURKEY IS INITIAL.
* get alias name from SFC
READ TABLE i_th_sfc ASSIGNING <l_s_sfc>
WITH TABLE KEY chanm = '0CURRENCY'.
IF sy-subrc = 0.
* get number of target column
READ TABLE i_t_component ASSIGNING
<l_s_component>
WITH KEY name = <l_s_sfc>-CHAALIAS.
IF sy-subrc = 0.
* number of target data component
l_compno = sy-tabix.
* get target data component
ASSIGN COMPONENT l_compno OF STRUCTURE
e_s_data
TO <l_comp_data>.
* MOVE
move i_s_sbook-LOCCURKEY to <l_comp_data>.
ENDIF.
ENDIF.
ENDIF.

* (10) LOCCURAM -----------------------------------


---------------------
IF NOT i_s_sbook-LOCCURAM IS INITIAL.
* get alias name from SFC
READ TABLE i_th_sfk ASSIGNING <l_s_sfk>
WITH TABLE KEY kyfnm = 'LOCCURAM'.
IF sy-subrc = 0.
* get number of target column
READ TABLE i_t_component ASSIGNING

2002 SAP AMERICA, INC. AND SAP AG 12


HOW TO IMPLEMENT A VIRTUAL INFOCUBE WITH SERVICES

<l_s_component>
WITH KEY name = <l_s_sfk>-kyfalias.
IF sy-subrc = 0.
* number of target data component
l_compno = sy-tabix.
* get target data component
ASSIGN COMPONENT l_compno OF STRUCTURE
e_s_data
TO <l_comp_data>.
* MOVE
<l_comp_data> = i_s_sbook-LOCCURAM.
ENDIF.
ENDIF.
ENDIF.

ENDFORM. " move_budget_to_data

2002 SAP AMERICA, INC. AND SAP AG 13


HOW TO IMPLEMENT A VIRTUAL INFOCUBE WITH SERVICES

***************************************************
12. Source code ****************
Main program: * System-defined Include-files.
*
***************************************************
Goto Æ Main program ****************
INCLUDE LZVIRTCTOP. "
Global Data
INCLUDE LZVIRTCUXX. "
Function Modules

***************************************************
****************
* User-defined Include-files (if necessary).
*
***************************************************
****************
* INCLUDE LZVIRTCF... "
Subprograms
* INCLUDE LZVIRTCO... " PBO-
Modules
* INCLUDE LZVIRTCI... " PAI-
Modules

(see comments in the code) INCLUDE LZVIRTCF02.

FUNCTION-POOL ZVIRTC.
13. Source code: "MESSAGE-ID ..
INCLUDE LZVIRTCTOP
Tables: sbook.

Global data declaration TYPE-POOLS: rs, rsd, rsdd, rsdpm, rsdpr, rsdu.

TYPES:
(see comments in the code) * Structure
* types
BEGIN OF gt_s_sbook,
CARRID TYPE S_CARR_ID,
CONNID TYPE S_CONN_ID,
CLASS TYPE S_CLASS,
FLDATE TYPE S_DATE,
BOOKID TYPE S_BOOK_ID,
CUSTTYPE TYPE S_CUSTTYPE,
LOCCURAM TYPE S_L_CUR_PR,
LOCCURKEY TYPE S_CURRCODE,
END OF gt_s_sbook,

* internal SBOOK Table


gt_t_sbook TYPE STANDARD TABLE OF gt_s_sbook
WITH DEFAULT KEY INITIAL
SIZE 10.

2002 SAP AMERICA, INC. AND SAP AG 14


HOW TO IMPLEMENT A VIRTUAL INFOCUBE WITH SERVICES

14. Query definition

“Supress Result Rows” is set to


“Always“ in the characteristic
properties

2002 SAP AMERICA, INC. AND SAP AG 15

You might also like