New Announcements and Updates




Official ABAP Programming Guidelines

Price:
Starting From $59.99
Product Code:
H3072
Average Rating:
( 12 product reviews )
Availability:
In stock!
Format:
Quantity:


Write your own product review

Product Details

ISBN:
978-1-59229-290-5
Author(s):
Horst Keller, Wolf Hagen Thümmel
Type:
Hardcover, 386 pages.
Year:
2009

Product Description and Table of Contents

How do I select the appropriate program type? Where should the local declarations of a procedure be positioned? Am I supposed to immediately replace all obsolete language elements in existing code? Should I use procedural or object-oriented ABAP? The official ABAP programming guidelines provide clarity and security by answering these questions, and many more that may arise in your daily work.

Readers learn the general principles that should be taken into account when you create new programs and classes and find the answers to your questions on style, including naming, commentation, and structure of programs and procedures. Plus, explore guidelines on individual aspects of architecture, such as object orientation, error handling, user interfaces, data storage, and much more. With this book you'll be able to ensure your ABAP programs run predictably with no surprises by gaining in-depth knowledge on data types and data objects, calculations and accesses, internal tables, and more.

That's just for starters! Explore volumes of practical tips and expert insights throughout the book, as well as examples of good and bad ABAP programming, to help you adopt effective working techniques and principles.

Highlights

  • Basic Rules:
    Separation of Concerns, Correctness and Quality, Program Type and Attributes, Modern ABAP, Checks for Correctness
  • Structure and Style:
    Code Formatting and Organization, Naming, Comments, Alternative Notations
  • Architecture:
    Object Orientation, Error Handling, User Interfaces, Data Storage
  • Secure and Robust ABAP:
    Data Types and Objects, Calculations and Accesses, System Fields, Internal Tables, Modularization, Dynamic Programming

 

About the Author(s)

Dr. Horst Keller and Dr. Wolf Hagen Thümmel work at SAP in the TD Core AS&DM ABAP group, whose members are responsible for the ABAP language. As a Knowledge Architect, Horst Keller is mainly responsible for documentation and rollout of ABAP and ABAP Objects; Wolf Hagen Thümmel focuses on language-related tools in the ABAP environment as well as in the area of mass checks for quality assurance.

 

Table of Contents

... Foreword ... 13

... Acknowledgments ... 15

1 ... Introduction ... 17

1.1 ... What Are Programming Guidelines ... 17

1.2 ... Why Programming Guidelines ... 18

1.3 ... Which Guidelines Are Involved Here ... 18

1.4 ... Target Audience ... 19

1.5 ... How to Use This Book ... 20

2 ... General Basic Rules ... 23

2.1 ... Separation of Concerns ... 23

2.2 ... KISS Principle ... 32

2.3 ... Correctness and Quality ... 34

3 ... ABAP-Specific Basic Rules ... 41

3.1 ... ABAP Objects as a Programming Model ... 41

3.2 ... Program Type and Program Attributes ... 50

3.2.1 ... Program Type ... 51

3.2.2 ... Program Attributes ... 55

3.2.3 ... Original Language ... 60

3.3 ... Modern ABAP ... 62

3.4 ... Checks for Correctness ... 65

3.4.1 ... Syntax Check ... 65

3.4.2 ... Extended Program Check ... 69

3.4.3 ... Code Inspector ... 72

3.4.4 ... ABAP Test Cockpit ... 76

4 ... Structure and Style ... 79

4.1 ... Source Code Formatting ... 80

4.1.1 ... Case Sensitivity ... 80

4.1.2 ... Statements per Program Line ... 84

4.1.3 ... Using the Pretty Printer ... 86

4.1.4 ... Line Width ... 89

4.2 ... Naming ... 91

4.2.1 ... Selecting the Language ... 92

4.2.2 ... Descriptive Names ... 94

4.2.3 ... Names of Repository Objects ... 101

4.2.4 ... Program-Internal Names ... 106

4.3 ... Comments ... 115

4.3.1 ... Selecting the Language ... 115

4.3.2 ... Content ... 117

4.3.3 ... Arrangement in the Source Code ... 120

4.4 ... Program and Procedure Structure ... 123

4.4.1 ... Global Declarations of a Program ... 124

