58
ABAP151: ABAP Objects for Java Developers

Abap151 - Abap Objects for Java Developers

Embed Size (px)

Citation preview

Page 1: Abap151 - Abap Objects for Java Developers

ABAP151:

ABAP Objects for Java Developers

Page 2: Abap151 - Abap Objects for Java Developers

Horst Keller, SAP AG

Björn Mielenhausen, SAP AG

Page 3: Abap151 - Abap Objects for Java Developers

ABAP Special Features

Summary

Motivation

Similarities Between Java and ABAP

Page 4: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 4

Learning Objectives

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

Write a program in ABAP as you would in Java

Find information on all ABAP statements

Understand the components of an ABAP program

Understand the types of ABAP programs

Understand the role of ABAP repository objects

Make use of the ABAP Workbench

Page 5: Abap151 - Abap Objects for Java Developers

ABAP Special Features

Summary

Motivation

Similarities Between Java and ABAP

Page 6: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 6

Motivation

What‘s in the box?© Wiley Publishing, Inc., 2004, ISBN 0-7645-6883-3

Page 7: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 7

Motivation

A little bit about ABAP ...

... and a lot of of J-words

Page 8: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 8

Motivation

Why should any Java developer care about ABAP?

Page 9: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 9

Motivation

That‘s why!

Page 10: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 10

Motivation

ABAP Java

rewrite code

reuse code

Some ABAP knowledge is required!

Millions of linesof coding

Millions ofdevelopers

Page 11: Abap151 - Abap Objects for Java Developers

ABAP Special Features

Summary

Motivation

Similarities Between Java and ABAP

Page 12: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 12

Similarities Between Java and ABAP

Like Java,

ABAP is a programming language

ABAP is object-oriented

ABAP runs on a virtual machine

ABAP is the foundation for a whole technology

Page 13: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 13

Similarities – Typical Java Development Tool

Page 14: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 14

Similarities – ABAP Development Tool

Page 15: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 15

Similarities - Classes

class Account {

private int amount;

public Account(String id) {...

}

public void deposit(int amount) {...

}...

}

Java

CLASS account DEFINITION.PUBLIC SECTION.METHODS: constructor IMPORTING id TYPE string,deposit IMPORTING amount TYPE i,

PRIVATE SECTION.DATA:amount TYPE i.

ENDCLASS.

CLASS account IMPLEMENTATION.METHOD constructor....

ENDMETHOD.METHOD deposit....

ENDMETHOD....

ENDCLASS.ABAP

Syntactical differences aside, ABAP supports classes as Java does

In ABAP, the declaration and implementation of a class are split intoseparate parts

Page 16: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 16

Similarities – Attributes and Methods

private int amount;

Java

PRIVATE SECTION.DATA:amount TYPE i

ABAP

Syntactical differences aside, ABAP supports attributes and methods as Java does (apart from method name overloading)

In ABAP, a class has three visibility sections (PUBLIC, PROTECTED, PRIVATE)

public void transfer(int amount,Account target)

throws NegativeAmountException

Java

PUBLIC SECTION.METHODS:transfer IMPORTING

amounttarget TYPE REF TO account

RAISING cx_negative_amount.

ABAP

Page 17: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 17

Similarities – Method Implementationspublic void withdraw ... {

if (this.amount>amount) {this.amount=this.amount-amount;

}else {throw new NegativeAmountException();

}}

Java

METHOD withdraw.IF me->amount > amount.me->amount = me->amount - amount.

ELSE.RAISE EXCEPTION TYPE cx_negative_amount.

ENDIF.ENDMETHOD.

ABAP

For basic operations, syntax can be translated almost one to one

”->” (or ”-”) replaces ”.”, ”.” replaces ”;”, ”me” replaces ”this”

In ABAP, blocks are built by keywords instead of {}

Raising exceptions follows the same principles

Page 18: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 18

Similarities – Exceptions and Inheritance

class NegativeAmountException extends Exception{ }

Java

CLASS cx_negative_amount DEFINITION INHERITING FROM cx_static_check.ENDCLASS.

ABAP

Exception classes must be derived from predefined superclasses

The superclasses define how exception handling is checked

Throwable

RuntimeException

Exception Error

cx_root

cx_no_checkcx_static_check cx_dynamic_check

Page 19: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 19

Similarities – Handling Objects in Java

