cancel
Showing results for 
Search instead for 
Did you mean: 

private class

ravi_kumar221
Participant
0 Kudos

hi help me soon i need to create one private class in my application  give me some  example

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I am not sure what sort of example you want.

To create a private class the only thing you have to do is:

Go to SE24,

Create a class

And in the popup, select 'Private' in Instantiation.

ravi_kumar221
Participant
0 Kudos

hi  how will i use private class in my program  pleas help me

Former Member

In the private class say ( ZCL_TEST) , create a static method say CREATE_OBJECT. In this method create an object of type ref to ZCL_TEST and set it as an exporting parameter of the method.

Now in your program call this method like ZCL_TEST=>CREATE_OBJECT and you will get the reference object from this method.

Now you can call any instance methods of this class using this reference.

ravi_kumar221
Participant
0 Kudos

Hi your ans is very helpful for me but can u explain        why we need private        ClASS

Former Member
0 Kudos

Hi,

One very simple scenario for creating a Private class is when you dont want that instances of the class can be created outside the class.

The creation of a Private class is generally used along with 'FINAL' to make the class as singleton. In this case, the class can be instantiated only once.

ravi_kumar221
Participant
0 Kudos

what is singleton  class

Former Member
0 Kudos

Singleton Class is a class that can be instantiated only once.

You can search on google. You will get better answers.

Answers (2)

Answers (2)

JanarthananE
Contributor
0 Kudos

Hi Ravi,

Can you put a exact scenario were u r facing the problem..? then its easy to solve.

Refer the following link for better understanding.

http://www.saptechnical.com/Tutorials/WebDynproABAP/Class/Index.htm

http://wiki.sdn.sap.com/wiki/display/WDABAP/Passing+Values+between+Views+using+Assistance+class+in+W...

Hope its useful to u.

Regards

Jana

farooq_basha
Active Participant
0 Kudos

Hi Ravi,

I am not sure what exactly u r looking but as per my understanding i am mention below solution.

Create a class in SE24 and in property mention superclass as  CL_WD_COMPONENT_ASSISTANCE

Build ur logic accordingly in the methods of class(Zclass) and assign to component ->  ASSISTANCE CLASS - zclass.

Regards,

Farooq