Thursday, July 25, 2013

SAP ABAP Naming Standards







AMENDMENT HISTORY

Version
Author
Page No
Description
Reviewed By
Approved By
Review Date
Approval Date















Declarative Element

Naming Standards

Work variables

Should start with ‘W_’.

Example: 
DATA: 
     W_ACCT_NUM  TYPE.  N  VALUE 0.  “ G/L acct

Constants

Should start with ‘C_’.

Example:
CONSTANTS:
    C_SOLDTO   LIKE BVBPA-PARVW   " Sold-to partner
                          VALUE 'AG.

Flags

Should start with ‘FL_’.

Example:
DATA:
    FL_NEW_PAGE(1)  TYPE C,             "  New page indicator

Field strings

Should start with ‘FS_’.

Example:
DATA:
    FS_BVBPAKOM LIKE BVBPAKOM.    " Communication structure

DATA:
     BEGIN OF FS_OUTPUT,                       " Record structure
          LINE(1000),                                     
     END OF FS_OUTPUT.

Types

Should start with ‘TYPE_’.

Example:
TYPES:
   TYPE_TABLE_INDEX LIKE SY-TABIX.

Type declaration for structures

Should start with ‘TYPE_S_’.

Example:
TYPES:
    BEGIN OF TYPE_S_REPORTLINE,                           
         PKUNAG   LIKE S510-PKUNAG,         " Sold-to party   
         NAME1     LIKE KNA1-NAME1,           " Customer name   
         MATNR     LIKE S510-MATNR,           " Material number 
        UMMENGE LIKE S510-UMMENGE,    " Quantity        
        VRKME      LIKE VBAP-VRKME,         " Sales UoM       
    END OF TYPE_S_REPORTLINE.                              

Type declaration for internal tables

Should start with ‘TYPE_T_’.

Example:
[TYPES:
   BEGIN OF TYPE_S_STRUC,                                        
         NAME(10) TYPE C,                                    
         AGE         TYPE I,                                    
    END   OF TYPE_S_STRUC. ]                                      
                                                              
TYPES:
    TYPE_T_TAB1 TYPE STANDARD TABLE OF TYPE_S_STRUC WITH
    DEFAULT KEY.

Internal table

Should start with T_.

Example:
DATA:
     T_CRED_MEMO_HDR TYPE STANDARD TABLE     
                                           OF TYPE_S_CRED_MEMO_HDR 
                                           INITIAL SIZE 30         
                                           WITH HEADER LINE.       

Parameters

Should start with ‘P_’.

Example:
PARAMETERS:
    P_UNBLK   AS    CHECKBOX DEFAULT ' ',
    P_SIMUL    RADIOBUTTON GROUP  RG1,
    P_PRNAME   LIKE TSP01-RQDEST.

Select-options

Should start with ‘S_’.

Example:
SELECT-OPTIONS:
     S_VKORG   FOR S510-VKORG.      " Sales organization

Ranges

Should start with ‘R_’.

Example:
RANGES:
      R_USERID       FOR   BKPF-USNAM.

Formal parameters

Formal parameters passed by value, should start with ‘PV_’.
Formal parameters passed by reference, should start with ‘PC_’.
Formal parameters passed by value and result, should start with ‘PR_’
Formal parameters representing Internal tables that are passed by TABLES, should start with ‘PT_’


Example:
    PV_DOC_DATE  à Value parameter
    PC_USERID       à Reference parameter
   PR_MATNR        à Value and Result parameter

Local data declarations

Should start with ‘L’ followed by the naming conventions specified for the global data elements.

Example:
Local variable declaration:
DATA:
     LW_USERID LIKE BKPF-USNAM.     “ User id

Local constant declaration:
CONSTANTS:
     LC_SOLDTO   LIKE BVBPA-PARVW       “ Sold-to partner
                             VALUE ‘AG’.

Local Static data declarations

Should start with ‘LS’ followed by the naming conventions specified for the global data elements.

Example:
Local Static variable declaration:
STATICS:
     LSW_USERID LIKE BKPF-USNAM.     “ User id

Macro

Should start with ‘M_’.

Class

Should start with ‘CLS_’.

Object

Should start with ‘OBJ_’.

Interface

Should start with ‘INT_’.

Blocks defined on the selection-screen

If a program contains multiple selection-screens, the corresponding selection-screen number should prefix the block name.

Module pool for screen

Program name should begin with ‘SAPMZ’.

Function Modules

Customer defined function modules should start with ‘Z_’.

Objects (Programs, Tables, Views etc.)

Customer-defined objects should start with ‘Z’

Lock Objects

Should start with ‘EZ_’.


Note:
1.   Underscore “_” is to be used to separate words or letters that define a variable instead of hyphens “-”
2.   Wherever possible, the reference to data dictionary fields and structures should be used when developing ABAP programs.

No comments:

Post a Comment