6
Developers are increasingly making use of modeling in ABAP development tools — UI development tools based on the Web Dynpro programming paradigm are good examples — to build programs without having to painstakingly write them line by line. Digging into the code, though, is still the trickiest part of any application development, so it’s not surprising that the bulk of a developer’s time is spent with the ABAP Editor and Debugger tools. Despite a selection of model-driven programming tools, the typical ABAP developer probably spends as much as 95% of his time writing — and reworking — code using the ABAP Editor and Debugger. Whenever your work relies so much on any one tool, the addition of any new time-saving feature will have some major impact on productivity and speed up projects significantly. Even from a more user-oriented perspective, you shouldn’t underestimate the power of a user-friendly coding environment. It can make sitting down at the computer to make last-minute changes to your application to adapt to new business requirements — or even worse, to edit code you didn’t design on your own — all the more bearable. 1 With all their new features, the latest versions of the ABAP Editor and Debugger (available with SAP GUI 6.40 patch level 10 for SAP NetWeaver 2004s) are generating quite a buzz — but don’t just take my word for it. Both the ABAP Editor and Debugger won first prize at the “SDN Jam Session” demo competition at the 2005 SAP TechEd conferences in both Vienna and Boston.To help show what the excitement is all about, this article looks at the new editing and debugging tools (see Figure 1), and highlights some time- saving features: Automated and customizable syntax coloring, bookmarking, and collapsible code views to help better organize New ABAP Editor and Debugger Boost Developers’ Productivity Regular Feature Under Development Karl Kessler, SAP AG and manage even the most complex development code Code templates, dynamic content, and auto-correct options that “under- stand” what developers are coding Figure 1 Some Sample Views of the New ABAP Editor and Debugger Environments 1 For example, I admit that I didn’t like the early Java development tools, as they were inherently slower than typical Windows applications. But when Eclipse arrived on the scene using Windows resources more or less natively for Java development, I instantly became enthusiastic. A cool development environment makes a big difference! Subscribe today.Visit www.SAPinsider.com. This article appeared in the Apr May Jun 2006 issue of SAP Insider and appears here with permission from the publisher, Wellesley Information Services (WIS), www.WISpubs.com.

ABAP Debugger New

Embed Size (px)

DESCRIPTION

How to Use New Debugger and Abap editor

Citation preview

Page 1: ABAP Debugger New

Developers are increasingly making use of modeling in ABAP developmenttools — UI development tools based onthe Web Dynpro programming paradigmare good examples — to build programswithout having to painstakingly writethem line by line. Digging into the code,though, is still the trickiest part of anyapplication development, so it’s notsurprising that the bulk of a developer’stime is spent with the ABAP Editor andDebugger tools. Despite a selection ofmodel-driven programming tools, thetypical ABAP developer probably spendsas much as 95% of his time writing —and reworking — code using the ABAPEditor and Debugger.

Whenever your work relies so muchon any one tool, the addition of any newtime-saving feature will have some majorimpact on productivity and speed upprojects significantly. Even from a moreuser-oriented perspective, you shouldn’tunderestimate the power of a user-friendlycoding environment. It can make sittingdown at the computer to make last-minutechanges to your application to adapt tonew business requirements — or evenworse, to edit code you didn’t design onyour own — all the more bearable.1

With all their new features, the latest versions of the ABAP Editor and Debugger (available with SAP GUI6.40 patch level 10 for SAP NetWeaver2004s) are generating quite a buzz —but don’t just take my word for it. Boththe ABAP Editor and Debugger wonfirst prize at the “SDN Jam Session”demo competition at the 2005 SAPTechEd conferences in both Vienna andBoston.To help show what the excitementis all about, this article looks at the new editing and debugging tools (seeFigure 1), and highlights some time-saving features:

■ Automated and customizable syntaxcoloring, bookmarking, and collapsiblecode views to help better organize

New ABAP Editor and Debugger BoostDevelopers’ Productivity

Regular Feature

UnderDevelopment

Karl Kessler, SAP AG

and manage even the most complexdevelopment code

■ Code templates, dynamic content,and auto-correct options that “under-stand” what developers are coding

Figure 1 Some Sample Views of the New ABAP Editor and DebuggerEnvironments

1 For example, I admit that I didn’t like the early Javadevelopment tools, as they were inherently slower thantypical Windows applications. But when Eclipse arrivedon the scene using Windows resources more or lessnatively for Java development, I instantly becameenthusiastic. A cool development environment makes a big difference!

Subscribe today. Visit www.SAPinsider.com.

This article appeared in the Apr ■ May ■ Jun 2006 issue of SAP Insider and appears here with