public class BankApplication {

public static void main(String[] args) {

Account account1;Account account2;int amnt;

account1 = new Account("...");account2 = new Account("...");

try {amnt = ...;account1.transfer(amnt,account2);

}catch (NegativeAmountException excRef) {System.out.println("Negative Amount");

}}

}

Java

Reference Variables

Object Creation

Method Invocation

Exception Handling

Page 20: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 20

Similarities – Handling Objects in ABAP

CLASS bank_application DEFINITION.PUBLIC SECTION.CLASS-METHODS main.

ENDCLASS.

CLASS bank_application IMPLEMENTATION.METHOD main.DATA: account1 TYPE REF TO account,

account2 TYPE REF TO account,amnt TYPE i,exc_ref TYPE REF TO cx_negative_amount,text TYPE string.

CREATE OBJECT: account1 EXPORTING id = `...`,account2 EXPORTING id = `...`.

TRY.amnt = ...account1->transfer( EXPORTING amount = amnt

target = account2 ).CATCH cx_negative_amount INTO exc_ref.text = exc_ref->get_text( ).MESSAGE text TYPE 'I'.

ENDTRY.ENDMETHOD.

ENDCLASS.ABAP

Reference Variables

Object Creation

Method Invocation

Exception Handling

Page 21: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 21

Similarities – Keywords 1

Four-byte integer iintIncludes packages-importInterface implementationINTERFACESimplementsBranchingIF, ENDIFifIterationWHILEforSimple precision floating point numbers-floatException handlingCLEANUPfinallyFinal classes and methodsFINALfinalBoolean value-falseBranchingELSE, ELSEIFelseDouble precision floating point numbersfdoubleIterationDOdoBranchingWHEN OTHERSdefaultProceed with next iterationCONTINUEcontinueConstant data objectCONSTANTSconstClass definitionCLASSclassCharacter data typec, stringcharException handlingCATCHcatchBranchingWHENcaseOne-byte integerbbyteLeaves an iterationEXITbreakBoolean data type-booleanAbstract classes and methodsABSTRACTabstractPurposeABAPJava

Page 22: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 22

Similarities – Keywords 2

IterationWHILEwhileReturn value of a methodRETURNINGvoidException handlingTRYtryBoolean value-truePrevent serialization- (implemented by self defined serialization)transientPropagates exceptionsRAISINGthrowsSelf referencemethisThreading/parallel processingCALL FUNCTION DESTINATION IN GROUPsynchronizedBranchingCASEswitchAddresses the super class supersuperEnforces IEEE norm for floating point operations-strictfpStatic class componentsCLASS-...staticTwo-byte integersshortLeaves a methodRETURNreturnProtected componentsPROTECTEDprotectedPrivate componentsPRIVATEprivatePackages- (supported by tools)packageNull referenceCLEAR, INITIALnullObject instantiationCREATEnewInvocation APIBY KERNEL MODULEnativeEight-byte integer-longInterface definitionINTERFACEinterfacePurposeABAPJava

Page 23: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 23

Similarities – Built-in Data Types

Time field (HHMMSS)t-Character stringstring-

Date field (YYYYMMDD)d-

Packed number (BCD)p-Numeric character fieldn-

Byte stringxstring-

Two-byte integersshort

Single precision floating point

-float

Double precision floating point

fdouble

Eight-byte integer-longFour-byte integeriint

Character fieldccharOne-byte integerb, xbyteBoolean data type-booleanDescriptionABAPJava

Handling dates

Handling times

Variable length

Business calculations

ABAP specials:

Page 24: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 24

Similarities – J2EE Architecture

DesktopApplication

DynamicHTML Pages

EnterpriseBeans

JSP

EnterpriseBeans

DB DB

Presentation Layer

Application Layer (WAS)

Database Layer

Page 25: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 25

Similarities – ABAP Architecture

SAP GUIDynamic

HTML Pages

ABAPPrograms

BSP

ABAPClasses

DB

Presentation Layer

Application Layer (WAS)

Database Layer

(Web) Dynpro

Page 26: Abap151 - Abap Objects for Java Developers

ABAP Special Features

Summary

Motivation

Similarities Between Java and ABAP

Page 27: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 27

ABAP Special Features – Many Keywords 1

DATABASEDATADCUSTOMER-FUNCTION

