ABAP Coding Standards and Guidelines
ABAP Coding Standards and Guidelines
Rev Date Originator(s) Change Details To see history of changes please click HERE.
A AUG/11/17 Paul Jackson Initial Release.
B May/01/01 Edwin Soh & Nisha Parihar 7.5 Coding Standards
1. Purpose
1.1. The purpose of this standard is to define naming conventions, programming standards, and
development practices that will be utilized as SAP R/3 development standards for all R/3 development.
By following these standards, the ongoing maintenance of custom development objects will be a
highly manageable entity.
2. Scope
2.1. This standard applies to the ABAP team, which develops code for implementation in applications or
systems.
2.2. This standard applies to any SAP project that requires development, which is executed by the ES
team.
2.3. This standard excludes SAP BW/BI developers who follow processes laid down by BI team
management
3. Definitions/ Terminology
4. Responsibilities
4.1. ES team Management is responsible for ensuring this standard is implemented, maintained, and
effective.
4.2. The ES Team Director is responsible for maintaining and approving this document, as well as ensuring
communication to all levels of the STS organization.
4.3. The ES Team ABAP developers are responsible for adhering to the coding standards and guidelines
described in this document. This includes permanent Jabil employees and independent
consultants/contractors.
5. Reference Documents
6. Process
Contents
About This Guide ................................................................................................................... 6
Introduction ...................................................................................................................... 6
Attributes.............................................................................................................................. 7
Tables ......................................................................................................................................... 14
Views .......................................................................................................................................... 15
Structures ................................................................................................................................... 16
Naming ....................................................................................................................................... 17
New messages............................................................................................................................ 18
ALV ................................................................................................................................. 36
Interface ......................................................................................................................... 37
IDocs ...................................................................................................................................... 37
Function Modules................................................................................................................ 56
BADI ....................................................................................................................................... 59
VOFM ..................................................................................................................................... 60
PF-Status ................................................................................................................................ 61
Screen painter........................................................................................................................ 63
Modules ................................................................................................................................. 64
Plugs....................................................................................................................................... 71
UI Elements Names................................................................................................................ 71
Model Class............................................................................................................................ 73
Character Format................................................................................................................... 83
Scripting ................................................................................................................................. 96
Documentation ...................................................................................................................... 97
Workflow ........................................................................................................................ 98
Introduction
The purpose of this reference document is to define naming conventions, programming
standards, and development practices that will be utilized as SAP R/3 development
standards for all R/3 development. By following these standards, the ongoing maintenance
of custom development objects will be a highly manageable entity.
Convention Explanation
Severity 1
Severity 2
Severity 3
Severity 4
Severity 5
Note : Hawkeye classifies each rule according to the degree of impact each rule could have
on the organization – from a scale of 1 (most impact) to 5 (least impact). Even though
severity 5 rules are on the lower impact end of the spectrum, they point out issues in the
code that should not be allowed for new development.
Attributes
Authorization Group
Jabil requires that all custom developed programs have an authorization group assignment
that meets the Jabil’s SAP Security and Authorization Guidelines.
Package
Packages are used in the Transport system. They are used to group all objects that are
related to the same development to ensure they are transported together.
Type
Logical Database
Do NOT use a logical database as a program attribute. To use an existing logical
database, call it explicitly using the function module LDB_PROCESS from within a
method.
Example: Z_MM_OUTPUT
When assigning a package to an object pay attention to the
transport layer property. For example:
Z_MM_ENHANCEMENTS is set to go to STG only (programs /
tables)
Z_MM_OUTPUT is set to go across clients and to STG (for
Smartforms)
ABAP Reports
ABAP program names may be up to 40 characters long.
Example: Z_MM_INVENTORY
Position Description Value
1 Designates type of Z – Customer program for
object production Y – Test program
2 Underscore To promote readability
3 to n Functional Area View Functional areas
n+1 Underscore To promote readability
n+2 to 40 Program description Descriptive, yet concise text. Use underscores
to enhance readability.
The following naming conventions are in accordance with Hawkeye Master Rules.
Severity 2
Follow the below naming conventions
Description Convention
NC - FIELD-GROUPS FG_
NC - TABLES (FORM) T_
NC - TABLES (FUNCTION) T_
NC - CONSTANTS (Global) C_
NC - CONSTANTS (Local) C_
NC - PARAMETER P_
NC - SELECT-OPTIONS SO_
NC - VARIABLES (Global) V_
Data Declaration
Internal tables
Internal tables should begin with a LT_ (T_ for local tables) and the remaining positions
should be filled with the table name that it most closely resembles from the data dictionary.
Internal tables should not use a header row.
All internal tables which will not need to be sorted more than once should be a sorted table
when possible. This enhances the performance. Below is an example if you needed all
data from the MARA table.
DATA:
t_mara TYPE SORTED TABLE OF mara
WITH UNIQUE KEY matnr.
When an internal table is used and the program only needs specific fields from the SAP
table(s); a TYPE should be created with those specific fields.
The following internal table is a subset of the material master table MARC.
TYPES:
BEGIN OF ty_marc, matnr
TYPE matnr, werks TYPE
Variables
For variables that are defined after data dictionary fields (use them whenever possible),
begin the name with V_ (LV_ for local variables) and the remaining positions should be
filled with the field name from the data dictionary.
DATA: v_matnr TYPE matnr.
When the variable is a work area structure, include s_. For a global variable which is a
work area it would be s_marc; local variable with work area ls_marc. This is helpful for
maintenance of the program; other developers will be able to see in a quick glance this is a
work area (structured variable) rather than just a single value.
DATA: ls_marc TYPE ty_marc.
Field-symbols
When READing / LOOPing always assign to field symbols, rather than reading INTO a
structure. Always use fields symbols as local – can cause major issues if global field
symbols are used. This causes issues for future maintenance as well.
FIELD-SYMBOLS:
<l_lips_tot> TYPE ty_lips.
Select-options
Begin with so_, and the remaining positions should be filled with the field name from the
data dictionary:
SELECT-OPTIONS: so_matnr
FOR v_matnr.
Parameters
For parameters that are defined like data dictionary fields (use this whenever possible),
begin with a P_, and the remaining positions should be filled with the field name from the
data dictionary:
PARAMETERS: p_werks TYPE
werks_d.
Types
With the new ABAP OO standards the TYPES statement will be utilized when defining
structures for internal tables and work areas, and begin with TY_ (or lty_ for local –
however, most types should be used as global).
TYPES:
Messages
All programs should contain at least one message of type S so that the user sees a
response from the system. When programs are scheduled to run in the background, the
only way to influence the job log is via message commands. All status and error messages
should be accessed via the message class libraries.
Data Dictionary
Tables
Technical attributes shall be determined according to the development specification.
The maximum name size for customer tables is 16 characters.
All indexes must be approved by the NetWeaver Team before
being moved to Production.
Severity 1
This is a Data Dictionary Requirement that Client Specified Tables MUST have the first
field of the table defined as CLIENT (MANDT).
Example: ZMM_LOOKUP
Position Description Value
Views
The creation of a view is to be used as a third option. Please try direct table selects, then a
table join before resorting to a view. If a view does need to be created, proper
documentation and reasoning must be presented at the time of the code review.
Views are transparent tables consisting of an alternate view or combination of multiple
tables, such as a joined table. The length of the view name will vary based on the primary
table name for that view. The maximum name length of a view is 16 characters.
Example: ZMM_V_MATERIALS
Position Description Value
Structures
Used for common data layouts between programs.
Structure name length may be a maximum of 30.
Example: ZMM_S_INVENTORY
Position Description Value
Table Types
Used for common data arrays between programs.
Table Type name length may be a maximum of 30.
Example: ZMM_T_INVENTORY
Position Description Value
Fields/Domains/Data elements
Follow SAP naming conventions except for placing a Z in the first position.
Example: ZWERKS.
The maximum length for table fields is 30 characters. Data Elements and Domain names
may be a maximum of 30 characters.
Table Maintenance
When creating a table maintenance view, create a new function group per table.
Message Classes
Creation of a message class or a new message should only be done if an accurate
message does not already exist in SAP. To search for a message, execute SAP
transaction SE16, choose table T100, and enter a portion of the message into the Text
field.
For example, if you are looking for a message with the word plant in it:
Naming
Example: Z_MM
Position Description Value
2 Application
Area
New messages
Numbered 001 – 999, and the next free number should be used. Long text should be added
to all new messages to provide a course of action if the message is displayed in the
program.
Variants
Variants are program specific objects that define set parameters entries required at
program execution time. If the Variant is intended for use with a scheduled background
job, the Variant should be built in the DEV environment and moved to STG and PRD
with the program source.
The name of the variant should include the plant code / customer number or some text
that is self-explanatory.
Function Groups
A function group is the main program for the function modules it contains. Functions that
use the same data are normally assigned to the same function group. It is common
practice to place all function modules that use the same data in a single function group.
For example, if you have a set of function modules that all use the same internal table,
you could place them in a function group containing the table definition in its global data.
Example: ZMM1
Function Groups may be named using up to 26 characters.
Position Description Value
Function Modules
Function modules should always reference data dictionary structures in the interfaces
for export, import, and tables. This is mandatory if the function module being created is
to be used for RFC (remote function call) interfaces.
Function Module names can be up to 30 characters.
Example: Z_MM_GET_BOM
Position Description Value
HANA Connections
The naming standards for Stored Procedures will be SP_ (Module name)
_PROJECTNAME_FREE TEXT .
The Naming standards for views in HANA are as follows:
Attribute Views - AT_MODULENAME_FREE TEXT
Analytic View - AN_MODULENAME_FREE TEXT
Calculation Views - CA_MODULENAME_FREE TEXT
Example: Z_MM_HAN_MATERIAL_MOVEMENTS
SAP Personas
All ABAP developments those developed to support Personas, unless otherwise stated
below should follow Jabil ABAP Development Coding Standards and Guidelines.
Function Group and Function Module naming:
Function group name should start with ZPERS and Function Module name should start
with Z_PERS.
Position Description Value
• The following conventions are from the SAP Help Library for Class Builder.
• When naming the development objects use glossary terms instead of dictionary
terms. For example ZCL_PLANT is preferred over ZCL_WERKS.
• Use English Names.
• Since names are not case sensitive, use the underscore as a separator in the
name.
• Names should describe the action, not the implementation of the action. For
example:
PRINT_FORM is preferred over FORM_TO_SPOOL
Coding Standards
Below are the guidelines to be followed while using ABAP keywords and procedures. If
these rules are not followed while coding, it can result in risk depending on severity.
Severity 1
• The parameter / select-option in the SUBMIT statement does not exist on the selection
screen of the called program. Verify that the parameters and select options match
between the SUBMIT statement and the called program selection screen.
• The parameter / select-option in the SUBMIT statement does not exist on the selection
screen of the called program. Verify that the parameters and select options match
between the SUBMIT statement and the called program selection screen.
Severity 3
• If leaving your select-options wide-open (i.e. no database selection restrictions) causes
long runtimes or times out, and is not intended to be used in that manner, add an AT
SELECTION-SCREEN check/error that at least some database selection fields have
been entered.
• Use keyword TYPE when declaring data objects rather than LIKE (which is an
old convention). LIKE should only be used when a data declaration refers to an
existing data object defined in your program. LIKE is also commonly used for
declaring the line type of an internal table i.e. LIKE LINE OF.
TYPE is a common convention found in most other modern programming
languages.
Note: In OO programming, any reference to a dictionary type MUST use the
keyword TYPE. LIKE will fail syntax check.
• Use the variable length statement STRING and XSTRING when declaring
character and byte data variables. It provides better use of memory than fixed
length text statements TYPE C and TYPE X.
• Avoid the declaration of global variables as much as possible. Avoid passing
Global to Subroutines and Methods.
Avoid setting global variables in too many places. A preferred approach to setting
global is to use dedicated recognized methods that follows best practice naming
convention such as SET_* A length declaration is required when using
offsets.
• Do not use implied defaults on data declarations. Be explicit when TYPING your
data variable. Always Specify the TYPE and Length
• Validate that the FIELDS are used in the program. It is possible that it is
referenced indirectly such as parameter passing to a procedure. If the field is not
used anywhere, remove unreferenced fields from the program.
Severity 4
• TITLEBARS should have a title defined.
Select
Severity 1
• When using "Select... For all Entries" the following rules MUST be followed: ·
Check to make sure driver ITAB is not empty · Always SORT the ITAB (driver
table) by keys.
· Specify all keys used in the WHERE clause.
· DELETE Adjacent Duplicates Comparing the keys that were sorted.
· All Primary Key Fields must be in the Select List.
· The WHERE clause must include INDEX fields to make use of index scan.
· If index fields are not available as part of the WHERE clause, then it is better
not to use FOR ALL ENTRIES. The better option would be a SELECT WHERE
into an ITAB. Any further filtering can be done using ABAP Memory.
• Select Single should provide all fields of the Primary Key. The purpose of a
select single is to retrieve a single unique row based on the unique primary key
fields(s). Without all key fields specified, there may be multiple rows that satisfy
the partial key criteria resulting in any one of the rows being returned. Therefore,
the specific record expected may not be the one returned.
• The database cursor may be lost as a result of certain call sequences that
contain COMMIT. For example, a Commit work or PERFORM inside a
SELECT/ENDSELECT is problematic.
Severity 2
• Avoid incomplete Select statement and errors.
Severity 3
• When the same text literal is used repeatedly in an arithmetic or logical
expression, define the value as a Constant instead of a text literal and name the
constant descriptively. This check determines if there is hard coding contained in
the following statements: SELECT, DELETE, SORT, LOOP, WHEN, IF, READ.
• Do not create empty coding blocks inside blocks such as IF...ENDIF,
WHILE...ENDWHILE, SELECT MAX, etc. Empty coding blocks add no value and
are considered maintenance overhead.
• Select with aggregate function on buffered table.
• Avoid the use of CHECK statements after a SELECT. Instead use a WHERE
statement to filter the data.
• Avoid the use of SELECT ... INTO CORRESPONDING especially for tables with
a large number of fields. The CORRESPONDING clause results in DB overhead.
The corresponding target fields are not know until runtime and therefore need to
be rebuilt at execution. It has a negative effect on performance. Instead, specify
the individual fields required and define the work area to correspond to the fields
being selected.
• Avoid the use of buffered tables in a sub query to avoid bypassing the buffer.
• Use SELECT SINGLE with full key when accessing Single Record Buffered
Table or buffer will be bypassed.
• Consider using an inner or outer join operation within a single SELECT or use a
database view, rather than nested SELECT statements. Using the FOR ALL
ENTRIES IN option (inner join) is fast unless the number of rows is large (> 1000
approx). Be aware that specifying an empty table using the FOR ALL ENTRIES
IN option will return all records.
• AT statement is used to perform some aggregate operations, in this if addition is
performed then SELECT with Aggregate can do the same thing
• Unlinked fields in a join
• Never use SELECT / ENDSELECT, unless doing a single select without the table
key in the where clause. Other than this case, SELECT / ENDSELECT should
never be used. SELECT.. INTO should be used instead.
SELECT matnr werks mmsta
INTO s_marc
FROM marc
UP TO 1 ROWS
WHERE werks IN so_werks.
ENDSELECT.
Loops
Severity 1
• Avoid LOOP at ITAB and then modifying by index in the loop. This can lead to
unpredictable results and performance costs. Avoid inserting new lines while
looping over an internal table. Recommendation: If you have to add new lines
inside the LOOP use APPEND to add the new line at the end of the internal
table.
• Avoid violations within loops hidden by PERFORM
• Internal tables - declare variable for loop counter
• Avoid Indirect Index Access to an Internal Table. All INSERT statements need to
be either placed within a LOOP or use a specific row INDEX. Duplicate records
for a unique internal table index will cause a program dump. For all internal table
operations make sure the system is clearly able to identify the internal table row
where the change, delete or insert needs to occur.
Severity 2
• Incorrect usage of DB ops and errors in loops.
• Avoid LOOP/ENDLOOP blocks within SELECT...ENDSELECT statements. They
are very performance expensive.
• Nested Loops can cause inefficient processing when programmed incorrectly.
Use parallel cursor technique for nested loops with standard tables. It is the most
efficient means of processing Nested Loops. The performance gains are
significant.
• Replace Updates inside a loop with a single set level process update to the
Database outside of the loop. This will reduce the trips to the Database and
improve performance.
• Avoid database accesses inside a loop to minimize performance issues.
• During LOOP Processing of an internal table, do not delete or overwrite the table
that is being looped.
Documentation Category Selective
Jabil Proprietary and Confidential Printed copies are reference only 04-IT60-STS-001 Rev A
Page 27 of 103
ABAP Coding Standards and Guidelines
Revision A Released Date AUG/11/17
• FOR BREAK LEVEL processing with the AT command inside a LOOP at ITAB,
sort by the break level fields before entering the LOOP.
Severity 3
• Nested loops can cause performance issues. This applies to any form of Nested
Loop i.e. WHILE or DO inside of a Loop or a LOOP inside of WHILE or DO. In
the case of a Loop within a Loop, explore the possibility of using a Parallel cursor
technique where checks are in place to ensure that the inner loop record exists
using READ and uses EXIT to exit inner loop when keys are different. With large
tables, the performance gains are significant.
• When using LOOP AT, ASSIGNING, MODIFY and UPDATE statements are
redundant. The Assigning is a pointer. Any changes to the row become explicit
on the row being processed so there is no need to issue the update or Modify
commands.
• Where statements should always include index fields for performance reasons,
especially for LARGE tables.
Severity 4
• Use LOOP AT ITAB and assign to a field symbol. This technique improves
performance on medium and large ITABs.
• Avoid using ON CHANGE OF statement for Break level processing.
Unpredictable results can occur with ON CHANGE OF because it is specific to a
single field whereas the AT... ENDAT triggers a break when any change occurs
in the field specified or fields left of the specified field.
Severity 5
• DO NOT LOOP an itab to retrieve a specific record when a single READ will do
the job.
Internal Tables
Severity 1
• When using the addition FOR ALL ENTRIES in ITAB, the driver table ITAB and
table fields must have the same type and length.
Severity 2
• When Processing a Standard Internal Table:
- Always use the Binary Search option i.e. READ ITAB with KEY Binary
Search.
- READ the Internal Table by Keys
- Be sure that table is sorted by same key that is used in the READ WITH
KEY statement (or data will be missed)
• During LOOP Processing of an internal table, do not delete or overwrite
the table that is being Looped.
• When sorting internal tables, always be explicit by using "SORT BY key1
? keyn", never just "SORT" on its own.
• FOR BREAK LEVEL processing with the AT command inside a LOOP at
ITAB, sort by the break level fields before entering the LOOP.
Severity 3
• Nested internal table passed by value
• Use the TRANSPORTING clause with READ and MODIFY wherever
possible to transport only the fields necessary.
• Avoid sequential access on internal tables. On large tables, this can be
costly. A sequential access will happen if internal tables have incomplete
keys or in the case of standard tables, Binary Search clause is missing.
For internal tables avoid using the obsolete version of READ TABLE ...
WITH KEY. Instead specify an appropriate UNIQUE or NON-UNIQUE
INDEX as part of the internal type definition and use READ TABLE ...
WITH TABLE KEY. Note: The addition BINARY SEARCH is still required
to avoid sequential reads when using STANDARD tables.
This rule also applies to change or delete access in internal tables, e.g.
deleting data in an internal table with a WHERE condition results in a full
scan of the internal standard table. A better solution is to define the table
as a SORTED table with a non unique (or unique) key. In the DELETE
statement use the WHERE condition in combination with WITH TABLE
KEY and the key fields. Now the access will be able to leverage the sort
sequence.
• For tables that need to be processed more than once in a program,
consider reading the database once, and storing the result in an internal
table, so that you don’t need to read the database a second time for the
same data, you read the internal table instead. For large internal tables
however, an inner/outer join may be faster.
Severity 4
• Use LOOP AT ITAB and assign to a field symbol. This technique improves
performance on medium and large ITABs.
• When using Non-Numeric Index Value to delete rows from an internal
table, use the format 'DELETE ITAB FROM FS_PLAN.'
Severity 5
• Use the COLLECT statement only for hashed tables. Never for standard
and sorted tables.
Severity 1
Severity 2
• Case Statement requires a- When Others- clause. Any condition that is
not met will have a fallout path. In the -When Others-, always provide an
action or a generic message so that the program can announce that an
unexpected situation has been encountered.
• WHEN must be the first statement after a CASE statement.
• Never duplicate a WHEN condition. Unexpected program behavior could
result with duplicated WHEN conditions.
Severity 3
• Do not create empty coding blocks inside blocks such as IF...ENDIF,
WHILE...ENDWHILE, SELECT MAX, etc. Empty coding blocks add no
value and are considered maintenance overhead.
Severity 4
• Use operators ( >=, <=, =, <>, >, <) rather than the obsolete words GE,
LE, EQ, NE, GT, LT
Severity 1
• Avoid explicitly turning off the SAP Extended program check in ABAP
Code i.e. the SET EXTENDED Program Check OFF statement is not
permitted
Severity 2
• Usage of select on pool/cluster table
• Unrecommended use of secondary indexes
• Returning parameter - long field
• Parameter passed by value
• Large table should be normalized
• Incomplete table attributes Illegal buffering parameter
• Missing first field of index
• Missing index field in where
• Parallel cursor
• Avoid the use of Buffered Tables in a Join. This will cause bypass of the
buffer.
• Use a WHERE condition with appropriate indexes where possible.
• Replace Updates inside a loop with a single set level process update to
the Database outside of the loop. This will reduce the trips to the
Database and improve performance.
Severity 3
• Tables buffered in the SAP table buffer should be changed as seldom as
possible. In certain cases, local changes of a few records in a table can
Documentation Category Selective
Jabil Proprietary and Confidential Printed copies are reference only 04-IT60-STS-001 Rev A
Page 31 of 103
ABAP Coding Standards and Guidelines
Revision A Released Date AUG/11/17
Severity 1
Function Calls). There are some syst fields that are exempt: SY-
LSIND,
• The actual parameter category must match the formal parameter
category. This means that if a parameter is passed as a USING, it should
be received as a USING.
Severity 2
• USING parameters must match CHANGING parameters.
• Include program type attribute must be correctly set to indicate it is an
Include
Severity 3
• As a general rule, PASS BY REFERENCE should be used where possible
for performance reasons. This test examines whether it is possible to
improve the performance of a parameter transfer for a method, form,
function module, or event. However, there are programmatic reasons for
using by VALUE. i.e. in the case of a RETURNING parameters, it is
always by VALUE. Specifically, the test checks for the following situations:
· The type of the VALUE parameter contains tables whose row type in turn
contains internal tables. · The type of the VALUE parameter contains
tables with different row types. · The type of the VALUE parameter
contains strings, but no tables. · The parameter type is a flat field with a
length > 100 bytes/characters. · The type of the VALUE input parameter is
a flat field with a length <= the parameter
• Define USING parameters by VALUE. Define CHANGING and Internal
Tables by REFERENCE.
• Do not use TABLES statement when passing internal tables to FORMS.
This will result in an internal table with Header being created local to the
form. ITABS with header are obsolete.
• RETURN Statement should be used to exit a procedure (FORM, FMOD,
METHOD).
EXIT should not be used.
If a conditional statement (i.e LOOP, IF, etc. ) is in the procedure, the
programmer
can code either EXIT or RETURN depending on the desired exit
scenario i.e. is the intent to leave the conditional block or to exit the
procedure
Authorization Checks
Severity 1
Severity 1
• Under no circumstances should any program directly update SAP
delivered tables. Updating of SAP tables should be performed using pre-
delivered API's that perform the update
• Changing SAP system fields SYST is prohibited.
Severity 3
• Tables buffered in the SAP table buffer should be changed as seldom as
possible. In certain cases, local changes of a few records in a table can
cause invalidation of the table in the buffer in other application servers.
This will result in entries no longer being current in the buffer and will
therefore have to be imported again from the database. Avoid any of the
following scenarios that will invalidate the buffer: - UPDATE/DELETE with
a WHERE on single-record-buffered table. - UPDATE/DELETE dbtab,
UPDATE/DELETE dbtab FROM WA and UPDATE/DELETE dbtab FROM
ITAB each invalidate only the specified records - UPDATE/DELETE with a
WHERE invalidates the entire table in the buffer. - UPDATE/DELETE with
a WHERE on generically buffered table and generic key not fully specified.
- UPDATE/DELETE with a WHERE, and the generic key in the WHERE
condition is not fully specified, all the generic areas of the buffer are
invalidated. - INSERT/UPDATE/MODIFY/DELETE on completely buffered
table. Each change of a completely buffered table invalidates the table in
the buffers of the other application servers of the system. If the parameter
"Only 'buffering switched on' " is set in the check, accesses to tables that
allow the option 'buffering' in their technical properties, but have 'switched
off' set, are not checked.
ALV
All new reports should be done in the ALV format. Use Z_FI_COGS_ADJ_POSTING as
a template to creating a new ALV grid, using SALV. More program examples given by
SAP (which all start with SALV*) can be found as reference as well. There should be no
WRITE statements used in future programs. If there is a need to modify the data in the
grid then the original type of SAP classes should be used, for example
CL_GUI_ALV_GRID.
Use SAP Class / Methods instead of the older REUSE_ALV_... function modules. With
the exception of the REUSE_ALV_VARIANTXXX functions since the new class does
not give this as an option. Examples of the use of these are in the template mentioned
above.
Severity 3
• Use ABAP List Viewer instead of Classic Lists. WRITE statements and classic report
writing techniques are obsolete and should be replaced with ALV programming using the
SAP List Viewer Object model. Complete ABAP? OO programming is supported using
SALV that delivers user flexibility for output format, feature rich programming, and end
user capabilities without the need for additional programming. The area of report writing
has gone through several progressions. As a programmer you will encounter all flavors
of report programming as listed below. ? Classic List reporting using Write statements?
The first introduction of ALV with the REUSE* functions? This was then replaced with
the Class based ALV using CL_GUI_ALV_GRID? And now a complete delivery of the
ALV object model called SALV. All new report programming should use SALV* classes
Severity 5
• List Processing Event Blocks are obsolete. All report programming should be performed
using the ALV object model. Therefore, any list processing events that are traditionally
used for controlling lists in classic programming are considered obsolete. This would
include Top-of-Page, End-of-Page, New-Page, at PF. Selection screen events are still
used to support selection screens.
Interface
IDocs
Message Types
A logical name for a packet of IDoc data being sent inbound/outbound to/from SAP R/3.
Example: ZMMFDR
Position Description Value
1 Required by SAP Z
1 Required by SAP Z
1 Required by SAP Z
3-6 IDOC
8-12 INPUT
1 Required by SAP Z
3-8 MASTER
10-13 IDOC
15-20 CREATE
IDoc Types
SAP format that is used to interpret the data of a business transaction. An IDoc type
consists of the following components:
• A control record – It is identical for each IDoc type
• Several data records – One data record consists of a fixed key part and a variable data
part. The data part is interpreted using segments, which differ depending on the IDoc
type selected.
• Several status records – They are identical for each IDoc type and describe the
statuses an IDoc has already passed through or the status an IDoc has attained.
Example: Z_MM_FDR01
Position Description Value
1 Required by SAP Z
Segments
Data record of an IDoc type.
6 H – Header data
I – Item data
Inline Declarations
Use inline declaration for omitting data type declaration. The operand type of write positions
is statically fixed and well known to the compiler, hence data type declaration can be
omitted.
OLD NEW
DATA lv_var TYPE string. DATA(lv_var) = 'Hello World'.
lv_var = 'Hello World'.
DATA lv_tabix TYPE i. DATA(lv_tabix) = lines( lt_itab ).
lv_tabix = lines( lt_itab ).
DATA lt_scarr TYPE STANDARD TABLE OF SELECT * FROM scarr INTO TABLE @DATA(lt
scarr. _scarr).
SELECT * FROM scarr INTO TABLE lt_scarr.
FIELD- LOOP AT lt_scarr ASSIGNING FIELD-
SYMBOLS <fs_scarr> LIKE LINE OF lt_scarr SYMBOL(<fs_scarr>).
. ...
LOOP AT lt_scarr ASSIGNING <fs_scarr>. ENDLOOP
...
ENDLOOP.
DATA lv1 TYPE … lv_oref->meth( IMPORTING
DATA lv2 TYPE … e1 = DATA(lv1)
e2 = DATA(lv2)
lv_oref->meth( IMPORTING …
e1 = lv1 ).
e2 = lv2
…
).
Inline data declaration only works with table type with explicit key otherwise syntax error “A
value of the generic type <table type> cannot be constructed” will occur. If one doesn’t care
about the key, addition: “DEFAULT KEY” or “EMPTY KEY” can be used.
OLD NEW
TYPES ty_itab TYPE STANDARD TABLE O TYPES ty_itab TYPE STANDARD TABLE OF st
F string. ring WITH DEFAULT KEY.
DATA lt_itab TYPE ty_itab. DATA(lt_itab) = VALUE ty_itab( ( |Hello| ) ( |Worl
APPEND 'Hello' TO lt_itab. d| ) ).
APPEND 'World' TO lt_itab.
Constructor Expressions
… operator type ( … ) …
Type is either the explicit data type or the character #. Use character # if data type at
operand position is unique and fully identifiable
Instance Operator
Use NEW operator to create an object or anonymous data object. It functions like a
statement CREATE OBJECT … TYPE ….
OLD NEW
FIELD-SYMBOLS <fs_date> TYPE data. DATA lv_dref TYPE REF TO data.
DATA lv_dref TYPE REF TO data. lv_dref = NEW datum( sy-datum ).
Or
Value Operators
Use VALUE operator to create a result of a data type specified by type or at operand data
type.
OLD NEW
DATA lv_scarr TYPE scarr. DATA(lv_scarr) = VALUE scarr( carrid = 'AA'
lv_scarr-carrid = 'AA'. carrname = 'American Airlines'currcode = 'US
lv_scarr-carrname = 'American Airlines'. D' ).
lv_scarr-currcode = 'USD'.
DATA: DATA lt_r_carrid TYPE RANGE OF scarr-
lt_r_carrid TYPE RANGE OF scarr-carrid, carrid.
lv_carrid LIKE LINE OF lt_r_carrid. lt_r_carrid = VALUE #( ( sign = 'I' option = 'B
lv_carrid-sign = 'I'. T' low = 'AA' high = 'BA' )
lv_carrid-option = 'EQ'. ( sign = 'I' option = 'EQ' low = '
lv_carrid-low = 'AA'. UA' ) ).
APPEND lv_carrid TO lt_r_carrid.
lv_carrid-low = 'UA'. Or
APPEND lv_carrid TO lt_r_carrid.
DATA lt_r_carrid TYPE RANGE OF scarr-
carrid.
lt_r_carrid = VALUE #( sign = 'I' ( option =
'BT' low = 'AA' high = 'BA' )
( option = 'EQ' low = 'UA' ) ).
Conversion Operators
Use CONV operator to convert value into a data type specified by type or at operand data
type. CONV closes the gap where VALUE cannot be used to construct value for elementary
data type.
OLD NEW
DATA lv_text TYPE char255. DATA lv_text TYPE char255.
DATA lv_helper TYPE string. DATA lv_xstr TYPE xstring.
DATA lv_xstr TYPE xstring.
lv_xstr = cl_bcs_convert=>string_to_xstring
lv_helper = lv_text. ( CONV #( lv_text ) ).
lv_xstr = cl_bcs_convert=>string_to_xstring
( lv_helper ).
Corresponding Operators
Note:
• Whenever needed, use BASE addition to specify a
start value of the target structure or internal table
before the CORRESPONDING operator is evaluated.
• When CORRESPONDING is used by comparing two
internal tables, the second internal table has should
be sorted table or hashed table.
OLD NEW
... ...
MOVE- lv_struct_2 = CORRESPONDING #( BASE (
CORRESPONDING lv_struct_1 TO lv_struct lv_struct_2 ) lv_struct_1 ).
_2. ...
... lt_itab_2 = CORRESPONDING #( lt_itab_1 )
MOVE- .
CORRESPONDING lt_itab_1 TO lt_itab_2.
... ...
TYPES ty_t_source TYPE STANDARD TABL TYPES ty_t_source TYPE STANDARD TAB
E OF ty_source WITH NON- LE OF ty_source WITH NON-
UNIQUE SORTED KEY mkey COMPONENT UNIQUE SORTED KEY mkey COMPONEN
S s1 s2. TS s1 s2.
DATA lt_source TYPE ty_t_source. DATA lt_source TYPE ty_t_source.
... ...
LOOP AT lt_target ASSIGNING <fs_target>. lt_target =
READ TABLE lt_source WITH TABLE KEY CORRESPONDING #(
mkey lt_target FROM lt_source
COMPONENTS s1 = <fs_target>- USING KEY mkey
t1 s2 = <fs_target>-t2 s1 = t1 s2 = t2
ASSIGNING <fs_source>. MAPPING
IF sy-subrc = 0. t3 = s3
<fs_target>-t3 = <fs_source>-s3. EXCEPT * ).
ENDIF.
ENDLOOP.
Casting Operators
Use CAST operator to perform up-cast or down-cast for an object inside the parentheses.
OLD NEW
DATA lv_oref_structdesc TYPE REF TO cl_a DATA lv_components TYPE abap_compdesc
bap_structdescr. r_tab.
DATA lv_components TYPE abap_compdesc lv_components = CAST cl_abap_structdescr(
r_tab. cl_abap_typedescr=>describe_by_name( 'S
lv_oref_structdesc ?= cl_abap_typedescr=>d CARR' ) )->components.
escribe_by_name( 'SCARR' ).
lv_components = lv_oref_structdesc-
>components.
Reference Operators
Use REF operator to construct data reference variable at operand position. It functions like
the statement GET REFERENCE.
OLD NEW
DATA: DATA:
lv_oref_sql lv_oref_sql TYPE REF TO cl_sql_statem
TYPE REF TO cl_sql_statement, ent,
lv_oref_result TYPE REF TO cl_sql_resul lv_oref_result TYPE REF TO cl_sql_resul
t_set, t_set,
lv_statement TYPE string, lv_statement TYPE string,
lt_result TYPE STANDARD TABLE OF sc lt_result TYPE STANDARD TABLE OF
arr WITH DEFAULT KEY, scarr WITH DEFAULT KEY.
lv_oref_output TYPE REF TO data. …
… lv_oref_result = lv_oref_sql-
lv_oref_result = lv_oref_sql- >execute_query( lv_statement ).
>execute_query( lv_statement ). lv_oref_result-
GET REFERENCE OF lt_result INTO lv_ >set_param_table( REF #( lt_result ) ).
oref_output. …
lv_oref_result-
>set_param_table( lv_oref_output ).
…
Lossless Operator
OLD NEW
DATA: TRY.
lv_exact_result TYPE decfloat34, DATA(lv_exact_result) = EXACT decfloat34
lv_rounded_result TYPE string, ( 5 / 3 ).
lv_exc TYPE REF TO cx_sy_conversio CATCH cx_sy_conversion_rounding INTO D
n_rounding. ATA(lv_exc).
TRY. DATA(lv_rounded_result) = lv_exc->value.
COMPUTE EXACT lv_exact_result = CATCH cx_sy_conversion_exact_not_sup.
5 / 3. ENDTRY.
CATCH cx_sy_conversion_rounding IN
TO lv_exc.
lv_rounded_result = lv_exc->value.
ENDTRY.
Reduction Operator
Use REDUCE as iteration expression to reduce a set of data object to: single data object or
summarized data object.
OLD NEW
... ...
DATA lv_tot_seat TYPE s_seatsocc. DATA(lv_tot_seat) =
LOOP AT lt_sflight ASSIGNING <fs_sflight> REDUCE s_seatsocc(
WHERE carrid = 'AA' . INIT seat = 0
lv_tot_seat = lv_tot_seat + <fs_sflight>- FOR ls_sflight IN lt_sflight
seatsocc. WHERE ( carrid = 'AA' )
ENDLOOP. NEXT seat = seat + ls_sflight-seatsocc
).
... ...
TYPES: TYPES:
BEGIN OF ty_summary, BEGIN OF ty_summary,
carrid TYPE sflight-carrid, carrid TYPE sflight-carrid,
connid TYPE sflight-connid, connid TYPE sflight-connid,
seatsocc TYPE sflight-seatsocc, seatsocc TYPE sflight-seatsocc,
END OF ty_summary, END OF ty_summary,
ty_t_summary TYPE STANDARD TABLE ty_t_summary TYPE STANDARD TABLE O
OF ty_summary WITH DEFAULT KEY. F ty_summary WITH DEFAULT KEY.
Filter Operator
Use FILTER operator to retrieve a subset of data in a new internal table from an existing
internal table based on the where condition specified.
FILTER with EXCEPT keyword can be used as a variant for table filter which works like ‘for
all entries’.
OLD NEW
LOOP AT lt_all_sflights ASSIGNING DATA( lt_sflight_lh ) = FILTER #( lt_all_sflights
<fs_flight> WHERE carrid = 'LH'. USING KEY carrid WHERE carrid = 'LH' ).
APPEND <fs_flight> TO lt_flight_lh.
Or (with EXCEPT variant)
CLEAR: <fs_flight>.
ENDLOOP. DATA(lt_no_lh) = FILTER #( lt_all_sflights
EXCEPT WHERE carrid = 'LH' ).
Conditional Operator
Use COND and SWITCH operator to construct a result of a data type specified by type or at
operand data type based on logical expressions inside the parentheses.
OLD NEW
DATA lv_format TYPE string. DATA(lv_format) =
CASE lv_dnot. COND string(
WHEN 'X'. WHEN lv_dnot = 'X'
lv_format = 'z,zzz,zzz.zz'. THEN 'z,zzz,zzz.zz'
WHEN 'Y'. WHEN lv_dnot = 'Y'
lv_format = 'z zzz zzz,zz'. THEN 'z zzz zzz,zz'
WHEN ''. WHEN lv_dnot = ''
lv_format = 'z.zzz.zzz,zz'. THEN 'z.zzz.zzz,zz'
WHEN OTHERS. ELSE
MESSAGE 'Format is not supported' TYP THROW cx_rs_format_not_supported( )
E 'E'. ).
ENDCASE.
DATA lv_format TYPE string. DATA(lv_format) =
CASE lv_dformat. SWITCH string( lv_dformat
WHEN '1'. WHEN '1'
lv_format = 'DD.MM.YYYY'. THEN 'DD.MM.YYYY'
WHEN '2'. WHEN '2'
lv_format = 'MM/DD/YYYY'. THEN 'MM/DD/YYYY'
WHEN '3'. WHEN '3'
lv_format = 'MM-DD-YYYY'. THEN 'MM-DD-YYYY'
WHEN OTHERS. ELSE
MESSAGE 'Format is not supported' TYP THROW cx_rs_format_not_supported( )
E 'E'. ).
ENDCASE.
Sub Expressions
FOR Operator
Use FOR operator as sub expression in specific main constructor expression (NEW, VALUE
and REDUCE) to perform an iteration.
Note:
• FOR with addition UNTIL or WHILE can replace
statement DO and WHILE to create conditional
iteration.
• FOR with addition IN can replace statement LOOP to
create table iteration.
OLD NEW
DATA lt_itab TYPE STANDARD TABLE OF DATA lt_itab TYPE STANDARD TABLE OF i.
i.
DATA lv_count TYPE i VALUE 11. lt_itab = VALUE #( FOR n = 11 THEN n + 10
WHILE n < 40 ( n ) ).
WHILE lv_count < 40.
APPEND lv_count TO lt_itab. Or
lv_count = lv_count + 10.
ENDWHILE. lt_itab = VALUE #( FOR n = 11 THEN n + 10
UNTIL n > 40 ( n ) ).
... ...
DATA lv_tot_seat TYPE s_seatsocc. DATA(lv_tot_seat) =
LOOP AT lt_sflight ASSIGNING <fs_sflight> REDUCE s_seatsocc(
WHERE carrid = 'AA' . INIT lv_seat = 0
lv_tot_seat = lv_tot_seat + <fs_sflight>- FOR ls_sflight IN lt_sflight
seatsocc. WHERE ( carrid = 'AA' )
ENDLOOP. NEXT lv_seat = seat + ls_sflight-seatsocc
).
LET Operator
Use LET expression as sub expression in main constructor expression to construct auxiliary
field (helper variable) for holding data at runtime and to be used in main constructor
expression.
OLD NEW
... ...
DATA lt_scarr TYPE STANDARD TABLE O DATA lt_scarr TYPE STANDARD TABLE OF s
F scarr carr
WITH NON-UNIQUE WITH NON-UNIQUE
SORTED KEY id SORTED KEY id
COMPONENTS carrid. COMPONENTS carrid.
... ...
LOOP AT lt_sflight ASSIGNING <fs_sflight lt_itab =
>. VALUE #(
APPEND INITIAL LINE TO lt_itab ASSIG FOR ls_sflight IN lt_sflight
NING <fs_itab>. LET lv_airlines =
IF sy-subrc = 0. VALUE #(
<fs_itab>-carrid = <fs_sflight>-carrid. lt_scarr[
<fs_itab>-connid = <fs_sflight>-connid. KEY id
<fs_itab>-fldate = <fs_sflight>-fldate. COMPONENTS
READ TABLE lt_scarr WITH TABLE KEY carrid = ls_sflight-carrid
id ]-carrname OPTIONAL )
COMPONENTS carrid = <fs_sflight>- IN
carrid ( VALUE #(
ASSIGNING <fs_scarr>. BASE CORRESPONDING #( ls_sflight )
IF sy-subrc = 0. carrname = lv_airlines )
<fs_itab>-carrname = <fs_scarr>- ) ).
carrname.
ENDIF.
ENDIF.
ENDLOOP.
Table Expressions
Use ... itab[ ... ] to find row in question and returns it as the result at result position data type
or at operand data type. It can be used as an argument of the table function.
OLD NEW
DATA lv_flight TYPE spfli. TRY.
READ TABLE lt_flight INDEX 1 INTO lv_flight. DATA(lv_flight) = lt_flight[ 1 ].
IF sy-subrc = 4. CATCH cx_sy_itab_line_not_found.
... ...
ENDIF. ENDTRY.
Or
Or
Table Functions
Line Existence
line_exists checks the existence of the row in question. It returns “truth” or “false” as result.
Note: It does not fill the system fields ie: sy-tabix and sy-subrc.
OLD NEW
READ TABLE lt_flight INDEX 1 TRANSPORTING IF line_exists( lt_flight[ 1 ] ).
NO FIELDS. ...
IF sy-subrc = 0. ENDIF.
...
ENDIF.
Line Index
line_index returns the number of row found of the row in question. If it is not found, no
exception is raised, value 0 is returned instead.
Note: It does not fill the system fields ie: sy-tabix, and sy-subrc.
OLD NEW
DATA lv_idx TYPE sy-tabix. DATA(lv_idx) = line_index( lt_flight[ carrid = 'AA' ] ).
READ TABLE lt_flight WITH KEY carrid = 'A
A' TRANSPORTING NO FIELDS.
lv_idx = sy-tabix.
String Expression
String expression chains two or more operands to create character string. String expression
consists of string operator or string template.
String Operator
Use string operator && to concatenate two or more operand in a string expression.
String Template
String template is enclosed by two characters | within the same line to create character
string.
Use control characters: \n, \r and \t to display line break, return and tabulator in the output.
lv_text TYPE string.
lv_text = |First line.\r\ttab\ttab\n\ttab\ttab\rLast line.|.
Use embedded expression { … } within string template. Depends on the effect, some can be
used together.
lv_text = |{ 'Hello World' WIDTH = 20 ALIGN = CENTER CASE = UPPER PAD = '*' }|.
Below are the predefined format of embedded expressions and the effects
Function Modules
Severity 1
BDCs are very performance intensive and all measures should be taken to NOT
create BDCs unless absolutely necessary. First check for an existing BAPI and if
it does not exist, check for new BAPIs on OSS (possible to add them to our
current system).
Batch data input sessions should be limited to approx. 250 @actions per BDC
group. This number can vary greatly depending on the quality of the data being
processed. Large batch ABAP programs are to be avoided due to the single-
threaded nature of the batch environment. These programs are to be broken up
into smaller batch programs, where appropriate.
Utilize transaction code SHDB to record an R/3 transaction and generate a
program skeleton contains all screen and field information in the required BDC
format. Replace the field entries you wish to convert as variables and add the
necessary file handling logic to the generated program.
Note:
BDC technology relies on screen layouts. If a screen layout changes, the code
stops working. This makes the code highly unreliable during the application of
Support Packs, Enhancement Packs and Upgrades. Therefore programs need to
use BAPIs to submit business functions. - Submitting database operations
directly from ABAP by calling database functions directly (e.g.
'DB_COMMIT"). Any use of these functions introduces a high risk of transaction
inconsistencies and needs to be avoided.
• When creating a new user exit, always create a new INCLUDE for your specific
task, unless this is a BADI implementation. This will keep the code separate
from other developers and will allow changes for multiple projects.
• Verify the version you are working on is the same as the version in production. If
not work with other developer who is working on the user exit to make sure these
will move to production in the proper order, without overwriting one another’s
code.
• Do not use CALL TRANSACTION, COMMIT WORK, CHECK, EXIT statements
or add any new popup windows within a user exit. Any of these statements can
have adverse effects. If you must call a function or transaction that will do a
COMMIT WORK, call it in a SEPARATE TASK so it does not have any negative
effect on the current transaction.
Example: change is needed in MV45AFZZ, find the place you need the code
and insert the following code (named according to your project) and make all
changes within the include:
INCLUDE z_sd_mv45afzz_2225_gof.
Note: Be certain to not use EXIT statements in this new INCLUDE,
because if there are multiple INCLUDES after yours they may not get
executed.
CMOD / SMOD
Transaction SMOD is used to view SAP Enhancements. CMOD is used to implement
an enhancement into a project.
BADI
Note: To see what BADIs are called for any given transaction, go to
se37 and put a break-point within the function
SXV_GET_CLIF_BY_NAME. View the name field when the break-
point is hit – this will give you all BADIs which are executed.
SAP has implemented numerous areas where custom development can be placed
using BADIs. When possible, the development team should attempt to implement a
BADI rather than a CMOD or basic user exit because there can be multiple
implantations of these without any issues.
To view BADIs available through transaction se18; to create a BADI use transaction
se19.
VOFM
The VOFM transaction is used for Requirement and Formulas. The functional analyst
should tell you the menu path and the original requirement to copy from. For example
the requirement may be for a new Scale Based formula, the functional spec should
specify to follow the menu path:
The developer should create a new routing (by entering a 3 digit number starting with 9,
when double clicking on the new routine number, the developer will be asked for an
object access code. The developer should screen print this and send the request to
your development manager (along with the PR / SR and description of use). The
development manager will approve it and send the request to the IT BSG Netweaver
team to get the access code. Once this has been received, the developer can then
copy the code from the original routine into the new routine and make required changes.
Dialog Programming
• Entering data
• Choosing a menu item
• Clicking a button
• Clicking or double clicking an entry
Position Description Value
7-8 User
defined;
should be
meaning
full for the
application
PF-Status
PF Status is a custom status bar defined to be used by a screen, or interactive program
to enable user actions. The standard SAP format must be used. The table below
defines the usage of standard function keys. These function keys do not have to be
enabled but when used, must comply- with the standards defined in this section.
These function keys are not to be replaced by user-defined keys.
PF Key OK-CODE Description
09 MARK Select
10 Menu bar
13 PRINT Print
14 DELETE Delete
Include programs
Position Description Value
1–5 Same as
positions 4-8
in Module pool
name
6–8 Object name TOP – Data declarations
Onn – PBO modules (nn = 01 – 99)
Inn – PAI modules (nn = 01 – 99)
Fnn – Forms (subroutines) (nn = 01
– 99)
Screen painter
SAP screens are referred to as dynpros. Standard SAP components, such as
transactions, menus and tables contain dynpros and the associated processing logic. A
developer may also create customized dynpros.
The identification of a screen painter dynpro consists of an ABAP program name and a
four-digit dynpro number. The number range reserved for custom dynpros should be
between 9000-9999. The initial screen number for a given transaction should be 9000
and additional screen numbers increment by 10. Example: Module Pool: SAPMZF01
Screen #: 9000
Flow logic
***************************************************************
Process Before Output.
module SET_STATUS. " Called by all screens
*Enter screen specific modules here i.e. dynamic screen *locking, etc.
***************************************************************
Process After Input.
* Process fast-exit commands
module PAI_EXIT AT EXIT-COMMAND. “Called by all screens
* Enter screen specific modules here i.e. Field checks, Loops, * Table
Controls etc.
Modules
************************************************************
* Module PAI_INPUT INPUT
************************************************************
* <descriptive text>
************************************************************ MODULE
PAI_INPUT INPUT.
CASE SY-DYNNR. " Interrogate screen number
WHEN ‘0100’. "Screen 0100
SET SCREEN 0.
LEAVE SCREEN.
WHEN ‘0200’. "Screen 0200
* First process any de-queuing of entries, pop-ups to confirm data loss, etc.
CASE SY-UCOMM. " Interrogate system field to find out which fast
exit pressed
WHEN ‘RW’.
SET SCREEN 0.
WHEN OTHERS.
SET SCREEN 0100.
ENDCASE
LEAVE SCREEN.
*... Add any subsequent screens
ENDCASE.
INPUT
************************************************************
* Module USER_COMMAND INPUT
************************************************************
* <descriptive text>
************************************************************
MODULE USER_COMMAND INPUT.
“codes
*... Add subsequent screens
ENDCASE.
Class Properties
Instantiation
Consider using private instantiation and offer appropriate factory methods. This allows
you to:
-Control the instantiation of your class from within the class.
-Control the parameters passed to the constructor.
-Share the instances of your class effectively by passing the same object reference to
different clients when appropriate.
Final
Set classes as ‘Final’. Remove the ‘Final’ setting only when sub-classes are needed
for inheritance.
Use inheritance moderately. When in doubt, prefer interfaces to achieve polymorphism.
Inheritance is one of the most powerful, but also one of the more subtle features ABAP
OO offers. If you use inheritance (e.g. for reusing method implementations), keep the
paths of your inheritance tree short and terminate them with final classes. For the reuse
of interfaces, exploit the concept of interface composition in favor of inheritance.
General Data
Field Setting
Released internally Always blank.
Fixed point arithmetic Always marked to on.
Unicode checks active Always marked to on.
Shared Memory-Enable Optional.
Message Class Optional.
Program Status Set to ‘Customer Production Program’
Forward Declarations
Forward Declarations replace Type-Pools and Include statements. Therefore, use
‘Forward Declarations’ to pull in pooled statements rather than coding the TYPE-
POOLS or INCLUDE statement within class methods.
Documentation
Note: Class history (flowerbox) should be maintained at the bottom of the
Class Documentation.
See the class ZCL_AU_ STANDARDS_EXAMPLE.
• Use the Method Documentation editor to document all class methods. It is
mandatory to document all public and protected methods. Documentation for
Private methods is optional. However, complex logic should be documented within
the method to enable easier maintenance.
• Use the Class Documentation text editor to document the Class and include links to
the public method documentation. Links are added by using the menu path Insert-
>Link and then choose ‘Class-Method’.
• Class history (flowerbox) should be maintained at the bottom of the Class
Documentation. To paste in the template while editing Class Documentation,
navigate the menu path: Insert →Text → Documentation. On the pop-up screen,
enter “Z_MAINTENANCE_LOG” for the text name and select the option ‘Expand
Immediately’. Once the template is pasted into your class documentation, modify as
desired.
Attributes
Note: The visibility preference of attributes is private or protected over
public. When public visibility is required, they should be declared as
‘READ-ONLY’, unless there is justification. Public attributes that are not
declared as ‘READ-ONLY’ compromise the encapsulation property of
object-oriented programming.
• Always declare attributes as private or protected where possible.
• If public attributes are required, they should be declared as ‘READ-ONLY’,
unless there is a requirement to reduce encapsulation.
• Only create a global attribute if the attribute is used by more than one method
or by external classes. Otherwise keep attributes defined within their local
methods.
• Like vs. Type
In data definitions, use TYPE instead of LIKE to be ABAP OO compliant.
Methods
• Methods that can be set with ‘Private’ or ‘Protected’ visibility, must be set
accordingly.
• Document all public and protected methods using the method documentation
editor, with the exception of the CONSTRUCTOR and
CLASS_CONSTRUCTOR classes. Method documentation is not required for
the CONSTRUCTOR and CLASS_CONSTRUCTOR methods.
• The cyclomatic number of a method (the number of branches due to tests)
should not be greater than 10.
• See the section ABAP Object Component Naming Conventions, for method
naming convention.
• Use exception classes for error processing.
• The use of static methods, such as CLASS_CONSTRUCTOR, should be
limited. Instantiation is preferred over the direct use of classes via static
methods are that you can: o Use inheritance and method redefinition, if
needed.
Documentation Category Selective
Jabil Proprietary and Confidential Printed copies are reference only 04-IT60-STS-001 Rev A
Page 68 of 103
ABAP Coding Standards and Guidelines
Revision A Released Date AUG/11/17
• Method parameters are regarded from the point of view of the method that
implements them. Please see the section, Data Definition Naming
Conventions, for method parameter naming conventions.
Class-local types
When defining local classes and local types within a global class, separate the local
class definition and types from the local class implementations, into their proper
locations. See the workbench menu for Class-local types in the class builder.
Macros
Use methods or procedures to modularize the functionality of a program, rather than
macros.
The use of macros is discouraged for the following reasons:
• They increase difficulty of reading code.
• Their implementation provides only bare minimum of functionality.
Exception Classes
• In exception processing use class-based exceptions.
• Do NOT catch exceptions by specifying the abstract root classes of the
exception tree: CX_ROOT, CX_STATIC_CHECK, CX_DYNAMIC_CHECK
and CX_NO_CHECK. Only use the abstract root classes when catching
exceptions at the highest levels of software architecture (e.g., some global
dispatcher, garbage collector, network connection, etc). When creating a
new exception sub-classes, determine the right exception type super-class:
CX_STATIC_CHECK, CX_DYNAMIC_CHECK or CX_NO_CHECK.
1 Mostof these ABAP OO standards are reproduced from the articles “An insider guide to writing awesome
ABAP programs Part 1 -3”. Authored by Andreas Blumenthal and Horst Keller. These articles appeared in
the SAP Professional Journal January-March 2006.
1–4 Webdynpro
component name
should start with
zwd_.
7 underscore
Supply Function
Supply_<name>
Plugs
Outbound plug: TO_<target view name>
Inbound plug FR_<source View name>
UI Elements Names
Element Name
BTN_<any_name>
Button
Caption CAPTION_<any_name>
CheckBoxgroup CBG_<any_name>
DropDownbyIndex DDBI_<any_name>
DropDownbyKey DDBK_<any_name>
FileDownload FD_<any_name>
FileUpload FU_<any_name>
Group GR_<any_name>
Horizontalgutter HG_<any_name>
Inputfield INP_<any_name>
ItemlistBox ILB_<any_name>
Image IMG_<any_name>
Label LBL_<any_name>
MessageArea MSA_<any_name>
PageHeader PH_<any_name>
RadioButton RB_<any_name>
RadioButtonIndex RBGI_<any_name>
Tab T_<any_name>
Table TBL_<any_name>
Tableheader TBLH_<any_name>
TableColumn TBLC_<any_name>
TableCellEditor TBLCE_<any_name>
TableColumnHeader TBLCH_<any_name>
TabScript TS_<any_name>
TableContainer TC_<any_name>
TextEdit TXTE_<any_name>
TextView TXTV_<any_name>
ToolBar TB_<any_name>
Tree TR_<any_name>
TreeItemType TIT_<any_name>
TreeNodeType TNT_<any_name>
TriStateCheckBox TSCB_<any_name>
ViewContainerElement VC_<any_name>
Assistance Class
ZCL_SD_ASSIST_ <desc>
In the description/documentation of Assistance class provide full name of webdynpro
component.
• Use Assistant class for coding that is required within the component, but is not linked
directly with the layout or with the function of a controller. This could be, for example,
a call of the application layer or UI-based editing of the data.
• All text elements should reside in Assistance class.
Model Class
Model class name should follow Jabil Class naming standards. In addition, provide web
Dynpro component in description field.
• Number of controllers used by each controller should not exceed 8. For example,
if you are using component controller and custom controllers.
Generation Limit
Generation limit check should return all green lights when applied for Web Dynpro
components.
Right click on Webdynpro Component -> Check -> Generation Limit.
Development Tips
Dos and Dont's: Web Dynpro Components
• Use Web Dynpro components only for managing the views and context. Note
that Web Dynpro components are not lightweights!
• Delete all Web Dynpro component instances as soon as they are no longer
needed. To do that,
useIF_WD_COMPONENT_USAGE=>DELETE_COMPONENT.
• Use dynamic navigation or dynamic component usages only if it is absolutely
necessary. Set the lifetime of a view to when visible, if the view is displayed
only once in an application.
• Singleton Node:
When you create a context node below the root node, the Singleton checkbox
is selected by default. If you have deep data structures with large amounts of
data, consider only loading the data for the selected element of the main node
into the memory. The other factor to consider, however, is the performance loss
connected to the required invalidation and refilling of the corresponding context
node or nodes. You need to decide whether to minimize the memory load
created by large amounts of data or minimize the runtime caused by invalidation
and filling actions. Use singleton nodes only if the data in the memory will reach
a critical amount if you take no action. If not, you may prefer to work with non-
singleton nodes and delete any data that you do not yet need, or will never need,
from the memory explicitly.
• Supply function:
▪ Supply functions can only access context data that is contained in the
corresponding parent node or is contained in another node that is on a
next-highest level compared to the node filled by the corresponding supply
function.
Dialog Box
Dialog boxes / popups are special display elements that open alongside a running
application. Dialog boxes always start a separate phase model instance, which means
that their source window cannot be refreshed or edited while the dialog box is open
(while the phase model instance still exists). You can avoid dialog boxes in many cases
by displaying content in an additional window view. This removes the source of many
errors and improves performance.
SAPscript forms
When customizing SAPscript forms for Jabil, follow these standards. Properties
(language key, default text format, etc.) that are not mentioned in this document should
use the SAP defaults.
Documentation Category Selective
Jabil Proprietary and Confidential Printed copies are reference only 04-IT60-STS-001 Rev A
Page 78 of 103
ABAP Coding Standards and Guidelines
Revision A Released Date AUG/11/17
Note:
• SAPscript forms are client-dependent objects, please create them in the
Configuration client, DEV 010, and transport them to the other DEV clients for
unit testing.
• SAP script form design and configuration should be in dev010, but the
subroutines which can be called from inside script should be done in dev20
(since it is an ABAP report). If you write your own SAP script program (called
print program), you should do it in dev020 too (Because it is an ABAP report).
• The user settings determine how information is presented to the user. Although
the same standards apply whichever settings are chosen, this document
contains screens based on the settings shown below. From the initial SAPscript
screen (SE71) follow Settings > Form Painter.
5 Separator _
X – Vidifax
Z0114_PORX (Bedford custom
Vidifax)
1 Custom indicator Z
2 Underscore _
5 Underscore _
All other settings Use original form setting unless otherwise necessary.
Layout Windows
Windows should have descriptive names.
• MAIN – Contains Line item information.
• XXXXADDR – Address (XXXX – 4-char description of address).
• XXXTOTAL – Total (XXX – 3-char description of total (QTY, INV, etc.))
• HEADER – Header Information
• FOOTER – Footer Information
• LOGO – Jabil Logo
Paragraph Format
Paragraph name: Length 2. First character must be a letter.
Note: Be cautious when changing an SAP defined paragraph, a change can have odd
results if it’s used in other parts of the form. It’s better to make a copy in most cases.
Character Format
Character Format Name: Character length 2.
Text Elements
Names should be descriptive. Spaces are not allowed per SAP.
Windows
Window Name: 8-char (as descriptive as possible)
Window Types
• /: ENDADDRESS
Fonts
When possible, use the same font type throughout the form. Also, use the same font
sizes for the main body of the layout. Use bold characters to highlight text.
Window coordinates
In specifying window coordinates and sizes, use whole numbers as much as possible.
Printer
In order to make sure that the layout set functions properly, the configuration of the
output device should be checked. Confirm that the print control device defined for the
printer is capable of printing the text formats (font type, font size, character pitch) and
paper size. For double-sided printouts, the printer definition should be checked.
Advanced modifications
Do not modify the Print Program unless other options have been ruled out. This is due
to the complexity of the maintenance issues. Most modifications can be met with
SAPscript Form commands. In SAPscript, you can use the PERFORM command in a
window to carry out advanced functions like:
• Obtain data from the database that is needed at print time
• Access tables not declared in the print program
• Carry out complex ABAP calculations
• Format data
Do not confuse the SAPscript PERFORM command with the ABAP PERFORM
statement. A special table structure is used with the SAPscript PERFORM command.
Adobe Forms
PDF Scenarios
Print Forms
Print forms are PDF forms that are used for output purposes only. No user interaction is
possible.
Online Scenario
Online scenarios feature the following characteristics;
• access to an SAP system is required and possible
Offline Scenario
Offline scenarios feature the following characteristics;
• no access to an SAP system is possible or required
• independent from other user-interface technologies
Print program
In order to call PDF form either Print form or Offline interactive form, program should
follow below sequence of function module;
• FP_JOB_OPEN
• FP_FUNCTION_MODULE_NAME (Form name never hard coded)
• CALL <Name_Returned_From_ FP_FUNCTION_MODULE_NAME>
• FP_JOB_CLOSE
To avoid hard coding form name in program to get its function module
name, while defining output type in NACE, remember to add form name in
“PDF/Smartform Form” field and “Form Type” as PDF. At runtime, NAST
structure field SFORM will contain form name.
Unless a specific output device is required, the default printer should be set to ‘PDF1’.
This will resolve to the default PDF printer for any user.
Note:
For print program syntax, follow ABAP coding standards as laid out in the ABAP
sections of this document.
Naming Conventions
Interface
Interface Name
Position Description Value
Interface Elements
Position Description Value
EX Exceptions
Global
Definitions
(Global Data)
V Variable
S Structure
T Table
TY Types
<fs> Field Symbols
Initialization
IO Code Initialization
Forms
Naming an Adobe form will depend on whether the form has been copied from a
standard SAP form template or created entirely as custom. If the form has been copied
from a standard SAP template, the original name of the form needs to be included in the
form name. This creates a logical link between the two and also simplifies the process
of locating existing versions of the template.
For Example:
VICS_BOL as Z_SD_VICS_BOL
Print Forms
Position Description Value
1 Always contains this static Z – Customer program for production Y –
value -> Test program
Note:
When the form is a copy of a standard SAP form, the
description should be the SAP form name
Interactive Forms:
Position Description Value
1 Always contains this Z – Customer program for production
static value -> Y – Test program
2 Underscore To promote readability
3 to n Mode ONLI for Online form
OFFL for Offline form
n+1 Underscore To promote readability
Note:
When the form is a copy of a standard SAP form, the
description should be the SAP form name
FOL Folder
DTA Data
STR Structure
LOP Loop
Standard Objects
Position Description Value
SUB Subform
NUM Numeric
TBL Table
TXT Text
DEC Decimal
DAT Date
TIM Time
CIR Circle
REC Rectangle
LIN Line
BAR Barcode
Configurable Objects
Form Interface
While creating form Interface, keep all interface parameters as optional. This will allow
more flexibility to use same Interface for multiple forms.
Adding program logic in Form Interface is not allowed for all custom print programs.
For all SAP Standard Print Programs, copy to a Z Program and make necessary
modifications. If Standard Program not feasible to be copied, we can write code in
Interface in below cases:
▪ Minor additions like Address, Logo, Header/Footer text etc needs to be displayed in
output.
▪ Existing internal table / Structure available in Form Interface parameters is short of
fields to be displayed and additional data at item level needs to be added. The data
retrieval logic will be added only for newly added fields with simple data selection
logic. Complex data selection logic should be avoided in order to have good
performance.
Note:
Before starting the development, requirement to add logic in Interface, please make
sure to discuss with any of the Tech Leads.
Standard Texts
Texts should not be placed directly onto a form but created as Standard Texts in
transaction SO10 ’s and defined in the form context in ADLC.
Image Library
Form graphics (such as logo’s, signatures, etc) should be created in the SAP Form
Graphics library (transaction SE78) and bound to a graphics node in the form context in
ADLC.
Address Nodes
Address lines should not be passed directly to a form unless a specific format
unsupported by ADLC is required. Address nodes should be created in the form
context in ADLC and bound to an address number for automatic formatting.
Context View
Address Node
Image Node
Text Node
Scripting
For Adobe print forms scripting should be kept to a
minimum. FormCalc should always be used over Java
Script.
Master Pages
Master pages should be used sparingly and should only contain template objects that
should appear on multiple pages. In the case of a single page form, only objects that
would logically appear on multiple pages should be placed on the master page.
Examples;
Page numbers, logo’s, headers and footers, layout guides
Documentation
Form documentation should be maintained. To maintain form documentation navigate
to menu path Goto→Documentation→Change from the Form Builder.
Workflow
Workflow Naming Standards
Packages
Workflow related developments will be grouped under separate package for each
functional area. Z_MM_WF
Z_SD_WF
Z_FI_WF
Z_PP_WF
Z_SM_WF
Z_QM_WF
Z_PM_WF
Z_HR_WF
Z_CA_WF
Position Description Value
Workflow Templates\Task\Rule
Abbr.: Start with ZMM_PURQ
Position Description Value
Business Object
Subtype Naming Standards i.e. BUS0022
Object Type: Example ZBUS0022
➔ Uses prefix ‘Z’ along with complete BO name.
Appendices
Functional Areas
Abbreviations
SD – Sales/distribution
BD – Basic Data
BI – Billing
CS – Sales Support
CX – Common across SD
ED – EDI
IS – Sales Info system
SH – Shipping
SL – Sales
SO – Sales Order Management
TR - Transportation
MM – Material management
BD – Basic Data
CM – Common across MM
ED – EDI
IM – Inventory Mang.
PI – Purchasing Info System
IV – Invoice Verification
PR – Purchasing
WM – Warehouse Mang.
CB – Consumption- Based Planning
PP – Production planning
PD – Plant Data Collection
AO – Assembly Orders
PC – Planning & Control
PO – Production Orders
MD – Material Requirements Planning
CP – Capacity Planning
MP – Master Planning
SP – Sales & Operations Planning
FI – Financial
AP – Accounts Payable
AR – Accounts Receivable
CF – Common across FI
ED - EDI
FC – Financial Controlling
FM – Funds Management
GL – General
Ledger LC –
Consolidation
SM – Service management
QM – Quality management
QP – Quality Planning
QI – Quality Inspection
QC – Quality Control
CA – Quality Certificates
QN – Quality Notifications
PM – Project management
HR – Human Resources
BD – Basic Data
CC – Common across HR
PA – Personal Administration
TI – Time Management
IW – Incentive Wages
BN –
Benefits PY
- Payroll
CA – Cross-Application Components
AU – ABAP Development Utilities
MD – Master Data Management
ABAP OO Programming
Parameter Data Type Prefix Rule Example
Type
Importing single fields, i_ singular nouns i_document_number
generics,
numeric
objects io_ singular nouns io_grid
8. Revisions History & Change Details: Go back to cover page – click HERE