ABAP201: Best of ABAP – The Ultimate ABAP 6.

40 Feature Show

Contributing Speakers
Andreas Blumenthal
SAP AG

Karsten Bohlmann
SAP AG

Boris Gebhardt
SAP AG

Christoph Stoeck
SAP AG

© SAP AG 2004, SAP TechEd / ABAP201 / 2

Agenda

Generic Programming

Checkpoints in ABAP

ABAP Debugger

Shared Objects

ABAP Unit

Simple Transformations

Memory Inspector

© SAP AG 2004, SAP TechEd / ABAP201 / 3

SAP TechEd / ABAP201 / 4 .ABAP Unit © SAP AG 2004.

ABAP Developer Mr. They developed their own SAP NetWeaver based flight booking system.ABAP Unit – A Little Story (Version 1) We visit a mid sized company XYZ based somewhere in the US. SAP TechEd / ABAP201 / 5 . Dummy Development request from Controlling: “Please sort the flights in our flight booking system by price (ascending) so that all employees will most likely choose the cheapest flight.” © SAP AG 2004.

Ideally it is the smallest code part which can be tested in isolation. How does an ABAP Unit test looks like? The ABAP Unit tests are realized as methods of a local class (with the addition “FOR TESTING”). This local class is part of the class. What is an Unit? An unit can be considered as a non-trivial. function or form) where a given input or action causes a verifiable effect. SAP TechEd / ABAP201 / 6 .ABAP Unit – What Should I Know ? What is ABAP Unit? ABAP Unit is the ABAP framework for module/unit tests. function group or program you want to test. © SAP AG 2004. accessible code portion (method.

which contains static methods (e.g. (-> No performance or security drawbacks) Which services are provided by ABAP UNIT? ABAP Unit provides a service class CL_AUNIT_ASSERT. strings or internal tables in order to verify test results. ASSERT_EQUALS) to compare e. SAP TechEd / ABAP201 / 7 .g. © SAP AG 2004.ABAP UNIT – What Should I Know ? Why is the test class part of the productive code? ABAP Unit tests and the linked production code are in sync In a productive system the ABAP Unit tests are not part of the productive program load.

Dummy. © SAP AG 2004.ABAP Unit – A Little Story (Version 2) This time the flight system is verified by ABAP Unit tests. SAP TechEd / ABAP201 / 8 . Let’s see how this will influence the fate of Mr.

SAP TechEd / ABAP201 / 9 .Still Need of Integration and System Testing © SAP AG 2004.

be on the safe side! © SAP AG 2004. SAP TechEd / ABAP201 / 10 .Thank you… Test a lot. test well.

SAP TechEd / ABAP201 / 11 .Checkpoints in ABAP © SAP AG 2004.

Checkpoints in ABAP Task: “Create utility for reversing strings” Examples: 'ABC' 'OTTO' -> 'CBA' -> 'OTTO' '12345' -> '54321' © SAP AG 2004. SAP TechEd / ABAP201 / 12 .

Checkpoints in ABAP Demo © SAP AG 2004. SAP TechEd / ABAP201 / 13 .

SAP TechEd / ABAP201 / 14 normal termination .Checkpoints in ABAP system state consistent state program flow © SAP AG 2004.

SAP TechEd / ABAP201 / 15 normal termination .Checkpoints in ABAP system state unexpected behavior consistent state program flow © SAP AG 2004.

SAP TechEd / ABAP201 / 16 .Checkpoints in ABAP system state system state unexpected behavior : assertion runtime error normal termination consistent state program flow normal termination consistent state program flow find cause of error in shorter time © SAP AG 2004.

SAP TechEd / ABAP201 / 17 normal termination runtime error .Checkpoints in ABAP system state undetected error normal termination system state : assertion consistent state program flow consistent state program flow find more errors enhance program correctness © SAP AG 2004.

SAP TechEd / ABAP201 / 18 . BREAK-POINT .Checkpoints in ABAP ASSERT .Statement: ASSERT ID SUBKEY FIELDS CONDITION group subkey dobj1 dobj2 .Statement: BREAK-POINT ID group.. log_exp. © SAP AG 2004..

SAP TechEd / ABAP201 / 19 .Checkpoints in ABAP Demo © SAP AG 2004.

while system is running Activation granularity Logical „checkpoint groups“ Compose „variants“ from Checkpoint groups. classes. variants. All checkpoints in programs. function groups. development components User. server Assertion mechanism Abort. classes Extract checkpoint groups from programs.Checkpoints in ABAP Activation method dynamic. SAP TechEd / ABAP201 / 20 . debug or protocol © SAP AG 2004. function groups. packages.

Checkpoints in ABAP ABAP checkpoints support developers in writing correct code Activated in SAP development systems ( abort. server ) No activation. no performance loss !!! © SAP AG 2004. SAP TechEd / ABAP201 / 21 . protocol ) Code instrumented with checkpoints is easier to support and maintain Can be activated on the fly in productive systems ( activation for dedicated user.

SAP TechEd / ABAP201 / 22 .Memory Inspector © SAP AG 2004.

SAP TechEd / ABAP201 / 23 . like Internal Tables Class Instances (Objects) Strings Anonymous Data Objects Increasing number of long-running transactions T1 T2 T3 T4 T1 © SAP AG 2004.Memory Inspector: Motivation What is the Memory Inspector ? Tool to analyze dynamic memory consumption Why do we need the Memory Inspector ? Increasing usage of dynamic memory objects.

Memory Inspector Demo © SAP AG 2004. SAP TechEd / ABAP201 / 24 .

2003 ) © SAP AG 2004.Memory Inspector: Features Summary In ABAP Debugger TopN-Consumer-Lists Aggregation of types (class/data) Find References Memory consumption overview In Stand-Alone TA Analyzing memory snapshots Comparing memory snapshots Growth of memory objects in different views Available in Release 6. SAP TechEd / ABAP201 / 25 .20 ( SP 29. Sept.

SAP TechEd / ABAP201 / 26 .Shared Objects © SAP AG 2004.

Data Access without Buffering Common data DB computed and/or copied for each user session Common Data User X Session Common Data User Y Session © SAP AG 2004. SAP TechEd / ABAP201 / 27 .

Data Access with Buffering EXPORT Shared Memory DB Common Data Common data computed once exported (copied) to shared memory imported (copied) into each user session IMPORT Common Data User X Session Common Data User Y Session © SAP AG 2004. SAP TechEd / ABAP201 / 28 .

SAP TechEd / ABAP201 / 29 .Data Access with Shared Objects Attach for Write Shared Memory DB Common Data Common data computed once written in place in shared memory accessed without copying by a read attach Attach for read User X Session User Y Session © SAP AG 2004.

Areas and Area Instances Shared Objects memory Part of the shared memory Shared Memory Shared Objects Memory Area I n s t a n c e I n s t a n c e Area I n s t a n c e Shared Objects areas Organizational units Defined at design time Shared Objects area instances Content stored at runtime Identified by unique name © SAP AG 2004. SAP TechEd / ABAP201 / 30 .

Working with Area Instances Attach for write Fill the contents Instance Root © SAP AG 2004. SAP TechEd / ABAP201 / 31 .

Working with Area Instances Attach for write Fill the contents Commit changes Instance Root © SAP AG 2004. SAP TechEd / ABAP201 / 32 .

Working with Area Instances Attach for write Fill the contents Commit changes Attach reader1 Instance Root © SAP AG 2004. SAP TechEd / ABAP201 / 33 .

SAP TechEd / ABAP201 / 34 .Working with Area Instances Attach for write Fill the contents Commit changes Attach reader1 Attach reader2 Instance Root © SAP AG 2004.

Working with Area Instances Attach for write Fill the contents Commit changes Attach reader1 Attach reader2 Detach reader1 Instance Root © SAP AG 2004. SAP TechEd / ABAP201 / 35 .

SAP TechEd / ABAP201 / 36 .Working with Area Instances Attach for write Fill the contents Commit changes Attach reader1 Attach reader2 Detach reader1 Detach reader2 Instance Root © SAP AG 2004.

SAP TechEd / ABAP201 / 37 .Shared Objects Demo © SAP AG 2004.

SAP TechEd / ABAP201 / 38 .g. at 1st read attach) Transactionality Propagation of area invalidation across AppServer instances Client dependency Displacement Customizable memory and lifetime restrictions Multi-Attach to different areas at once © SAP AG 2004.Additional Features Versioning Auto-Build (e.

Generic Programming © SAP AG 2004. SAP TechEd / ABAP201 / 39 .

Flight connection and Carrier IDs or Flights and bookings or … © SAP AG 2004.Challenging Development Request Senior management wants a generic table display tool where they can display joined tables freely. e.g. SAP TechEd / ABAP201 / 40 .

Join of SPFLI and SCARR SELECT SPFLI~MANDT SPFLI~CARRID … SCARR~CURRCODE SCARR~URL … FROM SPFLI join SCARR ON SPFLI~MANDT = SCARR~MANDT AND SPFLI~CARRID = SCARR~CARRID © SAP AG 2004.g.Problem Analysis Selecting the Data from the database: e. SAP TechEd / ABAP201 / 41 .

SAP TechEd / ABAP201 / 42 . © SAP AG 2004.Problem Analysis Selecting the Data from the database: e.g. Join of SFLIGHT and SBOOK SELECT SFLIGHT~MANDT SFLIGHT~CARRID … SBOOK~BOOKID SBOOK~CUSTOMID … FROM SFLIGHT join SBOOK ON SFLIGHT~MANDT = SBOOK~MANDT AND SFLIGHT~CARRID = SBOOK~CARRID AND SFLIGHT-CONNID = SBOOK-CONNID.

Problem Solution Step 1 How shall I cover all these different SELECTS in one program ? Use Dynamic Open SQL: SELECT (select_clause_it) FROM (from_clause). ABAP © SAP AG 2004. Dr. SAP TechEd / ABAP201 / 43 .

SAP TechEd / ABAP201 / 44 . components = struct_type->get_components( ).Problem Solution Step 2 Nice. © SAP AG 2004. ABAP Use RTTS: struct_type ?= cl_abap_typedescr=>describe_by_name( dbtable ). but where do I get the DB table components from ? Dr.

SAP TechEd / ABAP201 / 45 .RTTS Class Hierarchy CL_ABAP_TYPEDESCR CL_ABAP_TYPEDESCR CL_ABAP_DATADESCR CL_ABAP_DATADESCR CL_ABAP_OBJECTDESCR CL_ABAP_OBJECTDESCR CL_ABAP_ELEMDESCR CL_ABAP_ELEMDESCR CL_ABAP_REFDESCR CL_ABAP_REFDESCR CL_ABAP_INTFDESCR CL_ABAP_INTFDESCR CL_ABAP_CLASSDESCR CL_ABAP_CLASSDESCR CL_ABAP_COMPLEXDESCR CL_ABAP_COMPLEXDESCR CL_ABAP_STRUCTDESCR CL_ABAP_STRUCTDESCR CL_ABAP_TABLEDESCR CL_ABAP_TABLEDESCR © SAP AG 2004.

but now we are lost ! For each DB table combination I need a result table ITAB with totally different components! © SAP AG 2004.Problem Solution Step 3 SELECT (select_clause) INTO TABLE ITAB FROM (from_clause). Perfect. SAP TechEd / ABAP201 / 46 .

Problem Solution Step 3 Create the internal table you need during runtime ! Dr. SAP TechEd / ABAP201 / 47 . ABAP © SAP AG 2004.

SAP TechEd / ABAP201 / 48 method CREATE .RTTS Class Hierarchy CL_ABAP_TYPEDESCR CL_ABAP_TYPEDESCR CL_ABAP_DATADESCR CL_ABAP_DATADESCR CL_ABAP_OBJECTDESCR CL_ABAP_OBJECTDESCR CL_ABAP_ELEMDESCR CL_ABAP_ELEMDESCR CL_ABAP_REFDESCR CL_ABAP_REFDESCR CL_ABAP_INTFDESCR CL_ABAP_INTFDESCR CL_ABAP_CLASSDESCR CL_ABAP_CLASSDESCR method CREATE CL_ABAP_COMPLEXDESCR CL_ABAP_COMPLEXDESCR CL_ABAP_STRUCTDESCR CL_ABAP_STRUCTDESCR CL_ABAP_TABLEDESCR CL_ABAP_TABLEDESCR method CREATE © SAP AG 2004.

END OF struc.Working with Type Objects Getting type objects CL_ABAP_STRUCTDESCR by name (method: describe_by_name) by creation (method: create) struc name age o o TYPES: BEGIN OF struc. age TYPE i. name TYPE string. SAP TechEd / ABAP201 / 49 . © SAP AG 2004.

Working with Type Objects

Getting type objects
CL_ABAP_STRUCTDESCR

by name (method: describe_by_name) by creation (method: create)

struc

name age

o o

Working with type objects

TYPES: BEGIN OF struc, name TYPE string, age TYPE i, END OF struc.

CREATE DATA ... TYPE HANDLE ... ASSIGN ... CASTING TYPE HANDLE ...

© SAP AG 2004, SAP TechEd / ABAP201 / 50

Dynamic Type Creation

Demo

© SAP AG 2004, SAP TechEd / ABAP201 / 51

Simple Transformations

© SAP AG 2004, SAP TechEd / ABAP201 / 52

LT XS Simple Transformations Network XSLT XS LT DB © SAP AG 2004. .. …. SAP TechEd / ABAP201 / 53 L XS T … ..... … .40 XML Doc … . .. …. … .. . …. . …. … …. …... …. …. . . HTML / Text ..XML Mapping Tasks in ABAP XS LT ABAP Data in ew n 6. ….

40) only for ABAP ↔ XML only linear transformations (no DOM) speedup over XSLT: 10 – 30.10) works on canonical XML representation of ABAP data (asXML) builds DOM for source side arbitrarily complex transformations basis of: XI 2. “unlimited” size of data reversible (one program for both directions) basis of: XI 3.0 / Web Services Both symmetric: no generation of ABAP code / XML schemas integrated in workbench (maintenance / transport) integrated in ABAP: CALL TRANSFORMATION © SAP AG 2004. SAP TechEd / ABAP201 / 54 .ABAP / XML Mapping Languages XSLT (since 6.0 Simple Transformations (since 6.

Simple Transformations Demo © SAP AG 2004. SAP TechEd / ABAP201 / 55 .

out: XML) – e. SAP WebDynpro) Simple mappings.: http://xml.amazon. SAP TechEd / ABAP201 / 56 . high throughput Simple Transformations Complex mappings. limited throughput XSLT © SAP AG 2004.g.com/onca/xml3?locale=us&t=te&dev-t=te&KeywordSearch=ABAP&mode=books&type=lite&f=xml Custom XML Persistence XML-Based Repositories (e.ABAP / XML: When To Use What System Landscape Integration Exchange Infrastructure SOAP-Based Web Services ABAP Web Services Direct XML Processing in ABAP REST-Based Web Services (in: URI.g.

