Show TOC Anfang des Inhaltsbereichs

Diese Grafik wird im zugehörigen Text erklärt Beispiel für Invertierungsroutine  Dokument im Navigationsbaum lokalisieren

In diesem Beispiel werden aus dem Feld PASSFORM (Anrede) der Quelle die "deutschen" Schlüssel 'HERR' und 'FRAU' im Zielmerkmal auf die "englischen" Schlüssel 'MR' und 'MRS' abgebildet. Alle anderen Werte aus dem Quellfeld werden auf den Initialwert abgebildet.

So sieht das Coding der Routine aus:

Syntax

*---------------------------------------------------------------------*
*       CLASS routine DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_transform DEFINITION.
  
PUBLIC SECTION.

    
TYPES:
      
BEGIN OF _ty_s_SC_1,
*      Field: PASSFORM Anrede.
        PASSFORM           
TYPE C LENGTH 15,
      
END   OF _ty_s_SC_1.
    
TYPES:
      
BEGIN OF _ty_s_TG_1,
*      InfoObject: 0PASSFORM Anrede.
        PASSFORM           
TYPE /BI0/OIPASSFORM,
      
END   OF _ty_s_TG_1.
  
PRIVATE SECTION.

    
TYPE-POOLS: rsd, rstr.

*$*$ begin of global - insert your declaration only below this line  *-*
    
DATA p_r_set_mr    TYPE REF TO cl_rsmds_set.
    
DATA p_r_set_mrs   TYPE REF TO cl_rsmds_set.
    
DATA p_r_set_space TYPE REF TO cl_rsmds_set.

*$*$ end of global - insert your declaration only before this line   *-*
    
METHODS
      compute_0PASSFORM
        
IMPORTING
          request                  
type rsrequest
          datapackid               
type rsdatapid
          SOURCE_FIELDS              
type _ty_s_SC_1
        
EXPORTING
          RESULT                   
type _ty_s_TG_1-PASSFORM
          monitor                  
type rstr_ty_t_monitor
        
RAISING
          cx_rsrout_abort
          cx_rsrout_skip_record
          cx_rsrout_skip_val.
    
METHODS
      invert_0PASSFORM
        
IMPORTING
          i_th_fields_outbound         
TYPE rstran_t_field_inv
          i_r_selset_outbound          
TYPE REF TO cl_rsmds_set
          i_is_main_selection          
TYPE rs_bool
          i_r_selset_outbound_complete 
TYPE REF TO cl_rsmds_set
          i_r_universe_inbound         
TYPE REF TO cl_rsmds_universe
        
CHANGING
          c_th_fields_inbound          
TYPE rstran_t_field_inv
          c_r_selset_inbound           
TYPE REF TO cl_rsmds_set
          c_exact                      
TYPE rs_bool.
ENDCLASS.                    "routine DEFINITION
*$*$ begin of 2nd part global - insert your code only below this line  *
... 
"insert your code here
*$*$ end of 2nd part global - insert your code only before this line   *

*---------------------------------------------------------------------*
*       CLASS routine IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_transform IMPLEMENTATION.

  
METHOD compute_0PASSFORM.

*   IMPORTING
*     request     type rsrequest
*     datapackid  type rsdatapid
*     SOURCE_FIELDS-PASSFORM TYPE C LENGTH 000015
*    EXPORTING
*      RESULT type _ty_s_TG_1-PASSFORM

    
DATA:
      MONITOR_REC    
TYPE rsmonitor.

*$*$ begin of routine - insert your code only below this line        *-*

    
CASE SOURCE_FIELDS-passform.
      
WHEN 'HERR'. RESULT = 'MR'.
      
WHEN 'FRAU'. RESULT = 'MRS'.
      
WHEN OTHERS. RESULT = space.
    
ENDCASE.

*$*$ end of routine - insert your code only before this line         *-*
  
ENDMETHOD.                    "compute_0PASSFORM


Die dazugehörige Invertierungsroutine sieht so aus:

Syntax