CURSOR-SELECTIONCURSORCURRENTCURRENCY

CSEQUENCECSCREATECPICPCOVERCOUNTRYCOUNT

COSHCOSCORRESPONDINGCOPIESCONVERTCONVERSIONCONTROLSCONTROL

CONTINUECONSTANTSCONNECTIONCONNECTCONDITIONCONDENSECONCATENATECOMPUTE

COMPRESSIONCOMPONENTSCOMPONENTCOMPARINGCOMMONCOMMITCOMMENTCOLUMN

COLORCOLLECTCOL_TOTALCOL_POSITIVECOL_NORMALCOL_NEGATIVECOL_KEYCOL_HEADING

COL_GROUPCOL_BACKGROUNDCODEPAGECODECOCNCLOSECLOCK

CLIKECLIENTCLEARCLEANUPCLASS-POOLCLASS-METHODSCLASS-EVENTSCLASS-DATA

CLASSCIRCULARCHECKBOXCHECKCHARLENCHARACTERCHAR-TO-HEXCHANGING

CHAIN-REQUESTCHAIN-INPUTCHAINCENTEREDCEILCATCHCASTINGCASE

CALLINGCALLCACBYTE-NSBYTE-NABYTE-CSBYTE-CO

BYTE-CNBYTE-CABYTEBYPASSINGBYBUFFERBTBREAK-POINT

BOUNDSBOUNDARIESBOUNDBLUEBLOCKSBLOCKBLANKSBLANK

BLACKBIT-XORBIT-ORBIT-NOTBIT-ANDBITBINARYBIG

BETWEENBEGINBEFOREBACKWARDBACKGROUNDBACKAVGAUTHORITY-CHECK

AUTHORITYATTRIBUTESATANATASSIGNINGASSIGNEDASSIGNASSERT

ASINASCENDINGASARITHMETICAREAARCHIVEAPPLICATIONAPPENDING

APPENDAGEAPPENDANYANDANALYZERALLALIASESAFTER

ADJACENTADDACTUALACTIVATIONACOSACCEPTINGABSTRACTABS

Java has about 50 keywords – ABAP has more than 700 …

Page 28: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 28

ABAP Special Features – Many Keywords 2

INOUTINNERINITIALIZATIONINITIALINHERITINGINDEX-LINEINDEXINCREMENT

INCLUDINGINCLUDEINIMPORTINGIMPORTIMPLEMENTATIONIMMEDIATELYIGNORING

IFIDSIDENTIFICATIONIDICONIHOTSPOTHOLD

HNHINTHIGHHIDEHELP-REQUESTHELP-IDHEADINGHEADER

HEAD-LINESHAVINGHASHEDHANDLERHANDLEGTGROUPSGROUP

GREENGLOBALGETGENERATEGEGAPSFUNCTION-POOLFUNCTION

FTOFROMFRIENDSFREEFRAMESFRAMEFRACFOUND

FORWARDFORMATFORMFORFONTFLUSHFLOORFIXED-POINT

FIRST-LINEFIRSTFINDFINALFILTERFILEFIELDSFIELD-SYMBOLS

FIELD-GROUPSFIELDFETCHFEXTRACTEXTENSIONEXTENDEDEXPORTING

EXPORTEXPONENTEXPIRATIONEXPEXIT-COMMANDEXITEXISTSEXECUTE

EXECEXCLUDINGEXCLUDEEXCEPTIONSEXCEPTION-TABLEEXCEPTIONEVENTSEVENT

ESCAPEERRORSERRORMESSAGEEQENTRYENTRIESENHANCEMENT-SECTION

ENHANCEMENT-POINT

ENHANCEMENTENDWHILEENDTRYENDSELECTENDPROVIDEENDMODULEENDMETHODENDLOOP

ENDINTERFACEENDINGENDIFENDIANENDFUNCTIONENDFORMENDEXECENDENHANCEMENT

ENDDOENDCLASSENDCHAINENDCATCHENDCASEENDATEND-OF-SELECTIONEND-OF-PAGE

END-OF-FILEEND-OF-DEFINITIONEND-LINES

END-ENHANCEMENT-SECTION

ENDENCODINGENABLINGENABLED

ELSEIFELSEEDITOR-CALLEDITEDYNPRODYNAMICDURING

DUPLICATESDUPLICATEDUMMYDODIVIDEDIVDISTINCTDISTANCE