4.4.2 ... Local Declarations ... 127

4.5 ... Source Code Organization ... 130

4.5.1 ... Source Code Modularization ... 130

4.5.2 ... Multiple Use of Include Programs ... 132

4.6 ... Alternative Notations ... 135

4.6.1 ... Alternative Language Constructs in Statements ... 135

4.6.2 ... Chained Statements ... 137

4.6.3 ... Method Calls ... 141

4.6.4 ... Assignments and Calculations ... 143

4.6.5 ... Calculation Expressions ... 145

4.7 ... Complexity ... 146

4.7.1 ... Expressions ... 147

4.7.2 ... Nesting Depth ... 149

4.7.3 ... Procedure Volume ... 150

4.7.4 ... Class Size ... 151

4.7.5 ... Dead Code ... 153

5 ... Architecture ... 155

5.1 ... Object-Oriented Programming ... 155

5.1.1 ... Encapsulation ... 156

5.1.2 ... Modularization ... 157

5.1.3 ... Static Classes and Singletons ... 161

5.1.4 ... Inheritance ... 166

5.1.5 ... Class References and Interface References ... 167

5.1.6 ... Local Types for Global Classes ... 169

5.1.7 ... Instance Constructor ... 171

5.2 ... Error Handling ... 172

5.2.1 ... Reaction to Error Situations ... 172

5.2.2 ... Classical and Class-Based Exceptions ... 174

5.2.3 ... Exception Categories ... 178

5.2.4 ... Exception Texts ... 180

5.2.5 ... Using Exception Classes ... 183

5.2.6 ... Handling and Propagating Exceptions ... 185

5.2.7 ... Cleanup After Exceptions ... 186

5.2.8 ... Catchable Runtime Errors ... 188

5.2.9 ... Assertions ... 190

5.2.10 ... Messages ... 191

5.3 ... User Interfaces ... 195

5.3.1 ... Selecting the User Interface Technology ... 195

5.3.2 ... Encapsulating Classical User Interfaces ... 199

5.3.3 ... Lists ... 204

5.3.4 ... Accessibility ... 207

5.4 ... Data Storage ... 208

5.4.1 ... Persistent Data Storage ... 208

5.4.2 ... Database Accesses ... 210

5.4.3 ... Client Handling ... 211

5.4.4 ... Using the Shared Memory ... 213

6 ... Secure and Robust ABAP ... 217

6.1 ... Data Types and Data Objects ... 217

6.1.1 ... Bound and Standalone Data Types ... 218

6.1.2 ... Declaration of Data Types and Constants ... 220

6.1.3 ... Declaration of Variables ... 224

6.1.4 ... Including Structures ... 226

6.1.5 ... Using Types ... 228

6.1.6 ... Referring to Data Types or Data Objects ... 230

6.1.7 ... Table Work Areas ... 232

6.1.8 ... Literals ... 233

6.1.9 ... Strings ... 236

6.1.10 ... Start Values ... 238

6.1.11 ... Data Objects for Truth Values ... 239

6.2 ... Assignments, Calculations, and Other Accesses to Data ... 241

6.2.1 ... Assignments Between Different Types ... 241

6.2.2 ... Avoiding Invalid Values ... 243

6.2.3 ... Using Conversion Rules ... 245

6.2.4 ... Specification of Numbers ... 247

6.2.5 ... Selecting the Numeric Type ... 249

6.2.6 ... Rounding Errors ... 253

6.2.7 ... Division by Zero ... 255

6.2.8 ... Casting ... 255

6.2.9 ... Runtime Errors When Accessing Data Objects ... 257

6.2.10 ... Anonymous Containers ... 259

6.2.11 ... Passing Global Data by Reference ... 260

6.3 ... System Fields ... 262

6.3.1 ... Access ... 262

6.3.2 ... Obsolete and Internal System Fields ... 264

6.3.3 ... Evaluation ... 265

6.3.4 ... Return Value ... 267

6.3.5 ... Using System Fields as Actual Parameters ... 268

6.3.6 ... Using System Fields on the User Interface ... 270

6.3.7 ... Using System Fields in Operand Positions ... 272

6.4 ... Internal Tables ... 273

6.4.1 ... Selecting the Table Category ... 274

