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

Class Inheritance?

Former Member
0 Likes
4,906

Hello!

I've created one class via SE24. Now I have a second class. This - second class - have to have an inheritance from first class. Where can I input it in SE24?

Thanks!!

1 ACCEPTED SOLUTION
Read only

former_member182670
Contributor
2,358

When you create class there is a popup dialog.

Next to class name there is a button with inheritance symbol (triangle)

When you press it field for super class will appear.

6 REPLIES 6
Read only

former_member182670
Contributor
2,359

When you create class there is a popup dialog.

Next to class name there is a button with inheritance symbol (triangle)

When you press it field for super class will appear.

Read only

Former Member
0 Likes
2,358

Hi,

Please go through this example:

"Example :

REPORT demo_inheritance.

CLASS counter DEFINITION.

PUBLIC SECTION.

METHODS: set IMPORTING value(set_value) TYPE i,

increment,

get EXPORTING value(get_value) TYPE i.

PROTECTED SECTION .

DATA count TYPE i.

ENDCLASS.

CLASS counter IMPLEMENTATION.

METHOD set.

count = set_value.

ENDMETHOD.

METHOD increment.

ADD 1 TO count.

ENDMETHOD.

METHOD get.

get_value = count.

ENDMETHOD.

ENDCLASS.

CLASS counter_ten DEFINITION INHERITING FROM counter.

PUBLIC SECTION.

METHODS increment REDEFINITION .

DATA count_ten.

ENDCLASS.

CLASS counter_ten IMPLEMENTATION.

METHOD increment.

DATA modulo TYPE I.

CALL METHOD super->increment .

write / count.

modulo = count mod 10.

IF modulo = 0.

count_ten = count_ten + 1.

write count_ten.

ENDIF.

ENDMETHOD.

ENDCLASS.

DATA: count TYPE REF TO counter,

number TYPE i VALUE 5.

START-OF-SELECTION.

CREATE OBJECT count TYPE counter_ten .

CALL METHOD count->set EXPORTING set_value = number.

DO 20 TIMES.

CALL METHOD count->increment.

ENDDO.

persistance class

There is a way to avoid building a fully object-oriented program while still working with non-object-oriented relational database. The object services layer now provides a persistence framework that closes the object-relational gap.

You no longer need to write SQL code as objects are transparently loaded from the database when needed. You must create a persistent class. Choose transaction SE24 and create a persistent class; this class must be protected.

steps :

Go to se 24 - choose persistence class

it will be always protected class.

next screen will give u the persistence button when u click on that it will ask u to

add the table or struture.

now u can see two division of the screen where bottom portion of the screen will list uall the fields available and u need to double click and map to the top portion.

Save the persistence class and hit back button..

Whenever u create persistence class zcl_example_persist - it will create two classes - zca_example_persist

and zcb_example_persist automatically

Where zca_example_persist is the agent class and zcb_example_persist is base agent class..

Save and activate.

Activate the whole class. Now that we have a persistent object to access the database table SFLIGHT, we must access it in a program. Here is a small example to read/write data into SFLIGHT using persistent objects.

REPORT ZPERSISTENCECLASS.

data : l_flight type ref to zcl_persist.

data : l_flight_agent type ref to zca_persist.

data : l_seatsfree type i.

data : l_seatsocc type i.

l_flight_agent = zca_persist=>agent.

CATCH CX_OS_OBJECT_NOT_FOUND .

*ENDTRY.

*TRY.

CALL METHOD L_FLIGHT_AGENT->GET_PERSISTENT

EXPORTING

I_CARRID = 'LH'

I_CONNID = '0400'

I_FLDATE = '20060701'

RECEIVING

RESULT = l_flight

.

CATCH CX_OS_OBJECT_NOT_FOUND .

*ENDTRY.

l_seatsfree = L_FLIGHT->GET_SEATSMAX( ) - L_FLIGHT->GET_SEATSOCC( ).

if l_seatsfree > 0.

l_seatsfree = L_FLIGHT->GET_SEATSOCC( ) + 1.

l_flight->set_seatsocc( l_seatsfree ).

endif.

Reward Points if found helpfull..

Cheers,

Chandra Sekhar.

Read only

Former Member
0 Likes
2,358

Hi

While creating the 1st class, we have to UBCHECK the FINAL check box.

If it is checked, we cant inherit from this class

Reward if useful

Narendra

Read only

Former Member
0 Likes
2,358

1.goto se24

2. Specify a class name and create

3. specify the object type as CLASS

4. now on the rt side of your class there is triangle button.clickon that

5. as soon as u click on that it will ask for a superclass

this how u can do it.

reward pts if useful.

Read only

Former Member
0 Likes
2,358

Hi,

While creating a new class you can find a button for 'Create Inheritance' at the right corner against the class name. Here you can input the super class name for inheritance.

Thanks,

Subathra

Read only

Former Member
0 Likes
2,358

first create class1 after that u create class2 and go to the properties tab of the class2 there u find three buttons subclass,super class and undo inheritance. here u select super class button. when ever u select SUPER CALSS button then automatically one text box appears there u enter the class1.

this is the way we can set the super class.

Regards,

Ashok