Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
633 views

Creating Virtual Cube Based On Function Module in SAP BI

Creating Virtual Cube Based on Function Module in SAP BI

Uploaded by

Sergio Manchado
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
633 views

Creating Virtual Cube Based On Function Module in SAP BI

Creating Virtual Cube Based on Function Module in SAP BI

Uploaded by

Sergio Manchado
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Creating Virtual Cube based on

Function Module in SAP BI

Applies to:
SAP BIW 3.5, SAP NetWeaver 7.0. For more information, visit the EDW homepage.

Summary
Present white paper is a guide for creating virtual cube based on function module. Actually it contains the
sample code of function module that can help a lot in writing your own code for virtual cube.

Author: Dheeraj Gupta


Company: L&T Infotech
Created on: 15 July 2011

Author Bio
Dheeraj Gupta is currently working in L&T Infotech. He has worked extensively in SAP BW 3.5 and
SAP BI 7.0. Currently he is responsible for various BI developments.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 1
Creating Virtual Cube based on Function Module in SAP BI

Table of Contents
Creating Virtual Cube ......................................................................................................................................... 3
Writing Function Module ZIFRS_VC2_FM...................................................................................................... 4
Related Content ................................................................................................................................................ 14
Disclaimer and Liability Notice .......................................................................................................................... 15

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 2
Creating Virtual Cube based on Function Module in SAP BI

Creating Virtual Cube


Creating virtual cube is as simple as creating normal cube. Only thing that we have to see is how to write its
function module. So creating cube is briefly explained below
When you create ‘Virtual Provider’ by right click on Info Area so you have to fill following details

For our example we will take ZIFRS_VC2 virtual cube which structure is as follows.

st nd
When you click Details button in 1 screen then 2 screen comes where you provide name of Function
Module and other details. As the main objective of this document is to tell how to write FM for VC so we will
not go in any other detail and will directly move to FM.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 3
Creating Virtual Cube based on Function Module in SAP BI

Writing Function Module ZIFRS_VC2_FM

This is main program for function module. When you create some function module in a group let us say
ZF_IPAD then this function module will be created as an include in program (shown above in rectangle) – In
include LZF_IPADUXX. You can include other includes in this main program that can have global functions.
Like below we have included LZF_IPADF01 that contains various functions explained later in this
document.
SAPLZF_IPAD
INCLUDE LZF_IPADTOP. " Global Data
INCLUDE LZF_IPADUXX. " Function Modules

*******************************************************************
* User-defined Include-files (if necessary). *
*******************************************************************
* INCLUDE LZF_IPADF... " Subprograms
* INCLUDE LZF_IPADO... " PBO-Modules
* INCLUDE LZF_IPADI... " PAI-Modules

INCLUDE LZF_IPADF01.
INCLUDE LZF_IPADTOP.

Include LZF_IPADTOP contains global data declaration, type pools definitions, various field-symbols,
structure definitions etc. Below all declarations will always be included for (name can change but will have to
change everywhere accordingly). The structure ls_cd_cube_struc is the structure (fields) of virtual cube
(shown earlier). Here standard infoobject should be named with removing ‘0’ (like 0BUS_AREA as
BUS_AREA) and customized object should be given name as /BIC/ZF_NCURR for ZF_NCURR info object
(prefixed with /BIC/).
FUNCTION-POOL ZF_IPAD. "MESSAGE-ID ..

TYPE-POOLS: rs, rsd, rsdd, rsdpm, rsdpr, rsdu,abap , slis.


DATA: it_fcat TYPE slis_t_fieldcat_alv,
is_fcat LIKE LINE OF it_fcat.
DATA: it_fieldcat TYPE lvc_t_fcat,
is_fieldcat LIKE LINE OF it_fieldcat.
DATA: e_t_table TYPE REF TO data.
DATA: e_t_line TYPE REF TO data.
FIELD-SYMBOLS: <l_table> TYPE ANY TABLE,
<l_line> TYPE ANY,
<l_field> TYPE ANY.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 4
Creating Virtual Cube based on Function Module in SAP BI