6.4.2 ... Secondary Keys ... 276

6.4.3 ... Initial Memory Allocation ... 280

6.4.4 ... Sorted Filling ... 281

6.4.5 ... Aggregated Filling ... 283

6.4.6 ... Output Behavior ... 284

6.4.7 ... Loop Processing ... 286

6.5 ... Modularization Units ... 287

6.5.1 ... Function Modules and Subroutines ... 288

6.5.2 ... Type of the Formal Parameters of Procedures ... 289

6.5.3 ... Transfer Type of Formal Parameters ... 292

6.5.4 ... Passing Output Parameters by Reference ... 294

6.5.5 ... Typing of Formal Parameters ... 296

6.5.6 ... Internal and External Procedure Calls ... 298

6.5.7 ... Exiting Procedures ... 302

6.5.8 ... Dialog Modules and Event Blocks ... 304

6.5.9 ... Macros ... 306

6.6 ... Dynamic Programming Techniques ... 309

6.6.1 ... Using Dynamic Programming Techniques ... 309

6.6.2 ... Runtime Errors During Dynamic Processing ... 311

6.6.3 ... Using Dynamic Data Objects ... 313

6.6.4 ... Memory Consumption of Dynamic Memory Objects ... 315

6.6.5 ... Administration Costs of Dynamic Memory Objects ... 318

6.6.6 ... Accessing Data Objects Dynamically ... 321

6.6.7 ... Generic Programming ... 324

6.7 ... Internationalization ... 329

6.7.1 ... Storing System Texts ... 329

6.7.2 ... Translation-Friendly Message Texts ... 331

6.7.3 ... Text Environment ... 333

6.7.4 ... Character Set of Source Code ... 335

6.7.5 ... Splitting Texts ... 336

6.7.6 ... Codepages for Files ... 337

A ... Obsolete Language Constructs ... 341

A.1 ... Procedures ... 342

... Subroutines ... 342

A.1.2 ... Table Parameters ... 342

A.1.3 ... Typing of Formal Parameters ... 343

A.2 ... Declarations ... 343

A.2.1 ... Declaring Type Groups ... 343

A.2.2 ... Interface Work Areas ... 343

A.2.3 ... Table Work Areas ... 344

A.2.4 ... Referring to Data Types ... 344

A.2.5 ... Declaring Field Symbols ... 344

A.2.6 ... Typing Field Symbols ... 345

A.2.7 ... Header Lines of Internal Tables ... 345

A.2.8 ... Declaring Internal Tables ... 345

A.2.9 ... Ranges Tables ... 346

A.2.10 ... Addressing Data Objects ... 346

A.2.11 ... Loading Classes and Interfaces ... 346

A.3 ... Object Generation ... 347

A.3.1 ... Anonymous Data Objects ... 347

A.4 ... Calls and Exits ... 347

A.4.1 ... Dialog Modules ... 347

A.4.2 ... Function Module Exit ... 347

A.4.3 ... External Subroutine Call ... 348

A.4.4 ... Exiting Programs ... 348

A.4.5 ... Exception Handling ... 348

A.5 ... Program Flow Control ... 349

A.5.1 ... Relational Operators ... 349

A.5.2 ... Case Distinction ... 349

A.5.3 ... Checking the Binding to Actual Parameters ... 349

A.5.4 ... Checking Changes of Data Objects ... 350

A.5.5 ... Loops for Memory Content ... 350

A.6 ... Assignments ... 350

A.6.1 ... Subfield Access ... 350

A.6.2 ... Converting Packed Numbers ... 351

A.6.3 ... Initialization ... 351

A.6.4 ... Temporary Storage of Data Objects ... 351

A.6.5 ... Casting ... 352

A.6.6 ... Dynamic Assignment to a Field Symbol ... 352

A.7 ... Calculation Statements ... 352

A.7.1 ... Component-Based Calculations ... 352

A.7.2 ... Calculations with Memory Content ... 353

A.8 ... Processing Character and Byte Strings ... 353

A.8.1 ... Searching in Character and Byte Strings ... 353

A.8.2 ... Replacements in Character and Byte Strings ... 353

A.8.3 ... Creating the Nine's Complement ... 354

A.8.4 ... Translating Characters and Numbers ... 354