permission from the publisher, Wellesley Information Services (WIS), www.WISpubs.com.

Page 2: ABAP Debugger New

and help programmers avoid syntactical errors

■ More sophisticated, state-of-the-artuser interfaces, including split windowsand customized screens, to comparedifferent sections of a program andspeed development and debugging

To get a taste of the new ABAPEditor and Debugger for yourself, simplydownload the latest “Sneak Preview”version of the ABAP application server(based on SAP NetWeaver 2004s),available on the SAP Developer Network(SDN) at www.sdn.sap.com/irj/sdn/downloads.This will give you some

experience with Web Dynpro ABAP inconjunction with the new editor anddebugger, and even allows you to shareyour findings in SDN forums. All thescreenshots and examples in this columnare taken from this demo version, so youcan use this article as a reference as youexplore the ABAP Editor and Debuggeron your own screen.

What’s New with the ABAP EditorA look at the ABAP Editor’s history(see sidebar below) reflects how the new editor is a real breakthrough in itsnative ABAP support and its new level

of controls sophistication. From a tech-nical standpoint, the new ABAP Editor,like its predecessor, relies on ActiveXcontrols technology. But this time, thistechnology knows about ABAP syntaxand can better predict and support theABAP developer’s actions.2

Like previous versions of the ABAPEditor, the new editor is tightly inte-grated into the classic Workbench tools,meaning all the familiar server-sidefeatures — such as activation, global

Subscribe today. Visit www.SAPinsider.com.

The new editor is a real breakthrough in its native ABAPsupport. Some of the limitations of earlier versions of theABAP Editor can be better understood by taking a quicklook back at how the ABAP Editor has evolved.

Early ABAP EditorsThe first application ever developed for SAP R/3 was theABAP Editor. After R/3 Basis was developed in the late1980s, SAP needed a strong programming environmentbased on UNIX and relational database technology for itsnew release.Two projects were launched: one based on Cprogramming and another developed in ABAP on the R/2platform. Since R/2 ABAP was more or less identical toR/3 ABAP back then, it’s not surprising that the ABAP-based solution was available first, and thus has become thecommonly used solution.The reason was simple: Even slightchanges in C always required a recompile and redeploy onthe various UNIX workstations (i.e., installation of a newlocal GUI), whereas the ABAP-based editor was stored indatabase tables and therefore, due to ABAP’s server-sidenature, was immediately available to all developers.

A Block-Editing and Tables-Based ApproachThis distribution and self-compiling feature of the ABAPEditor (and, in fact, all ABAP programs) helped to set upa rather stable environment in the early SAP R/3 days,which was key to its success. However, the ABAP-centricdesign also had its price: Its dialog characteristics reflecteda “block mode” editing environment. Users coming from an IBM environment felt comfortable with this, since theABAP Editor shared many features of editors that are

available on an IBM host, including the “block” on the leftside of the editor interface where you insert line commandsto copy, move, or delete lines. Developers who were used toUNIX or Windows, however, were expecting other types oftools; Windows users, for example, expected a new linewhen they hit “enter,” while mainframe users expected datato be transferred in block mode to the host.To address this,the ABAP Editor offered a “PC mode” that supported aWindows approach. From an implementation perspective,the ABAP Editor continued to use table controls — again,emphasizing handling of tabular data rather than code lines.

Incorporating ActiveX ControlsThe next innovation was triggered with SAP GUI’s supportof OLE, which allowed developers to embed native ActiveXcontrols capable of sophisticated frontend features such asdrag and drop, local search and replace, local scrolling,local printing, and support for keyboard accelerators.Thisinnovation was also reflected in the ABAP Editor, with acontrol-based editor plus backend features like syntaxcheck and Workbench navigation (including the now indis-pensable double-click that allows developers to jump fromthe code directly to the definition of a structure or field).

This ActiveX approach was a major step forward. Sinceit was being incorporated into a text editor-based approach,however, the ActiveX control-based editor was not aware ofthe ABAP syntax. Features that had become popular inVisual Basic programming, such as syntax coloring, couldnot be supported directly.This is where the new ABAPEditor comes into play.

A Brief History of the ABAP Editor

2 The control implementation is independent of theABAP syntax bindings. As a consequence, it is alsoused in other tools that require a different syntax,such as eCATT.

Page 3: ABAP Debugger New

search, navigation to other tools, properembedding into all major tools like class and function builder — are still fully available.

To get started with the new editor,simply switch on the “Front-End Editor(New)” preference setting (as shown onthe left screen in Figure 2) and log onas usual to the ABAP Editor. You’ll also be able to set yourself up to use the newdebugger in the Workbench settings,under the “Debugging” tab.

