10. Copying Program Code Copy Program ZDEMO001 Source program Target program ZDEMO001 ZDEMO002 Copy Program ZDEMO001 to ZDEMO002 Source Texts Documentation Variants GUI Status Screens Includes Request(organizer) Copy Copy ABAP Editor
16. INCLUDE Programs REPORT ZABAP. INCLUDE ZCOST. INITIALIZATION. . . . INCLUDE ZSUB * INCLUDE ZCOST * INCLUDE ZSUB
17. Commenting Programs DATA: SUM TYPE P, "Totals field COUNTER TYPE P. * New account * Initialize totals field CLEAR SUM. Partial Line Comment Comment Entire Line
The ABAP Workbench includes all tools necessary to design and develop programs, screens, menus, etc. It also contains performance and debugging facilities. Central to the workbench are the Repository Browser and the Data Dictionary.
The Object Navigator manages and organizes development objects in a hierarchical form, allowing easy navigation among objects and within the development environment. The ABAP Dictionary defines, maintains, and stores the data dictionary of the R/3 system. It stores all dictionary objects, including tables, relationships, documentation and help. The ABAP Editor is used to create and maintain ABAP programs and function modules. The Function Builder is used to define and maintain ABAP function modules (general purpose routines that can be called from other ABAP programs). The Screen Painter is used to define and maintain the graphical user interface screens. The Menu Painter is used for designing and maintaining menus for the graphical user interface.
The Object Navigator screen is divided into two areas: An area for displaying an object list as a hierarchy The object window, in which objects can be displayed and edited You can hide the hierarchy area using the Close browser pushbutton. You can display the object list for the object currently displayed in the object window using the Object list icon. You can select functions from a context menu in both screen areas. You are only given a choice of those functions that are relevant to displaying or editing the object on which the cursor is positioned. Right-click with the mouse to display the context menu. When designing a program, work is performed in the Object Navigator. Generally, the program is selected from the object list generated by the Object Navigator. The object list is hierarchical. The package is the highest level. Components of a program can be created, changed, or displayed from within the program’s object list by putting the cursor on the class or object type to be created or by putting the cursor on the package if the type hasn’t been used before.
The initial ABAP Editor screen can be accessed from the ABAP Development Workbench by choosing ABAP Editor. It can also be accessed via the transaction code SE38. Access to execute an ABAP report (non-developer) can be made via transaction code SE37 or the menu path System-> Services-> Reporting. The ABAP Editor is used to develop ABAP programs. The editor can also be used to test reports. The reporting function is used to start/execute reports. An ABAP program and many of its components (such as text elements or variants) can be created, changed, or displayed from this initial screen. Also, an ABAP program can be executed or debugged from this screen.
The first step in creating a program is the definition of the program attributes.
The SAP transport system requires the assignment of an ABAP program to a package or to identify it as a local object. Packages support the distributed development of large applications in SAP. A set of development objects make up a package, and packages are in turn components of the R/3 system. A set of development objects are, for example, programs, tables, data elements. Packages are also used to group the modules of SAP together, for example, MM or SD.
All customer-developed programs must start with a Z or Y. The Accenture naming convention for a program in this course: ZSER01-XX. (ZSER/exercise number/ID number) Hints: Words in capital letters are SAP expressions (eg: WRITE, TOP-OF-PAGE). Words beginning with capitals are names, menu names and path names (e.g.,: System -> User Profile -> User Defaults).
To copy a complete program, go to the initial screen for the ABAP Editor and click on the Copy pushbutton. Alternatively select Program -> Copy. The source and target program names must be entered: Source (the program to copy from) Target (the program to copy to) After pressing the Copy button, select the components of the source program to copy. Again click on the Copy button and create the object catalogue entry for the new program. Either enter a package and press the Save button, or simply press the Local Object button. Saving as a local object does not require the entry of a package. Remember to save.
To copy a piece of code, highlight it and push Ctrl+C You can also highlight the code and press the Copy button.
SAP provides three buffers (called the X,Y and Z). A buffer is a clipboard-like area that stores a particular section of a program in memory. Once a block has been selected, it can be copied to one of the three SAP clipboards. To insert the contents of a clipboard, select Utilities->Block/Buffer -> Insert X buffer.
The Test function (Program -> Test) can be used to start an ABAP program directly from within the editor. Press F8 to access the Test function.
Every ABAP program must start with either the PROGRAM or REPORT statement. Always use the Pattern pushbutton to insert a header into a report/program. Always include the program name, application, project, date of creation and a brief description of the program. All global declarations must be collected together at the beginning of the program in a declaration section.
The Pattern pushbutton in the ABAP Editor allows the user to insert statement templates into the program code. It provides a skeleton for the program code. From the Pattern pushbutton, the system prompts for an object type in the Insert Statement screen. It is possible to select one of the following: CALL FUNCTION - inserts a function call MESSAGE - inserts a MESSAGE statement for a specified message. Enter a message ID, message type, and a number. SELECT * FROM - inserts a SELECT from <table> statement. Enter the table name in the field provided. PERFORM - inserts a PERORM statement for a specified form routine AUTHORITY - CHECK - inserts an AUTHORITY - CHECK statement for a specified authorization object WRITE - inserts a WRITE statement for a specified structure or table CASE for status - inserts a CASE statement for a specified status Internal table - inserts an internal table. It is possible to copy the fields or the structure of an existing table. CALL DIALOG - inserts a CALL DIALOG statement for a specified dialog module Other pattern - inserts a predefined or user-defined ABAP statement After selecting a statement in code, fill out the template as the program requires.
ATS App. Prog. – ABAP Programming Module Presentations Large programs are usually divided into several Include files. Include programs are used to divide very large programs into smaller more manageable units. An INCLUDE is part of a programs source code, but it is stored separately in the repository-like a program. The source code it contains can be inserted into the program using the INCLUDE statement.
Accenture places a great deal of emphasis on program comments. Commenting can either be done in-line or online. Why? Clients like to understand the programs. If someone wants to maintain the program at a later date, he/she will understand it. To mark an entire line as a comment, enter an asterisk at the start of the line. To mark the remainder of a line as a comment, enter a double quotation mark on the line.