Professional Documents
Culture Documents
SAP BW虚拟Cube PDF
SAP BW虚拟Cube PDF
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:
You can read more about the different service variants in the BW 3.0B documentation under “Virtual
InfoCubes with Services”.
3.2 Realization
InfoCube type:
Virtual InfoCube
with Services
Click on Details:
Function Module:
Z_VIRT_INFOCUBE_CUBE
Set flags:
- With Navigation Attributes
Key figures:
Time characteristics:
8. No changing parameters
9. Exception parameters
* initialize
CLEAR: e_t_data, e_t_msg.
* initialize
CLEAR e_t_data.
if sy-subrc = 0. "
* create a working area
ASSIGN LOCAL COPY OF INITIAL LINE OF e_t_data
TO <l_s_data>.
* 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.
ENDFUNCTION.
*--------------------------------------------------
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.
* (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>
* (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
* (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.
<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.
***************************************************
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
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,