A.8.5 ... Text Editor ... 354

A.9 ... Internal Tables ... 355

A.9.1 ... Processing Statements ... 355

A.9.2 ... Key Specifications ... 355

A.9.3 ... Deleting a Table ... 356

A.9.4 ... Formatted Assignment ... 356

... HR Infotypes ... 356

A.10 ... Dynpro Flow Logic ... 357

A.10.1 ... Comparing Values ... 357

A.10.2 ... Accessing Databases ... 357

A.10.3 ... Extending Subscreens ... 357

A.10.4 ... Step Loops ... 358

A.11 ... Classical List Processing ... 358

A.11.1 ... Formatting ... 358

A.11.2 ... List Event ... 358

A.11.3 ... Print Parameters ... 359

A.11.4 ... Spool Request ... 359

A.11.5 ... Extreme Values and Calculations ... 359

A.12 ... Data Storage ... 360

A.12.1 ... Open SQL ... 360

A.12.2 ... Native SQL ... 360

A.12.3 ... Data Cluster ... 360

A.12.4 ... Data Clusters in the ABAP Memory ... 361

A.12.5 ... Data Clusters in the Database ... 361

A.12.6 ... Work Area for Data Clusters ... 361

A.12.7 ... Obsolete Database Accesses ... 362

      A.13 ... Contexts ... 362

      A.14 ... External Interfaces ... 363

A.14.1 ... XML Connection ... 363

A.14.2 ... CPI-C Interface ... 363

A.14.3 ... JavaScript Connection ... 363

B ... Automatic Check of Naming Conventions ... 365

B.1 ... Naming Conventions in the Code Inspector ... 365

B.2 ... Type-Specific Prefix Components ... 366

B.3 ... Prefixes for Procedure-Local Declarations ... 367

B.4 ... Structured Programming ... 369

B.5 ... Object-Oriented Programming ... 370

B.6 ... Assessment of the Naming Conventions ... 371

C ... Table of Rules ... 373

D ... Recommended Reading ... 377

E ... The Authors ... 379

... Index ... 381

  • 6 ... Secure and Robust ABAP ... 217
  • 6.1 ... Data Types and Data Objects ... 217
  • 6.1.1 ... Bound and Standalone Data Types ... 218
  • 6.1.2 ... Declaration of Data Types and Constants ... 220
  • 6.1.3 ... Declaration of Variables ... 224
  • 6.1.4 ... Including Structures ... 226
  • 6.1.5 ... Using Types ... 228
  • 6.1.6 ... Referring to Data Types or Data Objects ... 230
  • 6.1.7 ... Table Work Areas ... 232
  • 6.1.8 ... Literals ... 233
  • 6.1.9 ... Strings ... 236
  • 6.1.10 ... Start Values ... 238
  • 6.1.11 ... Data Objects for Truth Values ... 239
  • 6.2 ... Assignments, Calculations, and Other Accesses to Data ... 241
  • 6.2.1 ... Assignments Between Different Types ... 241
  • 6.2.2 ... Avoiding Invalid Values ... 243
  • 6.2.3 ... Using Conversion Rules ... 245
  • 6.2.4 ... Specification of Numbers ... 247
  • 6.2.5 ... Selecting the Numeric Type ... 249
  • 6.2.6 ... Rounding Errors ... 253
  • 6.2.7 ... Division by Zero ... 255
  • 6.2.8 ... Casting ... 255
  • 6.2.9 ... Runtime Errors When Accessing Data Objects ... 257
  • 6.2.10 ... Anonymous Containers ... 259
  • 6.2.11 ... Passing Global Data by Reference ... 260
  • 6.3 ... System Fields ... 262
  • 6.3.1 ... Access ... 262
  • 6.3.2 ... Obsolete and Internal System Fields ... 264
  • 6.3.3 ... Evaluation ... 265
  • 6.3.4 ... Return Value ... 267
  • 6.3.5 ... Using System Fields as Actual Parameters ... 268
  • 6.3.6 ... Using System Fields on the User Interface ... 270
  • 6.3.7 ... Using System Fields in Operand Positions ... 272
  • 6.4 ... Internal Tables ... 273
  • 6.4.1 ... Selecting the Table Category ... 274
  • 6.4.2 ... Secondary Keys ... 276
  • 6.4.3 ... Initial Memory Allocation ... 280
  • 6.4.4 ... Sorted Filling ... 281
  • 6.4.5 ... Aggregated Filling ... 283
  • 6.4.6 ... Output Behavior ... 284
  • 6.4.7 ... Loop Processing ... 286
  • 6.5 ... Modularization Units ... 287
  • 6.5.1 ... Function Modules and Subroutines ... 288
  • 6.5.2 ... Type of the Formal Parameters of Procedures ... 289
  • 6.5.3 ... Transfer Type of Formal Parameters ... 292
  • 6.5.4 ... Passing Output Parameters by Reference ... 294
  • 6.5.5 ... Typing of Formal Parameters ... 296
  • 6.5.6 ... Internal and External Procedure Calls ... 298
  • 6.5.7 ... Exiting Procedures ... 302
  • 6.5.8 ... Dialog Modules and Event Blocks ... 304
  • 6.5.9 ... Macros ... 306
  • 6.6 ... Dynamic Programming Techniques ... 309
  • 6.6.1 ... Using Dynamic Programming Techniques ... 309
  • 6.6.2 ... Runtime Errors During Dynamic Processing ... 311
  • 6.6.3 ... Using Dynamic Data Objects ... 313
  • 6.6.4 ... Memory Consumption of Dynamic Memory Objects ... 315
  • 6.6.5 ... Administration Costs of Dynamic Memory Objects ... 318
  • 6.6.6 ... Accessing Data Objects Dynamically ... 321
  • 6.6.7 ... Generic Programming ... 324
  • 6.7 ... Internationalization ... 329
  • 6.7.1 ... Storing System Texts ... 329
  • 6.7.2 ... Translation-Friendly Message Texts ... 331
  • 6.7.3 ... Text Environment ... 333
  • 6.7.4 ... Character Set of Source Code ... 335
  • 6.7.5 ... Splitting Texts ... 336
  • 6.7.6 ... Codepages for Files ... 337
  • A ... Obsolete Language Constructs ... 341
  • A.1 ... Procedures ... 342
  • ... Subroutines ... 342
  • ... ... 342
  • A.1.2 ... Table Parameters ... 342
  • A.1.3 ... Typing of Formal Parameters ... 343
  • A.2 ... Declarations ... 343
  • A.2.1 ... Declaring Type Groups ... 343
  • A.2.2 ... Interface Work Areas ... 343
  • A.2.3 ... Table Work Areas ... 344
  • A.2.4 ... Referring to Data Types ... 344
  • A.2.5 ... Declaring Field Symbols ... 344
  • A.2.6 ... Typing Field Symbols ... 345
  • A.2.7 ... Header Lines of Internal Tables ... 345
  • A.2.8 ... Declaring Internal Tables ... 345
  • A.2.9 ... Ranges Tables ... 346
  • A.2.10 ... Addressing Data Objects ... 346
  • A.2.11 ... Loading Classes and Interfaces ... 346
  • A.3 ... Object Generation ... 347
  • A.3.1 ... Anonymous Data Objects ... 347
  • A.4 ... Calls and Exits ... 347
  • A.4.1 ... Dialog Modules ... 347
  • A.4.2 ... Function Module Exit ... 347
  • A.4.3 ... External Subroutine Call ... 348
  • A.4.4 ... Exiting Programs ... 348
  • A.4.5 ... Exception Handling ... 348
  • A.5 ... Program Flow Control ... 349
  • A.5.1 ... Relational Operators ... 349
  • A.5.2 ... Case Distinction ... 349
  • A.5.3 ... Checking the Binding to Actual Parameters ... 349
  • A.5.4 ... Checking Changes of Data Objects ... 350
  • A.5.5 ... Loops for Memory Content ... 350
  • A.6 ... Assignments ... 350
  • A.6.1 ... Subfield Access ... 350
  • A.6.2 ... Converting Packed Numbers ... 351
  • A.6.3 ... Initialization ... 351
  • A.6.4 ... Temporary Storage of Data Objects ... 351
  • A.6.5 ... Casting ... 352
  • A.6.6 ... Dynamic Assignment to a Field Symbol ... 352
  • A.7 ... Calculation Statements ... 352
  • A.7.1 ... Component-Based Calculations ... 352
  • A.7.2 ... Calculations with Memory Content ... 353
  • A.8 ... Processing Character and Byte Strings ... 353
  • A.8.1 ... Searching in Character and Byte Strings ... 353
  • A.8.2 ... Replacements in Character and Byte Strings ... 353
  • A.8.3 ... Creating the Nine's Complement ... 354
  • A.8.4 ... Translating Characters and Numbers ... 354
  • A.8.5 ... Text Editor ... 354
  • A.9 ... Internal Tables ... 355
  • A.9.1 ... Processing Statements ... 355
  • A.9.2 ... Key Specifications ... 355
  • A.9.3 ... Deleting a Table ... 356
  • A.9.4 ... Formatted Assignment ... 356
  • ... HR Infotypes ... 356
  • ... ... 356
  • A.10 ... Dynpro Flow Logic ... 357
  • A.10.1 ... Comparing Values ... 357
  • A.10.2 ... Accessing Databases ... 357
  • A.10.3 ... Extending Subscreens ... 357
  • A.10.4 ... Step Loops ... 358
  • A.11 ... Classical List Processing ... 358
  • A.11.1 ... Formatting ... 358
  • A.11.2 ... List Event ... 358
  • A.11.3 ... Print Parameters ... 359
  • A.11.4 ... Spool Request ... 359
  • A.11.5 ... Extreme Values and Calculations ... 359
  • A.12 ... Data Storage ... 360
  • A.12.1 ... Open SQL ... 360
  • A.12.2 ... Native SQL ... 360
  • A.12.3 ... Data Cluster ... 360
  • A.12.4 ... Data Clusters in the ABAP Memory ... 361
  • A.12.5 ... Data Clusters in the Database ... 361
  • A.12.6 ... Work Area for Data Clusters ... 361
  • A.12.7 ... Obsolete Database Accesses ... 362
  • A.13 ... Contexts ... 362
  • A.14 ... External Interfaces ... 363
  • A.14.1 ... XML Connection ... 363
  • A.14.2 ... CPI-C Interface ... 363
  • A.14.3 ... JavaScript Connection ... 363
  • B ... Automatic Check of Naming Conventions ... 365
  • B.1 ... Naming Conventions in the Code Inspector ... 365
  • B.2 ... Type-Specific Prefix Components ... 366
  • B.3 ... Prefixes for Procedure-Local Declarations ... 367
  • B.4 ... Structured Programming ... 369
  • B.5 ... Object-Oriented Programming ... 370
  • B.6 ... Assessment of the Naming Conventions ... 371
  • C ... Table of Rules ... 373
  • D ... Recommended Reading ... 377
  • E ... The Authors ... 379
  • ... Index ... 381



