" Standard HANA class exists
IF zcl_exist=>class_exist( c_dbms_class-sap_std ) EQ abap_true.
_implementor = c_dbms_class-productive.
" Standard doesn't exist, see if a test class is available
ELSEIF zcl_exist=>class_exist( c_dbms_class-test ) EQ abap_true.
_implementor = c_dbms_class-test.
ENDIF.
DATA implementor TYPE REF TO zif_hana_class.
CREATE OBJECT implementor TYPE (_implementor_name)
EXPORTING
i_dbcon = i_dbcon.
CLASS ltc_handler DEFINITION DEFERRED.
CLASS zcl_my_hana_class DEFINITION LOCAL FRIENDS ltc_handler.
me->cut->_implementor = ???.
CLASS ltd_hdb DEFINITION.
PUBLIC SECTION.
INTERFACES zif_hana_class.
DATA db TYPE HASHED TABLE OF ... WITH UNIQUE KEY user_name.
ENDCLASS.
CLASS ltd_hdb DEFINITION.
PUBLIC SECTION.
INTERFACES zif_hana_class.
DATA db TYPE HASHED TABLE OF ... WITH UNIQUE KEY user_name.
CLASS-METHODS:
_get_my_abs_type_name
RETURNING
value(r_name) TYPE string.
ENDCLASS.
CLASS ltd_hdb IMPLEMENTATION.
...
METHOD _get_my_abs_type_name.
DATA one_of_me TYPE REF TO ltd_hdb.
CREATE OBJECT one_of_me
EXPORTING
i_dbcon = ''.
r_name = cl_abap_classdescr=>get_class_name( one_of_me ).
ENDMETHOD.
ENDCLASS.
me->cut->_implementor_name = ltd_hdb=>_get_my_abs_type_name( ).
methods IS_VALID
importing
!DATA_OBJECT type DATA
returning
value(RESULT) type ABAP_BOOL .
methods GET_DESCRIPTION
returning
value(RESULT) type STRING_TABLE .
CLASS lta_not_identical_objects DEFINITION FOR TESTING.
PUBLIC SECTION.
INTERFACES if_constraint.
TYPES: BEGIN OF two_objects,
object1 TYPE REF TO object,
object2 TYPE REF TO object,
END OF two_objects.
ENDCLASS.
CLASS lta_not_identical_objects IMPLEMENTATION.
METHOD if_constraint~is_valid.
FIELD-SYMBOLS <both_objects> TYPE two_objects.
ASSIGN data_object->* TO <both_objects>.
IF <both_objects>-object1 NE <both_objects>-object2.
result = abap_true.
ENDIF.
ENDMETHOD.
METHOD if_constraint~get_description.
INSERT `Those instances were supposed to be not the same object` INTO TABLE result.
ENDMETHOD.
ENDCLASS.
DATA not_the_same TYPE REF TO if_constraint.
CREATE OBJECT not_the_same TYPE lta_not_identical_objects.
DATA both_objects TYPE lta_not_identical_objects=>two_objects.
both_objects-object1 = first_instance.
both_objects-object2 = second_instance.
DATA ref_of_both_objects TYPE REF TO data.
GET REFERENCE OF both_objects INTO ref_of_both_objects.
cl_abap_unit_assert=>assert_that( act = ref_of_both_objects exp = not_the_same ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
9 | |
7 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |