Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Overwriting method for standard class

0 Kudos

Hello Experts,

I have a requirement where I need to insert a code in the class CL_ILM_CHECK_API. It has got a method EXECUTE_ANALYSIS_ARCH. I need to insert the code in the middle of the method.

I did a overwriting method and have created by going to Edit->enhancement operations->overwriting method.

There is another method named CREATE_TABLE_DYNAMIC which is called inside this overwriting method. When i try to activate the code, it is resulting in an error stating that the given method is private.

I have seen a variable called CORE_OBJECT referring to the class CL_ILM_CHECK_API.

How can i use this variable to solve my issues.

Also do i need to create a new method in the class CL_ILM_CHECK_API and make it public so that I can call the overwritten method.

Kindly provide your inputs on the same.

Regards,

ES

3 REPLIES 3

0 Kudos

Hi Eshwar,

The another method that is called in overwritten method might be private or protected method of that class. So this cannot be accessed in Overwritten method.

To call these methods, instead of overwritten method, implement implicit enhancement with all standard and your logic in place and at end use @ Check 1 =2 . or return statement so that your code is executed instead of standard.

Thanks.

Former Member
0 Kudos

Hi Eshwar,

You can modify the code where the call to the method create_table_dynamic is made as below:

core_object->create_table_dynamic( ).

Don't make any changes to the visibility of the overwritten method.

Let me know if you face any issues further.

Thanks and Regards,

Vinay Mutt

Sandra_Rossi
Active Contributor
0 Kudos

When you overwrite a method for a given class the first time, the system asks you whether you want to have access to private/protected members. You must reply "yes", which will make your local enhancement class a "friend" of the enhanced class. Then, you may use the CORE_OBJECT instance to access these private/protected members. No need to "create a new method".

As it seems you replied "no", you have to delete your enhancement implementation, activate, and create again, so that the system asks you the question again.

BUT, I would recommend to do it without an overwrite method, so that to benefit of upgrade procedure, by doing a change of standard (i.e. asking for an access key).