Product Reviews


Showing reviews 1-4 of 12 | Next

  1. Excellent to create clean and quality ABAP programs

    Posted by Angel Gil on Oct 4th, 2013

    This book is excellent for ABAPers who want to create clean and quality programs using the SAP coding practices.

    It lets you follow better ways to use SAP guidelines to develop ABAP applications, using several bad and good examples.


  2. Good Coverage of Coding Practices

    Posted by SN on Oct 2nd, 2013

    One of the best books covering quality and coding practices in ABAP. AS writing a good code is the habit and discipline, its always good to have this habit in the early stages as such a good bible for experienced and novices to follow good hygenie when you start coding.
    Great Work keep it up:-)
    Would have loved if the book also covered the Custom Code Mgmt Cockpit in details


  3. Good Coverage of Coding Practices

    Posted by SN on Oct 2nd, 2013

    A Must book for all ABAP Developers, experienced or novice ,as programming practices are habits its always good to follow good habits form start. This book can serve as bible to start every code as good quality code.
    Keep it up:-)
    Would have loved it Custom Code Mgmt Cockpit was also covered.


  4. Good Guide

    Posted by Anonymous on Sep 1st, 2013

    Now I can have some guidelines in coding. Before I second guess how to code in a good way, from variable naming and changing existing programs, this book is needed for a improved coding style :)


Showing reviews 1-4 of 12 | Next

Write your own product review
If you have purchased this book you can share your experience with others!
review guidelines

Find Similar Products by Category


Recently Viewed