Introduction
BI reports designed in query designer can be published in various manners. This data can be used for further processing by different SAP and non-SAP systems.
General approach is to push data from BI to other systems is using APD, but due to limitations of APD in some specific cases we had used report program using standard SAP Function Module RRW3_GET_QUERY_VIEW_DATA to generate query output into a flat file in application server.
This approach having some benefits over APD and we can avoid performance overheads of using APDs .
Why this Approach?
Objective: Our objective is to execute a query for certain set of selections and transfer the query output into a flat file.
Solutions:
Most commonly used approach for this kind of requirement is APD. APD involve data source, transformations and data targets. It reads the data from data sources, then performs the transformations and finally stores the result data into the data targets. It is a workbench with an intuitive, GUI for the creation, execution and monitoring of analysis processes. APD is easy to use and efficient in most of the scenarios but have some limitations.
Limitations of APD’s
Report program have some benefits over APD and can work in specific scenarios where APD can’t be used.
Design Process steps for using Report Program
Inputs to report:
Info provider name: optional field of type string (30)
Query name: mandatory field of type string (30)
View name: optional field of type string (30)
Parameters: optional table with two columns [Parameter name, string(30); Parameter value, string(250)]
Stored Procedure name: mandatory field of type string (50)
Logic Applied
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: DEPT_DTE FOR DEPARTURE_DATE. //for a range of values (multiple) needed for selection
PARAMETERS:
QUERY TYPE RSZCOMPID DEFAULT 'ZZCRM_U02_Q002_ESM_MS',
INFOPR TYPE RSINFOPROV DEFAULT 'ZCRM_U02'.
FISCYR FOR FISCAL_YEAR DEFAULT ‘2011’. //for single values
SELECTION-SCREEN END OF BLOCK B1.
V_EXT_NUM = 1.
CONDENSE V_EXT_NUM.
LOOP AT DEPT_DTE.
CONCATENATE C_VAR_NAME V_EXT_NUM INTO T_TABPARAM-NAME.
T_TABPARAM-VALUE = 'ZDEPT_DTE '. //technical name of query input selection parameter
APPEND T_TABPARAM.
CONCATENATE C_VAR_OPERATOR V_EXT_NUM INTO T_TABPARAM-NAME.
T_TABPARAM-VALUE = 'EQ'. //operator
APPEND T_TABPARAM.
CONCATENATE C_VAR_VALUE_LOW_EXT V_EXT_NUM INTO T_TABPARAM-NAME.
T_TABPARAM-VALUE = DEPT_DTE. //value provided by selection screen
APPEND T_TABPARAM.
V_EXT_NUM = V_EXT_NUM + 1. //for multiple values this increment is compulsory
CONDENSE V_EXT_NUM.
APPEND LINES OF T_TABPARAM[] TO I_TABPARAM[].
CALL FUNCTION 'RRW3_GET_QUERY_VIEW_DATA'
EXPORTING
I_INFOPROVIDER = INFOPR
I_QUERY = QUERY
I_VIEW_ID = ''
I_T_PARAMETER = I_TABPARAM
IMPORTING
E_AXIS_INFO = I_AXIS_INFO
E_CELL_DATA = T_CELL_DATA //columns data
E_AXIS_DATA = T_AXIS_DATA //rows data
E_TXT_SYMBOLS = T_TXT_SYMBOLS
EXCEPTIONS
NO_APPLICABLE_DATA = 1
INVALID_VARIABLE_VALUES = 2
NO_AUTHORITY = 3
ABORT = 4
INVALID_INPUT = 5
INVALID_VIEW = 6
OTHERS = 7.
Read table i_axis_info for axis 001.This will again be a table having fields
CHANM: Technical name of characteristics
CHAVL_EXT: To read key value of characteristics
CAPTION: To read text value of characteristics
Read all the rows and pass it to an internal table IT_ROW_COLUMN.
Read table i_axis_info for axis 000 to get number of key figures (columns) .Table T_CELL_DATA contain all the column values.
Read columns and populate them against rows into same internal table IT_ROW_COLUMN.
CONCATENATE '/interfaces/BW/' ‘FILENAME.CSV' INTO V_FILENAME .
//you can create file at your desktop by using CONCATENATE 'c:/TEMP/'‘FILENAME.CSV' into V_FILENAME or it can be passed as a selection parameter.
OPEN DATASET V_FILENAME FOR OUTPUT IN TEXT MODE
ENCODING DEFAULT MESSAGE D_MSG_TEXT.
IF SY-SUBRC NE 0.
WRITE: 'FILE CANNOT BE OPENED. REASON:', D_MSG_TEXT.
EXIT.
ENDIF.
LOOP AT IT_ROW_COLUMN ASSIGNING WA_ROW_COLUMN.
CONCATENATE
WA_ROW_COL-characteristic1_key
WA_ROW_COL- characteristic2_key
WA_ROW_COL- characteristic2_text
WA_ROW_COL-keyFigure1
WA_ROW_COL- keyFigure2
INTO V_STRING SEPARATED BY '|'. //Type of separator required in file
TRANSFER V_STRING TO V_FILENAME.
ENDLOOP.
CLOSE DATASET V_FILENAME.
The file written in application server can be seen after execution of report program by using transaction code AL11 in /interfaces/BW/ directory.
Limitations:
Points to Remember:
Sample Example
Query Details :
Sample Code (Refer attachment)
Sample Output (Refer attachment)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
8 | |
7 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 |