DISPLAY-MODEDISPLAYDISCONNECTDIRECTORYDIALOGDESTINATIONDESCRIBEDESCENDING

DEPARTMENTDELETINGDELETEDEFINITIONDEFININGDEFINEDEFERREDDEFAULT

DECIMALSDDMMYYDD/MM/YYYYDD/MM/YYDBMAXLENDAYLIGHTDATEDATASET

Page 29: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 29

ABAP Special Features – Many Keywords 3

REGEXREFRESHREFERENCEREFREDEFINITIONREDRECEIVINGRECEIVER

RECEIVEREAD-ONLYREADRANGERAISINGRAISERADIOBUTTONQUICKINFO

QUEUE-ONLYPUTPUSHBUTTONPUBLICPROVIDEPROTECTEDPROPERTYPROGRAM

PROCESSPROCEDUREPRIVATEPRINT-CONTROLPRINTPRIMARYPREFERREDPOSITION

POOLPLACESPINKPF-STATUSPFPERFORMINGPERFORMPATTERN

PARTPARAMETERSPARAMETER-TABLEPARAMETERPAGESPAGEPADDINGPACKAGE

POVERLAYOUTPUT-LENGTHOUTPUTOUTEROUTOTHERSORDER

OROPTIONSOPTIONALOPTIONOPENONLYONOLE

OFFSETOFFOFOCCURSOCCURRENCESOCCURRENCEOBLIGATORYOBJECTS

OBJECTONUMOFCHARNUMERICNUMBERNULLNSNP

NOTNON-UNIQUENON-UNICODENODESNODENO-ZERONO-TOPOFPAGENO-TITLE

NO-SIGNNO-SCROLLINGNO-HEADINGNO-GROUPINGNO-GAPSNO-GAPNO-EXTENSIONSNO-EXTENSION

NO-DISPLAYNONEXTNEW-SECTIONNEW-PAGENEW-LINENEWNESTING

NENBNAMENANMULTIPLYMOVE-CORRESPONDINGMOVE

MODULEMODIFYMODIFIERMODIFMODEMODMMDDYYMM/DD/YYYY

MM/DD/YYMINOR-IDMINMETHODSMETHODMESSAGESMESSAGE-IDMESSAGE

MEMORYMAXIMUMMAXMATCHCODEMATCHMASKMARGINMAJOR-ID

MAINMLTLPILOWERLOWLOOPLOGFILE

LOG10LOGLOCALELOCALLOAD-OF-PROGRAMLOADLITTLELISTBOX

LIST-PROCESSINGLISTLINESLINE-SIZELINE-SELECTIONLINE-COUNTLINELIKE

LEVELLENGTHLEGACYLEFT-JUSTIFIEDLEFTLEAVELEADINGLE

LAYOUTLATELASTLANGUAGEKINDKEYSKEYKERNEL

KEEPINGKEEPJOINJOBISINVERSEINTOINTERVALS

INTERNALINTERFACESINTERFACE-POOLINTERFACEINTENSIFIEDINSTANCESINSERTINPUT

Page 30: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 30

ABAP Special Features – Many Keywords 4

ZONEZYYMMDDYELLOW

XSTRLENXSTRINGXSEQUENCEXMLXWRITEWORKWORD

WITHOUTWITH-TITLEWITH-HEADINGWITHWINDOWWIDTHWHILEWHERE

WHENEVERWHENWARNINGWAITVISIBLEVIAVERSIONVARYING

VARYVALUESVALUE-REQUESTVALUEVALIDUTF-8USINGUSER-COMMAND

USERUPPERUPDATEUPUNTILUNPACKUNITUNIQUE

UNICODEUNDERUNASSIGNULINETYPESTYPE-POOLSTYPE-POOLTYPE

TRYTRUNCATIONTRUNCATETRUNCTRANSPORTINGTRANSLATETRANSFORMATIONTRANSFER

TRANSACTIONTRAILINGTRACE-TABLETRACE-FILETOP-OF-PAGETOP-LINESTOTITLEBAR

TITLE-LINESTITLETIMESTIMETEXTPOOLTEXTTESTINGTASK

TANHTANTABSTRIPTABLEVIEWTABLESTABLETABBEDTAB

TSYSTEM-EXITSYSTEM-EXCEPTIONSSYSTEM-CALLSYNTAX-CHECKSYMBOLSUPPRESSSUPPLIED

SUMSUFFIXSUBTRACTSUBSTRINGSUBSCREENSUBROUTINESUBMITSUBMATCHES

SUBKEYSTRUCTURESTRLENSTRINGSTOPSTEP-LOOPSTATICSSTATIC

STATEMENTSTATESTARTINGSTART-OF-SELECTIONSTANDARDSTAMPSTABLESQRT

SQLSPOTSSPOOLSPLITSPECIFIEDSOURCESORTEDSORTABLE

SORTSOMESKIPSIZESINHSINGLESINSIMPLE

SIGNSHORTDUMP-IDSHIFTSHAREDSETSEPARATEDSEPARATESELECTIONS

SELECTION-TABLESELECTION-SETSSELECTION-SETSELECTION-

SCREENSELECTIONSELECT-OPTIONSSELECTSECTION

SECONDSSEARCHSCROLLINGSCROLL-BOUNDARYSCROLLSCREENSAVINGSAP-SPOOL

SAPRUNROWSROUNDROLLBACKRIGHT-JUSTIFIEDRIGHTRFC

RETURNINGRETURNRESULTSRESULTRESPECTINGRESOLUTIONRESETRESERVE

REQUESTEDREQUESTREPORTREPLACINGREPLACEMENTREPLACERENAMINGREJECT

Page 31: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 31

ABAP Special Features – Many Keywords 5

Is a historically grown 4GL language

Is specialized for business applications

Sometimes uses keywords instead of operands

Has only few system classes

ABAP:

You:Can use most of these keywords in method implementations

Will find almost all of these keywords in existing coding

Page 32: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 32

ABAP Special Features – Many Keywords 6

Enables extensive syntax and type checks at compile time

Is more flexible when using additions and operands comparedto method calls

Is highly optimized with regard to performance

Enables efficient application development by powerful concepts - for example, large data volumes can be processed efficiently

Allows seamless and easy integration of important interfaces to services (for example, SQL, XSLT, screen programming, external programs, and so on)

Results in a consistent documentation of everything a businessapplication programmer needs to know

On the other hand, using language statementsinstead of classes:

Page 33: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 33

ABAP Special Features – Keyword Documentation

Page 34: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 34

ABAP Special Features – Runtime Environment 1

ABAP is the programing interface of SAP NetWeaver Web Application Server ABAP

→ You need a WAS to work with ABAP

1. A WAS is available in your enterprise: Everyone with developer authorizations can program ABAP

2. For training purposes, a Mini WAS ABAP is available

1. (Almost) for free atwww.sap.com/company/shop(SAP Knowlede Shop → General → SAP NetWeaver → WAS)

2. For free as SAP Press book CDs

Page 35: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 35

ABAP Special Features – Runtime Environment 2

Persistent Data(Database, Files, ...)

User Interface(SAP GUI, Web, ...)

WebApplicationServer

...SELECT * FROM ......

ABAP

ABAP Objects

Page 36: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 36

ABAP Special Features – Runtime Environment 3

WebApplicationServer

CLASS ...... SELECT * FROM ......

ENDCLASS.

CLASS ...... SELECT * FROM ......

ENDCLASS.

CLASS ...METHOD main.

...ENDMETHOD.

ENDCLASS.ABAP Programs

ABAP Virtual Machine

Processes

Page 37: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 37

ABAP Special Features – Program Execution 1

Magic word for ABAP program execution: Transaction code

Transaction codes call programs –for example, SE80 calls the ABAP Workbench, which is written in ABAP

Transaction codes are usually hiddenbehind menu entries, for example.

Transaction codes entered in theinput fields of the standard toolbar of an ABAP-based SAP System serveas shortcuts (SE93)

Page 38: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 38

ABAP Special Features – Program Execution 2

Creating a transaction code

execute method main of class bank_application in program BANKAPPLICATION

Page 39: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 39

ABAP Special Features – ABAP and Database Access 1

ABAP is tailor-made for (mass) data processing in businessapplications based on relational databases.

The language and the runtime environment have many features thatsupport business programming (for example, support of internationalization, distributed programming (RFC), authoritychecks).

The most important aspect of business programming in ABAP is itshandling of database tables:

Databases are generated from data types in the ABAP Dictionary

