Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

To find Queries by InfoObjects

Hi SDN Community

Here is a reversal of a post made by another developer

List of infoobjects used in a Query

This has the reverse logic... thanks for the tip.

&----


*& Report ZBW_FIND_CHARACTERISTICS_QUERY

*&

&----


************************************************************************

  • SAP Consulting BW Tools:

************************************************************************

*& Find Characteristics in BEx Queries using ABAP

*& List of infoobjects used in a Query

*& Developer: WBHADS 07/06/2011

&----


REPORT ZBW_FIND_CHARACTERISTICS_QUERY.

PARAMETER: CHARACT LIKE rszrange-IOBJNM.

DATA: s_characteristic LIKE rszrange-IOBJNM.

s_characteristic = CHARACT.

DATA: lv_count TYPE i.

DATA: lv_count1 TYPE i.

DATA: lv_count2 TYPE i.

  • Data Declaration

DATA: D_MSG_TEXT(50).

DATA: lc_DIRECTORY(30) TYPE c.

DATA: P_FILE(128).

DATA: FILENAME(128).

DATA: lc_query(60) TYPE c.

DATA: lc_date(30) TYPE c.

DATA: lc_time(30) TYPE c.

DATA: lc_start_time(60) TYPE c.

DATA: lc_syst(30) TYPE c.

DATA: lc_exception(120) TYPE c.

  • RSZELTDIR Directory of the reporting component elements

  • RSZELTTXT Texts of reporting component elements

  • RSZELTXREF Directory of query element references

  • RSRREPDIR Directory of all reports (Query GENUNIID)

  • RSZCOMPDIR Directory of reporting components

  • RSZRANGE Selection specification for an element

  • RSZSELECT Selection properties of an element

  • RSZELTDIR Directory of the reporting component elements

  • RSZCOMPIC Assignment reuseable component <-> InfoCube

  • RSZELTPRIO Priorities with element collisions

  • RSZELTPROP Element properties (settings)

  • RSZELTATTR Attribute selection per dimension element

  • RSZCALC Definition of a formula element

  • RSZCEL Query Designer: Directory of Cells

  • RSZGLOBV Global Variables in Reporting

data: gi_data like rszrange occurs 0 with header line.

  • Determine the queries

tables:

RSZELTTXT,

rszeltdir,

rszeltxref,

rszrange.

data: begin of lt_line occurs 0,

ELTUID like RSZELTDIR-ELTUID, "char 25

MAPNAME like RSZELTDIR-MAPNAME, "char 30

end of lt_line.

data: begin of lt_line1 occurs 0,

SELTUID like rszeltxref-SELTUID, "char 25

TELTUID like rszeltxref-TELTUID, "char 25

LAYTP like rszeltxref-LAYTP, "char 30

end of lt_line1.

data: begin of lt_line2 occurs 0,

ELTUID like rszrange-ELTUID, "char 25

IOBJNM like rszrange-IOBJNM, "char 25

end of lt_line2.

data: lt_tab like standard table of lt_line initial size 0.

data: lt_tab1 like standard table of lt_line initial size 0.

data: lt_tab2 like standard table of lt_line initial size 0.

data: lt_line20(128) TYPE c. " LIKE RSZELTXREF-SELTUID.

data: lt_line30(128) TYPE c. " LIKE RSZELTXREF-SELTUID.

clear lt_line.

lv_count = 0.

lv_count2 = 0.

  • Loop through all the queries

select * from RSZELTDIR

into corresponding fields of lt_line

where DEFTP = 'REP'

and OBJVERS = 'A'.

  • Filter by the Z Developed Queries

IF lt_line-MAPNAME CP 'Z*'.

clear lt_line20.

  • Get the Query Long Name

select single * from RSZELTTXT

into lt_line20

where eltuid = lt_line-eltuid "rszeltdir-eltuid

and objvers = 'A'

and langu = 'EN'.

  • Find all the query elements within the query

select * from rszeltxref

into corresponding fields of lt_line1

where seltuid = lt_line-eltuid "rszeltdir-eltuid

and objvers = 'A'.

IF lt_line1-laytp = 'FIX' OR lt_line1-laytp = 'COL' OR lt_line1-laytp = 'ROW'.

  • Determine if the Query Element is matching to the characteristic

select * from rszrange "appending table gi_data

into corresponding fields of lt_line2

where eltuid = lt_line1-teltuid "rszeltxref-teltuid

and objvers = 'A'

and enum = 1.

  • Populate tables

IF lt_line2-IOBJNM = s_characteristic.

append lt_line-MAPNAME to lt_tab.

lv_count = lv_count + 1.

ENDIF.

endselect.

ENDIF.

endselect.

ENDIF.

endselect.

sort lt_tab by MAPNAME.

delete adjacent duplicates from lt_tab comparing MAPNAME.

  • DIRECTORY represents path where file is stored .

lc_DIRECTORY = '/interfaces/EDW/data/CSM/'.

CONCATENATE 'EDW Queries by Characteristic -' SY-DATUM

'.txt' into P_FILE SEPARATED BY SPACE.

CONCATENATE lc_DIRECTORY P_FILE into FILENAME.

  • Opening the Log File

OPEN DATASET FILENAME FOR OUTPUT IN TEXT MODE

ENCODING DEFAULT.

IF SY-SUBRC NE 0.

WRITE: 'File cannot be opened. Reason:'. ", D_MSG_TEXT.

EXIT.

ENDIF.

CONCATENATE 'System Date -' SY-DATUM 'YYYYMMDD' into lc_date

SEPARATED BY SPACE.

CONCATENATE 'EDW System -' SY-SYSID into lc_syst

SEPARATED BY SPACE.

TRANSFER lc_date TO FILENAME.

TRANSFER lc_start_time TO FILENAME.

TRANSFER lc_syst TO FILENAME.

  • Queries for the parameters

  • loop at gi_data into lt_line.

loop at lt_tab into lt_line.

TRANSFER lt_line TO FILENAME.

endloop. "Query Loop

  • Closing the Log File

CLOSE DATASET FILENAME.

Former Member
Not what you were looking for? View more on this topic or Ask a question