Beruflich Dokumente
Kultur Dokumente
Copyright Notice
This document contains proprietary information of HCL Technologies Ltd. No part of this document may
be reproduced, stored, copied, or transmitted in any form or by means of electronic, mechanical,
photocopying or otherwise, without the express consent of HCL Technologies. This document is intended
for internal circulation only and not meant for external distribution.
PLCGN010 SAP Coding Guidelines
Revision History
Glossary
Abbreviation Description
Table of Contents
1 Introduction....................................................................................................................................... 4
1.1 Purpose .................................................................................................................................... 4
1.2 Scope ....................................................................................................................................... 4
2 SAP Development Standards .......................................................................................................... 4
2.1 Multi Country Approach............................................................................................................ 4
2.1.1 Country Identifier ........................................................................................................ 4
2.2 MODULE IDENTIFICATION............................................................................................................. 5
2.3 Repository Browser Objects..................................................................................................... 5
2.3.1 Development Class .................................................................................................... 5
2.4 Online Program ........................................................................................................................ 6
2.5 Dialogue Module ...................................................................................................................... 6
2.6 Transaction Code ..................................................................................................................... 7
2.7 Function Groups....................................................................................................................... 7
2.8 Includes .................................................................................................................................... 8
2.9 SET/GET parameter ID ............................................................................................................ 8
2.10 AREA MENU....................................................................................................................... 8
2.11 Message Class/ Number..................................................................................................... 9
2.12 Dictionary Objects ............................................................................................................... 9
2.12.1 Domain....................................................................................................................... 9
2.13 DATA ELEMENT................................................................................................................. 9
2.14 STRUTURES .................................................................................................................... 10
2.15 TABLE TYPE .................................................................................................................... 10
2.16 VIEW ................................................................................................................................. 11
2.17 TABLE ............................................................................................................................... 11
2.17.1 BUFFERING ............................................................................................................ 11
2.17.2 INDEXES ................................................................................................................. 12
2.17.3 LOCK OBJECT ........................................................................................................ 12
2.18 SEARCH Help................................................................................................................... 13
2.19 ABAP Editor ...................................................................................................................... 13
2.19.1 Documenting with ABAP Code ................................................................................ 13
2.19.2 Program Documentation .......................................................................................... 13
2.19.3 Extended Program Check........................................................................................ 13
2.19.4 Modification to Code ................................................................................................ 14
2.19.5 Multi Language and Currency.................................................................................. 14
2.19.6 ABAP List Viewer..................................................................................................... 14
1 Introduction
1.1 Purpose
This document describes the policy and procedures for creating SAP R/3 objects. All SAP R/3
developers will use these guidelines.
1.2 Scope
This procedure applies to all personnel developing SAP R/3 objects as part of the SAP
development process within Compass Group Plc .The policies and procedures in this document
define our requirements for the development of all R/3 objects and also incorporate SAP
recommendations where applicable. Compliance will ensure the support and development is
kept separate for customer and SAP R/3 delivered applications
Country Code
Great Britain GB
Ireland IE
Netherlands NL
Belgium BE
Norway NO
Examples:
ZBCREPO001 - Country Independent with standard layout
ZBCREPO001_NL-Dutch specific due to differing report layout for legal requirements
Other attribute settings / actions to note:
None
Bespoke Description
TC Terms and Conditions
YY Miscellaneous
Project based developments must be assigned to their own class, created centrally by the
department manager.
All other objects should be created as temporary local objects, these will be deleted from the
system as part of the quarterly release mechanism, each developer can create ‘permanent’
local objects by assigning them to class $DV2.
Identifier Description
REPO Read Only Report
PROG Periodic Insert/Change Internal to
SAP
INTF Periodic Insert/Change External to
SAP
PRIN Print Program (SAPScript Driver)
DATA One Time Master/Transaction Data
Load
EXTR One Time Data Extract
OTHE Other
Examples:
All dialog ABAP coding should take the following naming convention.
Example:
Example:
ZDEVS-Developers Scripts
Example:
2.8 Includes
Where common code can be re-used within a series of developments you should create
includes.
Example:
If no suitable standard parameter exists then create using the following convention.
Example:
Example:
Z_APL-APL Menu
Example:
Example:
Ensure both the <description> and attributes short text aid developers using search help
Use a generic SAP supplied domain name where possible
Maintain Field labels where required and remember to assess any need for translation
Assess the need for Parameter ID or change documentation
2.14 STRUTURES
Structures can be used as the dictionary equivalent of ABAP field strings and in large projects or
suites of programs you can create these definitions in the Dictionary and reference them using
the INCLUDE STRUCTURE statement. Create using the following convention.
Example:
2.16 VIEW
Four types of view are available and can involve one or more tables. Database views are the
dictionary equivalent of an inner join SELECT, projection views the equivalent of SELECT on a
single table using a field list, help views support outer joins and the maintenance view the
UPDATE of tables linked by key relationships.
From Release 4.x you may buffer views as well as tables, the use of this feature is detailed later
in this document.
Example:
2.17 TABLE
Before creating a database table you should ensure there is no redundant data being stored.
E.g. Texts for non unique entries should be held in separate ‘check’ tables.
Example:
2.17.1 BUFFERING
Buffering is not suitable for views or tables in which the accessed data changes frequently i.e.
more than once a day. The type of buffering will also depend on the size of the data table and
the volume and type of accesses.
Example:
An index should support the selection of data from a table, as an index must be updated as
entries are inserted to its main table they should be used carefully. Analyse how records are
accessed and try to re-code the SELECT to use an existing indexes or related tables.
Fields should be in order of selectivity such that the main data set is reduced in size as quickly
as possible
An index in only of use up to the first unspecified field so define as few fields as possible
An index will be used for a selection based on the Oracle optimiser (CBO) so do not create
‘similar’ indexes
Example:
Example:
Using the PATTERN pushbutton you will choose either the REPORT or HEADER template as
the basis of developing any new bespoke source code (excluding functions). Any new section of
code should be commented and any assumptions noted to ensure the QA sign off is achieved
and assist ongoing support of the development.
2.19.2 Program Documentation
Within the reporting dialog a user will have access to the program documentation saved within
the editor. The analyst should complete the wording for this section, supplying a short title and
purpose being the development
2.19.3 Extended Program Check
Before release of any development an extended program check will be performed by the
department manager, if this check fails the development will be rejected and passed back to the
developer for action. Therefore please run these checks yourself prior to release and correct
any errors or warnings. The revised programming standards outlined below should prevent
problems in new developments and help correct existing code developed prior to these
standards.
2.19.4 Modification to Code
Any modification made to any existing code, bespoke or standard must be commented in the
source header and around the lines modified. Any standard code changes will invoke the SAP
Modification Assistant, bespoke change should mirror this format as outlined below. If the
attributes do not have the Editor Lock set, please do so as part of the modification.
In the source header insert a comment line under the modification section with the following
details; SAP user ID, Date, Four digit DV2K9nnnn Transport Request number, PRJ CRF H/D
reference and short description.
Insert a *{ comment indicating if lines are being INSERTed, REMOVEd or REPLACEd
Existing code should be REMOVEd by inserting ‘*’ on relevant lines
Add INSERTed or REPLACEd code and end modification with *} comment line matching first
2.19.5 Multi Language and Currency
Historically all developments within Compass Group have been UK specific resulting in hard
coding of English text and no flexibility in currency reporting. In future the following must apply in
all developments;
All texts must be held as symbols and output as such using TEXT-nnn syntax
All currency amounts must be suffixed with CURR curr, determined via function module
Z_GET_ORG_DATA
Parameter Description
i_callback_program Program control is passed to when list is left ( SY-REPID
)
it_fieldcat Fields for output ( SLIS_FIELDCAT_ALV )
It_sort Fields for sort ( SLIS_SORTINFO_ALV )
t_outtab Internal table in order of ‘it_fieldcat’
All functions should be accessible via the menu and function keys or toolbar
Try to maintain a single status for similar screen rather than duplicate entries for each screen
Use the SET PF-STATUS ‘XXX’ EXCLUDING <table> syntax to disable unwanted functions
screen by screen
2.21.2 GUI Title
Program specific title up to 60 characters in length that can be either static or dynamic text. The
‘&’ code can be used within the static text and dynamically modified using the SET TITLEBAR
‘XXX’ WITH <text> syntax.
The short description, although not displayed at runtime, must contain a meaningful description
as the search help and object browser use it. There are no other standards covering the
attributes of the screen.
2.22.4 FLOW Logic
The flow logic must contain the PROCESS BEFORE OUTPUT (PBO) and PROCESS AFTER
INPUT (PAI) keywords even if no modules are called. Only add the PROCESS ON VALUE-
REQUEST or PROCESS ON HELP-REQUEST if you are adding this bespoke functionality.
Screen specific modules should be suffixed _<dyn> where <dyn> = screen number
Other modules should contain a CASE sy-dynnr statement to modify functionality based on
screen number
Always add a MODULE EXIT AT EXIT-COMMAND to capture ‘exit’ functions
Do not place SELECT statements in the PBO of a screen, code in the PAI of the calling screen
if possible
2.23 EFFICIENCY
Performance of both the system and coding is being continually reviewed and our current best
practices are included in the Developers Quick Reference Guide (QRG). These include from the
design of user interfaces, selection from the database, internal table management and loop
processing. As part of the Compass Group approach we require all developments to pass
through the runtime analysis transaction SE30, the QA process will reject any development that
will benefit from further performance tuning.
REPORT MODCODE.
• Add the line-count and line-size keywords.
TABLES: MKPF, BKPF, MSEG, LFA1.
• Place each table on a new line and include description.
DATA V_BUPER LIKE T009B-POPER.
APPEND REPORT.
ENDSELECT.
• Select above should be changed to use the FOR ALL ENTRIES syntax
using the internal table populated from MKPF.
• If we add the INTO TABLW syntax we must move the selection from LFA1
into a LOOP..ENDLOOP structure, e.g. when we write out the report.
ENDSELECT.
• No endselect will be required if INTO TABLE syntax is added.
LOOP AT REPORT.
IF REPORT-MBLNR NE V_LAST.
WRITE: / REPORT-USNAM, REPORT-BKTXT.
ENDIF.
WRITE: / REPORT-MATNR, REPORT-MENGE,
REPORT-MEINS, REPORT-LIFNR, REPORT-NAME1.
V_LAST = REPORT-MBLNR.
ENDLOOP.
• With a properly structured internal table control loop processing
can be used to add sub and grand totals.
• We need to read the vendor details here and internally buffer them
to avoid duplicate reads from the database.
END OF T_MSEG.
* Ranges
RANGES R_DATE FOR SY-DATUM. " Converted Period/Year Date
* Get Low end of date range
CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'
EXPORTING
I_GJAHR = P_YEAR
I_PERIV = '96'
I_POPER = P_PERIOD
IMPORTING
E_DATE = R_DATE-LOW
EXCEPTIONS
OTHERS = 1.
IF SY-SUBRC <> 0.
MESSAGE E000(Z1) WITH 'Date Conversion Failed'.
ENDIF.