Show TOC

Details for Implementing the Inversion RoutineLocate this document in the navigation structure

Use

Set Objects

The purpose of an inverse transformation is to convert selection conditions of the query that are formulated for the target of the transformation (outbound) into selection conditions for the source (inbound). To do this, the selection conditions are converted into a multidimensional set object. In ABAP objects, these are the instances of class CL_RSMDS_ST). The advantage of this representation is that set operations (intersection, union, and complement), that can only be processed with a great deal of effort with the usual RANGE table representation, can now be processed easily.

Universes

There are always two uniquely defined trivial instances of class CL_RSMDS_SET that represent the empty set and the total set (that is, all the values). You can recognize these instances from the result RSMDS_C_BOOLEAN-TRUE of the functional methods IS_EMPTY and IS_UNIVERSAL. All other instances are always assigned to a Universe (instance of class CL_RSMDS_UNIVERSE) and return the result RSMDS_C_BOOLEAN-TRUE for the specified methods. You can obtain the reference of the assigned universe for non-trivial instances of class CS_RSMDS_SET with method GET_UNIVERSE. This method returns an initial reference for these two trivial instances since the universe is not uniquely defined in this case.

A universe represents the sum of all the dimensions (represented by instances of the interface IF_RSMDS_DIMENSION). A dimension is always uniquely defined by a dimension name in the universe. With method GET_DIMENSION_BY_NAME in class CL_RSMDS_UNIVERSE, you can obtain a dimension reference using the unique dimension name. The dimension name is generally the same as the field name in a structure. There are different types of universe in the system (subclasses of class CL_RSMDS_UNIVERSE). The dimensions have different meanings. For example, a dimension corresponds to an InfoObject in class CL_RS_INFOOBJECT_UNIVERSE. In the case of InfoObjects, you have the two methods IOBJNM_TO_DIMNAME and DIMNAME_TO_IOBJNM that transform an InfoObject name into a dimension name or a dimension name into an InfoObject name. For an InfoObject-based universe, there is exactly one instance (singleton) that contains (nearly) all the active InfoObjects in the system as dimensions (with the exception of InfoObjects in InfoSets). This instance is returned with the method GET_INSTANCE of class CL_RS_INFOOBJECT_UNIVERSE.

In the case of DataSources, there is a uniquely defined universe for each combination of logical system name (I_LOGSYS), DataSource name (I_DATASOURCE) and segment ID (I_SEGID). You can find the reference of the universe with the method CREATE_FROM_DATASOURCE_KEY of class CL_RSDS_DATASOURCE_UNIVERSE. The initial segment ID always provides the primary segment, which normally is the only segment on which selection conditions can be formulated for a source and accepted. All the fields in the DataSource segment that are selected for direct access form the dimensions of a DataSource universe with the same name. Here, too, you get a dimension reference (instance for interface IF_RSMDS_DIMENSION) with the method GET_DIMENSION_BY_NAME of the universe.

If you want to project a selection to a given dimension from a general selection, that is for any instance of the class CL_RSMDS_SET, you first need a reference to the universe to which the instance belongs (method GET_UNIVERSE, see above). You get the dimension reference from the reference to the universe using the dimension/field name from method GET_DIMENSION_BY_NAME. With the dimension reference, you can then project a representation for a one-dimensional condition using method TO_DIMENSION_SET. You can then convert a one-dimensional projection into an Open SQL or RANGE condition for the corresponding field with the methods TO_STRING and TO_RANGES. Vice versa, you can create an instance on the dimension reference for a one-dimensional set object from a RANGE table using the method CREATE_SET_FROM_RANGES. The SIGNs 'I' and 'E' as well as the OPTIONs 'EQ', 'NE', 'BT', 'NB', 'LE', 'GT', 'LT', 'GE', 'CP' and 'NP' are supported. There are only restrictions for 'CP' and 'NP'. These may only be used for character-type dimensions/fields and may only contain the masking character'*', which must always be at the end of the character chain. For example, 'E' 'NP' 'ABC*' is a valid condition, but 'I' 'CP' '*A+C*' is not.

Using method GET_DIMENSIONS in class CL_RSMDS_SET, you can get a table with the references of all dimensions that are restricted in the corresponding instance of the set object. With the method GET_NAME, you can get the unique dimension name for each dimension reference in the table that is returned. In this way you can check if there is a restriction for a given InfoObject or field. It can be projected as described above.

With the universe reference, you can create an instance for a set object (especially for multidimensional set objects) from an Open SQL expression. In the Open SQL expression that is passed, the "field names" must be the valid dimension names in the universe. You may use elementary conditions with the comparison operators '=', '<>', '<=', '>', '<' und '>=' in the Open SQL expression. The left side must contain a valid dimension name and the right side must contain a literal that is compatible with the data type of the dimension. You can also use elementary conditions with 'BETWEEN', 'IN' and 'LIKE' with the appropriate syntax. Elementary conditions may be linked with the logical operators 'NOT', 'AND' and 'OR' to create complex conditions. You may also use parentheses to change the normal order of evaluation ('NOT' is stronger than 'AND', 'AND' is stronger than 'OR').

With the method CREATE_SET_FROM_RANGES of the universe reference, you can also directly create a set object for a multidimensional condition. To do this, the internal table passed in I_T_RANGES must contain a RANGE structure (with the components SIGN, OPTION, LOW and HIGH) in its row structure and must also have an additional component for a dimension name. Parameter I_FIELDNAME_DIMENSION must pass the name of these components to method CREATE_SET_FROM_RANGES.

You can always create an instance for the complementary condition for any instance of the class CL_RSMDS_SET using the functional method.

If two instances of the class CL_RSMDS_SET belong to the same universe, you can create an instance for the intersection or union by passing the other instance as parameter I_R_SET when you call the functional method INTERSECT or UNITE.