*$*$ begin of inverse routine - insert your code only below this line*-*
    
DATA l_r_set        TYPE REF TO cl_rsmds_set.
    
IF i_r_selset_outbound->is_universal( ) EQ rsmds_c_boolean-true.

*     If query requests all values for characteristic 0PASSNAME
*     request also all values from source field PASSNAME
      c_r_selset_inbound = cl_rsmds_set=>get_universal_set( ).
      c_exact = rs_c_true. 
"Inversion is exact

    
ELSE.
      
TRY.
          
IF me->p_r_set_mrs IS INITIAL.
*           Create set for condition PASSFORM = 'FRAU'
            me->p_r_set_mrs = i_r_universe_inbound->create_set_from_string( 
'PASSFORM = ''FRAU''' ).
          
ENDIF.
          
IF me->p_r_set_mr IS INITIAL.
*           Create set for condition PASSFORM = 'HERR'
            me->p_r_set_mr = i_r_universe_inbound->create_set_from_string( 
'PASSFORM = ''HERR''' ).
          
ENDIF.
          
IF me->p_r_set_space IS INITIAL.
*           Create set for condition NOT ( PASSFORM = 'FRAU' OR PASSFORM = 'HERR' )
            l_r_set           = me->p_r_set_mr->unite( me->p_r_set_mrs ).
            me->p_r_set_space = l_r_set->complement( ).
          
ENDIF.

*         Compose inbound selection
          c_r_selset_inbound = cl_rsmds_set=>get_empty_set( ).
*         Check if outbound selection contains value 'MR'
          
IF i_r_selset_outbound->contains( 'MR'  ) EQ rsmds_c_boolean-true.
            c_r_selset_inbound = c_r_selset_inbound->unite( me->p_r_set_mr ).
          
ENDIF.
*         Check if outbound selection contains value 'MRS'
          
IF i_r_selset_outbound->contains( 'MRS' ) EQ rsmds_c_boolean-true.
            c_r_selset_inbound = c_r_selset_inbound->unite( me->p_r_set_mrs ).
          
ENDIF.
*         Check if outbound selection contains initial value
          
IF i_r_selset_outbound->contains( space ) EQ rsmds_c_boolean-true.
            c_r_selset_inbound = c_r_selset_inbound->unite( me->p_r_set_space ).
          
ENDIF.
          c_exact = rs_c_true. 
"Inversion is exact

        
CATCH cx_rsmds_dimension_unknown
              cx_rsmds_input_invalid
              cx_rsmds_sets_not_compatible
              cx_rsmds_syntax_error.

*         Normally, should not occur
*         If the exception occurs request all values from source
*         for this routine to be on the save side
          c_r_selset_inbound = cl_rsmds_set=>get_universal_set( ).
          c_exact = rs_c_false. 
"Inversion is no longer exact

      
ENDTRY.
    
ENDIF.

*   Finally, add (optionally) further code to transform outbound projection
*   to inbound projection
*   Check if outbound characteristic 0PASSFORM (field name PASSFORM)
*   is requested for the drilldown state of the query
    
READ TABLE i_th_fields_outbound
         
WITH TABLE KEY segid     = 1           "Primary segment
                        fieldname = 
'PASSFORM'
         
TRANSPORTING NO FIELDS.
    
IF sy-subrc EQ 0.
*     Characteristic 0PASSFORM is needed
*     ==> request (only) field PASSFORM from the source for this routine
      
DELETE c_th_fields_inbound
        
WHERE NOT ( segid     EQ 1          OR
                    fieldname 
EQ 'PASSFORM'    ).
    
ELSE.
*     Characteristic 0PASSFORM is not needed
*     ==> don't request any field from source for this routine
      
CLEAR c_th_fields_inbound.
    
ENDIF.

*$*$ end of inverse routine - insert your code only before this line *-*
  
ENDMETHOD.                    "invert_0PASSFORM
ENDCLASS.                    "routine IMPLEMENTATION

Ende des Inhaltsbereichs