ebook img

BC - ABAP Programming PDF

1486 Pages·2001·6.65 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview BC - ABAP Programming

BC - ABAP Programming A B A C B . P L E H Release 4.6C BC - ABAP Programming SAP AG Copyright © Copyright 2001 SAP AG. 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. 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®, NT®, EXCEL®, Word®, PowerPoint® and SQL Server® are registered trademarks of Microsoft Corporation. IBM®, DB2®, OS/2®, DB2/6000®, Parallel Sysplex®, MVS/ESA®, RS/6000®, AIX®, S/390®, AS/400®, OS/390®, and OS/400® are registered trademarks of IBM Corporation. ORACLE® is a registered trademark of ORACLE Corporation. INFORMIX®-OnLine for SAP and Informix® Dynamic ServerTM are registered trademarks of Informix Software Incorporated. UNIX®, X/Open®, OSF/1®, and Motif® are registered trademarks of the Open Group. HTML, DHTML, XML, XHTML 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. SAP, SAP Logo, R/2, RIVA, R/3, ABAP, SAP ArchiveLink, SAP Business Workflow, WebFlow, SAP EarlyWatch, BAPI, SAPPHIRE, Management Cockpit, mySAP.com Logo and mySAP.com are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other products mentioned are trademarks or registered trademarks of their respective companies. 2 April 2001 SAP AG BC - ABAP Programming Icons Icon Meaning Caution Example Note Recommendation Syntax April 2001 3 BC - ABAP Programming SAP AG Contents BC - ABAP Programming.................................................................................17 Introduction to ABAP..................................................................................................................19 The R/3 Basis System: Overview...............................................................................................20 Position of the Basis System Within the R/3 System...............................................................21 Application Servers..................................................................................................................27 Work Processes.......................................................................................................................32 Overview of the Components of Application Programs.........................................................37 Structure of an Application Program........................................................................................38 Screens....................................................................................................................................40 Structure of ABAP Programs...................................................................................................44 Processing Blocks in ABAP Programs.....................................................................................49 ABAP Statements....................................................................................................................56 Logical Databases and Contexts.............................................................................................60 Memory Structures of an ABAP Program................................................................................66 Creating and Changing ABAP Programs..................................................................................68 Opening a Program from the Repository Browser...................................................................70 Opening Programs in the ABAP Editor....................................................................................73 Opening Programs Using Forward Navigation........................................................................74 Maintaining Program Attributes................................................................................................75 Editing Programs......................................................................................................................79 The ABAP Programming Language..........................................................................................82 ABAP Syntax................................................................................................................................83 Types and Objects......................................................................................................................87 Basic Statements........................................................................................................................90 Data Types and Data Objects..................................................................................................91 Data Types..........................................................................................................................92 Defining Data Types......................................................................................................96 Predefined ABAP Types...........................................................................................97 Local Data Types in Programs...............................................................................100 Data Types in the ABAP Dictionary........................................................................105 The TYPE Addition......................................................................................................112 The LIKE Addition........................................................................................................116 Data Objects.....................................................................................................................118 Literals.........................................................................................................................119 Text Symbols...............................................................................................................121 Variables......................................................................................................................123 Constants.....................................................................................................................129 Interface Work Areas...................................................................................................130 Predefined Data Objects..............................................................................................132 Compatibility......................................................................................................................133 Determining the Attributes of Data Objects......................................................................135 Examples of Data Types and Objects..............................................................................140 Processing Data.....................................................................................................................143 Assigning Values..............................................................................................................144 4 April 2001 SAP AG BC - ABAP Programming Assigning Values with MOVE......................................................................................145 Assigning Values with WRITE TO...............................................................................148 Resetting Values to Their Initial Value.........................................................................150 Numerical Operations.......................................................................................................151 Arithmetic Calculations................................................................................................152 Mathematical Functions...............................................................................................156 Business Calculations..................................................................................................158 Date and Time Calculations.........................................................................................159 Processing Character Strings...........................................................................................161 Shifting Field Contents.................................................................................................162 Replacing Field Contents.............................................................................................165 Converting to Upper or Lower Case or Replacing Characters....................................167 Converting into a Sortable Format...............................................................................168 Overlaying Character Fields........................................................................................169 Finding Character Strings............................................................................................170 Finding the Length of a Character String.....................................................................173 Condensing Field Contents.........................................................................................174 Concatenating Character Strings................................................................................175 Splitting Character Strings...........................................................................................176 Assigning Parts of Character Strings...........................................................................177 Single Bit Processing in Hexadecimal Fields....................................................................178 Setting and Reading Bits.............................................................................................179 Bit Operations..............................................................................................................181 Set Operations Using Bit Sequences..........................................................................183 Type Conversions.............................................................................................................186 Conversion Rules for Elementary Data Types............................................................187 Conversion Rules for References................................................................................191 Conversion Rules for Structures..................................................................................192 Conversion Rules for Internal Tables..........................................................................194 Alignment of Data Objects...........................................................................................195 Processing Sections of Strings.........................................................................................196 Field Symbols and Data References.....................................................................................200 Field Symbols...................................................................................................................201 Defining Field Symbols................................................................................................203 Assigning Data Objects to Field Symbols....................................................................207 Basic Form of the ASSIGN Statement...................................................................208 Assigning Components of Structures to a Field Symbol........................................213 Defining the Data Type of a Field Symbol..............................................................215 Data Areas for Field Symbols.................................................................................217 Data References...............................................................................................................219 Reference Variables....................................................................................................220 Creating Data Objects Dynamically.............................................................................221 Getting References to Data Objects............................................................................222 Dereferencing Data References..................................................................................223 Data References: Example..........................................................................................224 April 2001 5 BC - ABAP Programming SAP AG Logical Expressions...............................................................................................................225 Comparisons Between Different Data Types....................................................................226 Comparing Strings............................................................................................................230 Comparing Bit Sequences................................................................................................233 Checking Whether a Field Belongs to a Range................................................................235 Checking for the Initial Value............................................................................................236 Checking Selection Criteria...............................................................................................237 Checking Whether a Field Symbol is Assigned................................................................238 Combining Several Logical Expressions..........................................................................239 Controlling the Program Flow.................................................................................................240 Branching Conditionally....................................................................................................242 Loops................................................................................................................................245 Processing Large Volumes of Data.........................................................................................250 Internal tables.........................................................................................................................251 Creating Internal Tables....................................................................................................254 Internal table types......................................................................................................255 Internal table objects....................................................................................................259 Special Features of Standard Tables..........................................................................261 Processing Internal Tables...............................................................................................263 Operations on Entire Internal Tables...........................................................................264 Assigning Internal Tables.......................................................................................265 Initializing Internal Tables.......................................................................................267 Comparing Internal Tables.....................................................................................269 Sorting Internal Tables...........................................................................................271 Internal Tables as Interface Parameters................................................................276 Determining the Attributes of Internal Tables.........................................................277 Operations on Individual Lines....................................................................................278 Operations for all Table Types...............................................................................281 Inserting Lines into Tables................................................................................282 Appending Summarized Lines..........................................................................285 Reading Lines of Tables....................................................................................287 Changing Lines.................................................................................................292 Deleting Lines....................................................................................................295 Processing Table Entries in Loops....................................................................299 Operations for Index Tables...................................................................................306 Appending Table Lines......................................................................................307 Inserting Lines Using the Index.........................................................................311 Reading Lines Using the Index.........................................................................314 Binary Search in Standard Tables....................................................................315 Finding Character Strings in Internal Tables.....................................................316 Changing Table Lines Using the Index.............................................................318 Deleting Lines Using the Index.........................................................................321 Specifying the Index in Loops...........................................................................324 Access Using Field Symbols.......................................................................................326 Using Header Lines as Work Areas............................................................................328 6 April 2001 SAP AG BC - ABAP Programming Extracts..................................................................................................................................331 Defining an Extract............................................................................................................332 Filling an Extract with Data...............................................................................................334 Processing Extracts..........................................................................................................336 Reading an Extract......................................................................................................337 Sorting an Extract........................................................................................................340 Processing Control Levels...........................................................................................343 Calculating Numbers and Totals.................................................................................347 Formatting Data......................................................................................................................350 Example of Formatted Data..............................................................................................351 Formatting Data During Reading......................................................................................353 Refining Data Using Internal Tables.................................................................................355 Formatting Data Using Extracts........................................................................................359 Saving Data Externally..............................................................................................................361 Saving Data Objects as Clusters...........................................................................................362 Data Clusters in ABAP Memory........................................................................................363 Saving Data Objects in Memory..................................................................................364 Reading Data Objects from Memory...........................................................................365 Deleting Data Clusters from Memory..........................................................................367 Data Clusters in the Database..........................................................................................368 Cluster Databases.......................................................................................................369 Structure of a Cluster Database.............................................................................370 Example of a Cluster Database..............................................................................372 Saving Data Objects in Cluster Databases.................................................................374 Creating a Directory of a Data Cluster.........................................................................376 Reading Data Objects From Cluster Databases.........................................................378 Deleting Data Clusters from Cluster Databases..........................................................380 Open SQL Statements and Cluster Databases...........................................................382 Working with Files..................................................................................................................384 Working with Files on the Application Server...................................................................385 File Handling in ABAP.................................................................................................386 Opening a File........................................................................................................387 Basic Form of the OPEN DATASET Statement................................................388 Opening a File for Read Access.......................................................................389 Opening a File for Write Access........................................................................390 Opening a File for Appending Data...................................................................393 Using Binary Mode............................................................................................395 Using Text Mode...............................................................................................397 Opening a File at a Given Position....................................................................399 Executing Operating System Commands.........................................................401 Receiving Operating System Messages...........................................................402 Closing a File..........................................................................................................403 Deleting a File.........................................................................................................404 Writing Data to Files....................................................................................................405 Reading Data from Files..............................................................................................407 April 2001 7 BC - ABAP Programming SAP AG Automatic Checks in File Operations..........................................................................409 Authorization Checks for Programs and Files........................................................410 General Checks for File Access.............................................................................413 Working with Files on the Presentation Server.................................................................416 Writing Data to Presentation Server (Dialog)..............................................................417 Writing Data to Presentation Server (no Dialog).........................................................420 Reading Data from Presentation Server (Dialog)........................................................423 Reading Data from Presentation Server (no Dialog)...................................................426 Checking Files on the Presentation Server.................................................................428 Using Platform-Independent Filenames...........................................................................431 Maintaining Syntax Groups..........................................................................................432 Assigning Operating Systems to Syntax Groups........................................................433 Creating and Defining Logical Paths...........................................................................435 Creating and Defining Logical Filenames....................................................................437 Using Logical Files in ABAP Programs.......................................................................438 Modularization Techniques......................................................................................................441 Source Code Modules............................................................................................................443 Macros..............................................................................................................................444 Include Programs..............................................................................................................447 Procedures.............................................................................................................................449 Subroutines.......................................................................................................................451 Defining Subroutines...................................................................................................452 Global Data from the Main Program.......................................................................453 Local Data in the Subroutine..................................................................................455 The Parameter Interface.........................................................................................459 Terminating Subroutines........................................................................................464 Calling Subroutines......................................................................................................466 Naming Subroutines...............................................................................................467 Passing Parameters to Subroutines.......................................................................470 Examples of Subroutines........................................................................................472 Shared Data Areas.................................................................................................477 Function Modules..............................................................................................................480 Function Groups..........................................................................................................481 Calling Function Modules............................................................................................483 Creating Function Modules..........................................................................................488 Organization of External Procedure Calls.........................................................................494 Special Techniques...................................................................................................................496 Catchable Runtime Errors......................................................................................................497 Program Checks...............................................................................................................498 Catching Runtime Errors...................................................................................................500 Checking Authorizations........................................................................................................502 Checking User Authorizations...........................................................................................504 Defining an Authorization Check......................................................................................505 Checking the Runtime of Program Segments........................................................................508 GET RUN TIME FIELD.....................................................................................................509 Runtime Measurement of Database Accesses.................................................................511 8 April 2001 SAP AG BC - ABAP Programming Generating and Running Programs Dynamically...................................................................513 Creating a New Program Dynamically..............................................................................514 Changing Existing Programs Dynamically........................................................................516 Running Programs Created Dynamically..........................................................................517 Creating and Starting Temporary Subroutines.................................................................520 ABAP User Dialogs...................................................................................................................523 Screens.......................................................................................................................................524 Screen Elements....................................................................................................................526 Screen Attributes..............................................................................................................527 Screen Elements...............................................................................................................528 Screen Fields....................................................................................................................530 Screen Flow Logic............................................................................................................532 Processing Screens...............................................................................................................534 User Actions on Screens..................................................................................................535 Processing Input/Output Fields...................................................................................537 Pushbuttons on the Screen.........................................................................................542 Checkboxes and Radio Buttons with Function Codes................................................545 Using GUI Statuses.....................................................................................................548 Reading Function Codes.............................................................................................555 Finding Out the Cursor Position..................................................................................557 Calling ABAP Dialog Modules...........................................................................................560 Simple Module Calls....................................................................................................562 Controlling the Data Transfer......................................................................................565 Calling Modules Unconditionally..................................................................................568 Conditional Module Calls.............................................................................................572 Input Checks.....................................................................................................................577 Automatic Input Checks...............................................................................................578 Checking Fields in the Screen Flow Logic...................................................................581 Input Checks in Dialog Modules..................................................................................584 Field Help, Input Help, and Dropdown Boxes...................................................................589 Field Help.....................................................................................................................590 Input Help.....................................................................................................................595 Input Help from the ABAP Dictionary.....................................................................596 Input Help on the Screen........................................................................................601 Input Help in Dialog Modules.................................................................................603 Dropdown Boxes.........................................................................................................607 Modifying Screens Dynamically........................................................................................611 Setting Attributes Dynamically.....................................................................................612 The Field Selection Function.......................................................................................620 Setting the Cursor Position..........................................................................................631 Switching on Hold Data Dynamically...........................................................................633 Complex Screen Elements.....................................................................................................635 Status Icons......................................................................................................................636 Context Menus..................................................................................................................639 Subscreens.......................................................................................................................647 April 2001 9 BC - ABAP Programming SAP AG Tabstrip Controls...............................................................................................................653 Custom Controls...............................................................................................................661 Table Controls...................................................................................................................669 Using the LOOP Statement.........................................................................................670 Looping Through an Internal Table.............................................................................671 Example Transaction: Table Controls.........................................................................672 Looping Directly Through a Screen Table...................................................................676 How the System Transfers Data Values......................................................................678 Using Step Loops........................................................................................................679 Selection Screens.....................................................................................................................681 Selection Screens and Logical Databases............................................................................683 Defining Selection Screens....................................................................................................686 Defining Input Fields for Single Values.............................................................................689 Basic Form of Parameters...........................................................................................690 Dynamic Dictionary Reference....................................................................................691 Default Values for Parameters....................................................................................692 SPA/GPA Parameters as Default Values....................................................................693 Allowing Parameters to Accept Upper and Lower Case.............................................694 Reducing the Visible Length........................................................................................695 Defining Required Fields.............................................................................................696 Search Helps for Parameters......................................................................................697 Checking Input Values.................................................................................................698 Defining Checkboxes...................................................................................................699 Defining Radio Buttons................................................................................................700 Hiding Input Fields.......................................................................................................701 Modifying Input Fields..................................................................................................702 Defining Complex Selections............................................................................................703 Selection Tables..........................................................................................................704 Basic Form of Selection Criteria..................................................................................707 Selection Criteria and Logical Databases....................................................................711 Default Values for Selection Criteria............................................................................713 Restricting Entry to One Row......................................................................................715 Restricting Entry to Single Fields.................................................................................716 Additional Options for Selection Criteria......................................................................717 Formatting Selection Screens...........................................................................................718 Blank Lines, Underlines, and Comments....................................................................719 Several Elements in a Single Line...............................................................................721 Blocks of Elements......................................................................................................723 Calling Selection Screens......................................................................................................724 Calling Standard Selection Screens.................................................................................725 Calling User-Defined Selection Screens...........................................................................726 User Actions on Selection Screens........................................................................................732 Pushbuttons on the Selection Screen...............................................................................733 Checkboxes and Radio Buttons with Function Codes......................................................735 Pushbuttons in the Application Toolbar............................................................................736 10 April 2001

Description:
SAP AG. BC - ABAP Programming. April 2001. 3. Icons. Icon. Meaning. Caution. Example. Note. Recommendation. Syntax
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.