sap abap naming conventions.doc
TRANSCRIPT
Type Description DL Initial value C Character 1 Space N Numeric t
TYPES Simple type definition - TYPES type. - TYPES type(len).
Definition of a structured type - TYPES: BEGIN OF structype ... END OF structype.
Definition of an internal table type - TYPES itabtype {TYPE tabkind OF linetype| LIKE tabkind OF lineobj} [WITH [UNIQUE|NON-UNIQUE] keydef] [INITIAL SIZE n]. - TYPES itabtype {TYPE RANGE OF type|TYPES itabtypeLIKE RANGE OF f}. - TYPES itabtype {TYPE linetype|LIKE lineobj} OCCURS n.
Type Description DL Initial value
C Character1Space N Numeric text 1'00...0' D Date YYYYMMDD8'00000000' T Time HHMMSS6'000000' X Byte (heXadecimal) 1X'00' I Integer40 P Packed number80 F Floating point number8'0.0' STRINGString variableempty string XSTRINGByte sequence (X string) variableempty X string
The system field SY-DBCNT contains the number of lines read so far ecah time the SELECT statement is executed. After ENDSELECT, SY-DBCNT contains the total number of records read.
The Return Code is set as follows: SY-SUBRC = 0:
The result table contains at least one record.
SY-SUBRC = 4:
The result table is empty.
SY-SUBRC = 8:
Applies only to SELECT SINGLE FOR UPDATE: You did not specify all of the primary key fields in the WHERE condition. The result table is empty.
Dictionary Objects
DDIC ObjectNaming StandardRepository EntryMeta Data Table
DomainZ*
Data ElementZ*
Lock ObjectEZ*
Search HelpZSH*
StructureZS*
TableZ* or ZT*
Table TypeZ* or ZTY*
Table IndecesZ## 3 character unique name
Type GroupZTG*
ViewZV*
Sample Program Types
R - ReportD - Data LoadI - IncludeX - Interfaceetc.
SAP ObjectNaming StandardRepository EntryMeta Data Table
Application LogZ*Area MenuZ*Batch Input SessionZ*Change DocumentZ*PackageZ*Dialog ModuleZ*CMOD Enhancement ProjectZ*Form PoolSAPFZ*
Generated Include modules should follow SAP suggested recommendations
For ExampleFZ*TOP - Data declarationsFZ*F## - Subroutines
Function GroupsZ*Function ModulesZ_*Gui StatusZ*IncludeZI*Memory IDZM*Message ClassZ*Messages Numbernumeric 3 digits 1-999Module PoolSAPMZ*
Generated Include modules should follow SAP suggested recommendations
For ExampleMZ*TOP - Data declarationsMZ*O## - PBO modulesMZ*I## - PAI modulesMZ*F## - Subroutines
Number RangeZNR*ProgramZtype* where type identifies the program functionScreen4 charactersGUI TitleZ*Transaction CodeZ*
Naming Conventions
Naming Conventions lend consistency and readabilty to your code. This in turn improves the overall maintainability of code. When naming your objects and variables, try to avoid arcane acronyms. Spell it out where possible.
Refer to the table below for accepted industry standard naming conventions for objects and variables within a program.
Program Internal ObjectsConventionExample
Class - locallcl_*lcl_salesorder
Class - Interfacelif_*lif_salesorder
Constantc_* or co_*c_open_indicator
Data Referencedr_*dr_openorder
Data Variables - Globalv_* or gv_*v_order
Data Variables - Locallv_*lv_order
Data Variables - Staticlsv_*lsv_order
Field Symbols
Internal Table - Standardt_*t_orders
Internal Table - Sortedts_* or to_*ts_orders
Internal Table - Hashedth_*th_orders
Parameterspa_*pa_order
Rangesra_*ra_orders
Reference Variablerf_*rf_orders
Select-Optionsso_*so_date
Structurest_* or w_*st_orders
Table Controltc_*tc_orderlines
Typesty_*ty_ordertype
Work Areaw_*w_order
Interface Parameters
Subroutine Formal ParametersConventionExample
Usingu_* or p_*
Changingc_* or p_*
Raisingr_* or p_*
Method SignatureConventionExample
Importingim_*
Exportingex_*
Changingch_*
Returningre_*
Raisingcx_* for exception classes
Exceptionsnot applicable
Function InterfaceConventionExample
Importingim_*
Exportingex_*
Changingch_*
Tablest_*
Exceptionsnot applicable
Raisingnot applicable
Functions/Methods
FUNCTIONS
Use the built in documentation features found in SE37 to document the purpose of the function modules and the usage of the Interface parameters.The use of naming standards for interface parameters is not a common practice, although it should be so SAPdomain recommends the following:
Importing Parameters: IM_*Exporting Parameters: EX_*Changing Parameters: CH_*Tables Parameters: TB_*
METHODS
For Methods Use the Following naming standard for the signature of the method.
Importing: IM_*Exporting: EX_*Changing : CH_*Returning: RE_*Raising: exception (no std)Exceptions: exception_class (no std)
Events
List Processing Events are executed in a predefined order according to the rules of the ABAP interpreter and therefore the order in which they appear in an ABAP program is not important. However there is a standard practice among programmers (for readability) to order events according to the order of execution.
It is good practice to identify events with a comment banner. i.e.
List Processing Events
Guidelines by Topic
Error Handling
Functions
Methods
Message Types - A E X I W S
Return Code Checking
SQL
A very through public document available on this topic area can be found in SDN