ecently, I was talking with a Java developer who was fairly new to the SAP world but claimed to already be an ABAP expert. He was commenting on the ABAP programming language. In several of his comments he remarked that ABAP Objects didn't have persistent objects or an OO transactional system. I found this rather interesting considering that ABAP Objects has both
of those things.
On the same day that I had the opportunity to set this poor misguided soul straight, I ran into another instance of persistence ignorance. There was a posting on the SAP Developer Network's (SDN) ABAP forum asking ABAP developers to fill out a survey for someone's master theses. One of the questions: "What are the weak points for ABAP Objects?" Among the choices given by the survey to answer the question: "No persistent objects or serializeable objects." ABAP Objects has both persistent and serializeable objects.
Five people out of 45 had selected this option as a weak point for ABAP Objects. I dedicate this solution to those five people and my Java friend.
A common misconception these days is that ABAP Objects has no support for serializeable and persistent objects. But it does.
Follow along to learn step-by-step how to create a serializeable data object class, a persistent object, and to use the Persistent Data Mapper.
In defense of those who might have agreed with the statement that lack of persistence and serializeable objects in ABAP Objects is a weakness, it is true that this functionality is not present before the 6.X releases of SAP's WebAS. All the examples that I am going to share today were developed on a 620 WebAS.
In a moment I'll jump into the heart of persistent objects, but first I'll address serializeable objects. If you want an ABAP Object class to be serializeable, all you have to do is add the IF_SERIALIZABLE_OBJECT interface. That's itpretty simple! Listing 1 is some sample ABAP code from which I have to serialize a data object class and write it out to an XML file on the presentation server:
The XML output looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<ASAP_ISSUE href="#o13" />
<asx:heap xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:abap="http://www.sap.com/abapxml/types/built-in"
|Editor's Note: This content was originally published on the SAP Developer Network. Reprinted with permission.