11-14-2012 9:12 PM
Hi, I am new to OO programming and trying to create a persistent class and call the query manager with parameters. I am getting the error 'The method is implemented in a subclass' as an exception. I created the persistent class ZCL_SOURCE_RECORD off of table EORD which generated actor class ZCA_SOURCE_RECORD and base class ZCB_SOURCE_RECORD. I must have missed something in the setup. Here is my program logic to call the method:
REPORT zptp_source_list.
************************************************************************
* T A B L E S *
************************************************************************
TABLES: eord, usr01.
************************************************************************
* D A T A D E F I N I T I O N *
************************************************************************
DATA: gt_eord TYPE eord_tty,
ft_select TYPE rsparams_tt,
query_mng TYPE REF TO if_os_query_manager,
query_by_eord TYPE REF TO if_os_query,
lt_records TYPE osreftab,
ierr TYPE REF TO cx_root,
agent TYPE REF TO zca_source_record.
FIELD-SYMBOLS <wa_eord>.
************************************************************************
* S E L E C T - O P T I O N S *
* P A R A M E T E R S *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK a1.
*SELECT-OPTIONS s_matnr FOR eord-matnr.
*SELECT-OPTIONS s_werks FOR eord-werks.
PARAMETERS p_matnr TYPE eord-matnr.
PARAMETERS p_werks TYPE eord-werks.
SELECT-OPTIONS s_lifnr FOR eord-lifnr.
SELECT-OPTIONS s_erdat FOR eord-erdat.
SELECT-OPTIONS s_ernam FOR eord-ernam.
SELECT-OPTIONS s_vdatu FOR eord-vdatu.
SELECT-OPTIONS s_bdatu FOR eord-bdatu.
SELECT-OPTIONS s_flifn FOR eord-flifn.
SELECT-OPTIONS s_notkz FOR eord-notkz.
SELECTION-SCREEN END OF BLOCK a1.
************************************************************************
* I N I T I A L I Z A T I O N *
************************************************************************
INITIALIZATION.
************************************************************************
* S T A R T - O F - S E L E C T I O N *
************************************************************************
START-OF-SELECTION.
PERFORM get_data.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* Get data for output
*----------------------------------------------------------------------*
FORM get_data .
agent = zca_source_record=>agent.
TRY.
query_mng = cl_os_system=>get_query_manager( ).
query_by_eord = query_mng->create_query(
i_filter = `MATNR = PAR1 AND WERKS = PAR2` ).
lt_records = agent->if_os_ca_persistency~get_persistent_by_query(
i_query = query_by_eord
i_par1 = p_matnr
i_par2 = p_werks ).
LOOP AT lt_records ASSIGNING <wa_eord>.
ENDLOOP.
CATCH cx_root INTO ierr.
MESSAGE ierr TYPE 'I'.
ENDTRY.
ENDFORM.
Any ideas?
Regards,
Todd
11-14-2012 9:21 PM
hello,
When a query is
created with the Query Manager’s CREATE_QUERY method, the filter conditions and
sort conditions are passed to it.
The query itself is
merely a container for the filter condition and the sort condition. A query is
executed by calling interface method IF_OS_CA_PERSISTENCY~GET_PERSISTENT_BY_QUERY
in the class actor of a persistent class. Similarly, the result of a query’s
execution is not bound to the query, but is returned by the class actor’s method
as a table of references.
best regards,
swanand
11-14-2012 9:21 PM
hello,
When a query is
created with the Query Manager’s CREATE_QUERY method, the filter conditions and
sort conditions are passed to it.
The query itself is
merely a container for the filter condition and the sort condition. A query is
executed by calling interface method IF_OS_CA_PERSISTENCY~GET_PERSISTENT_BY_QUERY
in the class actor of a persistent class. Similarly, the result of a query’s
execution is not bound to the query, but is returned by the class actor’s method
as a table of references.
best regards,
swanand
11-14-2012 9:34 PM
Swanand,
Thanks for the response. I follow you and thought that I was trying to do just that. However, when I run my program, I get the exception 'The method is implemented in a subclass' and my table lt_records does not get filled. What should I change to get past that or how cna I troubleshoot further?
Regards,
Todd
11-14-2012 9:41 PM
hello,
Probably you don't have to re-define these methods. The methods are automatically redefined by the system when you complete the OR mapping! Did you complete the OR mapping in your persistence class?
check this link
http://scn.sap.com/thread/1735340
best regards,
swanand
11-14-2012 9:53 PM
Swanand,
I think I did. I clicked on the Persistence button, specified my table and then imported the fields into the mapper. It generated all of the fields as attributes as well as the base and actor classes with the system methods. I activated everything and it appears to be correct but when I try to use it in my program I get the error at runtime.
Todd
11-15-2012 6:45 PM
Hello Todd,
The issue is due to the fact that the method's never got generated. You have to explicitly tell the mapper that you would be using queries. Attached is the screen shot on how to achieve it.
Hope this helps,
Venkat.
11-15-2012 6:56 PM