Академический Документы
Профессиональный Документы
Культура Документы
Query Data
Applies to:
This article is applicable to all the SAP BI 7.0 consultants who are novice with SAP ABAP skills. For more
information, visit the EDW homepage.
Summary
This document specifies the detailed understanding of using the standard SAP BI function modules
(RRW3_GET_QUERY_VIEW_DATA) to fetch the Query data.
Author Bio
Suraj Tigga is a Senior SAP BI / ABAP consultant at Capgemini Consulting, India. Suraj joined
Capgemini Consulting in 2008 and has worked on multiple SAP BI implementation and
support Projects.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 1
ABAP Code – To fetch SAP BI Query Data
Table of Contents
Scenario ....................................................................................................................................................... 3
Step-by-Step Solution ................................................................................................................................ 3
Query Design ............................................................................................................................................................... 3
ABAP Code (Logic) ...................................................................................................................................................... 4
Execution ..................................................................................................................................................................... 7
Related Content ............................................................................................................................................ 9
Copyright ....................................................................................................... Error! Bookmark not defined.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 2
ABAP Code – To fetch SAP BI Query Data
Scenario
To fetch the query output values and fed the data to a direct DSO.To handle huge amount of data
we have to design the ABAP code to support specific data package entered in the selection screen.
Step-by-Step Solution
ABAP Solution is explained in two sections:
Query Design: Shows the query elements whose values would be fed into Direct DSO
ABAP Code (Logic): Briefly explains the flow logic of the code.
Query Design
Technical Name: ZPHMMINM19_DJ28_INVENTORY
Query is built on a multiprovider PHMMINM19 which contain the material movements corresponding to
different regions. Now the key figure 0TOTALSTCK (Quantity Total Stock) is non-cumulative (which is based
on 0RECTOTSTCK (Receipt Quantity Total Stock) and 0ISSTOTSTCK (Issue Quantity Total Stock)).
Our aim was to fetch the values of 0TOTALSTCK specific to every month in a year. Since this is a non
cumulative key figure so the mapping of this key figure to any next level data target is not possible .So to get
the values we have to use BI query, which is further fed into direct DSO. To suffice this particular
requirement we have created a ABAP code which would pick the query output data for a particular month
and update the values in direct DSO.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 3
ABAP Code – To fetch SAP BI Query Data
When the ABAP code is executed in background then by default the last month values would be fetched
(Which would be executed for all the materials ranging from 00000001 to 10000000)
While executing the code in background a default variant has to be saved with values mentioned:
Month: 02/2010
Material: Range (00000001 to 10000000)
No of Data Packets: 1000
Update Data (DSO): Checked
Step2: Define the packet size with reference to the values entered in selection screen. This further defines
the low and high values for the materials
As mentioned above about the package size which has to be maintained so that the code works for the huge
data set records.
Since the data packet size is 1000 and total material range is (00000001 to 10000000).So for each iteration
(Of materials depending on the packet size) equal to [ (Material High Value) / (Packet Size) ] the function
module RRW3_GET_QUERY_VIEW_DATA is called.
Material High Value / Packet Size = (10000000 / 1000) = 10000.
Iteration 1: 00000001 – 00010000
Iteration 2: 00010001 – 00020000
Iteration 3: 00020001 – 00030000
Iteration count values would be stored in variable l_count .Simultaneously the low and high values would be
stored in wl_range-low and wl_range-high.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 4
ABAP Code – To fetch SAP BI Query Data
Step3: Populate the parameters to be filled before the function module RRW3_GET_QUERY_VIEW_DATA is
called
Brief details about the Function Module
Import Parameters:
I_INFOPROVIDER: Infoprovider name
I_QUERY: Query name
I_T_PARAMETER: Contains the selection conditions based on which the query data is returned
Export Parameters:
E_CELL_DATA: Contains Key Figure values
E_AXIS_DATA: Contains Characteristic Values
ABAP Code
* Infoprovider
w_i_infoprovider = 'PHMMINM19'.
* Query Name
w_i_query = 'ZPHMMINM19_DJ28_INVENTORY' .
* Calmonth
wa_i_parameter-name = 'VAR_NAME_1'.
wa_i_parameter-value = '0I_CALMO'.
APPEND wa_i_parameter TO t_i_parameter.
CLEAR wa_i_parameter.
wa_i_parameter-name = 'VAR_SIGN_1'.
wa_i_parameter-value = 'I'.
APPEND wa_i_parameter TO t_i_parameter.
CLEAR wa_i_parameter.
wa_i_parameter-name = 'VAR_OPERATOR_1' .
wa_i_parameter-value = 'BT'.
APPEND wa_i_parameter TO t_i_parameter.
CLEAR wa_i_parameter.
* Calmonth
wa_i_parameter-name = 'VAR_VALUE_LOW_EXT_1' .
wa_i_parameter-value = p_month.
APPEND wa_i_parameter TO t_i_parameter.
CLEAR wa_i_parameter.
wa_i_parameter-name = 'VAR_VALUE_HIGH_EXT_1'.
wa_i_parameter-value = p_month.
APPEND wa_i_parameter TO t_i_parameter.
CLEAR : wa_i_parameter.
* Material
CONCATENATE 'VAR_NAME_' l_count INTO l_name.
wa_i_parameter-name = l_name.
wa_i_parameter-value = '0S_MAT'.
APPEND wa_i_parameter TO t_i_parameter.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 5
ABAP Code – To fetch SAP BI Query Data
wa_i_parameter-name = l_operator.
wa_i_parameter-value = 'BT'.
APPEND wa_i_parameter TO t_i_parameter.
ENDIF.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 6
ABAP Code – To fetch SAP BI Query Data
Execution
Execute the ABAP Code and enter the values for month, material and data packet
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 7
ABAP Code – To fetch SAP BI Query Data
ABAP Code Report (Displays the values which are updated in DSO):
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 8
ABAP Code – To fetch SAP BI Query Data
Related Content
Help.sap Link
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
© 2010 SAP AG 9
ABAP Code – To fetch SAP BI Query Data
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 10