The ABAP REPORT should have the following structure i.e The CODING SEQ.
Program Declarartion
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.
TYPE-POOLS DECLARATION.
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.
CONSTANTS .
All constants should be declared here starting with C_name using
keyword CONSTANTS.
DATA VARIABLES
All data variables decalred with DATA keyword should be here
DATA STRUCTURES
All structures declared with DATA should be here.
INTERNAL TABLES
All internal tables should be declared here.
RANGES DEFINITIONS.
All the ranges defined in the program using RANGES statement should be declared here.
FIELD GROUPS DECLARATION.
FIELD SYMBOL DECLARATION.
Events Declaration
INITIALIAZATION.
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.
AT SELECTION-SCREEN.
START OF SELECTION
GET field1,field2.
END OF SELECTION.
List Events
TOP OF PAGE
END OF PAGE.
AT LINE-SELECTION.
AT USER_COMMAND.
AT PFn.
Declaration of FORM ROUTINES.
FORM ....
ENDFORM.
Varaible Declarartion
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_
C_ Constants
P_ Parameter
S_ Select Options
R_ Range Table
T_ Structure
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
diferent line.
e.g.
SELECT matnr mtart meins
FROM mara
WHERE ersda =
ENDSELECT.
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 .
OR
DATA: T_NAME TYPE TY_INT OCCURS 0 .
PROGRAM DOCUMENTATION
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.