Types :
*structure for CD report.
Begin of ls_cd_cube_struc,
BUS_AREA(4),
CHRT_ACCTS(4),
COMP_CODE(4),
COSTCENTER(10),
CO_AREA(4),
CURTYPE(2),
DUEDATE type d,
FISCPER3_E type n length 3,
GL_ACCOUNT(10),
BAL_FLAG(1),C4(4),
PROFIT_CTR(10),
SEGMENT(10),
/BIC/ZF_NCURR(1),
/BIC/ZNATUR_JV(4),
/BIC/ZTRANS_DT type d,
FISCPER(7) type N,
FISCVARNT(2),
FISCYEAR(4) type N,
CURRENCY(5),
CREDIT type p length 9 decimals 2,
DEBIT type p length 9 decimals 2,

End of ls_cd_cube_struc,

LZF_IPADF01

Following 2 function module will always be there for Virtual Cube function module. So these can be copied
as it is in new include LZF_IPADF01.
*&---------------------------------------------------------------------*
*& Form move_itab_to_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LS_AP_TAB text
* -->P_I_TH_SFC text
* -->P_I_TH_SFK text
* -->P_L_T_COMPONENT text
* <--P_<L_S_DATA> text
*----------------------------------------------------------------------*
FORM move_itab_to_data USING P_LS_AP_TAB type any
P_I_TH_SFC TYPE RSDRI_TH_SFC
P_I_TH_SFK TYPE RSDRI_TH_SFK
P_L_T_COMPONENT TYPE abap_compdescr_tab
CHANGING P_L_S_DATA type any.

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

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 5
Creating Virtual Cube based on Function Module in SAP BI

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

data: ls_data_elem type RSCHANM.

clear p_l_s_data.

loop at p_i_th_sfc assigning <l_s_sfc> .

* get number of target column


READ TABLE P_L_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 P_L_S_DATA
TO <l_comp_data>.
* find the corresponding field name for this infoobject
clear ls_data_elem.
CALL FUNCTION 'RSD_FIELDNM_GET_FROM_IOBJNM'
EXPORTING
I_NAME = <l_s_sfc>-CHANM
IMPORTING
E_DDNAME = ls_data_elem.
IF SY-SUBRC = 0.

ASSIGN COMPONENT ls_data_elem OF STRUCTURE P_LS_AP_TAB


TO <fieldvalue>.
* MOVE
if sy-subrc = 0.
move <fieldvalue> to <l_comp_data>.
endif.
endif.
ENDIF.

endloop.

** Now work on SFK


loop at p_i_th_sfk assigning <l_s_sfk>
where KYFNM <> '1ROWCOUNT'.

* get number of target column


READ TABLE P_L_T_COMPONENT ASSIGNING <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 P_L_S_DATA
TO <l_comp_data>.
* find the corresponding field name for this infoobject

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 6
Creating Virtual Cube based on Function Module in SAP BI

clear ls_data_elem.
CALL FUNCTION 'RSD_FIELDNM_GET_FROM_IOBJNM'
EXPORTING
I_NAME = <l_s_sfk>-KYFNM
IMPORTING
E_DDNAME = ls_data_elem.
IF SY-SUBRC = 0.

ASSIGN COMPONENT ls_data_elem OF STRUCTURE P_LS_AP_TAB


TO <fieldvalue>.
* MOVE
move <fieldvalue> to <l_comp_data>.
endif.
ENDIF.
endloop.
ENDFORM. " move_itab_to_data
FORM get_type_components
USING i_s_data TYPE any
CHANGING e_t_components TYPE abap_compdescr_tab.
DATA:
l_tdescr TYPE REF TO cl_abap_typedescr,
l_sdescr TYPE REF TO cl_abap_structdescr.
CLEAR e_t_components.
l_tdescr = cl_abap_typedescr=>describe_by_data( i_s_data ).
l_sdescr ?= l_tdescr.
e_t_components = l_sdescr->components.

ENDFORM. " GET_TYPE_COMPONENTS

ZIFRS_VC2_FM