With the method TRANSFORM, you can also transform an instance of a set object into an instance of a set object of another universe. If required, you can thus perform a projection or assign dimension names in a different manner. These methods are recommended, for example if the name of the source field differs from the name of the target field within the transformation. You can pass a reference to the target universe to the method in the optional parameter I_R_UNIVERSE. If the parameter remains initial, the system assumes that the source and target universes are identical. With parameter I_TH_DIMMAPPINGS you can map the dimension names of the source universe (component DIMNAME_FROM) in different dimension names on the target universe (component DIMNAME_TO). If component DIMNAME_TO remains initial, a restriction of the source dimension (in DIMNAME_FROM) is not transformed into a restriction of the target universe. As a result, there is a projection. The following mapping table

DIMNAME_FROM

DIMNAME_TO

AIRLINEID

CARRID

CONNECTID

CONNID

FLIGHTDATE

transforms a set object that corresponds to the Open SQL condition

AIRLINEID = 'LH' AND CONNECTID = '0400' AND FLIGHTDATE = '20070316' OR

AIRLINEID = 'DL' AND CONNECTID = '0100' AND FLIGHTDATE = '20070317'

into a set object that corresponds to the Open SQL condition

CARRID = 'LH' AND CONNID = '0400' OR

CARRID = 'DL' AND CONNID = '0100',

for example.

Start and End Routines

Parameters I_R_SELSET_OUTBOUND and I_R_SELSET_OUTBOUND_COMPLETE are passed to the start and end routines for the transformation of the selection conditions. The references passed in the two parameters are identical for simple queries, and parameter I_IS_MAIN_SELECTION is defined by the constant RS_C_TRUE. For complex queries that, for example contain restricted key figures or structure elements with selections, the inverse start routine is called several times. The first time, I_R_SELSET_OUTBOUND is called with the restrictions from the global filter and the restrictions that are shared by all structure elements. In this call, parameter I_IS_MAIN_SELECTION is also set to RS_C_TRUE. There are further calls with selections for the specific structure element. However, they are combined so that they no longer overlap. In these calls, I_IS_MAIN_SELECTIN is set to RS_C_FALSE. The complete selection condition is contained in I_R_SELSET_OUTBOUND_COMPLETE for all calls. In order to transform the selections exactly in the start and end routines, the transformation of I_R_SELSET_OUTBOUND into a set object C_R_SELSET_INBOUND in the universe of the source structure (is passed as a reference with parameter I_R_UNIVERSE_INBOUND) must be made exactly for each call. This must be documented by returning the value RS_C_TRUE in parameter C_EXACT.

Expert Routines

Parameter I_R_SELSET_OUTBOUND always passes the complete selections of the target to the expert routine. The expert routine must return a complete selection for the source in C_R_SELSET_INBOUND. As previously for the start and end routines, it could be advantageous to break down a complex selection S into a global selection G and several disjoint subsections Ti (i = 1...n). You can break down the passed reference with the method GET_CARTESIAN_DECOMPOSITION. You can see the global selection in parameter E_R_SET; the subselections are entries in the internal table that is returned in parameter E_TR_SETS. For the decomposition, the following is always applicable:

and

You should invert the global selection and each subselection individually

and compose the inverted results again in the form

Usually you can only ensure an exact inversion of a complex selection condition by using this type of decomposition. If the method GET_CARTESIAN_DECOMPOSITION is called with I_REDUCED = RSMDS_C_BOOLEAN-FALSE, the following is already valid for the decomposition

It is no longer applicable if the call is made with I_REDUCED = RSMDS_C_BOOLEAN-TRUE and

is usually a superset of S. In this case, the selections Ti are usually simpler.

Passing the Selection Conditions

If the transformed selection conditions for the source return exactly the data records that satisfy the selection conditions of the target after execution of the transformation, then the inverse transformation is considered to be exact. This will not always be possible. For this reason a transformation that is not exact may provide more data records than are needed to satisfy the selection conditions of the target. You can ensure that the results are exact by filtering them with the selection conditions of the target. An inverse transformation, however, should not create a selection condition for the source that selects fewer data records from the source than are needed to satisfy the selection condition of the target.

An inverse transformation that is not exact is indicated by the return value RS_C_FALSE in parameter C_EXACT for at least one inverse routine run. This only has an effect on the performance for queries on the analytic manager (OLAP) since they are always filtered again there. However, in the RSDRI interface, in transaction LISTCUBE, and in function Display Data in the context menu of a VirtualProvider, there is no further filtering and the superfluous records are returned or displayed. The property of being exact for an inverse transformation otherwise only has an effect if it is called in the report-report interface. An inversion that is not exact always causes the selection screen to be displayed before the target transaction is executed. This gives the user the chance to check the selections again and to correct them if necessary.

An inverse routine that is not implemented always requests all the values for all the source fields of this routine. Accordingly, parameters C_R_SELSET_INBOUND and C_EXACT always contain an instance for the "All Values" condition or the value RS_C_FALSE when they are called.

Note

One final comment. Selections are always stored in a normed manner in a set object. This means, for example, that the two Open SQL expressions

CARRID = 'LH' AND FLDATE < '20070101'

and

CONNID <= '20061231' AND CARRID = 'LH'

have the same representation as the set object. If you call all the methods that cause the creation of a set object as result with the parameter I_FINAL = RSMDS_C_BOOLEAN-TRUE (this should normally be the default value), you must also make sure that the two objects are identical in the above case (that is, they should have the same references). To check if two instances of the class CL_RSMDS_SET represent the same selection condition, however, you should nevertheless use the method IS_EQUAL and check against the result RSMDS_C_BOOLEAN-TRUE.