State-of-the-Art ABAP - A Practical Programming Guide

Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

CD356

State-of-the-Art
ABAP – a Practical
Programming Guide
Contributing Speaker

Horst Keller
Knowledge Architect, SAP AG

© SAP AG 2006, SAP TechEd ’06 / CD356 / 2


Why ABAP Guidelines?

Where are the ABAP Guidelines?

What are the ABAP Guidelines?

State-of-the-Art ABAP Excercise


Learning Objectives

As a result of this workshop, you will be able to:


„ Tell the reasons for ABAP programming guidelines
„ Find the ABAP programming guidelines
„ Tell the most important ABAP programming guidelines
„ Program an application according to the ABAP programming
guidelines

© SAP AG 2006, SAP TechEd ’06 / CD356 / 4


Why ABAP Guidelines?

Where are the ABAP Guidelines?

What are the ABAP Guidelines?

State-of-the-Art ABAP Excercise


Introduction – ABAP in SAP NetWeaver

ABAP is a Programming Language of the Application


Server in SAP NetWeaver

SAP NetWeaver Usage Types

EP MI BI PI

ABAP Java

Application Server (AS)

© SAP AG 2006, SAP TechEd ’06 / CD356 / 6


Introduction – Application Server ABAP

Web Browser SAP GUI Application Client

Web Dynpro BSP Dynpro

ICM
ICF CFW

ABAP/ABAP Objects XSLT/ST

Object Services RFC


Interface
Open SQL Native SQL

Data Base Interface

Data Base
(AS ABAP Scheme)
© SAP AG 2006, SAP TechEd ’06 / CD356 / 7
Introduction – Evolution of ABAP

R/2 ABAP ABAP/4 ABAP Objects Unicode enabled Modern ABAP

© SAP AG 2006, SAP TechEd ’06 / CD356 / 8


Introduction – Motivation

Why ABAP Programming Guidelines?

„ ABAP is a vibrant, evolving language since almost 30 years


„ New developments in ABAP are introduced either through additions to
the existing feature set or replacement (and thereby making
superfluous or obsolete) of current features
„ The issue of superfluity and obsolescence can be troublesome:
– Why are there two ABAP programming models (object-oriented v.s.
procedural)?
– Why are there different statements to accomplish the same task?
„ SAP’s practice of maintaining strict downward compatibility prevents
the total extinction of obsolete features from the language

Programming Guidelines show you a way through the jungle


of possibilities resulting in Modern ABAP!

© SAP AG 2006, SAP TechEd ’06 / CD356 / 9


Introduction – Motivation

Aim of ABAP Programming Guidelines?


„ Defining the rules for a modern ABAP that matches the needs of
programming SAP NetWeaver’s Application server
„ Defining formal as well as conceptual rules that allow an application
developer to create programs that are:
– Correct
– Maintainable
– Well-structured
– Performing
– Readable
– Up-to-date
– Robust

This workshop will introduce the basic guidelines when and how to use
the many possibilities ABAP gives to business application developers
in a practical way

© SAP AG 2006, SAP TechEd ’06 / CD356 / 10


Why ABAP Guidelines?

Where are the ABAP Guidelines?

What are the ABAP Guidelines?

State-of-the-Art ABAP Excercise


ABAP Programming Guidelines – Publication

© SAP AG 2006, SAP TechEd ’06 / CD356 / 12


Why ABAP Guidelines?

Where are the ABAP Guidelines?

What are the ABAP Guidelines?

State-of-the-Art ABAP Excercise


ABAP Programming Guidelines – Key Messages

Writing modern ABAP means:


„ Keep your coding structured — always use ABAP Objects
„ Keep up the separation of concerns – model your applications strictly
service-oriented, always disentangle the logics for presentation and
application
„ Keep your coding clean — don’t use language elements that are
marked as obsolete, especially work only with Unicode enabled
programs
„ Keep your coding up-to-date — have an eye on the ABAP language
news and apply new constructs in your coding as they become
available (it might be worth the effort to rewrite one or the other of
your outdated application programs)
„ Keep up the quality - test all parts of your programs with the
appropriate tools

© SAP AG 2006, SAP TechEd ’06 / CD356 / 14


ABAP Programming Guidelines – ABAP Objects

Using
ABAP Objects:

Services

Application Services

Services NW AS ABAP Non-ABAP

Service Orientation!

© SAP AG 2006, SAP TechEd ’06 / CD356 / 15


ABAP Programming Guidelines – Separation of Concerns

