Application Development and Automation 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: 
Read only

OverWrite Exits for Classes

Former Member
0 Likes
3,787

Hi,

I am trying to create Overwrite exit for the class, while doing this SAP is creating local class in some include and giving me chance to put my code in the same method for which i am trying to create over write exit.

Problem is from this local class i am not able to access the global class methods in which i am doing all this stuff.

How can i use the methods of global class, though instation of this global class requires some mandatory parameters which i cannot provide...

is there any restrictions in using exits for class enhancements..

need your inputs....

Thanks..

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,153

hi,

May be possibility is that,the data of the class which you are accessing through your class is Protected....so first inherit the global class in your local class so that variables are visible to your local class ......

another way is through access any public method method of that global class in which required data is passed....

Regards

Gaurav

10 REPLIES 10
Read only

naimesh_patel
Active Contributor
0 Likes
2,153

You need to call another public method in your class and call that public method in the OverWrite method. Since this public method would be a part of the main class itself, you would be able to access all method / attributes of the class.

Regards,

Naimesh Patel

Read only

Clemenss
Active Contributor
0 Likes
2,153

Hi kranthi (or who feels good for),

please let me learn how to "create Overwrite exit" and where and how SAP creates what kind of local class.

I really do not understand what you are talking about.

Thank you.

Regards,

Clemens

Read only

0 Likes
2,153

As part of the Implicit enhancement for a class, you can create an overwtie method.

Go to SE24, enter the class name and menu class > Enhance.

Edit > Enhancement Operations > Add Overwrite Method

Try creating one, so, you would see how SAP creates Local class and links it back the Class.

Regards,

Naimesh Patel

Read only

Former Member
0 Likes
2,153

It's part of New Enhancement Framework.

Mohaiyuddin

Read only

Former Member
0 Likes
2,154

hi,

May be possibility is that,the data of the class which you are accessing through your class is Protected....so first inherit the global class in your local class so that variables are visible to your local class ......

another way is through access any public method method of that global class in which required data is passed....

Regards

Gaurav

Read only

Former Member
0 Likes
2,153

Just wondering if anybody has answer for this??

when i create over-write exit for a method in class by using new enhancement framework, it creates local class i mentioned earlier in this thread.

using this local class i need to call private method of the global class is it possible or forbidden by SAP??

please let me know in general,

whether local classes in Global classes can access private methods of global classes??

  • whether global classes which itself has local classes def and implementations in it can access local classes methods????*

Please Suggest!!!!

Edited by: kranthi kumar on Sep 20, 2010 4:57 PM

Read only

0 Likes
2,153

If you can make the Local class as the LOCAL FRIEND of the Global Class than yes, you can access the private attributes / methods of the Global Class in the Local Class. If you can write this type of code in the LOCAL TYPES of global class, than you can access the components of the Global Class.

Like:


class LCL_ZTEST_NP_TESTING DEFINITION DEFERRED.   " Local class
class ZCL_TEST_NP_2 DEFINITION LOCAL FRIENDS LCL_ZTEST_NP_TESTING.  " Global Class

But we can't Change to LOCAL TYPES of the Standard Class without registering the object.

So, you should create a Public Method in the Global Class and access the private components. Then you should call this public method in your Local class.

Regards,

Naimesh Patel

Read only

0 Likes
2,153

Thanks for your reply, it seems SAP has restricted this type of enhancement i presume, however for the reverse case like, global class accessing the local class implemenatations ( which are implemented inside global class ) i have read some article "Accessing the inaccessible" but i could not understand, can you please brief with example.

Thanks in advance.

Read only

0 Likes
2,153

Accessing the inaccessible - Article link?

Read only

0 Likes
2,153

this is the link

[Accessing the Inacessible - Local Classes within Global Classes |http://wiki.sdn.sap.com/wiki/display/ABAP/AccessingtheInacessible-LocalClasseswithinGlobalClasses]