I wanted to create an abstract super class for my persistent classes, which provides some functions to query against any other persistent class which is member of that class.
So I tried to add this abstract class as superclass, when I got following error:
The superclass of a persistent class must be persistent
Message no. OO629
Is there some kind of good workaround? (I mean something diffrent from making an Interface and Copy-Paste the functions into each subclass)
Here is what I want to do (Try IE if it does not work with chrome or friefox
Short Abstract:
user
) user_has_tag
), filling them into a attribute tag
) using the general function again. Here my abstract superclass (with the general function QUERY_BY_UUID
:
CLASS zcl_ps_hrmobject DEFINITION
PUBLIC
ABSTRACT
CREATE PUBLIC .
PUBLIC SECTION.
METHODS get_uuid
RETURNING
VALUE(ro_uuid) TYPE uuid .
PROTECTED SECTION.
METHODS query_by_uuid
IMPORTING
!ir_agent TYPE REF TO object
RETURNING
VALUE(rt_entries) TYPE osreftab
RAISING
cx_os_object_not_found
cx_os_query_error .
METHODS get_query
RETURNING
VALUE(rr_query) TYPE REF TO if_os_query .
PRIVATE SECTION.
CONSTANTS lc_query_method_name TYPE string VALUE 'IF_OS_CA_PERSISTENCY~GET_PERSISTENT_BY_QUERY'. "#EC NOTEXT
DATA mlr_query TYPE REF TO if_os_query .
ENDCLASS.
CLASS zcl_ps_hrmobject IMPLEMENTATION.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Protected Method ZCL_PS_HRMOBJECT->GET_QUERY
* +-------------------------------------------------------------------------------------------------+
* | [<-()] RR_QUERY TYPE REF TO IF_OS_QUERY
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD get_query.
rr_query = me->mlr_query.
ENDMETHOD.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_PS_HRMOBJECT->GET_UUID
* +-------------------------------------------------------------------------------------------------+
* | [<-()] RO_UUID TYPE UUID
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD get_uuid.
* must be implemented in subclass
RAISE EXCEPTION TYPE cx_os_no_implementation
* EXPORTING
* textid =
* previous =
.
ENDMETHOD.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Protected Method ZCL_PS_HRMOBJECT->QUERY_BY_UUID
* +-------------------------------------------------------------------------------------------------+
* | [--->] IR_AGENT TYPE REF TO OBJECT
* | [<-()] RT_ENTRIES TYPE OSREFTAB
* | [!CX!] CX_OS_OBJECT_NOT_FOUND
* | [!CX!] CX_OS_QUERY_ERROR
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD query_by_uuid.
DATA: lr_query TYPE REF TO if_os_query,
lr_uuid TYPE uuid.
lr_query = me->get_query( ).
lr_uuid = me->get_uuid( ).
*TRY.
CALL METHOD ir_agent->(lc_query_method_name)
EXPORTING
i_query = lr_query
* i_parameter_tab =
i_par1 = lr_uuid
* i_par2 =
* i_par3 =
* i_subclasses = OSCON_FALSE
* i_upto = 0
* i_options = IF_OS_QUERY_OPTIONS=>DEFAULT_OPTIONS
RECEIVING
result = rt_entries.
* CATCH cx_os_object_not_found .
* CATCH cx_os_query_error .
*ENDTRY.
ENDMETHOD.
ENDCLASS.
否。您的描述听起来像您可能想仔细看一下生成的代理类和查询服务提供的方法。
I solved the problem with an interface and a static helperclass.
The interface enforces three getter:
get_uuid ( )
get_query ( )
get_query_method_name ( )
Now each Element implements this interface.
In the helperclass I now have the Query_by_uuid function I wanted to heritate, which gets a Instance type of that interface ( ir_root_instance
).
Here the function
METHOD QUERY_BY_UUID.
DATA: lr_query TYPE REF TO if_os_query,
lr_uuid TYPE uuid,
lv_query_method_name TYPE string.
lr_query = ir_root_instance->get_query( ).
lr_uuid = ir_root_instance->get_uuid( ).
lv_query_method_name = ir_root_instance->get_query_method_name( ).
*TRY.
CALL METHOD ir_agent->(lv_query_method_name)
EXPORTING
i_query = lr_query
* i_parameter_tab =
i_par1 = lr_uuid
* i_par2 =
* i_par3 =
* i_subclasses = OSCON_FALSE
* i_upto = 0
* i_options = IF_OS_QUERY_OPTIONS=>DEFAULT_OPTIONS
RECEIVING
result = rt_entry.
* CATCH cx_os_object_not_found .
* CATCH cx_os_query_error .
*ENDTRY.
ENDMETHOD.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.