Wednesday, December 07, 2005

[BW] Find BW report element ID with table RSZELTDIR

You can use table RSZELTDIR to search for the element id of all query components.
Useful for transport!!
RSZELTXREF - Query <--> Query elements

===========================
REPORT ZQUERY_DEF_TEST .

Tables: rszeltdir, "query element table
rszelttxt, "query element texts
rszcompdir, "global query elements
e071. "objects in transport requests


*parameters
parameters: Req_id like e071-trkorr.

* selection screen to input long ID 25 char generated name
select-options: long_ID for rszeltdir-eltuid.


*itab to hold related info
data: begin of i_query_desc occurs 0,
local, "Local to Query
eltuid like rszeltdir-eltuid, "25 char generated ID
compid like rszcompdir-compid, "technical name
deftp like rszeltdir-deftp, "element type
el_txt(16), "element type text
* txtsh like rszelttxt-txtsh, "short text
txtlg like rszelttxt-txtlg, "long text
owner like rszcompdir-owner, "owner
end of i_query_desc.

data: xlocal.

sy-tvar0 = Req_id.

*find all query objects for transport request entered
select * from e071 where trkorr = req_id and
object = 'ELEM'.
* add them to the select-options list
long_ID-low = e071-obj_name.
append long_ID.
clear long_ID.

endselect.


*loop through select option table and find details of Query element
Loop at long_ID.
clear: i_query_desc,
rszeltdir,
rszelttxt,
rszcompdir,
xlocal.

select single * from rszeltdir where eltuid = long_ID-low and
objvers = 'A'.
if sy-subrc <> 0.
write: / long_ID-low, ' Query element not found.'.
write: / .

else.
select single * from rszelttxt where eltuid = long_ID-low and
objvers = 'A'.
* if sy-subrc <> 0.
* write: / long_ID-low, ' not found in table RSZELTTXT.'.
endif.

select single * from rszcompdir where compuid = long_ID-low and
objvers = 'A'.
if sy-subrc <> 0.
* write: / long_ID-low, ' not found in table RSZCOMPDIR.'.
xlocal = 'X'.
endif.

* fill itab for list
i_query_desc-local = xlocal.
i_query_desc-eltuid = rszeltdir-eltuid. "25 char generated ID
i_query_desc-compid = rszcompdir-compid. "technical name
i_query_desc-deftp = rszeltdir-deftp. "element type
case i_query_desc-deftp.
when 'SEL'.
if xlocal = 'X'.
i_query_desc-el_txt = 'Selection'.
else.
i_query_desc-el_txt = 'Restricted K/Fig'.
endif.
when 'REP'.
i_query_desc-el_txt = 'Query'.
when 'VAR'.
i_query_desc-el_txt = 'Variable'.
when 'STR'.
i_query_desc-el_txt = 'Structure'.
when 'CKF'.
i_query_desc-el_txt = 'Calculated K/Fig'.
when 'FML'.
i_query_desc-el_txt = 'Formula'.
endcase.
* i_query_desc-txtsh = rszelttxt-txtsh. "short text
i_query_desc-txtlg = rszelttxt-txtlg. "long text
i_query_desc-owner = rszcompdir-owner. "owner

append i_query_desc.
clear i_query_desc.

endloop. "@ long_ID

* list results

sort i_query_desc by local deftp owner.

loop at i_query_desc.
write: / sy-vline,
i_query_desc-eltuid, sy-vline, "25 char generated ID
i_query_desc-compid , sy-vline, "technical name
i_query_desc-deftp , sy-vline, "element type
i_query_desc-el_txt, sy-vline, "element text
*write: / i_query_desc-txtsh , "short text
i_query_desc-txtlg(40) , sy-vline, "long text
i_query_desc-owner , sy-vline.
write: sy-uline .

endloop. "@ i_query_desc