Shared Top Border

Enterprise Resource
Planning Portal

 

Advertise | Founder BLOG

ERPGenie.COM ABAP Tips and Tricks Database

THE ultimate
ERP website

 

Forums | Vote for us |

Google    Other Search Options

Login

Login to view more content!!!





Lost Password?
No account yet? Register

Registered Access

Poll

What area of ABAP are you interested in?
 
Home arrow Tips and Tricks arrow ABAP OO arrow Managing persistent objects with object services
Managing persistent objects with object services PDF Print E-mail
User Rating: / 0
PoorBest 
Written by Dany Charbonneau   
Sunday, 03 June 2007
Note: This only works for WAS 6.10 and over.

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.



In the class builder, a new button is added in the main toolbar, press it :
in the next screen, you just have to map which fields you need in your persistent class



After having saved the previous screen, you will notice that the system creates a set/get method for each field that you selected.



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.

Code:
REPORT zdany_sflight_persistent.

DATA : l_flight TYPE REF TO zcl_dany_sflight,
l_flight_agent TYPE REF TO zca_dany_sflight,
l_seatsfree TYPE i,
l_seatsocc TYPE i.

* Reference to the class agent, ALWAYS required for any operation
l_flight_agent = zca_dany_sflight=>agent.

TRY.
*We read a record from SFLIGHT using a unique key
l_flight = l_flight_agent->get_persistent(
i_carrid = 'LH'
i_connid = '0400'
i_fldate = '20031030' ).

*We read a specific field
l_seatsfree = l_flight->get_seatsmax( ) - l_flight->get_seatsocc( ).
IF l_seatsfree > 0.
l_seatsocc = l_flight->get_seatsocc( ) + 1.
* We write back a specific field into the DB
l_flight->set_seatsocc( l_seatsocc ).
ENDIF.
ENDTRY.

COMMIT WORK.
There are lots of other methods and techniques that you can use in persistent classes.

A demonstration of this can be found in program DEMO_CREATE_PERSISTENT.

Related Items:

 
< Prev   Next >

Google Search

Statistics

Contribution Activity
Utilities: 38
Tips and Tricks: 333
Sample Code: 164
Total Contributions: 550

Member Activity
Members: 6182 since 2/1/2007!
New: 9 since yesterday!
Visitors: 1010442
We have 1 guest online

Newest Members

Welcome our newest members:

Google Ads

Shared Bottom Border

Contact Us | Polls | Add URL | Contribute | Privacy | Terms | Feedback

Discussion Forum | BLOG | Consultants: Post your resume | Companies: Advertise on ERPGenie.COM | Post Job
Financials Consultant | Consultant Review | Gallia Consulting | Supply Chain Project | SAP Financials Forum
GenieHoldings.COM, Inc. | Genie Press | WorkflowGenie | ESAGenie | ERPTopSites | ABAP Tips and Tricks | SAP Solutions Database

EDIGenie | Searching Survivor