Professional Documents
Culture Documents
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:
Author Bio
The author works for Tata Consultancy Services Ltd. His expertise includes SAP BI and ABAP.
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
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?
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Related Content
For more information, visit the EDW homepage