Можно еще v_cmp_join.
Function module to search for queries by certain elements BY Serge Daniel KnappCode:
FUNCTION zwul_query_search.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(PI_IOBJ) TYPE RSD_IOBJNM OPTIONAL
*" REFERENCE(PI_CUBE) TYPE RSINFOCUBE OPTIONAL
*" REFERENCE(PI_UNAME) TYPE XUBNAME OPTIONAL
*" REFERENCE(PI_TYPE) TYPE CHAR1 DEFAULT 'A'
*" EXPORTING
*" REFERENCE(E_T_COMPLIST) TYPE RZD1_T_COMPDIR_COMPIC
*"----------------------------------------------------------------------
* Table type for key figure/characteristic
TYPES: BEGIN OF t_eltuid,
eltuid TYPE sysuuid_25,
END OF t_eltuid.
* Data definition
DATA: lt_eltuid TYPE TABLE OF t_eltuid, " Unique IDs for InfoObject
lr_cube TYPE RANGE OF rsinfocube, " Range for faster search (Cube)
lr_owner TYPE RANGE OF rsowner, " Range for faster search (owner)
lr_tstpnm TYPE RANGE OF rststpnm, " Range for faster search (modifier)
ls_cube LIKE LINE OF lr_cube, " Local structure InfoCube (range)
ls_owner LIKE LINE OF lr_owner, " Local structure Owner (range)
ls_tstpnm LIKE LINE OF lr_tstpnm. " Local structure Modifier (range)
* create ranges for input variables
FREE lr_cube.
CLEAR ls_cube.
IF pi_cube IS NOT INITIAL.
ls_cube-sign = 'I'.
ls_cube-option = 'EQ'.
ls_cube-low = pi_cube.
APPEND ls_cube TO lr_cube.
ENDIF.
* create two ranges, one for owner, one for modifier
* --> one select statement can be used, otherwise you will need two
IF pi_uname IS NOT INITIAL.
IF pi_type = 'A'.
FREE lr_owner.
FREE lr_tstpnm.
CLEAR ls_owner.
ls_owner-sign = 'I'.
ls_owner-option = 'EQ'.
ls_owner-low = pi_uname.
APPEND ls_owner TO lr_owner.
ELSEIF pi_type = 'M'.
FREE lr_owner.
FREE lr_tstpnm.
CLEAR ls_tstpnm.
ls_tstpnm-sign = 'I'.
ls_tstpnm-option = 'EQ'.
ls_tstpnm-low = pi_uname.
APPEND ls_tstpnm TO lr_tstpnm.
ENDIF.
ENDIF.
* Is InfoObject provided? --> Character or Key figure?
FREE lt_eltuid.
IF pi_iobj IS NOT INITIAL.
* Get all characteristics (if applicable)
SELECT DISTINCT eltuid FROM rszselect
APPENDING CORRESPONDING FIELDS OF TABLE lt_eltuid
WHERE objvers = 'A'
AND ( iobjnm = pi_iobj OR coniobjnm = pi_iobj ).
* Get all key figures (if applicable)
SELECT DISTINCT eltuid FROM rszrange
APPENDING CORRESPONDING FIELDS OF TABLE lt_eltuid
WHERE objvers = 'A'
AND iobjnm = rsd_c_metaiobj-keyfigure
AND seltp = rzd1_c_seltp-keyfig
AND low = pi_iobj.
ENDIF.
* Search for queries with infoobject, cube and user (if applicable)
SELECT d~compuid x~objvers x~infocube t~txtlg d~compid u~owner u~tstpnm
INTO CORRESPONDING FIELDS OF TABLE e_t_complist
FROM ( ( ( rszeltxref AS x
INNER JOIN rsrrepdir AS d
ON d~compuid = x~seltuid
AND d~objvers = x~objvers
AND d~infocube = x~infocube )
INNER JOIN rszelttxt AS t
ON t~eltuid = x~seltuid
AND t~objvers = x~objvers )
INNER JOIN v_cmp_join AS u
ON u~compuid = x~seltuid
AND u~objvers = x~objvers )
FOR ALL ENTRIES IN lt_eltuid
WHERE x~teltuid = lt_eltuid-eltuid
AND x~objvers = 'A'
AND x~infocube IN lr_cube
AND u~owner IN lr_owner
AND u~tstpnm IN lr_tstpnm
AND u~deftp = 'REP'.
* The statement selects a bit more entries than needed, delete the unnecessary information
DELETE ADJACENT DUPLICATES FROM e_t_complist COMPARING compuid.
ENDFUNCTION.