4 Replies Latest reply: Jun 13, 2012 1:22 PM by Arelis Arelis RSS

Characteristic Relationship - Exit Class - check masterdata

Arelis Arelis
Currently Being Moderated

Hello Friends.

Let me share Business Scenario.

I have Real-Time InfoCube containing two InfoObjects: Z_MAT (Material) and Z_COL (Color). I have Z_MAT Material Master Data, where I have an attribute of Material Z_COLOR (Color), describing the same attribute, but realized as another InfoObject than this one from InfoCube. Now I need a Characteristic Relationship, checking if Color assigned by user in Input Ready Query is correct from Master Data point of view. I cannot use Master Data Attributes type, because Color assigned in Master Data is different Info Object that this one in InfoCube. That's why I want to to create Characteristic Relationship type Exit Class. Could you give me instruction / hints, how to do it? When I select Characteristic Relationship without derivation and type Exit Class, how to create Exit Class itself, code, how to see it on the list etc.?

Thanks in advance!

A.

  • Re: Characteristic Relationship - Exit Class - check masterdata
    Andrey Uryukin
    Currently Being Moderated

    Hi.

     

    First you need to create your own class (SE24) with superclass CL_RSPLS_CR_EXIT_BASE (if you are not familiar with ABAP you can ask your ABAP team)

    Next, redefine DERIVE method and add the following code (sire you need to insert your own logic in: in my code there is a place between "*** Start of derivation algoritm" and "*** End of derivation algoritm". Add your own logic - master data check - with ABAP team as well.

     

    METHOD if_rspls_cr_methods~derive.

    **** infrastructure needed by the buffer:
      DATA: l_s_mesg   TYPE if_rspls_cr_types=>tn_s_mesg,
            l_is_valid TYPE rs_bool.

      FIELD-SYMBOLS: <l_th_buf> TYPE HASHED TABLE,
                     <l_s_buf>  TYPE ANY.
      CLEAR e_t_mesg.

    **** use the buffer?
    **** o_use_buffer is switched on by default in the constructor
      IF o_use_buffer = rs_c_true.
    *   yes:
        ASSIGN o_r_th_buf->* TO <l_th_buf>.
        ASSIGN o_r_s_buf->*  TO <l_s_buf>.
        <l_s_buf> = c_s_chas.
        READ TABLE <l_th_buf> INTO <l_s_buf> FROM <l_s_buf>.
        IF sy-subrc = 0.
          IF o_r_is_valid->* = rs_c_true.
            c_s_chas = <l_s_buf>.
            RETURN.
          ELSE.
            IF e_t_mesg IS SUPPLIED.
              APPEND o_r_s_mesg->* TO e_t_mesg.
            ENDIF.
            RAISE EXCEPTION TYPE cx_rspls_failed
              EXPORTING
                msgid = o_r_s_mesg->msgid
                msgty = o_r_s_mesg->msgty
                msgno = o_r_s_mesg->msgno
                msgv1 = o_r_s_mesg->msgv1
                msgv2 = o_r_s_mesg->msgv2
                msgv3 = o_r_s_mesg->msgv3
                msgv4 = o_r_s_mesg->msgv4.
          ENDIF.
        ENDIF.
      ENDIF.

    **** Start of derivation algorithm

      FIELD-SYMBOLS: <source_char>   TYPE ANY.
      FIELD-SYMBOLS: <target_char>   TYPE ANY.

      ASSIGN COMPONENT '/BIC/YOUR_SOURCE_CHAR' OF STRUCTURE <l_s_buf> TO <source_char>.
      ASSIGN COMPONENT '/BIC/YOUR_TARGET_CHAR' OF STRUCTURE <l_s_buf> TO <target_char>.

      <source_char>   = <target_char>.

      l_is_valid = 'X'.

    **** End of derivation algorithm

    * update the buffer with the result:
    *  l_s_mesg should contain a message in the 'invalid' case
    *  l_is_valid should indicate whether derivation was possible
    *  <l_s_buf> should contain the derived fields
      IF o_use_buffer = rs_c_true.
        o_r_is_valid->* = l_is_valid.
        IF o_r_is_valid->* = rs_c_true.
          INSERT <l_s_buf> INTO TABLE <l_th_buf>.
          c_s_chas = <l_s_buf>.
        ELSE.
          IF e_t_mesg IS SUPPLIED.
            o_r_s_mesg->* = l_s_mesg.
            APPEND l_s_mesg TO e_t_mesg.
          ENDIF.
          INSERT <l_s_buf> INTO TABLE <l_th_buf>.
          RAISE EXCEPTION TYPE cx_rspls_failed
            EXPORTING
              msgid = l_s_mesg-msgid
              msgty = l_s_mesg-msgty
              msgno = l_s_mesg-msgno
              msgv1 = l_s_mesg-msgv1
              msgv2 = l_s_mesg-msgv2
              msgv3 = l_s_mesg-msgv3
              msgv4 = l_s_mesg-msgv4.
        ENDIF.
      ENDIF.


    ENDMETHOD.

     

    Last, in modeler select derivation type exit class and select your class.

     

    Regards.