You are on page 1of 15

How to Get the List of Queries Having a Particular Variable, Infoobject

Applies to:
SAP BI 7.0. For more information, visit the EDW homepage.

Summary
Sometimes it is extremely tedious task to get the list of queries having a particular Variable, Info Object rather checking one by one from metadata repository. This paper gives the list of tables and how to retrieve the information using these tables. In order to retrieve this information into an Excel for better documentation and distribution, a program is written with integration of OLE2 Concept which is supported by ABAP rather than printing on screen.

Author:

Vamsi Kiran Talluri

Company: Tata Consultancy Services Ltd. Created on: 20 May 2011

Author Bio
The author works for Tata Consultancy Services Ltd. His expertise includes SAP BI and ABAP.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 1

How to Get the List of Queries Having a Particular Variable, Infoobject

Table of Contents
Introduction ......................................................................................................................................................... 3 How to Get the List of all the Queries that are Having a Particular Variable ...................................................... 4 Tables.............................................................................................................................................................. 4 How to Retrieve this Information from the Tables ........................................................................................... 4 Sample Code .................................................................................................................................................. 5 How to Get the List of all the Queries that are Having a Particular Infoobject ................................................... 6 Tables.............................................................................................................................................................. 6 How to Retrieve this Information from the Tables ........................................................................................... 6 Sample Code .................................................................................................................................................. 7 How to Get the List of all the Queries on a Multiprovider / Infocube .................................................................. 8 Tables.............................................................................................................................................................. 8 How to Retrieve this Information from the Tables ........................................................................................... 8 Sample Code .................................................................................................................................................. 8 ABAP OLE Automation ....................................................................................................................................... 9 Output .................................................................................................................................................... 10 Conclusions ...................................................................................................................................................... 13 Related Content ................................................................................................................................................ 14 Disclaimer and Liability Notice .......................................................................................................................... 15

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 2

How to Get the List of Queries Having a Particular Variable, Infoobject

Introduction
Sometimes it is extremely tedious task to get the list of queries having a particular Variable, Info Object rather checking one by one from metadata repository. This paper gives the list of tables and how to retrieve the information using these tables. In order to retrieve this information into an Excel for better documentation and distribution, a program is written with integration of OLE2 Concept which is supported by ABAP rather than printing on screen.

This paper provides the information for the below questions 1) How to get the list of all the queries that are having a particular variable? 2) How to get the list of all the queries that are having a particular Infoobject? 3) How to get the list of all the queries on a Multiprovider / Infocube?

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 3

How to Get the List of Queries Having a Particular Variable, Infoobject

How to Get the List of all the Queries that are Having a Particular Variable
Tables a) RSZGLOBV b) RSZELTXREF c) RSRREPDIR d) RSZELTTXT

How to Retrieve this Information from the Tables a) In Order to find the list of all the queries having a particular variable, we need to first find the UID of the variable. This can be obtained in the advanced tab of the variable in Query designer or you can obtain the same information in table RSZGLOBV where in we enter variable name in VNAM and UID is obtained from VARUNIID field. EX: 0I_FY_OP Variable.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 4

How to Get the List of Queries Having a Particular Variable, Infoobject

b) We need to take above UID, go to table RSZELTXREF and place this UID into TELTUID field c) From the above step, we may get multiple values of SELTUID if this Variable is used in more than one query. We need to take each of the above SELTUID and repeat steps d, e to get the query UID. d) Take the SELTUID obtained in above step and go back to the table again and place this value in TELTUID after executing we may get more than one value. Take a single SELTUID obtained in this step and repeat this same step d until we get no entries while placing SELTUID into TELTUID of the same table. e) The last SELTUID where you get no entries from the table when placed into TELTUID field of RSZELTXREF is the UID of the query. f) Once we get UID, we can get the Infocube, Technical name of query from RSRREPDIR, and the description of the Query from RSZELTTXT.

g) Repeat the steps from c f for next SELTUID for the other query list.

Sample Code
DATA : L_ELTUID type RSZELTDIR-ELTUID. SELECT-OPTIONS : VRQUER FOR RSZELTXREF-SELTUID. Select * from RSZELTXREF where OBJVERS = 'A' and TELTUID IN VRQUER. L_ELTUID = RSZELTXREF-SELTUID. Perform GETVAR_IO. ENDSELECT.

FORM GETVAR_IO. Select single * from RSZELTXREF where OBJVERS = 'A' and TELTUID = L_ELTUID.