The New Look of the ABAP Editor

Figure 3 reveals the new ABAP Editor.Compare this to earlier versions — theonly thing that looks familiar is theactual ABAP code!

The most obvious change is all thecolor; automated syntax highlightingcolor-codes different syntacticalelements. Keywords, such as DATA and CHECK, are shown in blue; stringconstants are green; custom code is in black; and comments are italicized —and all of these can be customized,which I’ll explain in the next section.

There are other features that devel-opers will welcome:

■ In the leftmost column of the editorscreen, developers can insert symbols,such as breakpoints, to indicate stop-ping points throughout the program —there was no way to display thesecontrol icons in the previous version of the editor

■ To indicate newly added or changedcode, triangles appear to the right ofthe corresponding line numbers wherecode has been edited

■ Numbered bookmarks can be easilyinserted and manipulated using acontext menu to more flexibly navigate to important points withinyour program

Customization OptionsThe ABAP Editor’s color and styleassignments are certainly not fixed. If

you prefer alternate colors and shading,you can customize the editor by simplyclicking the customize button in thelower right corner of the main ABAPEditor window, which brings you to theOptions menu. Figure 4 on the next pageshows the various customization options,which include changing the color forbreakpoints (in this case, setting it todark red). Here you can also change the various types of items you can

display, including errors and breakpoints.Other customization features include the ability to:

■ Set auto-correction options forfrequently occurring misspellings

■ Establish rules for “pretty printing,”including indentation settings

■ Format code using font, color, word-wrapping styles, etc.

Subscribe today. Visit www.SAPinsider.com.

Figure 2 Switching On the New ABAP Editor and Debugger Tools

Figure 3 New ABAP Editor Features Include Syntax Coloring, LineNumbering, Bookmarks, and Breakpoints

Click to accessthe Options menuand customizeyour settings

Page 4: ABAP Debugger New

Split Screens for Easier Maintenance

Clicking the split bar button at the topright of the main ABAP Editor screenallows you to see two views of the sameprogram, as shown in Figure 5.This splitview helps you maintain related parts of aprogram within the same window — forexample, you can program data defini-tions and the affected sections of code inparallel — instead of having to open asecond SAP GUI window to do so.

Clearer Views of Even the MostComplex ProgramsAnother outstanding feature of the new code editor is its support foroutlining syntactical structures such as CASE…ENDCASE and METHOD…ENDMETHOD (see Figure 6). With the“+” and “-” buttons, you can easilycollapse and expand the body of syntac-tical structures within your code, andtherefore better follow the inner structureof your programs by hiding details thatare currently out of scope.

Features to Make Development More EfficientCode templates are a powerful means toabstract recurring syntactical patterns.With templates at hand, the system canprovide hints — while you enter code —that a template is available. For example,if you type the keyword “select,” thesystem will automatically suggest to use the code template for “select.” Ifyou simply press CTRL+ENTER, thesuggested template will be inserted.(Misspellings can be corrected on the fly in the same way.)

The new ABAP Editor comes with alarge selection of common, predefinedtemplate patterns (such as FORM…ENDFORM). But you can also definecustom templates on your own, helpingenforce customized programming guide-lines and the like.

Figure 7 shows the template editor,which is integrated within the customizingdialog in the Options menu.The templatemechanisms also allow you to insert

dynamic fields (such as date/time) andintegrate dialog input (such as the formname) to provide fully flexible templates.

Additional Editing Features Other features that have been enhancedfor the new ABAP Editor include:

■ Extended dialogs for find and replace

■ A clipboard that holds code fragmentscut during your editing session

■ Capabilities to print and export codesnippets or full programs in multipleformats (HTML, PDF, etc.) forsharing code in SDN, for example

I could go on for quite some timeabout additional new editing capabilities,but let’s press on to look at the featuresof the new ABAP Debugger. As youexplore the new debugger, note that thenew features of the ABAP Editor arefully integrated into the debugging tool,and vice versa. Now communicationbetween the two tools is seamless.

Exploring the Features of the New DebuggerThe debugger has recently gone through significant architectural changes and includes new features

Subscribe today. Visit www.SAPinsider.com.

Figure 4 Customizing the ABAP Editor Through the Options Menu

Figure 5 Split View Eases Program Maintenance

Page 5: ABAP Debugger New

that developers will see and benefit from immediately.

In the past, debugger screens wereviewed as part of the screen flow of atransaction whenever some breakpointor watchpoint condition was met.Theadvantage of this approach was itsspeed: I have never seen a debuggingenvironment come up that fast. Whileother debuggers typically appear, slowlyinitialize the debug environment, andload a lot of symbolic information, theclassic ABAP Debugger screens displayed