ABAP Debugger © SAP AG 2004. SAP TechEd / ABAP201 / 57 .

Mr.Our Little Story Continues… Manager Some years after the dismissal of Mr. was promoted and is now manager of all ABAP developers.ABAP Debugger . the successor of Mr. He uses the new version of their internal flight booking system. He wants to book a flight for a business trip. Premium Developer © SAP AG 2004. which was developed by his premium developer. Dummy we visit again our company XYZ. SAP TechEd / ABAP201 / 58 . Smith. Dummy.

The document is not intended to be binding upon SAP to any particular course of business. SAP TechEd / ABAP201 / 59 . © SAP AG 2004.New ABAP Debugger – Outlook Please note that this document is subject to change and may be changed by SAP at any time without notice. product strategy and/or development.

New Dynamik Test Tools for ABAP Developers .sap. New ABAP Debugger and Memory Inspector. Checkpoints ABAP254.sdn. 4h Hands-on New ABAP Debugger.com/services/ Related SAP Education Training Opportunities http://www.com/education/ Related Workshops/Lectures at SAP TechEd 2004 ABAP UNIT.sap.com Search for ABAP Knowledge Center SAP Customer Services Network: www. SAP TechEd / ABAP201 / 60 .com SAP Developer Network: www.sap. 2h Hands-on © SAP AG 2004. Memory Inspector ABAP255.sap.Further Information Public Web: www.