Separation of Concerns:
„ A basic programming model for supporting stability and
maintainability
„ Software is decomposed and organized in more manageable parts,
resulting in greater comprehensibility, reusability, scalability and
maintainability.
„ Separates presentation logic from application logic
– Coding that manages screen flow or screen appearance (as well as event
handlers for screen and control events) is not mixed with screen-
independent application or business coding
„ Is the basis for:
– Programming of reusable services (Access to business logic using
different UIs or different automated clients)
– Testing of business logic by using isolated unit tests
„ Is supported by the MVC (Model View Controller) approach
– Web Dynpro ABAP: automatically based on MVC
– BSP: offers MVC support
– Classic Dynpro: no built-in MVC Support

© SAP AG 2006, SAP TechEd ’06 / CD356 / 16


Separation of Concerns – MVC for Classic Dynpro

GUI Status GUI Functions

Dynpro
Screen View
Dynpro
PBO Layout PAI
Fields

Global PBO
Globale FUNCTION PAI
Globale
Data, Globale
Module MODULES Globale
Module
Daten
Daten Daten
Daten Control
Local
Classes CALL SCREEN …

Function Group
ise!!
e
c
r is
EExxeerc
Global Local
lokale
lokale
Class Classes
Klassen Model
Klassen

Class Pool

© SAP AG 2006, SAP TechEd ’06 / CD356 / 17


ABAP Programming Guidelines – Clean ABAP
Rule: Use only Unicode-enabled ABAP Objects!
„ Automatically ...
– prohibits many obsolete statements and additions ABAP Objects
– requires many implicit syntax completions to be explicit
– detects and prevents potentially incorrect data handling
– carries out stricter static checks Unicode-enabled
– separates byte and character string processing
– handles structures appropriately according to their layout
– does not permit uncontrolled memory manipulation

© SAP AG 2006, SAP TechEd ’06 / CD356 / 18


ABAP Programming Guidelines – Up-to-date Programs

Rule: New language elements better serve the same


purpose as existing language elements!

REPLACE ALL OCCURRENCES OF ` `


IN text WITH `-`.

WHILE sy-subrc = 0.
REPLACE ` ` WITH `-` INTO text .
ENDWHILE.

FIND REGEX regex IN TEXT ...

SEARCH text FOR pattern ...

© SAP AG 2006, SAP TechEd ’06 / CD356 / 19


ABAP Programming Guidelines – Program Quality

Rule: Complete test coverage for

„ Development Tests with ABAP Unit


„ Usage Tests with eCATT
„ Memory Tests with Memory Inspector
„ Performance Tests with Performance Analysis and Runtime
Analysis
„ Static Tests with Code Inspector

Test Coverage can be checked with Coverage Analyzer

© SAP AG 2006, SAP TechEd ’06 / CD356 / 20


Why ABAP Guidelines?

Where are the ABAP Guidelines?

What are the ABAP Guidelines?

State-of-the-Art ABAP Excercise


Exercise

Transfer a classic Dialog Program to ABAP Objects

„ Identify the Concerns of a given Module Pool


„ Separate the Concerns
– transfer all screen handling into the methods of a local class of a
function group
– transfer all application coding into the methods of a global class
„ Replace obsolete statemens (e.g. classic List processing) with
new concepts (i.e. ALV)
„ Replace the Dialog Transaction with an OO transaction
„ Prepare ABAP Unit Test Methods

© SAP AG 2006, SAP TechEd ’06 / CD356 / 22


Why ABAP Guidelines?

Where are the ABAP Guidelines?

What are the ABAP Guidelines?

State-of-the-Art ABAP Excercise


Further Information

Î Public Web
www.sap.com
SAP Developer Network:
http://www.sdn.sap.com/sdn/developerareas/abap.sdn
SAP Help Portal: http://www.help.sap.com
Î SAP Professional Journal
Volume 8, Issues 1 to 3, Page 3

Î SAP Press
ABAP Objects – ABAP Programming with SAP NetWeaver

Î ABAP Keyword-Documentation
Transaction ABAPHELP, always the first source of information

Î Related Workshops/Lectures at SAP TechEd ’06


All lectures and workshops about ABAP

© SAP AG 2006, SAP TechEd ’06 / CD356 / 24


THANK YOU FOR YOUR
ATTENTION !

QUESTIONS – SUGGESTIONS – DISCUSSION

© SAP AG 2006, SAP TechEd ’06 / CD356 / 25


Feedback
Please complete your session evaluation.

Be courteous — deposit your trash,


and do not take the handouts for the following session.

Thank You !

© SAP AG 2006, SAP TechEd ’06 / CD356 / 26

You might also like