Академический Документы
Профессиональный Документы
Культура Документы
Standards
Speaker name
:
Anuradha GRao
Title, HP
: Coding
Standards
2004 Hewlett-Packard Development Company, L.P.
The information contained herein is subject to change without notice
Date
:
Introduction
1. This document explains the standards of coding while handling different
type of objects.
04/05/16
HP Confidential
Coding Standards
04/05/16
HP Confidential
Coding Standards
Naming Conventions
ABAP Dictionary naming conventions have been defined for
each of the following object types:
Table
Structure
View
Append Structure
Field
Data Element
Domain
Lock Object
Search Help
Secondary Index
BAPI Fields
04/05/16
HP Confidential
Coding Standards
04/05/16
HP Confidential
Coding Standards
Database Table
Format:
Zyxn
Z = Fixed text for custom object designation
y = Site code
x = Alpha characters based on the standard abbreviations of the key fields
n = Optional numeric counter if necessary to make the object name unique
Examples:
Z1DFCHRFMD Default Characteristics Per Reference Model
ZGBLDCNORN Billing Document Number Ranges
04/05/16
HP Confidential
Coding Standards
Structure
Format:
ZyS_xn
Z = Fixed text for custom object designation
y = Site code
S_ = Fixed text for structure designation
x = Alphanumeric characters referring to the primary table name on which
the structure is based. If it is based on multiple tables or not based on a
table, then provide the abbreviation of a meaningful name by using the
Standard Abbreviation List.
n = Optional numeric counter if necessary to make the object name unique
Examples:
ZGS_KNA1 for standard SAP table KNA1
Z1S_BWRFMD BW Reference Models
04/05/16
HP Confidential
Coding Standards
View
A view is a virtual table that logically relates to one or more tables. That
is, the data of a view is not actually physically stored, but derived from
one or more other tables. A view can be tailored to the needs of a
specific application, making it possible to directly access specific data.
Format:
ZyV_xn
Z = Fixed text for custom object designation
y = Site code
V_ =Fixed text for view designation
x = Name of the view based on primary key of table
n = Optional numeric counter if necessary to make the object name unique
Examples:
ZGV_KNA1 for standard SAP table KNA1
ZGV_KNA101 for standard SAP table KNA1
04/05/16
HP Confidential
Coding Standards
Append Structure
An Append Structure is used to extend a standard SAP table with custom
fields. It is not a separate dictionary object like a Structure, but is
defined/maintained only through the table definition screen. The primary
advantage of using an Append Structure is that it is protected from being
overwritten when the system is upgraded. Therefore, after an upgrade the
fields in an Append Structure are added to the new standard tables, thereby
maintaining any custom extensions that may have been added to SAP
standard tables.
Format:
During the process of creating an Append Structure, the system proposes a
default name. The current standard is to accept the proposed name.
Examples:
ZAVBAK
04/05/16
HP Confidential
Coding Standards
Field
It is important to note that a field is not an object in the ABAP Dictionary.
It has no associated description, but it provides the link between a table and
a data element, which contains a description. The data element provides the
link to a domain, which contains the physical characteristics of the field.
Format:
ZZx
ZZ = Fixed text for custom object designation
x = Alphanumeric Characters from data element
Custom Table Field
x = Alphanumeric Characters from data element
Examples:
Table type
SAP
Custom
SAP
Custom
04/05/16
Field name
ZZWERKS
WERKS
ZZDELFLAG
DELFLAG
Data element
WERKS
WERKS
ZZGDELFL
ZZ1DELFL
HP Confidential
Coding Standards
Domain
WERKS
WERKS
ZZGFLA
ZZ1FLAG
10
Data Element
A Data Element stores field descriptions. All fields assigned to a data
element will have the same description. Data Elements also store the domain
name which contain the physical characteristics of a field
ZZyx
Format:
ZZ = Fixed text for custom object designation
y = Site code
x = Alpha characters based on the standard abbreviations of the Data
Element description
Examples:
ZZ7ORHDSTCD Order Hold Status Code
ZZGATTGNO Asset Tag Number
04/05/16
HP Confidential
Coding Standards
11
04/05/16
HP Confidential
Coding Standards
12
Domain
A Domain stores physical characteristics of a field; i.e., Data Type, Length,
and Range of Values, Validation Table are defined for a Domain.
Format:
ZZyx
ZZ = Fixed text for custom object designation
y = Site code
x = Alpha characters based on the standard abbreviations of the Domain
description
Examples:
ZZ7ORHSTCD Order Hold Status Code
ZZGAPOPCTY APO Procurement Type
04/05/16
HP Confidential
Coding Standards
13
Lock Object
Lock Objects prevent two or more users from simultaneously accessing the
same logical unit of data. Locks on the data are set or released by calling
certain function modules in an ABAP program. These functions are
automatically generated during the creation of the lock objects. Lock objects
must be defined in the ABAP Dictionary.
Format:
Ext
Examples:
EZ3TSLSORDX for a lock object for the table Z3TSLSORD
04/05/16
HP Confidential
Coding Standards
14
Search Help
Help views are used to output additional information when the online help
system is called.
Format:
Zyx
Z = Fixed text for custom object designation
y = Site code
x = Name of the standard object the Search Help is based on
Format for Custom Tables / Objects
x
x = Name of the custom object the Search Help is based on.
Examples:
ZGKNA1 for SAP standard table KNA1
Z3TFGFCST for custom table Z3TFGFCST
04/05/16
HP Confidential
Coding Standards
15
Secondary Index
The function of an index is to speed up the retrieval of data from a table.
An index is usually created on specific fields on the table based on the
retrieval search criteria.
Format:
Zn
Z = Custom Designation
n = A Number from 1-9
Examples:
Z1
Z2
04/05/16
HP Confidential
Coding Standards
16
BAPI Fields
BAPIs are interfaces for Business Objects. Together with the Business
Objects, BAPIs define and document the interface standard at the business
level. BAPI fields are merely fields within a structure in the ABAP
Dictionary. A BAPI structure is used to pass data to and from a BAPI
function module. Because the structure has visibility outside of SAP, it
makes sense to use meaningful descriptive names for the structure fields.
Format:
Program BAPIFELD, offered in SAP 4.6, generates English defaults for
external BAPI structures. The recommended default values should be used
when creating BAPI related structures.
Examples: N/A
04/05/16
HP Confidential
Coding Standards
17
04/05/16
HP Confidential
Coding Standards
18
HP Confidential
Coding Standards
19
Programming Conventions
Readability of the source code can be improved dramatically by following
certain standard programming conventions and style guidelines as follows:
Type 1 (executable) programs should be arranged in the following generally
accepted sequence:
Report statement
Table declarations
Data declarations
Data INCLUDES
Selection screen definition
Initialization
At selection-screen
Top-of-page, End-of-page
At line-selection, At user-command
Start-of-selection
End-of-selection
Forms
Form INCLUDES
04/05/16
HP Confidential
Coding Standards
20
04/05/16
HP Confidential
Coding Standards
21
HP Confidential
Coding Standards
22
04/05/16
HP Confidential
Coding Standards
23
04/05/16
HP Confidential
Coding Standards
24
04/05/16
HP Confidential
Coding Standards
25
Programming Authority-Checks
All custom ABAP programs and reports must address the need for security.
Some reports may not need to have an authority check if they do not
display sensitive data. Corporate guideline for Handling and Managing HPs
Information Assets, http://legal.hp.com/linkpub/chart.pdf, should be
followed. Document required special handling should have an authorization
check. This check allows Security Administration
04/05/16
HP Confidential
Coding Standards
26
04/05/16
HP Confidential
Coding Standards
27
Development Steps
Identify the field and values that are to be checked in the ABAP program.
Fields and values check are defined by the business processes as defined
by business owner. Past practices of linking the program attributes
authorization group to user security is not used.
Document the field and values required for this object to Security
Administration. Security Administration then creates the object with the
fields defined by the developer and notifies the developer of the
authorization object name. Security Administration will create a user to
test the object with.
Validate the authorization checks with the test user for that object. This
must be a joint effort between Security Administration and the
developer. Different values in the authorization need to be checked in
order to determine if all possible values are controlled by the program.
Once the testing and the object is ready for implementation, it will be
transport to production.
Inform the appropriate application module team of the authorization
objects so that it can be incorporated into programs and reports.
04/05/16
HP Confidential
Coding Standards
28
04/05/16
HP Confidential
Coding Standards
29
Process
CMODGotoText EnhancementsData ElementsNew DE Cust. Docu.
Customer Documentation Pop-Up screen appears. Enter the data element
name and press green check.
Document Maintenance: Initial Screen. Hit the DISPLAY button (or
CREATE if no documentation exists).
If DISPLAY was pressed, hit the CHANGE<>DISPLAY button.
Enter the following tags and text into new lines below any existing
documentation text:
U1
AS
U1
AS
U1
BL
04/05/16
Coding Standards
30
Examples
*
U1
AS
U1
AS
AS
AS
BL
BL
BL
BL
BL
BL
BL
BL
BL
04/05/16
ZP_STCLAS
HP Confidential
Coding Standards
31
04/05/16
HP Confidential
Coding Standards
32
Development Classes
Used to specify the transport layer for all included objects
Used to secure development access via S_DEVELOP authorization object
Used as nodes in the Application Hierarchy (transaction SE81)
Used as an object listing mechanism in the ABAP Workbench
Can easily transport all objects in a development class
04/05/16
HP Confidential
Coding Standards
33
Description
Examples
Z = Custom development
_B
04/05/16
HP Confidential
G = Global
1 = EMEA
3 = NA
7 = AP
R = Report
E = Enhancements
C = Conversions
I = Interfaces
M = Modifications(copies of SAP programs, or
includes inside SAP programs userexits,
function exits, etc.)
FIAA = Asset Accounting
FIAROI = Accounts Receivable\Open Items
FIARDU = Accounts Receivable\Dunning
FIARCR = Accounts Receivable\Correspondence
SDCM = Credit Management
SDEDI = IDoc interfaces for EDI
SDSLSSO = Sales\Sales Orders
SDPR = Pricing and Conditions
LOLIS = Logistics Information System
LOMM = Material Master
LOPDM = Product Data Management
MMPURPO = Purchasing\Purchase Orders
LESHP = Shipping
HERT, BACKPLANE, PIT, SMART_ATP
Coding Standards
34
Category
Development Class
Description
Reports
ZGRFIAROI
Z1RSDPR
Interfaces
Z3ILESHP_HEART
ZGISDPR_CPL
Conversions
ZGCSDSLSSO
Z7CFIAPOI
Enhancements
ZGESDOC
Z1ESDPR
Z3EFIARDU
04/05/16
HP Confidential
Coding Standards
35
Program Objects
Object Type
Executable
programs
(Non-IM3
development)
Explanation
da
d = Development
class
a = Description
Executable
program includes
bcnn
Module pool
SAPMdnn
Module pool
includes
04/05/16
Convention
Mdnntnn
b = main program
name
c = TOP for gobal
data
O for output
modules
I for input
modules
F for form
routines
nn = two digit
number for O, I, and
SAPM = fixed prefix
F
d = development
class
nn = 2 digit number
M = fixed prefix
dnn = module pool
suffix
tnn = TOP, Onn, Inn,
Fnn
(e.g. SAPs internal
convention)
HP Confidential
Examples
Z3RSDPR_OPENITEMS
ZGRFIAR_OVER90DAYS
Z3ILESHP_HEART_DELIVERIE
S
Current & Future
Z3RSDPR_OPENITEMSTOP
Z3RSDPR_OPENITEMSO01
Z3RSDPR_OPENITEMSI01
Z3RSDPR_OPENITEMSF01
Current & Future
SAPMZGECSSE01
Current & Future
MZECSSE01TOP
MZECSSE01O01
MZECSSE01I01
MZECSSE01F01
Current & Future
Coding Standards
36
Contd.
Transaction code
dnn
Function Group
dnn
Best practice is to
use the same suffix
as corresponding
module pool. When
impractical, the
format Zyb may be
used, where:
Z = Custom
development
y = Site code
b = Short
description
In addition, system
generated tcodes
names
are also
d = development
permitted.
class
nn = 2 digit number
Function Module
Zy_b
Layout Set
Zyxx_b_c
04/05/16
Z = Custom
development
y = Site code
b = Short
description
Z = Custom
development
y = Site code
xx = Application area
b = Org code, region
code, or country
identifier
c = Document type
HP Confidential
ZGECSSE01
ZGELESHP01
Current & Future Future
ZG_SERIAL_NUMBER_STATUS
Z3_IDOC_OUTPUT_ZORDERS2
Current & Future
Z1SD_NA_BILLING_DOCUMENT
Current & Future
Coding Standards
37
Contd.
Classes
Business objects
new
Business objects
custom SAP subtype
04/05/16
ZyCL_b
Z = Custom
development
y = Site code
CL = Class identifier
B = Short description
Z3CL_IM_C_CALC_BADI
Zyxxxxnn
Z = Custom
development
y = Site code
xxxx = SAP
application component
nn = 2 digit number
Z3MMIM0001
Zyb
Z = Custom
development
y = Site code
b = SAP Business
object
HP Confidential
ZGBUS2032
Coding Standards
38
04/05/16
HP Confidential
Coding Standards
39
The SAP run time values for system date (SY-DATUM) and system time
(SY-UZEIT) are set by the application server system date and time. The
SAP run time values for local date (SY-DATLO) and local time (SY-TIMLO)
are calculated as an offset from system time, based on the time zone
specified in the user master. If no time zone is specified, then the local
date and time will be identical to the system date and time
Use SY-DATLO and SY-TIMLO for all application specific dates and times.
This would include such things as (but not limited to); document date,
posting date, shipping date, billing date, requested date, material
availability date, effective date - all sorts...pricing, exchange rates, sales
status, etc.
Only use SY-DATUM and SY-UZEIT for system level functions where, for
example, you must maintain the integrity of the sequence of events. This
would include such things as (but not limited to); document creation date,
document change date, program execution time, date and time stamps used
in file names, etc.
04/05/16
HP Confidential
Coding Standards
40
04/05/16
HP Confidential
Coding Standards
41
As of 4.6 upgrade, this report tree is attached to the standard SAP area
menu (S000) via an enhancement area menu (ZREPTREE).
Non compliant area menus on ESG Americas :
Z9M1
Z9MN
04/05/16
HP Confidential
Coding Standards
42
HP Confidential
Coding Standards
43
04/05/16
HP Confidential
Coding Standards
44
04/05/16
HP Confidential
Coding Standards
45
04/05/16
HP Confidential
Coding Standards
46
04/05/16
HP Confidential
Coding Standards
47
04/05/16
Examples
Z0
Direction
01
2 character sequence
AA
Dot
0001
HP Confidential
Coding Standards
48
Examples
Custom development
Project ID
PRS
Free Form
CPL_REPORTS_PATH
04/05/16
Examples
Custom development
Project ID
PRS
Free Form
CPL_REPORTS
HP Confidential
Coding Standards
49
HP Confidential
Coding Standards
50
Contd
Non-IM/3 program:
Imported file name from FILE_GET_NAME function:
/opt/z9/QA2/PRS/.
Concatenate /opt/z9/QA2/PRS/ with filename to get the full path
/opt/z9/QA2/PRS/filename.
IM/3 program:
Imported file name from FILE_GET_NAME function:
/opt/z9/QA2/PRS/filename
04/05/16
HP Confidential
Coding Standards
51
04/05/16
HP Confidential
Coding Standards
52
04/05/16
HP Confidential
Coding Standards
53
Thank You
04/05/16
HP Confidential
Coding Standards
54