ABAP Cookbook
542
978-1-59229-326-1
Теги
Ключевые слова:
Разработка на ABAP / ABAP Development; Разработка на ABAP / ABAP Development
Функциональная область:
Информационные технологии / IT, Basis, ABAP; Информационные технологии / IT, Basis, ABAP
Ролевое назначение:
Ключевой пользователь / Expert; Ключевой пользователь / Expert
7505
0
Аннотация
With this book, get answers to typical ABAP development problems or tasks: persistence programming, interface programming, security and tracing techniques, etc. The complexity of the "recipes" ranges from the simple starter plates to the complex main courses—and some sweet deserts, of course! Each chapter is a short tutorial in itself, all organized and consolidated into an easy-to-read format. Many code samples, screenshots, and different icons will help you to follow the best practices provided. Enjoy your ABAP meal!
ISBN
978-1-59229-326-1
Обложка
Hardcover
Объём
542 страницы
Оглавление
Оглавление
- ... Introduction ... 17
- 1 ... String Processing Techniques ... 27
- 1.1 ... ABAP Character Types ... 27
- 1.2 ... Designing a Custom String Library ... 29
- 1.2.1 ... Developing the API ... 29
- 1.2.2 ... Encapsulating Basic String Processing Statements ... 33
- 1.3 ... Improving Productivity with Regular Expressions ... 36
- 1.3.1 ... Understanding Regular Expressions ... 36
- 1.3.2 ... Regular Expression Syntax ... 37
- 1.3.3 ... Using Regular Expressions in ABAP ... 46
- 1.3.4 ... Integrating Regular Expression Support into the String Library ... 53
- 1.4 ... Summary ... 56
- 2 ... Working with Numbers, Dates, and Bytes ... 57
- 2.1 ... Numeric Operations ... 57
- 2.1.1 ... ABAP Math Functions ... 58
- 2.1.2 ... Generating Random Numbers ... 60
- 2.2 ... Date and Time Processing ... 64
- 2.2.1 ... Understanding ABAP Date and Time Types ... 64
- 2.2.2 ... Date and Time Calculations ... 65
- 2.2.3 ... Working with Timestamps ... 66
- 2.2.4 ... Calendar Operations ... 70
- 2.3 ... Bits and Bytes ... 73
- 2.3.1 ... Introduction to the Hexadecimal Type in ABAP ... 73
- 2.3.2 ... Reading and Writing Individual Bits ... 75
- 2.3.3 ... Bitwise Logical Operators ... 76
- 2.4 ... Summary ... 79
- 3 ... Dynamic and Reflective Programming ... 81
- 3.1 ... Working with Field Symbols ... 81
- 3.1.1 ... What Is a Field Symbol ... 82
- 3.1.2 ... Field Symbol Declarations ... 83
- 3.1.3 ... Assigning Data Objects to Field Symbols ... 85
- 3.1.4 ... Casting Data Objects During the Assignment Process ... 89
- 3.2 ... Reference Data Objects ... 91
- 3.2.1 ... Declaring Data Reference Variables ... 91
- 3.2.2 ... Assigning References to Data Objects ... 93
- 3.2.3 ... Dynamic Data Object Creation ... 94
- 3.2.4 ... Performing Assignments Using Data Reference Variables ... 96
- 3.2.5 ... De-Referencing Data References ... 96
- 3.3 ... Introspection with ABAP Run Time Type Services ... 99
- 3.3.1 ... ABAP RTTS System Classes ... 99
- 3.3.2 ... Working with Type Objects ... 100
- 3.3.3 ... Defining Custom Data Types Dynamically ... 102
- 3.3.4 ... Case Study: RTTS Usage in the ALV Object Model ... 104
- 3.4 ... Dynamic Program Generation ... 106
- 3.4.1 ... Creating a Subroutine Pool ... 106
- 3.4.2 ... Creating a Report Program ... 107
- 3.4.3 ... Drawbacks to Dynamic Program Generation ... 108
- 3.5 ... Summary ... 108
- 4 ... ABAP and Unicode ... 109
- 4.1 ... Introduction to Character Codes and Unicode ... 109
- 4.1.1 ... Understanding Character-Encoding Systems ... 110
- 4.1.2 ... Limitations of Early Character-encoding Systems ... 111
- 4.1.3 ... What Is Unicode ... 111
- 4.1.4 ... Unicode Support in SAP Systems ... 113
- 4.2 ... Developing Unicode-Enabled Programs in ABAP ... 113
- 4.2.1 ... Overview of Unicode-Related Changes to ABAP ... 114
- 4.2.2 ... Thinking in Unicode ... 117
- 4.2.3 ... Turning on Unicode Checks ... 120
- 4.3 ... Working with Unicode System Classes ... 121
- 4.3.1 ... Converting External Data into ABAP Data Objects ... 121
- 4.3.2 ... Converting ABAP Data Objects into External Data Formats ... 124
- 4.3.3 ... Converting Between External Formats ... 126
- 4.3.4 ... Useful Character Utilities ... 129
- 4.4 ... Summary ... 131
- 5 ... Working with Files ... 135
- 5.1 ... File Processing on the Application Server ... 135
- 5.1.1 ... Understanding the ABAP File Interface ... 136
- 5.1.2 ... Case Study: Processing Files with the ABAP File Interface ... 141
- 5.2 ... Working with Unicode ... 148
- 5.2.1 ... Changes to the OPEN DATASET Statement to Support Unicode ... 149
- 5.2.2 ... Using Class CL_ABAP_FILE_UTILITIES ... 149
- 5.3 ... Logical Files and Directories ... 150
- 5.3.1 ... Defining Logical Directory Paths and Files in Transaction FILE ... 151
- 5.3.2 ... Working with the Logical File API ... 155
- 5.4 ... File Compression with ZIP Archives ... 157
- 5.4.1 ... The ABAP ZIP File API ... 158
- 5.4.2 ... Creating a ZIP File ... 159
- 5.4.3 ... Reading a ZIP File ... 163
- 5.5 ... File Processing on the Presentation Server ... 167
- 5.5.1 ... Interacting with the SAP GUI via CL_GUI_FRONTEND_SERVICES ... 167
- 5.5.2 ... Downloading a File ... 168
- 5.5.3 ... Uploading a File ... 171
- 5.6 ... Transmitting Files Using FTP ... 173
- 5.6.1 ... Introducing the SAPFTP Library ... 173
- 5.6.2 ... Wrapping the SAPFTP Library in an ABAP Objects Class ... 175
- 5.6.3 ... Uploading and Downloading Files Using FTP ... 176
- 5.6.4 ... Implementation Details ... 179
- 5.7 ... Summary ... 182
- 6 ... Database Programming ... 183
- 6.1 ... Object-Relational Mapping and Persistence ... 183
- 6.1.1 ... Positioning of Object-Relational Mapping Tools ... 184
- 6.1.2 ... Persistence Service Overview ... 184
- 6.1.3 ... Mapping Concepts ... 187
- 6.2 ... Developing Persistent Classes ... 189
- 6.2.1 ... Creating Persistent Classes in the Class Builder ... 190
- 6.2.2 ... Defining Mappings Using the Mapping Assistant Tool ... 192
- 6.3 ... Working with Persistent Objects ... 198
- 6.3.1 ... Understanding the Class Agent API ... 199
- 6.3.2 ... Performing Typical CRUD Operations ... 199
- 6.3.3 ... Querying Persistent Objects with the Query Service ... 204
- 6.4 ... Modeling Complex Relationships ... 206
- 6.4.1 ... Defining Custom Attributes ... 207
- 6.4.2 ... Filling in the Gaps ... 209
- 6.5 ... Storing Text with Text Objects ... 214
- 6.5.1 ... Defining Text Objects ... 214
- 6.5.2 ... Using the Text Object API ... 218
- 6.5.3 ... Alternatives to Working with Text Objects ... 222
- 6.6 ... Connecting to External Databases ... 223
- 6.6.1 ... Configuring a Database Connection ... 223
- 6.6.2 ... Accessing the External Database ... 225
- 6.6.3 ... Further Reading ... 230
- 6.7 ... Summary ... 231
- 7 ... Transactional Programming ... 233
- 7.1 ... Introduction to the ACID Transaction Model ... 233
- 7.2 ... Transaction Processing with SAP LUWs ... 235
- 7.2.1 ... Introduction to SAP Logical Units of Work ... 235
- 7.2.2 ... Bundling Database Changes in Update Function Modules ... 239
- 7.2.3 ... Bundling Database Changes in Subroutines ... 242
- 7.2.4 ... Performing Local Updates ... 244
- 7.2.5 ... Dealing with Exceptions in the Update Task ... 245
- 7.3 ... Working with the Transaction Service ... 248
- 7.3.1 ... Transaction Service Overview ... 248
- 7.3.2 ... Understanding Transaction Modes ... 249
- 7.3.3 ... Processing Transactions in Object-Oriented Mode ... 253
- 7.3.4 ... Performing Consistency Checks with Check Agents ... 259
- 7.4 ... Implementing Locking with the Enqueue Service ... 262
- 7.4.1 ... Introduction to the SAP Lock Concept ... 262
- 7.4.2 ... Defining Lock Objects ... 263
- 7.4.3 ... Programming with Locks ... 265
- 7.4.4 ... Integration with the SAP Update System ... 267
- 7.4.5 ... Lock Administration ... 267
- 7.5 ... Tracking Changes with Change Documents ... 268
- 7.5.1 ... What Are Change Documents ... 269
- 7.5.2 ... Creating Change Document Objects ... 269
- 7.5.3 ... Configuring Change-Relevant Fields ... 273
- 7.5.4 ... Programming with Change Documents ... 274
- 7.6 ... Summary ... 279
- 8 ... XML Processing in ABAP ... 283
- 8.1 ... Introduction to XML ... 283
- 8.1.1 ... What Is XML ... 284
- 8.1.2 ... XML Syntax ... 285
- 8.1.3 ... Defining XML Documents Using XML Schema ... 289
- 8.2 ... Parsing XML with the iXML Library ... 291
- 8.2.1 ... Introducing the iXML Library API ... 291
- 8.2.2 ... Working with DOM ... 292
- 8.2.3 ... Case Study: Developing XML Mapping Programs in ABAP ... 297
- 8.2.4 ... Next Steps ... 304
- 8.3 ... Transforming XML Using XSLT ... 304
- 8.3.1 ... What Is XSLT ... 305
- 8.3.2 ... Anatomy of an XSLT Stylesheet ... 305
- 8.3.3 ... Integrating XSLT with ABAP ... 308
- 8.3.4 ... Creating XSLT Stylesheets ... 308
- 8.3.5 ... Processing XSLT Programs in ABAP ... 310
- 8.3.6 ... Case Study: Transforming Business Partners with XSLT ... 311
- 8.3.7 ... Serialization of ABAP Data Objects Using asXML ... 314
- 8.4 ... Simple Transformation ... 317
- 8.4.1 ... What Is Simple Transformation ... 318
- 8.4.2 ... Anatomy of a Simple Transformation Program ... 318
- 8.4.3 ... Learning Simple Transformation Syntax ... 319
- 8.4.4 ... Creating Simple Transformation Programs ... 324
- 8.4.5 ... Case Study: Transforming Business Partners with ST ... 325
- 8.5 ... Summary ... 327
- 9 ... Web Programming with the ICF ... 329
- 9.1 ... HTTP Overview ... 329
- 9.1.1 ... Working with the Uniform Interface ... 330
- 9.1.2 ... Addressability and URLs ... 332
- 9.1.3 ... Understanding the HTTP Message Format ... 333
- 9.2 ... Introduction to the ICF ... 335
- 9.3 ... Developing an HTTP Client Program ... 336
- 9.3.1 ... Defining the Service Call ... 337
- 9.3.2 ... Working with the ICF Client API ... 338
- 9.3.3 ... Putting It All Together ... 340
- 9.4 ... Implementing ICF Handler Modules ... 346
- 9.4.1 ... Working with the ICF Server-Side API ... 347
- 9.4.2 ... Creating an ICF Service Node ... 348
- 9.4.3 ... Developing an ICF Handler Class ... 354
- 9.4.4 ... Testing the ICF Service Node ... 358
- 9.5 ... Summary ... 360
- 10 ... Web Services ... 361
- 10.1 ... Web Service Overview ... 361
- 10.1.1 ... Introduction to SOAP ... 362
- 10.1.2 ... Describing SOAP-Based Services with WSDL ... 365
- 10.1.3 ... Web Service Discovery with UDDI ... 365
- 10.2 ... Providing Web Services ... 366
- 10.2.1 ... Creating Service Definitions ... 367
- 10.2.2 ... Configuring Runtime Settings ... 373
- 10.2.3 ... Testing Service Providers ... 376
- 10.3 ... Consuming Web Services ... 378
- 10.3.1 ... Creating a Service Consumer ... 379
- 10.3.2 ... Defining a Logical Port ... 383
- 10.3.3 ... Using a Service Consumer in an ABAP Program ... 386
- 10.4 ... Next Steps ... 391
- 10.5 ... Summary ... 391
- 11 ... Email Programming ... 393
- 11.1 ... Introduction to BCS ... 393
- 11.2 ... Sending Email Messages ... 394
- 11.2.1 ... Understanding the Simple Mail Transfer Protocol ... 395
- 11.2.2 ... Sending a Plain Text Message ... 396
- 11.2.3 ... Working with Attachments ... 403
- 11.2.4 ... Formatting Email Messages with HTML ... 408
- 11.3 ... Receiving Email Messages ... 411
- 11.3.1 ... Configuring Inbound Processing Rules ... 412
- 11.3.2 ... Processing Inbound Requests ... 413
- 11.3.3 ... Potential Use Cases of Inbound Processing Rules ... 414
- 11.4 ... Summary ... 416
- 12 ... Security Programming ... 419
- 12.1 ... Developing a Security Model ... 419
- 12.1.1 ... Authenticating Users ... 420
- 12.1.2 ... Checking User Authorizations ... 420
- 12.1.3 ... Securing the Lines of Communication ... 421
- 12.1.4 ... Programming for Security ... 422
- 12.2 ... The SAP NetWeaver AS ABAP Authorization Concept ... 422
- 12.2.1 ... Overview ... 423
- 12.2.2 ... Developing Authorization Objects ... 424
- 12.2.3 ... Configuring Authorizations ... 430
- 12.2.4 ... Performing Authorization Checks in ABAP ... 433
- 12.2.5 ... Authorization Concept Review ... 434
- 12.3 ... Encrypting Data with ABAP ... 435
- 12.4 ... Performing Virus Scans ... 437
- 12.5 ... Protecting Web Content with CAPTCHA ... 438
- 12.5.1 ... What Is CAPTCHA ... 439
- 12.5.2 ... Developing a CAPTCHA Component with Adobe Flex ... 439
- 12.5.3 ... Integrating the CAPTCHA Component with BSPs ... 440
- 12.5.4 ... Integrating the CAPTCHA Component with Web Dynpro ... 443
- 12.6 ... Summary ... 444
- 13 ... Logging and Tracing ... 445
- 13.1 ... Introducing the Business Application Log ... 446
- 13.1.1 ... Configuring Log Objects ... 446
- 13.1.2 ... Displaying Logs ... 448
- 13.1.3 ... Organization of the BAL API ... 450
- 13.2 ... Developing a Custom Logging Framework ... 450
- 13.2.1 ... Organization of the Class-Based API ... 451
- 13.2.2 ... Configuring Log Severities ... 452
- 13.3 ... Case Study: Tracing an Application Program ... 453
- 13.3.1 ... Integrating the Logging Framework into an ABAP Program ... 453
- 13.3.2 ... Viewing Log Instances in Transaction SLG1 ... 456
- 13.4 ... Summary ... 458
- 14 ... Interacting with the Operating System ... 459
- 14.1 ... Programming with External Commands ... 459
- 14.1.1 ... Maintaining External Commands ... 460
- 14.1.2 ... Restricting Access to External Commands ... 462
- 14.1.3 ... Testing External Commands ... 463
- 14.1.4 ... Executing External Commands in an ABAP Program ... 465
- 14.2 ... Case Study: Executing a Custom Perl Script ... 467
- 14.2.1 ... Defining the Command to Run the Perl Interpreter ... 468
- 14.2.2 ... Executing Perl Scripts ... 469
- 14.3 ... Summary ... 474
- 15 ... Interprocess Communication ... 475
- 15.1 ... SAP NetWeaver AS ABAP Memory Organization ... 476
- 15.2 ... Data Clusters ... 477
- 15.2.1 ... Working with Data Clusters ... 478
- 15.2.2 ... Storage Media Types ... 478
- 15.2.3 ... Sharing Data Objects Using ABAP Memory ... 479
- 15.2.4 ... Sharing Data Objects Using the Shared Memory Buffer ... 482
- 15.3 ... Working with Shared Memory Objects ... 486
- 15.3.1 ... Architectural Overview ... 486
- 15.3.2 ... Defining Shared Memory Areas ... 489
- 15.3.3 ... Accessing Shared Objects ... 495
- 15.3.4 ... Locking Concepts ... 506
- 15.3.5 ... Area Instance Versioning ... 507
- 15.3.6 ... Monitoring Techniques ... 509
- 15.4 ... Summary ... 510
- 16 ... Parallel and Distributed Processing with RFCs ... 511
- 16.1 ... RFC Overview ... 512
- 16.1.1 ... Understanding the Different Variants of RFC ... 512
- 16.1.2 ... Developing RFC-Enabled Function Modules ... 513
- 16.2 ... Parallel Processing with aRFC ... 515
- 16.2.1 ... Syntax Overview ... 515
- 16.2.2 ... Configuring an RFC Server Group ... 518
- 16.2.3 ... Defining Parallel Algorithms ... 520
- 16.2.4 ... Case Study: Processing Messages in Parallel ... 522
- 16.3 ... Summary ... 529
- ... The Author ... 531
- ... Index ... 533