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

Persistent Objects and Inheritance

mike_mcinerney
Participant
0 Likes
437

I have a question about peristent objects and inheritance.

I've watered down an example.

Lets say I have two tables for doc headers and their line items.

HEADERS


Client		Key	MANDT		MANDT	CLNT
DocNumber	Key	DOC		BELNR_D	CHAR
HeaderText		DTEXT		BKTXT	CHAR
DocDate			DDATE		BLDAT	DATS
User Name		DOWNER		USNAM	CHAR

LINE ITEMS


Client		Key	MANDT		MANDT	CLNT
DocNumber	Key	DOC		BELNR_D	CHAR
LineItem	Key	LINEITEM	BUZEI	NUMC
Date			IDATE		DATUM	DATS
ItemText		ITEXT		SGTXT	CHAR

I want to create theses as persistent objects, and I want the detail object to inherit from the header object so that I can call doc related methods from the line item object.

Is this doable.

Intuitively, I tried

Create ZCL_HEADER as persistent (with actor and base class)

Do the Peristence Mapping

Create ZCL_DETAIL as persistent (with actor and base class)

Set SUperclass

Do the persistence mapping.

This did not work.

Is there an easy way to do this?

Thanks...

....Mike

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
0 Likes
380

I don't think the approch, you have taken, will work.

You can Create presistence classes for both the tables individually.

Now, create a wrapper class which can take care of all the GET and SET methods.

Like in your wrapper class, you have methods like INSERT_DATA, READ_DATA. Both the methods will have the Header and ITEM tables as the parameters. In the method implementation, you can call the GET and SET methods from the both persisitence class to insert or retrieve data.

Regards,

Naimesh Patel

2 REPLIES 2
Read only

naimesh_patel
Active Contributor
0 Likes
381

I don't think the approch, you have taken, will work.

You can Create presistence classes for both the tables individually.

Now, create a wrapper class which can take care of all the GET and SET methods.

Like in your wrapper class, you have methods like INSERT_DATA, READ_DATA. Both the methods will have the Header and ITEM tables as the parameters. In the method implementation, you can call the GET and SET methods from the both persisitence class to insert or retrieve data.

Regards,

Naimesh Patel

Read only

mike_mcinerney
Participant
0 Likes
380

withdrawn