This is main function module. It’s importing and exporting parameters will remain like this only. When any
query is executed based on VC or we directly see the data of VC then this gets executed and all importing
parameter are automatically passed. Now whatever we fill in E_T_DATA, that will pass to VC output data
that can be used in query or anywhere. Explanation of code is given below with code.
FUNCTION ZIFRS_VC1_FM.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(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
*" REFERENCE(I_FIRST_CALL) TYPE RS_BOOL
*" REFERENCE(I_PACKAGESIZE) TYPE I
*" EXPORTING
*" REFERENCE(E_T_DATA) TYPE STANDARD TABLE
*" REFERENCE(E_END_OF_DATA) TYPE RS_BOOL
*" REFERENCE(E_T_MSG) TYPE RS_T_MSG
*"----------------------------------------------------------------------
"-----------------------------------------------------------------------

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 7
Creating Virtual Cube based on Function Module in SAP BI

In above code I-INFOPROV attribute is passed at run time with the name of VC.
I_TH_SFC contains entries like
0BUS_AREA K____1031 0
0CHRT_ACCTS K____198 0
0COMP_CODE K____197 0
0COSTCENTER K____894 0
First column is Characteristic name and 2nd column is BW-DM field alias name and similarly ITH_SFK
contains entries for key figures.
I_T_RANGE table contains if you give some restriction in query or while data displaying.
DATA : C_FIRST_CALL TYPE RS_BOOL.
DATA : ITAB_FINAL_CD TYPE TABLE OF LS_CD_CUBE_STRUC.
DATA : WA_FINAL_CD TYPE LS_CD_CUBE_STRUC.

DATA: L_SELALIAS TYPE RSALIAS.

FIELD-SYMBOLS : <L_S_DATA_CD> TYPE ANY.


DATA : L_T_COMPONENT_CD TYPE ABAP_COMPDESCR_TAB.
DATA : CD_CUBE_STRUC TYPE LS_CD_CUBE_STRUC.
ASSIGN LOCAL COPY OF INITIAL LINE OF E_T_DATA TO <L_S_DATA_CD>.

Above statements are data declarations required in FM. Assign statement creates a structure of E_T_DATA
type and assigns it to <L_S_DATA_CD>.
* Now let us build a dynamic structure so that we can read the infoset
* Build field catelog.
CLEAR: IT_FIELDCAT , IT_FCAT.
REFRESH: IT_FIELDCAT , IT_FCAT.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = '/BIC/VZISFS_M022'
CHANGING
CT_FIELDCAT = IT_FCAT[].

Above statement is written because we want to read data from a multiprovider ZISFS_M02. We will use that
data to fill E_T_DATA table. So for reading data from multiprovider/ cube we have to use
'RSDRI_INFOPROV_READ' FM. This FM requires 1 parameter in import and to provide that parameter we
are going through above FM. We will find 1 structure with name /BIC/VCUBENAME2 or /BI0/VCUBENAME2
that we have to use here and output of this FM IT_FCAT will have following data. That is Column position,
field name, data types, reference table etc.
4 0COSTCENTER X Cost CHAR C 000010 /BIC/VZISFS_M022 Cost 000010
Center Center
5 0BUS_AREA X Business CHAR C 000004 /BIC/VZISFS_M022 Business 000004
area area
6 0CO_AREA X Controlling CHAR C 000004 /BIC/VZISFS_M022 Controlling 000004
Area Area
7 0PROFIT_CTR X Profit CHAR C 000010 /BIC/VZISFS_M022 Profit 000010
Center Center
So above statement will always come if you want to read data from Infoset/ Multiprovider.
LOOP AT IT_FCAT INTO IS_FCAT.
MOVE-CORRESPONDING IS_FCAT TO IS_FIELDCAT.

CALL FUNCTION 'RSSEM_UCR_GET_RETURNNM'

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 8
Creating Virtual Cube based on Function Module in SAP BI

EXPORTING
I_IOBJNM = IS_FCAT-FIELDNAME
IMPORTING
E_KEYRETURNNM = L_SELALIAS.
* exceptions
* x_message = 1
* others = 2.
IF SY-SUBRC <> 0.
E_END_OF_DATA = 'X'.
EXIT.
ENDIF.
IS_FIELDCAT-FIELDNAME = L_SELALIAS.
IS_FIELDCAT-REF_FIELD = IS_FCAT-FIELDNAME.
IS_FIELDCAT-REF_TABLE = IS_FCAT-REF_TABNAME.
APPEND IS_FIELDCAT TO IT_FIELDCAT.
ENDLOOP.

Above code creates another inter mediate table that is for the filling requirement of
'RSDRI_INFOPROV_READ' FM’s import parameter. Mainly this gets BW-DM field alias name for fields of
Multi provider b/c that is required for to communicate from RSDRI_INFOPROV_READ FM.
* Create a new Table
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = IT_FIELDCAT
IMPORTING
EP_TABLE = E_T_TABLE.
* Create a new Line with the same structure of the table.
ASSIGN E_T_TABLE->* TO <L_TABLE>.
CREATE DATA E_T_LINE LIKE LINE OF <L_TABLE>.
ASSIGN E_T_LINE->* TO <L_LINE>.

Above code creates dynamic table that is it creates E_T_TABLE that will have all columns mentioned in
IT_FIELDCAT. Columns name will be BW-DM field alias name. After that assign statement assigns
E_T_TABLE (pointer to table) to a field symbol. And similarly creates work area of E_T_TABLE and assign
that to <L_LINE>.
CALL FUNCTION 'RSDRI_INFOPROV_READ'
EXPORTING
I_INFOPROV = 'ZISFS_M02'
I_TH_SFC = I_TH_SFC
I_TH_SFK = I_TH_SFK
I_T_RANGE = I_T_RANGE
I_PACKAGESIZE = I_PACKAGESIZE
IMPORTING
E_T_DATA = <L_TABLE>
CHANGING
C_FIRST_CALL = C_FIRST_CALL
EXCEPTIONS
RUNTIME_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 9
Creating Virtual Cube based on Function Module in SAP BI

Finally above statement reads data of multi provider. For reading data from Infoset use 'RSQ_READ_DATA'
FM that is quite similar to above. For reading data from DSO/ Infoobject, you can use simple select
statement on Active table/ ‘M’ table of Infoobject respectively.
**** Read the data from the ODSes.

LOOP AT <L_TABLE> INTO <L_LINE>.

LOOP AT IT_FCAT INTO IS_FCAT.


READ TABLE IT_FIELDCAT INTO IS_FIELDCAT
WITH KEY REF_FIELD = IS_FCAT-FIELDNAME.
CASE IS_FCAT-REPTEXT_DDIC.

WHEN 'Business area'.


ASSIGN COMPONENT IS_FIELDCAT-FIELDNAME OF
STRUCTURE <L_LINE> TO <L_FIELD>.
WA_FINAL_CD-BUS_AREA = <L_FIELD>.
UNASSIGN <L_FIELD>.

In above statements starting from LOOP AT <L_TABLE>, <L_TABLE> contains data read from
MultiProvider. The column names in this table are BW-DM field alias names (like K___066 etc.) and work
area for VC has column names as BUS_AREA etc. So we have to reach from K___* names to field name in
VC. So IT_FCAT contains info objects description as ‘Business area’ etc. and IT_FIELDCAT contains K___*
names and joining b/w these 2 tables is IT_FIELDCAT-REF_FIELD = IT_FCAT-FIELDNAME. So reaching to
REPTEXT_DDIC = ‘Business area’ and assigning corresponding K___* component of structure <L_LINE>,
we can use corresponding info object BA through <L_FIELD>.

WHEN ''.
ASSIGN COMPONENT IS_FIELDCAT-FIELDNAME OF
STRUCTURE <L_LINE> TO <L_FIELD>.
WA_FINAL_CD-CURRENCY = <L_FIELD>.
UNASSIGN <L_FIELD>.

WHEN 'Chart of accounts'.


ASSIGN COMPONENT IS_FIELDCAT-FIELDNAME OF
STRUCTURE <L_LINE> TO <L_FIELD>.
WA_FINAL_CD-CHRT_ACCTS = <L_FIELD>.
UNASSIGN <L_FIELD>.

WHEN 'Company code'.


ASSIGN COMPONENT IS_FIELDCAT-FIELDNAME OF
STRUCTURE <L_LINE> TO <L_FIELD>.
WA_FINAL_CD-COMP_CODE = <L_FIELD>.

*****************************************
WHEN 'Cost Center'.
ASSIGN COMPONENT IS_FIELDCAT-FIELDNAME OF
STRUCTURE <L_LINE> TO <L_FIELD>.
WA_FINAL_CD-COSTCENTER = <L_FIELD>.
UNASSIGN <L_FIELD>.

WHEN 'Controlling Area'.


ASSIGN COMPONENT IS_FIELDCAT-FIELDNAME OF
STRUCTURE <L_LINE> TO <L_FIELD>.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 10
Creating Virtual Cube based on Function Module in SAP BI

WA_FINAL_CD-CO_AREA = <L_FIELD>.
UNASSIGN <L_FIELD>.

WHEN 'Currency Type'.


ASSIGN COMPONENT IS_FIELDCAT-FIELDNAME OF
STRUCTURE <L_LINE> TO <L_FIELD>.
WA_FINAL_CD-CURTYPE = <L_FIELD>.
UNASSIGN <L_FIELD>.

WHEN 'Due Date'.


ASSIGN COMPONENT IS_FIELDCAT-FIELDNAME OF
STRUCTURE <L_LINE> TO <L_FIELD>.
WA_FINAL_CD-DUEDATE = <L_FIELD>.
UNASSIGN <L_FIELD>.

WHEN 'Period (Entry)'.


ASSIGN COMPONENT IS_FIELDCAT-FIELDNAME OF
STRUCTURE <L_LINE> TO <L_FIELD>.
WA_FINAL_CD-FISCPER3_E = <L_FIELD>.
UNASSIGN <L_FIELD>.

WHEN 'G/L Account'.


ASSIGN COMPONENT IS_FIELDCAT-FIELDNAME OF
STRUCTURE <L_LINE> TO <L_FIELD>.
WA_FINAL_CD-GL_ACCOUNT = <L_FIELD>.
UNASSIGN <L_FIELD>.

WHEN 'Profit Center'.


ASSIGN COMPONENT IS_FIELDCAT-FIELDNAME OF
STRUCTURE <L_LINE> TO <L_FIELD>.
WA_FINAL_CD-PROFIT_CTR = <L_FIELD>.
UNASSIGN <L_FIELD>.

WHEN 'Segment'.
ASSIGN COMPONENT IS_FIELDCAT-FIELDNAME OF
STRUCTURE <L_LINE> TO <L_FIELD>.
WA_FINAL_CD-SEGMENT = <L_FIELD>.
UNASSIGN <L_FIELD>.

WHEN 'Flag for G\L Non Cur'.


ASSIGN COMPONENT IS_FIELDCAT-FIELDNAME OF
STRUCTURE <L_LINE> TO <L_FIELD>.
WA_FINAL_CD-/BIC/ZF_NCURR = <L_FIELD>.
UNASSIGN <L_FIELD>.

WHEN 'Nature'.
ASSIGN COMPONENT IS_FIELDCAT-FIELDNAME OF
STRUCTURE <L_LINE> TO <L_FIELD>.
WA_FINAL_CD-/BIC/ZNATUR_JV = <L_FIELD>.
UNASSIGN <L_FIELD>.

WHEN 'Translation Date'.


ASSIGN COMPONENT IS_FIELDCAT-FIELDNAME OF
STRUCTURE <L_LINE> TO <L_FIELD>.
WA_FINAL_CD-/BIC/ZTRANS_DT = <L_FIELD>.
UNASSIGN <L_FIELD>.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 11
Creating Virtual Cube based on Function Module in SAP BI

WHEN 'Fiscal year/period'.


ASSIGN COMPONENT IS_FIELDCAT-FIELDNAME OF
STRUCTURE <L_LINE> TO <L_FIELD>.
WA_FINAL_CD-FISCPER = <L_FIELD>.
UNASSIGN <L_FIELD>.

WHEN 'Fiscal Year Variant'.


ASSIGN COMPONENT IS_FIELDCAT-FIELDNAME OF
STRUCTURE <L_LINE> TO <L_FIELD>.
WA_FINAL_CD-FISCVARNT = <L_FIELD>.
UNASSIGN <L_FIELD>.

WHEN 'Fiscal year'.


ASSIGN COMPONENT IS_FIELDCAT-FIELDNAME OF
STRUCTURE <L_LINE> TO <L_FIELD>.
WA_FINAL_CD-FISCYEAR = <L_FIELD>.
UNASSIGN <L_FIELD>.

WHEN 'Total credit postgs'.


ASSIGN COMPONENT IS_FIELDCAT-FIELDNAME OF
STRUCTURE <L_LINE> TO <L_FIELD>.
WA_FINAL_CD-CREDIT = <L_FIELD>.
UNASSIGN <L_FIELD>.

WHEN 'Total Debit Postings'.


ASSIGN COMPONENT IS_FIELDCAT-FIELDNAME OF
STRUCTURE <L_LINE> TO <L_FIELD>.
WA_FINAL_CD-DEBIT = <L_FIELD>.
UNASSIGN <L_FIELD>.

ENDCASE.
APPEND WA_FINAL_CD TO ITAB_FINAL_CD.

ENDLOOP.
ENDLOOP.
*
* wa_final_cd-calday = p_date_cd.

Till here we have our data for VC in ITAB_FINAL _CD table. Now we have to push same in E_T_DATA.
* get description of components of <L_S_DATA_cd>
PERFORM GET_TYPE_COMPONENTS(SAPLRSDRC_SERVICES)
USING <L_S_DATA_CD>
CHANGING L_T_COMPONENT_CD.

Perform statement gives Length and types for E_T_DATA table (<L_S_DATA_CD>
The output in L_T_COMPONENT_CD will be and this will be used in following code.

Length Decimal Type Name


8 0 C K____198
8 0 C K____197
20 0 C K____894

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 12
Creating Virtual Cube based on Function Module in SAP BI

Now we have data in ITAB_FINAL_CD which we have to push in E_T_DATA. The FM


MOVE_ITAB_TO_DATA pushes corresponding fields (I_TH_SFC/SFK) from CD_CUBE_STRUC to
<L_S_DATA_CD> with the help of RSD_FIELDNM_GET_FROM_IOBJNM FM. It reads those fields that are
common in I_TH_SFC/SFK and <L_S_DATA_CD> from CD_CUBE_STRUC and puts that in
<L_S_DATA_CD>. L_T_COMPONENT_CD contains name of columns in <L_S_DATA_CD>. So with using
RSD_FIELDNM_GET_FROM_IOBJNM it gets K___* name and if it is there in I_TH_SFC/SFK then picking
no of row from L_T_COMPONENT_CD, it puts into same no column of <L_S_DATA_CD>.
LOOP AT ITAB_FINAL_CD INTO CD_CUBE_STRUC.

PERFORM MOVE_ITAB_TO_DATA
USING CD_CUBE_STRUC
I_TH_SFC
I_TH_SFK
L_T_COMPONENT_CD
CHANGING <L_S_DATA_CD>.

APPEND <L_S_DATA_CD> TO E_T_DATA.

ENDLOOP.

E_END_OF_DATA = 'X'.

ENDFUNCTION.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 13
Creating Virtual Cube based on Function Module in SAP BI

Related Content
Virtual InfoCubes with Services
How to implement a virtual infoprovider with services
Virtual InfoCubes
For more information, visit the EDW homepage.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 14
Creating Virtual Cube based on Function Module in SAP BI

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 | UAC - uac.sap.com
© 2011 SAP AG 15

You might also like