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: 

Persistent Classes

IanStubbings
Active Participant
0 Kudos

Hi

We are just upgrading to ECC6.0 and I am keen to introduce the newer concepts to the team here (ABAP Unit, Object Services etc). I came across the excellent weblog by Thomas Jung on Persistent Classes and would like to start using them for all custom tables.

However, I think I may come across resistance from some of the more 'traditional' developers not used to the OO world. Can anyone give me several advantages of this method of DB access rather than the usual select, update?

Cheers

Ian

2 REPLIES 2

Former Member
0 Kudos

Hi Ian,

It is very imporatnt to understand when it is required to use Persistent class before you use the same. Please do not have an undersatnding that persistent classes are a replacement of OPEN SQL statements like SELECT, MODIFY, UPDATE etc.

Persistent classes are used to make objects of classes persistent, global classes are as such persistent.Generally ABAP programs work with data and objects that are valid at runtime. They are transient i.e. temporary and disappear when program ends. To store this data permanently and independently of the program context, i.e. persistently, it must be stored in the database. This means <u><b>instances</b></u> of global classes can be written to database tables.

Persistent Services in ABAP Objects can be used to write the current attribute

values of objects defined as persistent to associated transparent tables.

On request, these values can be imported from the tables and assigned to an

object previously defined as persistent.

To use persistent services for objects, their types must be created as

persistent classes in Class Builder.

You can check the following URLs.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/840ad679-0601-0010-cd8e-998...

http://help.sap.com/saphelp_nw04/helpdata/en/f5/a36828bc6911d4b2e80050dadfb92b/frameset.htm

http://help.sap.com/saphelp_nw04/helpdata/en/f5/a36828bc6911d4b2e80050dadfb92b/frameset.htm

If you need any document on persistent classes please give your mail ID, I will send it.

<b>Award points if useful.</b>

Regards

Indrajit

uwe_schieferstein
Active Contributor
0 Kudos

Hello Ian

It seems to me that Indrajit has completely misunderstood the concept of persistent classes because using these classes SQL statements become obsolete, actually.

However, one of the biggest advantages of encapsulation DB access that we have an easy way to find out all accesses to a given table (by using the <i>Where-Used-List</i> for out persistent class).

<b>Encapsulation</b> facilitates enhancements. For example, if you need an authority check (perhaps our custom table contains company-codes specific data) then we could add an AUTHORITY_CHECK method to our persistent class at a single place yet the authority check is automatically valid for all applications using the class.

Your traditional programmers might argue that they can achieve the same using function modules. That's true although flexibilty is much higher using classes (just to mention event handling which we do not have for function modules).

SAP has almost completely converted the SAP core (SAP_BASIS and SAP_ABA) from classical to ABAP-OO programming. This transition is rapidly moving on into the business modules.

As time passes by I believe that classical programming will be completely superseded by ABAP-OO and the same will be true for classical programmers vs. ABAP-OO programmers.

Regards

Uwe