Escolar Documentos
Profissional Documentos
Cultura Documentos
mySAP Implementation
ABAP/4 Development
Standards and Guidelines
mySAP Solution
5th November 2007
Sample Document
Page 1 of 51
Development System Manual & Operating Procedure
TABLE OF CONTENTS
1 OBJECTIVE .......................................................................................................5
2 PURPOSE ..........................................................................................................6
4.2 Subroutines............................................................................................................. 19
Page 3 of 51
Development System Manual & Operating Procedure
5.1 SQL.......................................................................................................................... 29
Page 4 of 51
Development System Manual & Operating Procedure
1 Objective
The intent of this document is to provide a norm, structured approach to manage and
accomplish the development in SAP project implementation. This document provides a
standard technique and guidelines to ensure that development methodology and
developments are completed in time and within the permissible budget. The document
provides the framework from which a comprehensive plan for software development can
be accomplished. It also serves as a roadmap for a project management team and
developer to conceive, plan, act and deliver the best solution to a customer.
The goal of this document is to provide the development team with nomenclature to be
followed, adopted and practiced so as to deliver the quality development solution. This
will help the development team in planning, scheduling, monitoring and executing the
project in a most efficient manner.
Page 5 of 51
Development System Manual & Operating Procedure
2 Purpose
This document provides the definitive list of development standards for use with SAP
R/3 system objects (ABAP code, table definitions, and data dictionary components). Aside
from defining the general programming standards the document also serves to detail
naming and programming style conventions.
Adherence to the standards defined within this document will promote a consistent,
robust and high quality development deliverable.
Objects not meeting these standards will not be migrated from the development instance.
This document should be read in conjunction with the development methodology
document.
Page 6 of 51
Development System Manual & Operating Procedure
3 Naming Conventions
This section describes the naming conventions that will be used for ABAP developments.
Further naming conventions and structuring standards can be found in SAP on-line
documentation.
During upgrade to a new release of a SAP system a new suite of standard ABAP objects is
supplied. This will certainly overwrite any modifications to SAP standard code but since
all client-specific code is prefixed with a Z or a Y these will remain intact.
Page 7 of 51
Development System Manual & Operating Procedure
Page 8 of 51
Development System Manual & Operating Procedure
ZTEST_DESC where
Z Client Specific Modifications
TEST Indicates a test program
DESC Short description depicting purpose of test program
In addition it should be noted that these objects will have the $TMP
development class being local objects only.
Page 9 of 51
Development System Manual & Operating Procedure
NOTE: The SAP modification assistant should be used in all cases without exception
Page 10 of 51
Development System Manual & Operating Procedure
Security Implications
Addition to Area Menus
Conformity with SAP standard
Page 11 of 51
Development System Manual & Operating Procedure
Use Underscore ‘_’ and not hyphen ‘-’ character between other characters.
Where possible try to use locally declared variables rather than rely on global
variables
Page 12 of 51
Development System Manual & Operating Procedure
3.7.5 Constants
Format: C_ + field name LIKE <data dictionary field> or TYPE <ABAP
type>
where field name = ‘SAKNR’, ‘BUKRS’, ‘MATNR’
Use the LIKE option to refer to an SAP field where possible
3.7.6 Field-Symbols
Format: <FS_ + descriptive name>
3.7.7 Types
Used to declare custom data definitions in an ABAP program
Format: TY_+ descriptive name
Page 13 of 51
Development System Manual & Operating Procedure
If you are unsure as to the type of internal table to use – please use
TYPE STANDARD TABLE … however DO NOT USE pre-4.0
internal table logic i.e. tables with header lines as this is out dated
and inefficient programming!
3.7.10 Ranges
Format: R_ + descriptive name
Page 14 of 51
Development System Manual & Operating Procedure
Page 15 of 51
Development System Manual & Operating Procedure
Structures are defined in (almost) the same way as tables. The only difference is that no
database table is generated. The same data elements and domains can be used in
structures as are used in tables and it is even possible to Include tables. As a result, it is
possible to achieve a high level of consistency of data definitions even in complex
programs which link data taken from several places.
Structures are used in particular for defining data at the interface between module pools
and screens and for standardising parameters for function modules.
Since structures that are used more than once are defined centrally, they can also be
changed centrally. These changes are then effected at all relevant points by the active
ABAP Dictionary.
Table types INTTAB have no records in the database. These types of tables are structures
shared across multiple ABAP programs. The maximum length of INTTAB tables is 30
characters.
General Information
New control tables/DB tables must adhere to the above naming convention
standards. Control tables can be created by all members of the development and
process teams but should be contained in the specification package. Some SAP
objects violate the naming conventions. You can view these object names in table
TDKZ. These object names cannot be used for Customer Objects.
Note that all database tables should begin with client number defined in the MANDT
element.
Page 16 of 51
Development System Manual & Operating Procedure
3.8.8 Views
When defining a view use the following format: Z+descriptive name(max 12 chars) _V
e.g. ZEKETEKPO_V to name a database view that joins tables EKET & EKPO.
Page 17 of 51
Development System Manual & Operating Procedure
3.13 Package
The purpose of a package is to define the development and production SAP R/3 systems
for a set of programs.
All development work for a particular stream will be assigned to the same package. Only
objects that are non-specific should be assigned to the interface, basis or security classes.
ZXXn where
Z= fixed first character
XX = SAP R/3 Component as defined earlier
N= sequential next number 01,02,03 etc
The following classes have been created in development client 230:
Package Description
ZSD01 Sales and Distribution Development
ZMM01 Materials Management Development
ZPM01 Plant Maintenance Development
ZPP01 Production Planning Development
ZQM01 Quality Management Development
ZHCM01 Human Capital Management development
ZFI01 Financials Development
ZCO01 Controlling Development
Notes:
For any temporary test objects which are not supposed to be transported over to
the production environment, please use ‘Local Private Object - $TMP’.
The following development classes are to be used. If any below is not applicable,
then create one using the above convention.
Page 18 of 51
Development System Manual & Operating Procedure
4.2 Subroutines
Subroutines should be used to ease the creation, readability and maintainability of ABAP
programs. (Note: A report can call a subroutine from another report – e.g. PERFORM
new_routine (zmyprog)). It is recommended that a subroutine library be developed for
use in later development.
Page 19 of 51
Development System Manual & Operating Procedure
For example:
ZEMM_R001_01_E01
ZEMM_R001_01_T01_01 ZEMM_R001_01_F01_01
Header Declarations
PROGRAM STATEMENT
COMMENT BLOCK
TABLES
TYPES
CONSTANTS
STRUCTURE DEFINITIONS
INTERNAL TABLE DEFINITIONS
FIELD-GROUPS and FIELD-SYMBOLS
DATA
PARAMETERS and SELECT-OPTIONS
Page 20 of 51
Development System Manual & Operating Procedure
Processing Block
INITIALIZATION
AT SELECTION-SCREEN
START-OF-SELECTION
GET (if using logical databases)
END-OF-SELECTION
Interactive Events
AT LINE-SELECTION
AT PFnn
AT USER-COMMAND
Page Controls
TOP-OF-PAGE
END-OF-PAGE
Subroutines
FORMS
Page 21 of 51
Development System Manual & Operating Procedure
Documentation is developed using the SE38 ‘Documentation’ option and will generally be
based on the details from the functional specification(M30) document. A program should
not be signed off as complete until the documentation is completed.
A description of the program should be maintained on-line using the Goto -> Program
Doc. pull down menu in the ABAP/4 editor. (The difference between this form of
documentation verses comments in the program is that the target audience for this is the
end-user whilst the latter is for the developer/maintainer).
This On-line End User documentation must be done. User common end user language
but add enough technical details to allow users to use the program.
Use the following template for end user documentation:
Purpose: Describe the purpose of the program in detail.
User parameters: Describe the user parameters the program expect and process.
Timing: Describe how often or when the program should be run.
4.8 Commenting
Always provide extensive commenting to support future maintenance of your ABAP
code. Commenting should explain complicated areas of logic and should give guidance to
the logical ‘flow’ within a program. When deciding ‘how much is enough’ imagine what
degree of commenting you would like to quickly understand a program that you have not
written.
Where the program code can be clearly and concisely explained in line comments they
should be used above separate line comments, as they will not be as easily separated from
the code to which they relate. Line comments should be spaced out from the right hand
side of the statement to a consistent point where they do not interweave with the
programming code.
Where this is not possible the comment should be on a separate line preceding the
statement using a ‘comment block’ for lengthy comments (more than 3 lines).
**********************************************************
* 001+
* Modification to check the currency values etc etc
**********************************************************
Code Change…………
**********************************************************
* end of 001+
FORM statements should always include a comment block to describe the function
supported and the parameters passed to and from the routine.
Page 22 of 51
Development System Manual & Operating Procedure
Page 23 of 51
Development System Manual & Operating Procedure
FIELD COMMENTS
Logical Database Since this controls the access path to the data. You
must ensure that you are using the correct logical
database for optimal performance
Start via variant If you set this attribute, the user can only start your
report via a variant. You must therefore have
created at least one variant.
Page 24 of 51
Development System Manual & Operating Procedure
Transaction Codes
Transaction codes can be assign authorisation objects directly and as such are the most
convenient method of securing software. In order to further secure the program ensure
that the user is denied access to SE38 and SA38. Transaction codes should be used to
prevent access to the program entirely.
Authority Check
Embedding authority checks within programs enables direct control of data access, in this
way it is possible for a whole department to utilise a report but have data excluded for
certain individuals. Note this method can be used to prevent access to the program code
entirely, such as in an exit program.
In addition it’s important that the authority group is defined and that the field to be
checked is also determined.
AUTHORITY-CHECK OBJECT 'object_id '
ID ’ ’ FIELD ‘ ’
Page 25 of 51
Development System Manual & Operating Procedure
ZXXxxxxxxxx where
Z:sxxxxxxxxy where
Z = fixed first character of the program
s = SAP R/3 components
xxxxxxxx = any meaningful 8 characters that defines the object / field
y = A (all), D (display only), C (create only), E (Change
only), T (delete only), L (list display), B (block)
Page 26 of 51
Development System Manual & Operating Procedure
SR = B3
Errors = B4
where A = A1 + A2 + A3 + A4
B = B1 + B2 + B3 + B4
A1 + A2 + A3 = B1 + B2 + B3 + B4
Total Records Read =A
Total Error Records =B
Total Good Records =C
where A = B + C
Total No. of Records Processed for 1Q 1995 =A
No. processed for January = A1
No. processed for February = A2
No. processed for March = A3
Total No. of Error Records =B
Error records for January = B1
Error records for February = B2
Error records for March = B3
Total No. of Records Selected =C
Selected for January = C1
Selected for February = C2
Selected for March = C3
where A = A1 + A2 + A3
B = B1 + B2 + B3
C = C1 + C2 + C3
A=B+C
Total No. of Records Processed for dd.mm.yyyy = A
Total No. of Records Processed = A
BEDOK = A1
HAWK = A2
:
: = An
where A = A1 + A2 + .... An
Page 27 of 51
Development System Manual & Operating Procedure
Page 28 of 51
Development System Manual & Operating Procedure
5.1 SQL
In order to enhance the performance of your ABAP code a number of useful guidelines can
be used.
• Use SELECT SINGLE wherever possible to retrieve up to one row of information. It is
important to specify all the key fields to ensure a unique record.
• Be careful using the FOR ALL ENTRIES addition since this is very bad for very large
datasets (10,000+ records)
• Joins and subqueries are good
• Do not use SELECT * statement unless the program needs ALL columns from the
table. Instead, only specify the fields you require. This will also avoid unnecessary
network transports. The addition INTO CORRESPONDING FIELDS of the INTO
clause of the SELECT statement is worthwhile to use only for large amounts of data
where the external table and destination fields have the same names. Consider the use
of the DISTINCT option in the case of many duplicate entries.
The following example compares selecting all fields to selecting only the document
number, the item number and the material.
Avoid:. select * from vbap
where vbeln in s_docno.
….
endselect.
Use: select vbeln posnr matnr
into (wa_vbap-vbeln, wa_vbap-posnr, wa_vbap-matnr)
from vbap
where vbeln in s_docno.
….
endselect.
Important Points:
Page 29 of 51
Development System Manual & Operating Procedure
The order of the fields retrieved must match the order of the destination fields in the field
list.
• Use the SELECT...WHERE clause to restrict data rather than retrieve all rows and use a
CHECK or IF statements to filter data.
Avoid: select vbeln posnr matnr
into (wa_vbap-vbeln, wa_vbap-posnr, wa_vbap-matnr)
from vbap.
check s_docno.
….
endselect.
Use: select vbeln posnr matnr
into (wa_vbap-vbeln, wa_vbap-posnr, wa_vbap-matnr)
from vbap
where vbeln in s_docno.
….
endselect.
Important Points:
Order the columns in the where clause of a select in the same order as the key or index
table.
• WHERE Clause Tips
o Exploit the indexes of the database tables for an efficient use of the WHERE
clause. To do so check all index fields with the equality operator (EQ, =) and
concatenate these checks by AND. The primary key of a database table makes up
its primary index automatically. Secondary indexes for a database table can be
created in the ABAP Dictionary.
o If possible, include all columns of the key or an index in the where clause. Use a
default or appropriate value. If the column(s) is not included, the database may not
be able to fully utilise the index.
o Avoid complex WHERE clauses. The system must split up those into single
statements for the database system.
o Do not use the logical NOT in WHERE clauses but inverted operators instead. The
logical NOT is not supported by the database indexes.
• Try to avoid the select … endselect programming construct. Rather select all the
required records from the database directly into an internal table and loop at the table
to process the entries. This is usually faster than the select … endselect code, and also
allows easier debugging of the code.
Avoid: select vbeln posnr matnr
into (wa_vbap-vbeln, wa_vbap-posnr, wa_vbap-matnr)
Page 30 of 51
Development System Manual & Operating Procedure
from vbap
where vbeln in s_docno.
write:/ wa_vbap-vbeln, wa_vbap-posnr, wa_vbap-matnr.
endselect.
Use: select vbeln posnr matnr into table ts_vbap
from vbap
where vbeln in s_docno.
loop at ts_vbap into wa_vbap.
write:/ wa_vbap-vbeln, wa_vbap-posnr, wa_vbap-matnr.
Endloop.
• Avoid nested select statements if possible as they generally have poor performance. It
is preferable to select all the entries for each table directly into an internal table and use
nested internal table loops to process all the entries.
• Check runtime analysis tips and tricks for detailed comparisons in select performance
(SM30). SELECT statements.
• Use aggregate expressions in the SELECT clause to perform calculations instead of
transporting great amounts of data and calculating thereafter. This distributes the
processing load and minimises the network data transfer. Valid aggregate functions
include: MAX, MIN, AVG, SUM and COUNT.
• The storage of database tables in local buffers can lead to significant time savings. Use
the buffering of database tables whenever possible. Use the addition BYPASSING
BUFFER only if it is really necessary.
If DISTINCT, SINGLE FOR UPDATE, and aggregate expressions are used in the
SELECT clause, buffering should be turned off.
• Provide the appropriate selection criteria to limit the number of data base reads. Force
users to provide selection criteria by evaluating the selection criteria entered on the
selection screen during the AT SELECTION-SCREEN event.
• Create indices where needed to enhance query performance. This should be used in
large table lookups to increase efficiency. For example, SELECT…WHERE FieldA =
‘001’. In this case FieldA is not a key field, therefore an index should be created to
improve the efficiency of the select statement. Beware that there is always an
additional processing system overhead for indices. Therefore, only create indices if a
major performance benefit will be realised, especially if the program concerned is
executed many times throughout the day and is business critical.
Page 31 of 51
Development System Manual & Operating Procedure
Detailed below are a number of additional programming techniques that should be borne in
mind when implementing ABAP code.
• When testing fields "equal to" something, one can use either the nested IF or the CASE
statement. The CASE is better for two reasons. It is easier to read and the
performance of the CASE is more efficient.
• Do not use MOVE CORRESPONDING unless the data is contiguous.
• When records a and b have the exact same structure, it is more efficient to MOVE a TO
b than to MOVE-CORRESPONDING a TO b, if records a and b have the exact same
structure.
MOVE BSEG TO *BSEG. is better than
MOVE-CORRESPONDING BSEG TO *BSEG.
• Do not use the COLLECT statement with large internal tables as this can be very CPU
intensive.
• When reading a single record in an internal table, the READ TABLE WITH KEY is not
a direct READ on a on a sorted table. Therefore, SORT the table and use READ
TABLE WITH KEY BINARY SEARCH.
• Use the SORT...BY when sorting internal tables.
SORT ITAB BY FLD1 FLD2. is more efficient than
SORT ITAB.
• Avoid hard-coding and use of literals in ABAP code. Use reference tables to drive
processing to support business change flexibility and reduce ongoing maintenance
costs. If hard-coding and literals are required, be sure to include these as constants.
• The Tips & Tricks function is very useful in comparing different methods of coding
without going to the trouble of coding both and then performing your own run-time
analysis. System > Utilities > Runtime Analysis > Tips & Tricks.
Use logical databases and ‘GET’ events wherever reads on parent/child segments need to
be performed e.g. require data from both MARA then MARD table - use GET MARA then
GET MARD. (Note you do not need to use an LDB if data from only the MARA or MARD
table is required.)
Page 32 of 51
Development System Manual & Operating Procedure
Where an LDB is used provide defaults or checks for the standard selection-
options/parameters wherever possible.
Avoid use of logical data bases as much as possible - use SELECT statements instead.
(Logical databases are good as a reference tool to look up database hierarchies).
5.4 Debugging
When testing ABAP, use of the debugging tool plays an essential role in checking the
value of variables during the execution of the program. This tool should be used during
the unit testing to ensure programs are executing as desired.
You can use the debugging tool by selecting Program > Debugging from the ABAP
program Development Initial screen.
In addition to the static programming of breakpoints, ABAP’s on-line debugging tools also allow
you to set breakpoints and interrupt conditions dynamically. This makes the whole process of
debugging reports much more flexible and the consequent advantage is that you do not have to
change your code. Watchpoints can now be set based on the value a field takes (like R/2).
Once you have stopped the report processing, you can view the contents of all the fields
(up to 8), internal tables and database tables referenced in the report. The system fields
SY-TABIX and SY-DBCNT are now displayed at the bottom of the screen along with SY-
SUBRC.
Finally, you can change the contents of fields for debugging purposes and then resume
report processing, with the changed data. To set breakpoints select Breakpoints > Set from
the ABAP: Editor screen. Then execute the program.
Beware that in order to debug SAPscript programs, hard-coded breakpoints are often
required. Be sure to remove these once testing is complete and the program transported.
Use the syntax BREAK username, rather than BREAK-POINT, as this will ensure the code
only stops when running under the specified username.
Page 33 of 51
Development System Manual & Operating Procedure
6 SAPscript Techniques
• Always copy the SAP standard print programs where available and, in most instances,
the layout set. Never start a complex SAPscript (e.g. Invoice, Purchase Order) from the
beginning, as this will require far more development time to complete.
• When creating a new layout set by copying a SAP standard, always change the
original language from D to E and then activate.
6.2 Standards
• Naming convention for layout sets – this will follow the same as the program name,
except the version number will be prefixed L. For example a purchase order layout set
would be:
ZMM_DESC where
Z First character of the program
MM SAP R/3 module/component
DESC Meaningful description i.e. PO printing, INVOICE.
• When copying SAP standard print programs ensure they have a standard header
block as defined earlier. Also ensure that any code that is added, removed or changed
is commented in the standard fashion.
Page 34 of 51
Development System Manual & Operating Procedure
6.4 Tips
• Text elements must be maintained individually for each layout set language. Any
other changes to the layout set i.e. window size or paragraphs, will be copied from the
original language to the other languages.
Page 35 of 51
Development System Manual & Operating Procedure
Page 36 of 51
Development System Manual & Operating Procedure
• An object is original in only one system. In the case of objects delivered by SAP, the
original system is at SAP itself. These objects are only copies in customer systems.
This applies to your development system and all other systems that come after it.
• If you write your own applications, the objects that you create are original in your
development system. You assign your developments to a change request, which has
the type Development/Correction.
This request ensures that the objects are transported from the development system into
the subsequent systems
• Changes to an original are called corrections. They are recorded in a change request
whose tasks have the type "Development/correction".
• If, on the other hand, you change a copy (an object outside its own original system),
the change is recorded in a task with the type "Repair". Repairs to SAP objects are
called modifications.
• When you repair your own objects (for example, if something goes wrong in your
production system), you can correct the original in your development system straight
away. When you change copies, you must correct the original immediately!
• However, you cannot do this with SAP objects, because they are not original in any of
your systems.
• You should only modify the SAP standard if the modifications you want to make are
absolutely necessary for optimizing workflow in your company. Be aware that good
background knowledge of application structure and flow are important prerequisites
for deciding what kind of modifications to make and how these modifications should
be designed.
During an upgrade or an import of R/3 Support Packages, new objects delivered overwrite
existing objects of the SAP standard. In order to help customers keep those objects that have
been modified in a previous release, SAP now offers upgrade adjustment for all objects being
upgraded in the form of transactions SPAU and SPDD. These transactions allow customers to
enter their modifications into the corresponding new objects being delivered at upgrade. The
Modification Assistant supports this process of adopting customer modifications. In general,
objects altered using the Modification Assistant can now be automatically accepted into the
upgraded system if the modifications undertaken in the original version do not directly overlap
those made in the customer version. If collisions occur between the two versions at upgrade
Page 37 of 51
Development System Manual & Operating Procedure
(naming collisions, or if SAP has deleted an object modified by a customer), the system offers
semi-automatic adjustment support. In some cases, however, you may still have to manually
adjust objects using ABAP Workbench tools.
• Whenever you upgrade your system, apply a support package, or import a transport
request, conflicts can occur with modified objects.
• Conflicts occur when you have changed an SAP object and SAP has also delivered a
new version of it. The new object delivered by SAP becomes an active object in the
Repository of your system.
• If you want to save your changes, you must perform a modification adjustment for
the objects. If you have a lot of modified SAP objects, your upgrade can be slowed
down considerably.
• To ensure consistency between your development system and subsequent systems,
you should only perform modification adjustments in your development system. The
objects from the adjustment can then be transported into other systems.
The aim of the Modification Assistant is to make modification adjustments easier. This is
because (among other reasons) the modifications are registered in a different layer
Page 38 of 51
Development System Manual & Operating Procedure
• If you want to change an SAP object, you must provide the following information:
o SSCR key
o Change request
• The system informs you that the object is under the control of the Modification
Assistant. Only restricted functions are available in the editor.
• You can switch the Modification Assistant on or off for the entire system by changing
the R/3 profile parameter eu/controlled_modification. SAP recommends that you
always work with the Modification Assistant.
• You can switch off the Modification Assistant for single Repository Objects. Once you
have done so, the system no longer uses the fine granularity of the Modification
Assistant.
• In modification mode, you have access to a subset of the normal editor tools. You can
access these using the appropriate pushbuttons. For example, in the ABAP Editor, you
can:
o Insert
The system generates a framework of comment lines between which you can enter
your source code.
o Replace
Position the cursor on a line and choose Replace. The corresponding line is
commented out, and another line appears in which you can enter coding. If you
want to replace several lines, mark them as a block first.
o Delete
Select a line or a block and choose Delete. The lines are commented out.
o Undo modifications
This undoes all of the modifications you have made to this object.
o Display modification overview
Choose this function to display an overview of all modifications belonging to this
object.
Page 39 of 51
Development System Manual & Operating Procedure
APPENDICES
Page 40 of 51
Development System Manual & Operating Procedure
REPORT ZTEMPLAT.
* NO STANDARD PAGE HEADING. "Switches off standard heading
* LINE-SIZE nnn. "Line is nnn characters
* LINE-COUNT pp. "Page has pp lines
*****************************************************************************************
* PROGRAM: xxxxxxxx *
* *
* Copyright (C) and all other rights in this program *
* are reserved by xxxxxxxxxxxxxxxxxxxxxxxxxxxx *
* *
* TITLE: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx *
* *
* AUTHOR: I.Surname DATE: xx/xx/xxxx *
* *
* DESCRIPTION: *
PROGRAM
* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx * HEADER
* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx *
* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx *
* *
*****************************************************************************************
* CHANGE HISTORY *
* *
* Mod Date Changed By Description Chng ID *
* xx/xx/xxxx xxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx *
* *
****************************************************************************************
*-----------------------------------------------------------------------------------------------------*
* EXTERNAL TABLE DECLARATIONS *
*-----------------------------------------------------------------------------------------------------*
*-----------------------------------------------------------------------------------------------------*
* TYPES *
*-----------------------------------------------------------------------------------------------------*
Page 41 of 51
Development System Manual & Operating Procedure
*-----------------------------------------------------------------------------------------------------*
* CONSTANTS *
*-----------------------------------------------------------------------------------------------------*
*-----------------------------------------------------------------------------------------------------*
* STRUCTURE DECLARATIONS *
*-----------------------------------------------------------------------------------------------------*
*-----------------------------------------------------------------------------------------------------*
* INTERNAL TABLE DECLARATIONS *
*-----------------------------------------------------------------------------------------------------*
*-----------------------------------------------------------------------------------------------------*
* FIELD GROUPS & FIELD SYMBOLS *
*-----------------------------------------------------------------------------------------------------*
*-----------------------------------------------------------------------------------------------------*
* VARIABLE DECLARATIONS *
*-----------------------------------------------------------------------------------------------------*
*-----------------------------------------------------------------------------------------------------*
* SELECT-OPTIONS AND PARAMETERS *
*-----------------------------------------------------------------------------------------------------*
*-----------------------------------------------------------------------------------------------------*
* INITIALIZATION EVENT - processing prior to selection screen *
*-----------------------------------------------------------------------------------------------------*
INITIALIZATION.
*-----------------------------------------------------------------------------------------------------*
* AT SELECTION-SCREEN EVENTS - validate user input *
*-----------------------------------------------------------------------------------------------------*
AT SELECTION-SCREEN.
* -------- S T A R T O F M A I N P R O C E S S I N G -------- *
*-----------------------------------------------------------------------------------------------------*
* START-OF-SELECTION - start of database access *
Page 42 of 51
Development System Manual & Operating Procedure
*-----------------------------------------------------------------------------------------------------*
START-OF-SELECTION.
*-----------------------------------------------------------------------------------------------------*
* END-OF-SELECTION - end of logical database selections *
*-----------------------------------------------------------------------------------------------------*
END-OF-SELECTION.
* ----------- E N D O F M A I N P R O C E S S I N G ----------- *
*-----------------------------------------------------------------------------------------------------*
* DIFFERENT PROGRAM EVENTS *
*-----------------------------------------------------------------------------------------------------*
AT USER-COMMAND. "When user presses function key or enters a
"command in the command field
*-----------------------------------------------------------------------------------------------------*
* EVENTS RELATING TO REPORT PROCESSING *
*-----------------------------------------------------------------------------------------------------*
TOP-OF-PAGE. "Point during list processing when a new page is
"started
END-OF-PAGE. "Point during list processing when a page is ended
*-----------------------------------------------------------------------------------------------------*
* FORMS *
*-----------------------------------------------------------------------------------------------------*
Page 43 of 51
Development System Manual & Operating Procedure
Naming Convention
Page 44 of 51
Development System Manual & Operating Procedure
Page 45 of 51
Development System Manual & Operating Procedure
literal text.
(i.e., WRITE:/TEXT-001. “WRITE CUSTOMER
INFORMATION; or WRITE/ ‘CUSTOMER’(001).)
5 User default date format ( see SU50 ) is used instead of
hard coding of date format in the program.
6 No hard coding of currency output formats in the
program.
7 When output is designed to print on a laser printer,
consider the output of the report so that it will fit for
both A4 and Letter papers.
8 RESERVE statement is used to determine whether a
group of lines can fit on a page.
Data Definition
1 Variable names are descriptive, meaningful and
understandable.
2 Variables that are not changed in the program are
defined with CONSTANT
Statement. ( CONSTANT PI TYPE F VALUE
‘3.14159265359’.)
3 Comments are included after each field ( tables, fields
of internal tables, constants, variables, etc.) to
describe the meaning or purpose of the field.
4 LIKE verb is used while declaring the fields whenever
feasible.
5 When declaring data, type and length are not left as
default.
6 INCLUDES are created for data declarations and any
data structure that will be used in more than one ABAP
program.
7 Global variables are minimized by declaring local
variables or by passing through parameters and
arguments while creating Internal Subroutine.
Online Standard
1 The field with an “OK” format should be defined as
OK_CODE.
2 Screen and program field names should generally be
identical.
3 When handling a lock entry failure, invoke an error
message (type E) to prevent user from progressing to
the next transaction.
4 AT PF-key is used instead of AT Pfnn in program.
Batch Program / Interface Standard
1 “Success” messages (type ‘S’, which will be output to
“Job Log” when the batch programming is
Page 46 of 51
Development System Manual & Operating Procedure
Page 47 of 51
Development System Manual & Operating Procedure
ENDSELECT statement.
5 WHERE clause is organized with simple logic. WHERE
clauses with very complex logic should be avoided.
6 For all frequently used SELECT statements, try to use
an index by specifying the index fields
concatenated with logical ANDs in the WHERE clause.
7 Conditional execution of performs should always be
checked before calling the form.
8 Use SELECT SINGLE only with primary keys - often
fields will not be taken into account with SELECT
SINGLE.
9 Aggregate functions should be used when calculating
the MAX, MIN, SUM, AVG, COUNT of a
database table.
10 VIEW or JOIN is used to replace nested SELECT
statement.
11 Whenever possible, use array operations instead of
single-row operations to modify your database
tables.
12 Whenever possible, use column updates instead of
single-row updates to update your database
tables.
13 When selecting a certain number of rows use SELECT
Up to n rows, or if you just want one row without
a full primary key, use SELECT UP to 1 rows,
instead of using EXIT in SELECT/ENDSELECT.
14 Since views do not have a primary key, ORDER BY
PRIMARY KEY should only be used in database
tables.
15 Since “ORDER BY fi…fn” is not automatically
supported by a (sorted) index, you should sort the
result set with SORT on the application server instead
of with….ORDER BY fi…fn on the database server.
16 No direct updates to ABAP supplied tables.
17 When loading data into internal table, use SELECT…
from <tab> INTO (APPENDING) TABLE <itab>
instead of a SELECT/APPEND combination.
18 Use a VIEW or JOIN instead of “SELECT…for all entries
in TABLE <itab>”.
Internal Table
1 Header line of Internal Table is cleared before moving
data into it.
2 Internal Table is defined with ‘OCCURS 0’ if the
maximum size of the table is potentially >= 8KB. If the
data to be read is estimated to be under 8K, then
Page 48 of 51
Development System Manual & Operating Procedure
Page 49 of 51
Development System Manual & Operating Procedure
Page 50 of 51
Development System Manual & Operating Procedure
Page 51 of 51