If sy-subrc eq 0. L_ELTUID = RSZELTXREF-SELTUID. PERFORM GETVAR_IO. Else. Select RDIR~COMPUID RDIR~INFOCUBE RDIR~COMPID RTXT~TXTLG from RSRREPDIR as RDIR join RSZELTTXT as RTXT on RDIR~COMPUID = RTXT~ELTUID appending Corresponding fields of table it_var_io where RDIR~objvers = 'A' and RDIR~COMPUID = L_ELTUID and RTXT~objvers = 'A' and RTXT~LANGU = 'E'.

Endif. ENDFORM.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 5

How to Get the List of Queries Having a Particular Variable, Infoobject

How to Get the List of all the Queries that are Having a Particular Infoobject
Tables a) RSZSELECT b) RSZELTXREF c) RSZELTDIR d) RSRREPDIR e) RSZELTTXT How to Retrieve this Information from the Tables a) In Order to find the list of all the queries having a particular Infoobject, we need to first find the UID of the Infoobjects in various queries. In the above case, the UID for a variable is same across all the queries, but the UID of an Infoobject varies per query. So we will get the list of UIDs in ELTUID field from RSZSELECT table with IOBJNM field as input. b) We need to take this UID and once we get the above UID, go to table RSZELTXREF and place this UID into TELTUID field as shown below. c) From the above step, we may get multiple values of SELTUID if this Infoobject is used in more than one query. We need to take each of the above SELTUID and repeat steps d, e to get the query UID. d) Take the SELTUID obtained in above step and go back to the table again and place this value in TELTUID we may get more than one value. Take a single SELTUID obtained in this step and repeat this same step d until we get no entries while placing SELTUID into TELTUID of the same table. e) The last SELTUID where you get no entries from the table when placed into TELTUID field of RSZELTXREF is the UID of the query. f) Once we get UID, we can get the Infocube, Technical name of query from RSRREPDIR, and the description of the Query from RSZELTTXT.

g) Repeat the steps from c f for next SELTUID for the other query list.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 6

How to Get the List of Queries Having a Particular Variable, Infoobject

Sample Code
DATA : L_ELTUID type RSZELTDIR-ELTUID. SELECT-OPTIONS: IOQUER FOR RSZSELECT- IOBJNM. Select * from RSZSELECT where OBJVERS = 'A' and IOBJNM IN IOQUER. L_ELTUID = RSZSELECT-ELTUID. Perform GETQUER_IO. ENDSELECT.

FORM GETQUER_IO. Select single * from RSZELTXREF where OBJVERS = 'A' and TELTUID = L_ELTUID.

If sy-subrc eq 0. L_ELTUID = RSZELTXREF-SELTUID. PERFORM GETQUER_IO. Else. Select RDIR~COMPUID RDIR~INFOCUBE RDIR~COMPID RTXT~TXTLG from RSRREPDIR as RDIR join RSZELTTXT as RTXT on RDIR~COMPUID = RTXT~ELTUID appending Corresponding fields of table it_qry_io where RDIR~objvers = 'A' and RDIR~COMPUID = L_ELTUID and RTXT~objvers = 'A' and RTXT~LANGU = 'E'.

Endif. ENDFORM.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 7

How to Get the List of Queries Having a Particular Variable, Infoobject

How to Get the List of all the Queries on a Multiprovider / Infocube


Tables a) RSRREPDIR b) RSZELTTXT How to Retrieve this Information from the Tables a) Give the name of the Multiprovider/ Infocube on which we want to get the list of all the reports into the INFOCUBE field of the RSRREPDIR. This returns the list of all the queries for which the technical name is present in COMPID and query UID is present in COMPUID field. Using the COMPUID field, go to RSZELTTXT table and place this value into ELTUID field and the TXTLG/TXTSH gives the description of the Query.

b)

Sample Code
SELECT-OPTIONS : MULTPROV FOR RSRREPDIR-INFOCUBE. Select * from RSRREPDIR into Corresponding fields of table it_qry where INFOCUBE in MultProv and objvers = 'A' and COMPUID not like '!%'. Select Single * from RSZELTTXT where ELTUID = RSRREPDIR-COMPUID and objvers = 'A' and LANGU = 'E'. EndSelect.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 8

How to Get the List of Queries Having a Particular Variable, Infoobject

ABAP OLE Automation