Database access is integrated into the language as Open SQL

Performance of database accesses is optimized via a bufferingmechanism integrated into the runtime environment

OLTP (Online Transaction Programming) is supported by the SAP LUWconcept (transaction and enqueue handling) for many user systems

Page 40: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 40

ABAP Special Features – ABAP and Database Access 2

ID AMOUNT

... ...Database

ABAP Dictionary

CLASS account DEFINITION.PUBLIC SECTION.METHODS:

constructorIMPORTING id TYPE accounts-id,

depositIMPORTING amount TYPE accounts-amount,

PRIVATE SECTION.DATA:

amount TYPE accounts-amount.ENDCLASS.

CLASS account IMPLEMENTATION.METHOD constructor.SELECT SINGLE amount

FROM accountsINTO (amount)WHERE id = id.

ENDMETHOD....

ENDCLASS.ABAP

Page 41: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 41

ABAP Special Features – The ABAP Type System 1

Types

Data Types

Elementary Daty Types

Fixed Length

Variable Length

Objects

Data Objects

Elementary Data Objects

Static Data Objects

Dynamic Data Objects

f

i

x

Floating Point Numbers

Integers

Byte Fields

string

xstring

Character Strings

Byte Strings

data, any

clike

csequence

numeric

simple

xsequence

c

d Date Fields

n Numeric Text Fields

t Time Fields

p Packed Numbers

Text Fields

Generic Types

Page 42: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 42

ABAP Special Features – The ABAP Type System 2Types

Data Types

Complex Data Types

Structured Types

Table Types

Object Types

Classes

Interfaces

Objects

Data Objects

Complex Data Objects

Structures

Internal Tables

Reference Types

Data References

Object References

Reference Variables

Data Reference Variables

Object Reference Variables

Interface References Interface Reference Variables

Class References Class Reference Variables

Objects

Index Tables

Standard Tables

Sorted Tables

Hashed Tables

Standard Tables

Sorted Tables

Hashed Tables

data, any

object

any table

[standard] table

sorted table

hashed table

index table

Page 43: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 43

ABAP Special Features – The ABAP Type System 3

TYPES account_tab_type TYPE HASHED TABLE OF accountsWITH UNIQUE KEY id.

DATA account_tab TYPE account_tab_type.

DATA account_wa TYPE accounts.

SELECT *FROM accountsINTO TABLE account_tabWHERE id = ...

READ TABLE account_tabWITH TABLE KEY id = ...INTO account_wa.

ABAP

Local Type in Program Internal Table Type

ABAP Dictionary

Internal Table

Structure

Page 44: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 44

ABAP Special Features – ABAP’s Procedural Heritage 1

ABAP Objects, the object-oriented extension of ABAP isvery similar to JAVA:

ABAP Objects is based on classes and interfaces.

Classes and interaces have attributes and methods as components.

Objects are created from classes and are accessed via referencevariables.

Polymorphism is supported by interface implementation and singleinheritance.

Addtionally, ABAP Objects allows events as components of classes

Events are declared with EVENTS and can be raised inside methodsusing RAISE EVENT.

Methods can become event handlers with METHODS ... FOR EVENTEvents can be registered at runtime using SET ACTIVATION

But: there was an ABAP world before ABAP Objects!

Page 45: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 45

ABAP Special Features – ABAP’s Procedural Heritage 2

Before the introduction of methods in classes, modularization was carried out with function modules (external) and subroutines (internal) in programs:

ABAP Program

* Global Declarations ...DATA ...

FORM ...DATA ......

ENDFORM.

Function Group

* Global Declarations ...DATA ...

FORM ...DATA ......SELECT * FROM ......

ENDFORM.

......CALL FUNCTION ...PERFORM ......END...

FUNCTION ...DATA ......PERFORM ......

ENDFUNCTION.

Page 46: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 46

ABAP Special Features – ABAP’s Procedural Heritage 3

Before the introduction of transaction codes linked to methods in classes, program execution was carried out using transaction codes linked to dynpros(screens) or by calling a special reporting process in the runtime environment:

ABAP Program

* Global Declarations ...DATA ...

LOAD-OF-PROGRAM....

START-OF-SELECTION....

ABAP Virtual MachineReporting Process

SUBMIT ...

ABAP Program

* Global Declarations ...DATA ...

MODULE ......