immediately since the debugger was partof the ABAP runtime environment.

On the other hand, the debugger waslimited from a user-interface perspective.The debugger’s UI control was imple-mented inside one work process in thekernel, meaning that the debugger andthe process being debugged ran in thesame internal session. For the user, thismeant that the classic debugger appearedin the same SAP GUI window as theapplication being debugged — whichwas often confusing. From a technical

point of view, this meant that the debuggershared its context data with the applica-tion being debugged, and vice versa.3

These limitations of the classicdebugger are solved by a two-processarchitecture in the new ABAP Debugger,where the debugger and the debuggedtransaction run in cleanly separatedexternal modes using different windowsthat communicate with each other. Alldebug controls, such as “single step” and“continue until next breakpoint,” arenow done in separate windows, while the debugged transaction runs in its own window. When a debug condition is met (for example, when the programhits a breakpoint in the code), then thedebugger window is ready for input and links back to the original program.The transaction window is blocked until program execution is resumed inthe debugger and the next screen isdisplayed in the transaction window.4

This “new” architecture is notcompletely new — it was first introducedin SAP Web Application Server 6.40.But with this architecture come lots ofnew features for the ABAP Debugger,including advanced user interface control.

A More Sophisticated Look and Feel

Like its classic counterpart, the newdebugger explicitly comes up when youenter “/h” in the command field of anyapplication. Figure 8 on the next pageshows the main window of the newdebugger. Note the differences. With thenew debugging architecture, the brand-newABAP Editor control is used, bringingthe latest features (such as syntax high-lighting) right into your debugging envi-ronment. On the right side of the screen,you see the variables display. I picked a

Subscribe today. Visit www.SAPinsider.com.

Figure 6 Collapsing and Expanding Code Sections for a Clearer View ofProgram Structure

Figure 7 Defining and Editing Code Templates from the Options Menu

3 An ABAP-based implementation was not possible, asthe debugger and the debugged transaction ran in thesame internal mode, causing interference betweendebugger and “debuggee.”

4 For more details on how the new debugger works, see“Introducing the next generation of ABAP debugging— the New ABAP Debugger” by Boris Gebhardt andChristoph Stöck in the January-February 2006 issueof SAP Professional Journal (www.sappro.com).

Page 6: ABAP Debugger New

specialized desktops for certain debug-ging tasks. Each desktop is a collectionof tools that you can easily customize.For example, if you want to control the flow of execution and display twointernal tables simultaneously, you canopen the tool dialog and select theappropriate tools. I selected the table tooltwice; the result is shown in Figure 9.With the two internal tables displayedside by side, it is now fairly easy to findand correct errors.

Other Debugging FeaturesThe debugger offers a variety of addi-tional tools, including a Diff tool tocompare variables or internal tables inparallel and a tool to display the innerstructure of objects, as well as specialfeatures including stack display, anoverview of breakpoints, the capability toset watchpoints, and more. You can alsotransfer the actual parameter of a func-tion module call into the test environ-ment for function modules.

A complete discussion of all the newfeatures is certainly beyond the scope of this column. Again I invite you to testdrive the 2004s download, availablefrom SDN at www.sdn.sap.com/irj/sdn/downloads.

SummaryAll the buzz around the new ABAPEditor and Debugger is well deserved.The new features and design of theABAP Editor and Debugger betterunderstand the syntactical elements of the language, greatly enhancing the productivity of your ABAP develop-ment teams. As always, the tools are integrated into the familiar environment of an ABAP Workbench.But unlike earlier versions, the tools are now integrated with each other —the new editing environment is fullyreflected in the debugging environment,and vice versa. What’s more, the toolsalso offer many new customization capabilities to personalize each user’sdesigntime and runtime environment.This is cool, time-saving stuff for ABAP developers!

Karl Kessler joined SAP in 1992. He is the

Product Manager of the SAP NetWeaver

foundation, which includes SAP NetWeaver

Application Server, Web Dynpro, ABAP

Workbench, and SAP NetWeaver Developer

Studio, and is responsible for all rollout

activities. You can reach him via email

at [email protected].

Figure 8 The New Look of the ABAP Debugger User Interface

Figure 9 Customized Desktop Comparing Two Tables in the New ABAP Debugger

Variables display

couple of variables from the runningtransaction with the traditional double-click, but you can also easily hover overthe code and a transient window pops up,immediately showing the variable’s value.

Customization Options to TailorDebugger Desktops to UserPreferencesAnother major difference is the way thenew debugger lets the user configuredesktops to his needs and switch to

Subscribe today. Visit www.SAPinsider.com.