a. This paper uses OLE Automation concept supported by ABAP for putting the data from internal tables to desktop application like Excel in our case which can be useful for better documentation. b. In Order to use OLE, we need to include the type-pool OLE2 which is included in the INCLUDE OLE2INCL. The list of applications that are supported by OLE can be checked in SOLE transaction. c. We need to create various OLE objects for creating an excel application and corresponding sheet.
DATA: application TYPE ole2_object, workbook TYPE ole2_object, sheet TYPE ole2_object, cells TYPE ole2_object. CREATE OBJECT application 'excel.application'. SET PROPERTY OF application 'visible' = 1. CALL METHOD OF application 'Workbooks' = workbook. CALL METHOD OF workbook 'Add'.

d. In order to print the header for meaningful description in the excel we need to use below statements..
CALL METHOD OF application 'Worksheets' = sheet EXPORTING #1 = 1. CALL METHOD OF sheet 'Activate'. CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = 1 #2 = 1. SET PROPERTY OF cells 'Value' = 'MULTIPROVIDER'. CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = 1 #2 = 2. SET PROPERTY OF cells 'Value' = 'QUERY UID'. CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = 1 #2 = 3. SET PROPERTY OF cells 'Value' = 'QUERY TECHNICAL NAME'. CALL METHOD OF sheet 'Cell s' = cells EXPORTING #1 = 1 #2 = 4. SET PROPERTY OF cells 'Value' = 'QUERY DESCRIPTION'. The output of the internal table(IT)can be put into the excel application as below. Loop in the internal table and put each of the record in Excel which is similar to printing on the screen. loop at IT into WA index_ex = sy-tabix + 1. CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index_ex #2 = 1. SET PROPERTY OF cells 'Value' = WA-infocube. CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index_ex #2 = 2. SET PROPERTY OF cells 'Value' = WA-compuid. CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index_ex #2 = 3. SET PROPERTY OF cells 'Value' = WA-compid. CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index_ex #2 = 4. SET PROPERTY OF cells 'Value' = WA-txtlg. endloop.

e. There are several other properties of OLE where we can use for formatting colours, font etc. which are not covered in this paper.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 9

How to Get the List of Queries Having a Particular Variable, Infoobject

Output
After implementing with little modifications to sample code and after integration with ABAP OLE in a program, below are the screenshots of the program execution screen and the outputs in Excel.

On executing this program, we get the above selections. IOQUER, here we need to input the Infoobject technical name and it gives all the queries where it has been used into an Excel. 1) We want to know the list of all the queries having Infoobject 0CALDAY.

These are the list of the queries that are having 0CALDAY. The Excel can be saved for documentation and distribution.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 10

How to Get the List of Queries Having a Particular Variable, Infoobject

In order to cross check, I have taken the first report and we can see 0CALDAY is present, similarly for other reports also the field is present.

2) We want to know the list of all the queries having variable 0TCTDATS (shown in above screenshot i.e. variable of 0CALDAY).

For this we first need to get the UID of 0TCTDATS, we can go to RSZGLOBV and put the variable name in VNAM and the UID can be obtained from VARUNIID. In this case it is D06YIRSC5PZEJ6WEA52ESJ0Y2 and enter the UID in VRQUER selection.

After executing the output is obtained in Excel as below. We can see the first query as the above query itself where this particular variable has been used.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 11

How to Get the List of Queries Having a Particular Variable, Infoobject

3) List of all queries on a Multiprovider / Infocube.

From RSRT, I could see the same three queries are present on the given Infocube/Multiprovider.

Note: I had taken single Multiprovider, single Infoobject or variable at a time and brought the output into excel. You can give more than one Multiprovider and you can get all the list of queries on them at a single go.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 12

How to Get the List of Queries Having a Particular Variable, Infoobject

Conclusions
The above sample code can be implemented one time and can be used for obtaining the where used list of all the queries based on various criteria, saving more time while documentation and other purposes in our corresponding projects. There is one standard program provided by SAP, which I want to mention in my paper i.e. RSRQ_QUERYDEFINITION which gives the entire query definition where in we can see a query has an particular Infoobject or variable. We can also get the same information from Metadata Repository. But the main advantage of the above one time program is we need not go and check each and every report one by one. Also the outputs are obtained into Excels which can be used for better documentation and distribution. This paper doesnt speak in depth about the OLE concepts. It aims in bringing the data from internal tables to Excel application.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 13

How to Get the List of Queries Having a Particular Variable, Infoobject

Related Content
For more information, visit the EDW homepage

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 14

How to Get the List of Queries Having a Particular Variable, Infoobject

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 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 15

You might also like