SAP Persistence - Creating Source Code Automatically

1,243 views 26 slides Aug 19, 2015
Slide 1
Slide 1 of 26
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26

About This Presentation

Want to generate ABAP source code automatically? Learn how to use this new SAP feature with persistence services and work with databases in an object-oriented way (ABAP OO). In this training session, Blackvard CEO Lukas Dietzsch will teach you how to generate persistence classes and the required ABA...


Slide Content

Blackvard Management Consulting SAP Persistence Creating Source Code Automatically Copyright © Blackvard Management Consulting – All rights reserved www.blackvard.com

Erin Lett is the Operations Manager for Blackvard Management Consulting. She holds a Bachelor’s Degree from Stetson University in Communications and has been working in the SAP, eLearning, and Software Development industries for the past 6 years. For further information please visit: www.blackvard.com [email protected] Copyright © Blackvard Management Consulting - All rights reserved www.blackvard.com Your Host Erin Lett

Short Bio: Lukas M. Dietzsch is managing director at Blackvard Management Consulting, LLC. He is holding a Master’s degree in Information Technology and is an experienced IT solution architect and project lead. His strong background in adapting to requirements and standards in different industries and on various platforms are valuable assets for Blackvard customers. He is repeatedly commended by customers for driving efficient solutions for complex problems in globally distributed team environments and meeting tough deadlines . For further information please visit: www.blackvard.com Lukas M. Dietzsch [email protected] Copyright © Blackvard Management Consulting - All rights reserved www.blackvard.com Managing Director

Persistence Service Overview SAP Persistence Service Overview was previously covered in our “Understanding Persistence” webinar. Overview Concepts Used In Persistence Transient vs. Persistent Data Data In Object-oriented Programming Persistence Service/Persistence Classes/Managed Objects The “Understanding Persistence” webinar can be viewed via the following link: http://www.blackvard.com/understanding-persistence /

Agenda What Will B e C overed: Introduction SAP Persistence Overview – Previous Webinar Components of Persistence Get A Flight Object Create A Flight Object Questions About Us

Let’s begin by talking a little bit about the basic architecture of SAP Persistence. To better understand how to create source code automatically. Components Of Persistence

Begin by using the SE24 transaction , in Class Builder, to create a new Class with the name ZCL_MY_FLIGHT . Since it will be in the Persistent Class of the database table called SFLIGHT . Fill in all required fields and then select the Class T ype Persistent Class & click Save . Select where you wish to store the new class & click Save again. Create Persistent Class

After saving the new class, verify your Persistent Class, by clicking the Interfaces tab. It implements the interface IF_OS_STATE . Interfaces

Under the Friends tab, it also displays as a friend of the abstract agent class, ZCB_MY_FLIGHT . Friends

Now connect the Persistent Class to an ABAP Dictionary object . 2 ways for connecting & persistence mapping of a DDIC (depends on Netweaver version): by clicking the Persistence button on top OR Navigate via “ Goto > Persistence r epresentant ” to the mapping Set Persistence Representation

Now assign a Table/View/Structure to the Class . Select the database table that consists of flights, called SFLIGHT . Click the Continue icon to confirm. Assign Table

After assigning the table, Class Builder loads metadata into the lower Table/Fields section. Double-click on any one of the fields to load it into the Maintain Area . Maintain Properties of Attributes

Using the Maintain Area , you can now modify the ID , Description , Field Visibility , etc. After completing the maintenance, simply press Enter to assign it to the Persistent Class as an attribute. Add Attribute To Persistent Class

After pressing Enter , the field appears under the Class as an Attribute & loads the next field into the Maintain Area accordingly. Select each column/field you want to add to your class. Double-click on the name, then click the black arrow icon to add it to the class. Add Attribute To Persistent Class

If all fields are not required, the unused columns can remain in the lower area and be added later as needed. After applying the workflow to each field, the following appears: Add Attribute To Persistent Class

After Saving the Persistence Mapping , return to the Class D efinition using SE80 or SE24. Verify the Attributes & Methods . New Attributes

Along with the new attributes, GET & SET methods are also generated. Class Builder will activate the Actor Classes , along with the Persistent Class . Save your work ! The Persistent Class is complete & can now be used. New GET/SET Methods

Sample Use Cases for SFLIGHT

In the core of the TRY-CATCH block, reference the Agent C las s & Save it in the r eference variable lo_flight_agen t by querying the class attribute of the zca_my_flight called agent. Get A Flight Object

Ask the agent to retrieve a persistent from the database using the “BA” business key . Save the receiving reference of the flight instance in the reference variable, in the local object called “ lo_flight ”. You now have an initialized instance of the zcl_my_flight & can call its GET - and SET methods , e.g. such as GET_CARRNAME() . Get A Flight Object

This process is very effective & reusable between various clients such as: ABAP classes, ABAP programs, Function Modules, etc. Now verify the results: Get A Flight Object

Create a flight object using the Persistent Class by referencing the Agent C lass & S aving it in the variable lo_flight_agent . Ask the agent to create a persistent in the database with the key parameters of: i_CARRID , i_CONNID and i_FLDATE (the key values of the database table SFLIGHT ) Set a new price ( set_price ) Call the COMMIT statement. Save your work & Activate . Run the report . Create A Flight Object

Here you can see the results of the coding in the first line : Our newly created entry appears in database table SFLIGHT (check by using transaction SE11 or SE16n). Create A Flight Object

Have Additional Questions? Want To get trained? Please Set U p A Consultation. Email: [email protected] Require A Consultation?

Technical project lead and ABAP architect responsible for quality in technical scope and budget in a global roll-out of SAP Logistics applications (SAP LE / LO) Conducting multiple SAP ABAP and SAP HANA® trainings for various US companies Implementation of a standard SAP software solution for Spend Management within SAP AG & ARIBA (annual spend volume 3 Bill. EUR ) which can be used in all SAP systems Improved claims management using SAP FS-CM which is generating annual savings of 15 Mio € for a huge German public healthcare organization Implemented a global solution for procurement processes at BMW AG using SAP SRM / B2B Blueprinting and implementation of SAP software for banking credit cancelations for VOLKSWAGEN Key Achievements of Blackvard Management Consulting in Previous P rojects What We’ve Accomplished

An overview of current and previous customers: Customers That Recommend Blackvard