4h Hands on Simple Transformations ABAP252. Advanced & Generic Programming in ABAP. 4h Hands on © SAP AG 2004. ABAP Troubleshooting. Shared Memory Programming Made Easy. ABAP . ABAP Shared Objects.Further Information Related Workshops/Lectures at SAP TechEd 2004 Shared Objects ABAP251. 4h Hands-on Generic Programming ABAP351. 4h Hands-on ABAP Troubleshooting ABAP253. SAP TechEd / ABAP201 / 61 .XML Mapping.

sdn. SAP TechEd / ABAP201 / 62 .sap.com/ © SAP AG 2004.SAP Developer Network Look for SAP TechEd ’04 presentations and videos on the SAP Developer Network. Coming in December. http://www.

Questions? Q&A © SAP AG 2004. SAP TechEd / ABAP201 / 63 .

SAP TechEd / ABAP201 / 64 . and do not take the handouts for the following session. Be courteous — deposit your trash.Feedback Please complete your session evaluation. Thank You ! © SAP AG 2004.

Parallel Sysplex. R/3. OS/2. xApps. and MultiWin are trademarks or registered trademarks of Citrix Systems. XHTML and W3C are trademarks or registered trademarks of W3C®.. without representation or warranty of any kind. ICA. VideoFrame. mySAP. Nothing herein should be construed as constituting an additional warranty. OS/400. Data contained in this document serves informational purposes only. SAP. The information contained herein may be changed without prior notice. MetaFrame. UNIX. MaxDB is a trademark of MySQL AB. HTML. Oracle is a registered trademark of Oracle Corporation. IBM. Inc. OSF/1. xApp. AS/400. Inc. mySAP. WebSphere. These materials are subject to change without notice. World Wide Web Consortium. 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. SAP TechEd / ABAP201 / 65 . Microsoft. Citrix. Java is a registered trademark of Sun Microsystems. Inc. All other product and service names mentioned are the trademarks of their respective companies. Sweden. OS/390. XML. xSeries. Massachusetts Institute of Technology. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only. and Informix are trademarks or registered trademarks of IBM Corporation in the United States and/or other countries. © SAP AG 2004. Intelligent Miner.Copyright 2004 SAP AG. Program Neighborhood. and PowerPoint are registered trademarks of Microsoft Corporation. X/Open. Windows. pSeries. AFP. Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. 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 Rights Reserved No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. and Motif are registered trademarks of the Open Group. zSeries. S/390. DB2.com. JavaScript is a registered trademark of Sun Microsystems. AIX. National product specifications may vary. Tivoli. iSeries. z/OS. and SAP Group shall not be liable for errors or omissions with respect to the materials. WinFrame. Outlook. used under license for technology invented and implemented by Netscape. MVS/ESA. DB2 Universal Database. Netfinity. if any.

Sign up to vote on this title
UsefulNot useful