The ABAP REPORT should have the following structure i.e The CODING SEQ.
DECLARATION SECTION .
Things like Report Name,Programmer Name ,Request For Change(RFC)
number, Change History Etc.
INCLUDE DECLARATIONS .
Includes like programTOP for data declaration, programF01 for form routines
programO01 for PBO modules,programI01 for PAI modules Etc.
Data Work area declaration
TABLES DECLARATION .
Here declare all the tables by using TABLES keyword.
Any type pools used in the report like VRM(for use with ListBox)
should be declared here using TYPE-POOLS command.
TYPES DECLARATION .
Any type sused should be deined here by using TYPES keyword.
All constants should be declared here starting with C_name using
All data variables decalred with DATA keyword should be here
All structures declared with DATA should be here.
All internal tables should be declared here.
All the ranges defined in the program using RANGES statement should be declared here.
FIELD GROUPS DECLARATION.
FIELD SYMBOL DECLARATION.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR field.
AT SELECTION-SCREEN ON HELP-REQUEST FOR field.
AT SELECTION-SCREEN ON FIELD field.
AT SELECTION-SCREEN ON BLOCK block.
AT SELECTION-SCREEN OUTPUT.
START OF SELECTION
END OF SELECTION.
TOP OF PAGE
END OF PAGE.
Declaration of FORM ROUTINES.
Variables should have descriptive names if possible .Variable names having meaningful words should be separated by ‘_’ like CUST_NAME .Suitable 1st letter should be used with variables to suggest their type and purpose like :
W_ Normal work variables declared with DATA statement
e.g. DATA: W_NAME.
TY_ All types declared in the program shold start from TY_
S_ Select Options
R_ Range Table
I_ internal Table
EVERY ABAP statement on a single line.
Every ABAP statement should be on single line e.g.In case of SELECT
statement to retrieve records every clause like FROM ,WHERE etc should be on
SELECT matnr mtart meins
WHERE ersda =
Pretty painter should be used to indent the code properly.
All the parameters used in a form routine should be properly typed in
form definition if it is possible as the performance of sap code increases .
Text symbols should be used extensively .i.e TEXT-nnn or text(nnn) should
be used instead of only literal text,for language translation and code readibility
and maintenance benefits.
Message class should be declared in the REPORT statement with the addition MESSAGE-ID and long text should be created for each message used if possible.
Table Declaration Guidelines
Every customer table name should begin with z and 2nd and 3rd character should
represent the application to which that table belongs e.g.
SD sales and distribution
MM material management
QM Quality mangement
BC Basis components.
The rest part of the table name shopuld be descriptive as much as possible.
The delivery class of tables should be ‘A’ and ‘C’ .
INTERNAL TABLE GUIDELINES
Before using the READ TABLE statement the internal table should be sorted
as it increases performance. BINARY SEARCH addition should be used with
READ TABLE int KEY key BINARY SEARCH.
To sort an internal table use SORT BY f1 f2 instead of SORT .
To create internal tables it is recommended that a line type or work area should
be first created using the TYPES statement .
TYPES : BEGIN OF TY_INT,
NAME(14) TYPE C,
ADDRESS(30) TYPE C,
END OF TY_INT.
DATA : T_NAME TYPE STANDARD TABLE OF TY_INT WITH HEADER LINE .
DATA: T_NAME TYPE TY_INT OCCURS 0 .
Every program before relesing it should be properly documented . Short comments should be inserted at every important junction in the program
describing the purpose of code .
When doing modification to an existing program the 10 digit change request
should be inserted where the changes or addition has been done. The existing
code should be commented out with change request number instead of deleting it.