Académique Documents
Professionnel Documents
Culture Documents
UM ABAP
Development
Standards
The University of Mississippi
4/01/2009
UM ABAP Development Standards 2
Table of Contents
NAMING STANDARDS
1. Program names may be between 5 and 40 characters in length. Program names will be
composed of the following subfields:
a. Z — all programs must begin with the letter “Z”.
c. “_” — separate the prefix from the remaining program name by an underscore
“_”.
d. If the program is for use by UMMC only, characters 5-10 must include “UMMC_”.
f. When writing a temporary or training program, please use the prefix “ZTST_XX_”
for the beginning of your program name. This will indicate that this program should
not be used on a regular basis in the production environment.
g.
PROGRAM STANDARDS
1. A template program ZTEMPLATE in client 110 has been provided for your convenience.
Please be careful not to update this program directly. Copy it to your new program name,
and then modify your program. Be sure to change the “Title” field on the attribute page of
your program to reflect a description of what your program does.
2. All programs should include a comment box at the beginning of the program listing the
following information (see ZTEMPLATE):
a. Program name
b. Author
c. Date written
d. Description of the program. Be sure to list any special considerations and/or
situations. List any tables being used, with a brief description of the table.
e. All modifications to the program should also be documented in this area. (See
Coding Standards: Source Code Document for more information.
3. Use descriptive data and paragraph names. Do NOT use a hyphen “-“ in variable names or
in paragraph (“form”) names. Use the underscore “_” instead. SAP uses the hyphen “-“ to
separate a table name from the field name in the table. Using an underscore will increase
readability of your program.
4. Group parameters and select-options together. Group table names together. All data items
should be at the beginning of the program before any event logic.
a. Names of parameters and select-options are limited to 8 characters.
b. Table names are limited to 16 characters.
6. Use indentation to make the reading of your program easier. This is automatically set when
you use Pretty Printer (see Code Standard: Formatting).
8. All emails generated from SAP programs should use proper grammar and punctuation and
appropriate line-wrapping.
DIALOG PROGRAM STANDARDS
1. Module Pool
a. Transactions are maintained using SAP transaction SE38 (ABAP Editor).
b. PAI (Process after Input) should contain the logic to be executed after the user has
selected a function key, menu item, etc.
TRANSACTION STANDARDS
Transactions are maintained using SAP transaction SE93 (Maintain Transactions).
User must select the appropriate “Start object“ on the first “Transaction Creation Screen”.
Depending on the underlying associated object (e.g.: Reports or Dialog Programs) user
selects the appropriate Start object type.
Figure 1
The following two sections describe the Transaction standards for Start object: Reports and
Dialog Programs respectively:
1. Reports
a. Transaction Code name can be up to 20 characters. The standard naming
convention (ZXX_) should be used (see Naming Standards).
Figure 2
2. Dialog Programs
Figure 3
CODING STANDARDS
1. Formatting
a. Standardize formatting should be used to format all programs, function modules, etc.
To setup, select ‘Setting’ under the ‘Utilities’ option on the SAP toolbar. Select
‘ABAP Editor’ option. Within this option, select ‘Pretty Printer’. Check the
following options:
i. Indent
ii. Convert Uppercase/lowercase
iii. Keyword Uppercase
Figure 4
c. Whenever possible, the LIKE parameter should be used to define the type of a
variable.
b. INCLUDE files can't define their own Text Elements - any Text Elements to which
they refer must be defined in the main program which invokes the INCLUDE file.
TIP: You can use the INITIALIZATION event of the “include” program to set the
values of these text elements.
8. Usage of UserIDs in programs
a. In no case should a production program or function contain a UserID as either literal
or constant data. In the development system it may be necessary to code temporary
breakpoints for specific UserIDs, however, these debugging techniques must be
removed before the program is transported.
9. Messages
a. Declare the message class in the report statement. While it is possible to specify the
message class each time a message is output, it is easier to specify once it in the
report statement. You can still use a message from another class than the one
defined in the report by adding the class in parentheses after the message. Messages
can be defined using SAP transaction SE91 (Message Maintenance: Initial Screen).
b. Messages should use proper grammar and punctuation.
10. Development Class
a. The development class of any program, table, function, etc., should be ZDEV for
UM clients only. If a special development class is required, authorization must be
request from BASIS (see Authorization Standards for more information).
b. All programs should also have a modification log displayed at the top of the
program. This log should the initials of the developer making the change, the date
of the change, and a description of the change. The log should be dated with the
most recent change first. For example:
Figure 5
c. Comment work fields, and fields in work records especially those used for
interfacing. Comments should explain what the code is doing.
Figure 6
Figure 7
e. It is also helpful to include comments for each block of code designed to accomplish
a task. For example:
Figure 8
b. The import and export parameters of function modules should be documented at the
top of the source code section of the function module with brief descriptions of the
fields and their typical contents. Also, any special requirements or usage should be
noted.
c. The first letter of the parameter’s name should indicate the direction in which the
parameter was passed:
Input or importing = I
Output or exporting = E
Bi-directional or changing = C
d. The second letter of the parameter’s name should indicate the nature of the formal
parameter:
Single value or variable = V
Single structure or record (however complicated) = S
Internal table (however complicated the line structure) = T
e. Function modules that contain database reads should also contain at least one
EXCEPTION parameter.
f. All RFCs (Remote Function Call) must contain at least one EXCEPTION parameter.
PERFORMANCE STANDARDS
1. General Performance Standards
a. "Dead" code - (Avoid leaving "dead" code in the program. Comment out (or delete)
variables that are not referenced and code that is not executed. Use program -->
check --> extended program to check to see a list of variables which are not
referenced statically.
Figure 9
b. Logical databases - Most SAP modules have logical databases that are available for
your use. However, it has been found that unless you are using a lot of the data from
the logical databases, the runtime of the program using a logical database is greatly
increased from one directly accessing a database table using a “SELECT” statement.
This is better:
IF f1 NE 0.
PERFORM sub1.
ENDIF.
FORM sub1.
...
ENDFORM.
Than this:
PERFORM sub1.
FORM sub1.
The University of Mississippi | Confidential
UM ABAP Development Standards 17
IF f1 NE 0.
...
ENDIF.
ENDFORM.
d. IF statements - When coding IF tests, nest the testing conditions so that the outer
conditions are those which are most likely to fail. For logical expressions with AND,
place the mostly likely false first and for the OR, place the mostly likely true first.
e. CASE vs. nested Ifs - When testing fields "equal to" something, one can use either
the nested IF or the CASE statement. The CASE is generally better because it is
easier to read.
f. MOVE-ing structures - 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.
g. SELECT – Direct SELECT statements should only be used if the data can not be
accessed using a function module or an evaluation path. When possible the
SELECT statements should be stored in a function module.
h. SELECT and SELECT SINGLE - When using the SELECT statement, study the
key and always provide as much of the left-most part of the key as possible. If the
entire key can be qualified, code a SELECT SINGLE not just a SELECT. If you
are only interested in the first row or there is only one row to be returned, using
SELECT SINGLE can increase performance by up to 3x.
i. Check each SELECT statement for the use of index. This can be most easily
determined using the Code Inspector, transaction SCI, which will report on any
SELECT statement against large tables not using an index.
j. Check that there is no assumed sort order after the SELECT statement. Do not
assume that the data will be returned in primary key order.
l. SELECT – Direct SELECT statements should only be used if the data can not be
accessed using a function module or an evaluation path. When possible the
SELECT statements should be stored in a function module.
m. Small internal tables vs. complete internal tables - In general it is better to minimize
the number of fields declared in an internal table. While it may be convenient to
declare an internal table using the LIKE command, in most cases, programs will not
use all fields in the SAP standard table.
n. Refreshing internal tables – When you are done working with an internal table
REFRESH the table to release it from memory.
o. Row-level processing of a table - Selecting data into an internal table using an array
fetch versus a SELECT-ENDELECT loop will give at least a 2x performance
improvement. After the data has been put into the internal data, then row-level
processing can be done. For example, use:
select ... from table <..>
into <itab> (corresponding fields of itab)
where ...
loop at <itab>
<do the row-level processing here>
endloop.
instead of using:
q. SORTing internal tables - When SORTing internal tables, specify the fields to be
SORTed.
r. Deleting duplicates – After sorting internal tables, remember to use the command
“DELETE ADJACENT DUPLICATES FROM” to remove duplicate records.
s. Number of entries in an internal table - To find out how many entries are in an
internal table use DESCRIBE.
t. Length of a field - To find out the length of a field use the string length function.
LV_FLDLEN = STRLEN (FLD).
u. Nested SELECTs versus table views - Since OPEN SQL does not allow table joins,
often a nested SELECT loop will be used to accomplish the same concept.
However, the performance of nested SELECT loops is very poor in comparison to a
join. Hence, to improve performance by a factor of 25x and reduce network load,
you should create a view in the data dictionary, then use this view to select data.
w. Avoid unnecessary statements - There are a few cases where one command is better
than two. For example:
Use:
append <tab_wa> to <tab>.
Instead of:
<tab> = <tab_wa>.
append <tab> (modify <tab>).
And also, use:
if not <tab>[] is initial.
Instead of:
describe table <tab> lines <line_counter>.
if <line_counter> > 0.
endloop.
y. Clear vs Refresh – Use the CLEAR statement to initialize local variables and local
structures. Use the REFRESH statement to initialize local tables. If the table has a
header row, use “REFRESH lt_table[]” to clear both the table and the header row.
Don’t forget to re-initialize local variable and table before each re-use.
z. Report display – Make sure the case matches throughout the report. Do not mix all
upper-case displays with all lower-case displays. Ex:
Do not display:
SHIELA LONG, academic administrator, school of education
Instead use:
Sheila Long, Academic Administrator, School of Education
aa. System fields – ABAP automatically stores information necessary to control the
program’s internal flow of logic in some system fields and tables. These fields and
tables are accessible by the programmer. It is better to use a system field than to
create logic to generate the same data (i.e. current time, current date, table index,
etc.). A list of system fields and system tables can be found in The Official ABAP
Reference
2. Performance Checking
a. Performance diagnosis ⎯ SAP transaction SE30 (ABAP/4 Runtime Analysis) must
be ran on all new programs before they are put into production. This utility allows
statistical analysis of transactions and programs.
b. Error checking – Use the SAP transaction SCI (Code Inspector) to spot meaningful
error; however, the developer will still need to use judgment to filter out
meaningless errors.
DICTIONARY: TABLE STANDARDS
b. Field names do not have to begin with ‘Z’; however, the field name should be
descriptive.
3. Maintenance settings
a. "Tab. Maint. Allowed" 'X' or (blank)
i. An 'X' indicates that this table is to be maintained directly using the
"Standard Table Maintenance" functions (SM31 / SM30). This means that
the table can be maintained independently of any other table or application.
This should only be used for tables that have a relatively low number of
updates, done on an infrequent basis. Tables that are maintained this way are
typically used to set control information, or similar table values that change
infrequently, but will change. Examples are tax rates, overhead rates,
program control tables, message tables, program or error status tables, etc.
ii. Tables maintained this way should NOT have any dependency on other
tables or other entries in the same table for the validity of a new entry or new
value, unless that dependency can be validated through the use of a check
table for the field.
iii. X should be selected ONLY if the table is to be maintained by the "Standard
Table Maintenance" functions. (SM30 or SM31) Any table for which entries
are maintained / changed / inserted / deleted by an application should in most
cases not have this field checked.
RULES STANDARDS
1. Each University should have their own instance of programs ZGBBR000 and ZGBBS000, and
VSR.
Figure 10
Figure 11
Figure 12
d. School related: Begin with 1st three characters associated with school
i. LAxxxxx ( Liberal Arts)
ii. BUSxxxx (School of Business)
The University of Mississippi | Confidential
UM ABAP Development Standards 23
Figure 13
Figure 14
Figure 15
Figure 16
Figure 17
Figure 18
4. Rule Modules
a. Limited to 4 numbers with desc.
b. All descriptions same as Validation or Substitution as referenced.
Figure 19
5. Rule Containter
a. Limited to 12 characters.
b. In general, similar text as used in validation, but enhanced for Web display purposes.
i. PRxxxxxxxx for Pre-requisite
ii. COxxxxxxxx for Co-requisite
iii. SPECxxxxxx for Specialization
iv. IMSGxxxxx for Informational Message
Figure 20
TRANSPORTING STANDARDS
1. Communication
a. If you are going to working on a program, function module, table, structure, etc. for
a length of time, it is crucial that you communicate with the other developers before
transporting these items to production.
b. When transporting more than one transport group, be sure to transport the groups in
the order they were created.
c. When completing a project, transport ALL transport groups for that project into
production.
3. Re-imports
a. Re-import requests are submitted using the Transports transaction
ZTRANSPORT_FORM.
b. Requests for transports to be re-imported into QAS and PROD must be submitted in
PROD. Be sure to select the correct Target System.
c. If transports were not originally submitted in the correct order, they can be re-
submitted using the Reimport Request option.
d. When completing a project, transport ALL transport groups for that project into
production.
4. Critical Imports
a. Critical Import requests are submitted using the Transports transaction
ZTRANSPORT_FORM.
b. Requests for transports are generally done at set times during normal workdays.
Any requests for transports that need to be completed outside of these normally
scheduled times must be coded as Critical.
c. Only transports that are truly crucial to the operating of the system should be marked
as Critical.
The University of Mississippi | Confidential
UM ABAP Development Standards 26
d. Developers must enter an explanation for the critical transport in the “Requester’s
Comments for BASIS / Reason for Critical Transport”.
Figure 21
TESTING STANDARDS
1. Internal testing
a. All projects (including enhancements) should be tested internally within IT before
being reviewed by the requestor. Appropriate support teams in IT are available to
assist with this task.
b. All developers are responsible for developing their own test plans. Test plans
should include an appropriate sampling of data before and after project has ran.
They should also include measure to ensure the appropriate outcome.
AUTHORIZATIONS STANDARDS
The SAP authorization concept protects transactions, programs, and services in SAP
systems from unauthorized access. On the basis of the authorization concept, the administrator
assigns authorizations to the users that determine which actions a user can execute in the SAP
System after he or she has logged on to the system and authenticated himself or herself. Follow
standards to restrict access for any table, program, transaction or service.
a. The development class of any restricted program, table, function, etc., should not be
ZDEV. Consult with BASIS and create a new package specific to application
having name starting with Z, and use this package as development class.
Figure 22
b. For Dictionary objects: select Utilities-> Assign Authorization Group and enter
table/view name associated with newly created package name as Authorization
Group.
Figure 23
c. Submit a request with BASIS to link authorization object related to this new
package and restrict the access.
PROJECT LIFE CYCLE
Figure 24
1. Project request arrives via IT Work Request.
3. Approved projects
a. Written Requirements
i. IT and requestors develops and agree on written requirements.
ii. Requestor must sign-off on requirements before development on the project
can begin.
b. Design Document and Project Schedule
i. The Developer/Project Team will be responsible for creating a design
document and project schedule.
The University of Mississippi | Confidential
UM ABAP Development Standards 30
REFERENCES
1. The SAP Style Guide is available in the help documentation using the following path:
a. Help -> R/3 Library -> BC-Basis Components -> ABAP Workbench (BC-DWB) ->
BC-> SAP Style Guide.
2. The task code ABAPDOCU or ABAPHELP can be accessed through the command
window.
3. Inside the ABAP editor, you can click on the “Information” or “I” icon.