ENDMODULE.

Dynpro

PROCESS AFTER INPUT.MODULE ...

TCODE

Page 47: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 47

ABAP Special Features – ABAP Program Types 1

xxxxxTransaction Code

xSUBMITxxxxSubroutines

xFunction Modules

xxxxxMethods

xxxxxxInterfaces

xxxxxClasses

xReporting Events

xxxList Events

xxxSelection Screen Events

xxxDialog Modules

xxxDynpro

xxxxxxGlobal Data

Interface Pool

Class Pool

Type Pool

Subroutine Pool

Function Pool

Module Pool

Executable Program

SupportedFeatures

There are lot of different types of ABAP programs!

The type of a program defines its features and how it is executed in the runtimesystem.

Page 48: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 48

ABAP Special Features – ABAP Program Types 2

You might also encounter include programs. These are textually included in other programs and inherit their environment.

Page 49: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 49

ABAP Special Features – Development Environment 1

Java/J2EE (SAP solution)

RepositoryLocal Development

Environments

LocalDevelopment

Activation

Build Service J2EE Server

Check Out

Check In

SourceCode Archive

Pool Deployment

Page 50: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 50

ABAP Special Features – Development Environment 2

ABAPSAP Systems(Development)

ABAP Workbench

DevelopersDevelopersDevelopers

SAP Systems(Consolidation and Test)

WAS

DevelopersDevelopersQM, Tester

SAP Systems(Productive)

WAS

DevelopersDevelopersEnd User

CTS CTS

Repository Objectsin Packages

Programs, Screens, Classes, Interfaces, BSPs, Data Types, Function Modules, ...

Page 51: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 51

ABAP Special Features – Development Environment 3

Specialized Tools for various Repository Objects:

ABAP Editor for ABAP Source Code (programs, implementations).

Class Builder for Global Classes and Interfaces

ABAP Dictionary for Global Data Types and Database Tables

Function Builder for Function Groups and Function Modules

Web Application Builder for BSPs

Screen Painter for Dynpros

Menu Painter for Taskbars

...

Simple Usage via Forward Navigation in ABAP Worbench.

Page 52: Abap151 - Abap Objects for Java Developers

ABAP Special Features

Summary

Motivation

Similarities Between Java and ABAP

Page 53: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 53

Summary

ABAP Objects itself is very similar to Java.

However, ABAP is more than ABAP Objects.

In ABAP, the role of many statements is equivalent to that of methods in Java.

ABAP is in part a highly specialized programminginterface of the WAS.

It is sufficient to know the basic (Java-like) languageelements of ABAP in order to get started.

Complex (library-type) language elements of ABAP can belooked up on demand.

Page 54: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 54

Further Information

ABAP Documentation:Always the first source of information

Articles in Journals:http://www.intelligenterp.com/feature/archive/heymann.shtml

http://www.intelligenterp.com/feature/archive/keller.shtml

http://www.sappublications.com/insider/article.htm?key=20248

Many ABAP articles at http://www.sappro.com

SAP Press Books:ABAP Objects, Introduction: ISBN 0-201-75080-5 (English)ISBN 3-89842-147-3 (German)

ABAP Objects, Reference:ISBN 1-59229-011-6 (English)ISBN 3-89842-444-8 (German)for more books visit http://www.sap-press.com, http://www.sappress.de.

Page 55: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 55

SAP Developer Network

Look for SAP TechEd ’04 presentations and videos on the SAP Developer Network.

Coming in December.

http://www.sdn.sap.com/

Page 56: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 56

Q&A

Questions?

Page 57: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 57

Please complete your session evaluation.

Be courteous — deposit your trash, and do not take the handouts for the following session.

Feedback

Thank You !

Page 58: Abap151 - Abap Objects for Java Developers

© SAP AG 2004, SAP TechEd / ABAP151 / 58

No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice.

Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.

Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.

IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iSeries, pSeries, xSeries, zSeries, z/OS, AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli, and Informix are trademarks or registered trademarks of IBM Corporation in the United States and/or other countries.

Oracle is a registered trademark of Oracle Corporation.

UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.

Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc.

HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology.

Java is a registered trademark of Sun Microsystems, Inc.

JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape.

MaxDB is a trademark of MySQL AB, Sweden.

SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.

These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.

Copyright 2004 SAP AG. All Rights Reserved