You are on page 1of 19

SAP Procedure

Reference:
Title:
Author:
Date:
Version:
SAP Version:

SERVER1\SYS1:\COMMON\SAPPROJE\SETUP\PROC037.DOC (Word 7.0a)


ABAP/4 Programming Standard
Richard Harper
June 98
1.0
3E

Table Of Contents.
1.

INTRODUCTION. ......................................................................................................................... 2
1.1.
1.2.
1.3.
1.4.

2.

PURPOSE.................................................................................................................................... 2
SCOPE........................................................................................................................................ 2
AUDIENCE. ................................................................................................................................ 2
RELATED DOCUMENTS. ............................................................................................................. 2

DOCUMENT STRUCTURE......................................................................................................... 3
2.1. HEADER SECTION...................................................................................................................... 3
2.2. DATA SECTION. ......................................................................................................................... 3
2.2.1.
Variable Names. ............................................................................................................... 4
2.3. LOGIC SECTION. ........................................................................................................................ 5
2.3.1.
Statement Layout. ............................................................................................................. 5
2.3.2.
Comments. ........................................................................................................................ 6
2.3.3.
Forms And Functions. ...................................................................................................... 7

3.

REVISIONS. ................................................................................................................................... 9
3.1. IN-HOUSE PROGRAMS.............................................................................................................. 13
3.2. SAP STANDARD PROGRAMS. .................................................................................................. 13
3.2.1.
Chnge.............................................................................................................................. 13
3.2.2.
Date ................................................................................................................................ 14
3.2.3.
Who................................................................................................................................. 14
3.2.4.
Reason ............................................................................................................................ 14
3.2.5.
Access Key ...................................................................................................................... 14
3.2.6.
Tracking Changes........................................................................................................... 14

4.

MODULARISATION. ................................................................................................................. 15
4.1.
4.2.
4.3.
4.4.

INCLUDE PROGRAMS. .............................................................................................................. 15


FORMS (PROCEDURES). ........................................................................................................... 15
FUNCTIONS.............................................................................................................................. 15
MACROS.................................................................................................................................. 15

List Of Figures.
Figure 1 - SAP Revision History.............................................................................................................. 9
Figure 2 - SAP Change Report............................................................................................................... 13
List Of Tables.
Table 1 - Variable Prefixes....................................................................................................................... 4
Table 2 - SAP System Variables By Name ............................................................................................ 19

Page 1

SAP Procedure

1.

Introduction.
1.1.

Purpose.
The purpose of this document is to define a standard for programming in ABAP/4. It
provides the standard to which code inspections if implemented should take place.
These standards are designed to ensure:
Consistency in Coding.
Maintainability of Code.
Legibility of Code.

1.2.

Scope.
This document addresses programming in ABAP/4 for R/3 3.0e.

1.3.

Audience.
This document is intended for all programmers working on Interim Technology
UKs SAP system whether permanent or contract staff, It assumes an understanding
of the SAP environment.

1.4.

Related Documents.
PROC032 - Common Programming Procedures.

Page 2

SAP Procedure

2.

Document Structure.
The structure of an ABAP program shall be as follows:

Header Section
Data Section
Logic Section
Forms Section.

2.1.

Header Section.
The Header Section of the program shall contain the Report statement and a
comment block describing the function of the program. The report statement will be
defined in full rather than allowing SAP to supply the default for the page size and so
forth:
***********************************************************************
*
*
Program: ZSO0630
*
Title: Order Intake Analysis By Profit Centres
*
Analyst: Cecilia Chan
* Programmer: Richard Harper
*
Date: 12/05/98
*
Doc. Id: 31-10010013-06
*
***********************************************************************
*
* Change History
* Date
Reason
Who
*
REPORT ZSO0630 Message-Id 38
Line-Count 64(1)
Line-Size 132
No Standard Page Heading.

2.2.

Data Section.
The Data Section contains the data definitions that will be used at a global level by
the program. Any definitions not required by the program shall be omitted. In order
to aid documentation, Tables statements that are used only inside particular forms
shall be defined with in the form as though they are local to the form. Where they
are used in more than one form then they should be defined in the main program.
The definitions should be defined in the following order:

Constants
Tables
Data
Select-Options and parameters
Field Groups
Field Symbols

Definitions not defined in the SAP data dictionary should be commented as to their
use. Eg:
Data: Begin Of t_repdata Occurs 0,
*
*
Data common across all reports
*
vkorg
like vbak-vkorg,
vtweg
like vbak-vtweg,
spart
like vbak-spart,

Page 3

" Sales org


" Distribution Chnl
" Division

SAP Procedure

vkbur
vkgrp
erdat

like vbak-vkbur,
like vbak-vkgrp,
like vbak-erdat,

" Sales Office


" Sales Group
" Order Date

*
**********************************************************************
*
*
ZSO0600 - For Management
*
vbeln
like vbak-vbeln,
" P/O No.
kunnr
like vbak-kunnr,
" Customer Number
matkl
like vbap-matkl,
" Model
kwmeng
like vbap-kwmeng,
" Order Qty
waerk
like vbak-waerk,
" Currency
kzwi6
like vbap-kzwi6,
" Order Discount
kzwi6c
like vbap-kzwi6,
" Converted value
chnge
like vbak-netwr,
" Net Change
chngec
like vbak-netwr,
" Converted value
netwr
like vbak-netwr,
" Total order value
netwrc
like vbak-netwr,
" Converted value.
bezei
like tvaut-bezei,
" Change Indicator

2.2.1. Variable Names.


Variable names should conform as much as possible to the following
conventions:
The variables should be prefixed with a single character and an under score
(_). The single character defines the type of variable:
Variable Type
Constants
Internal Tables
Select Option Tables
Parameters
Form Parameters Using
Form Parameters Changing
Form Parameters - Tables
Field Groups
Field Symbols
Ranges
Working storage

Prefix
c_
t_
s_
p_
Pu_
Pc_
Pt_
g_
f_
r_
w_

Table 1 - Variable Prefixes


The second part of the variable name should identify the variable. If the
variable is a copy of a SAP defined variable and has an identical use then
this portion of the name should be the same as the definition. For example a
working storage version of mara-matnr could be defined as w_matnr.
Where possible always declare a variable using the like keyword which
associates a variable definition with a data dictionary item.
Within data definitions (and code blocks), system variables will be used
where required and not the literal value. (eg. Sy-langu instead of E). A
list of system variables is provided in appendix A.
Do not use two underscores within a variable name such as w__count as this
is the convention used in the programs documented in PROC032 'Common
Programming Procedures' to prevent conflict with any user programs.

Page 4

SAP Procedure

Apart from that variable names should be clear, meaningful abbreviations


of what they actually represent. Over long variable names (such as
w_vatonsales) should be avoided where the abbreviation (w_vat) is just as
easily understood.

2.3.

Logic Section.
The Logic Section contains the executable statements grouped under their respective
section headings. Any sections not required by the program shall be omitted. The
section headings will appear in the following order:

Initialisation
At Selection-Screen
Start-Of-Selection
Get Tables
Get Tables Late
End-Of-Selection
Top-Of-Page
End-Of-Page
At Line-Selection
At Pf-keys
At User-Command
Top-Of-Page During Line Selection

2.3.1. Statement Layout.


The way a program is written is largely a matter of personal preference, but
to enable different programmers to pick up programs written by others, a
style convention is required.

2.3.1.1.Layout of Statements.
Each statement should be on an individual line and lined up
vertically. Eg:
Move Field123 to Field2.
Move Field3
to Field4.

Do not concatenate statements as this obscures the logic of the


program:
Perform Procedure Using: A, B, C, D.

Instead separate these into separate statements:


Perform
Perform
Perform
Perform

Procedure
Procedure
Procedure
Procedure

Using
Using
Using
Using

A.
B.
C.
D.

Do not use multiple assignments:


w_result=w_var1=w_var2.

This should be coded as:


Move w_var2 to w_var1.
Move w_var2 to w_result.

Page 5

(How would you interpret this ?)

SAP Procedure

2.3.1.2. Indentation.
Program code should be indented to allow the structure and flow
of the program logic to be easily observed.
Indents should begin at the column of the next word on the line
causing the indentation:
Data: w_var1 type i,
w_var2 type i.
Loop At Vbak.
Perform Routine1.
EndLoop.
If w_material <> .
Perform ProcessMaterial.
Case w_material.
When 1.
.
.
When 2.
.
.
.
EndCase.
EndIf.

The Select clause should be indented as follows:


Select * from table up to 1 rows
Where condition1 and
condition2 and
condition3 and
....
and
....
or
....
Group by group condition
Order by order condition.

Data declarations should make sure that the type or like


reserved words all line up on the same column as can be seen in
section 2.2 above.

2.3.2. Comments.
Code should be commented in useful, meaningful ways. Comments should
always highlight a block of codes functionality. In order to take advantage
of ABAPs print functionality where comments can be highlighted, all
comments should begin with an asterisk in column one, with the actual text
starting at the indent level of the code.
To highlight comments even further, a blank comment should be at the top
and bottom of the comment block:
*
*
*

Any Model here ?


if w_modelfound = True.

*
*
*

Report Dependant Selection.


Clear t_Repdata.
Move-Corresponding vbak to t_repdata.
Case w_repid.
When c_zso0600.
Perform GetOrderDiscount
using vbak-vbeln
Changing w_kzwi6.

Page 6

SAP Procedure

*
*

Get the change reason.

2.3.3. Forms And Functions.


A Form (SAPs word for a Procedure) is a program module that performs an
action. A function is a program module that has a value. ABAP blurs the
distinction between Forms and Procedures somewhat as there is a changing
keyword that allows the variable passed to be changed rather that retaining
its previous value.
Forms and Functions should be used to modularise programs and to
improve readability and maintainability.
Wherever possible Forms should be self contained. Any communication
with the outside world should be carried out using formal parameters. Any
variables used in the routine should be declared inside the routine.
Further modularisation is possible using the Local and Static keywords.

2.3.3.1. Local.
The local keyword is used in association with a previously
defined global variable name. The current value of the variable is
pushed on the stack at the start of the routine and pulled from the
stack at the end, thus allowing changes to be made to the variable
whilst keeping the changes within the currently running
procedure.
This should be used in preference to assigning the value of a
global variable to a copy and using that as it preserves the
readability of the program.

2.3.3.2. Static.
This keyword preserves the value of the declared variable across
procedure calls. This should be used where a value has to be
carried across two or more calls to the procedure. Without using
this keyword, the variable would have to be declared at a higher
level. If the use of the variable is restricted to the current or lower
procedures and the value has to be preserved then this keyword
should be used. Again, to preserve readability of the program.
Below is a full Form declaration
Forms should be prefixed with the following comment block, also available
in ZBLANK:
*eject
**********************************************************************
*
*
Procedure:
*
*
Purpose:
*
*
Entry:
*
*
Exit:
*
*
Called By:
*
*
Calls:

Page 7

SAP Procedure

*
*
Modification History:
*
*
Date
Reason
*
Form ProcedureName
Tables
TableList
...
...
Using
ParameterList
...
...
Changing ChangeList.

Version

Who

Forms should be prefixed with the comment block above, also available in
ZBLANK:
All entries should start in the column after Modification History and can
extend for as many lines as required.
The entries are:

2.3.3.3. Procedure.
This is the name of the form.

2.3.3.4. Purpose.
This entry should details the function of the procedure.
action that it carries out.

The

2.3.3.5. Entry.
This entry should list any tables passed to the routine and any
Using variables with their name and function.
It should document any assumptions made by the routine and any
reliance (!!!) on global variables. (See Local/Static above)

2.3.3.6. Exit.
This entry details any variables and their function that are
changed by the routine.

2.3.3.7. Called By.


This is an optional entry. If the routine is used within a program
then this entry should contain a list of dependant routines.
Unfortunately, this cannot be defined if the routine is a general
routine such as the ones in ZBOSSINC.

2.3.3.8. Calls.
This entry details the procedures that are called by this routine.

2.3.3.9. Modification History.


Any changes to the routine after the initial write, entered under
the appropriate headings.

Page 8

SAP Procedure

3.

Revisions.
Programs tend to be subject to a never ending request for revisions. SAP contains a version
management system that is activated at each transport of the program. Therefore it makes
sense to use this system to track changes to our in-house programs.
Taking the Common SAP Procedures include program ZBOSSINC, the Version manager has
this to report on the Include program:

Figure 1 - SAP Revision History


This shows that there have been nine transports of the program to the live environment.
Previous versions can be recalled, and differences compared between versions:
Compare report sources
Left-hand column:
Report source:
Request:
Text:

ZBOSSINC Version 00008


M01K902911 22.05.1998 RHARPER
ZSO Report series changes.

Right-hand column:
Report source:
Request:
Text:

ZBOSSINC active version


M01K903193 01.06.1998 RHARPER
ZBOSSINC modification/upgrade.

Contents unchanged:

Page 9

SAP Procedure

000010
000020
000030
...
000460
000470
000480

000010
000020
000030
...
000460
000470
000480

***INCLUDE ZBOSSINC.
***********************************************************************
*
...
Data: w__grouphdr
type i,
" In group header routine
w__lineprinted type i,
" Line printed flag
w__runtotal
type i.
" Run total rec needed

The following lines were changed:


000490
*
000490
*eject
Contents unchanged:
000500 000500
***********************************************************************
000510 000510
*
000520 000520
*
macro:
Psub.
...
...
...
000740 000740
&1-low &1-high.
000750 000750
EndLoop.
000760 000760
End-Of-Definition.
The following lines were changed:
000770
*
000770
*eject
Contents unchanged:
000780 000780
***********************************************************************
000790 000790
*
000800 000800
*
Procedure:
Repheader.
...
...
...
001490 001490
Move False to w__grouphdr.
001500 001500
Move False to w__lineprinted.
001510 001510
ENDFORM.
The following lines were added:
001520
*eject
Contents unchanged:
001520 001530
***********************************************************************
001530 001540
*
001540 001550
*
Procedure:
WLine.
...
...
...
002230 002240
write ' ' no-gap.
002240 002250
enddo.
002250 002260
ENDFORM.
The following lines were added:
002270
*eject
Contents unchanged:
002260 002280
***********************************************************************
002270 002290
*
002280 002300
*
Procedure:
GroupHdr.
...
...
...
002810 002830
Move false to w__lineprinted.
002820 002840
Endif.
002830 002850
ENDFORM.
" Group Header.
The following lines were added:
002860
*eject
Contents unchanged:
002840 002870
***********************************************************************
002850 002880
*
002860 002890
*
Procedure:
PrintTitles.
...
...
...
003750 003780
EndWhile.
003760 003790
Endif.
003770 003800
ENDFORM.
" PrintTitles
The following lines were added:
003810
*eject
Contents unchanged:
003780 003820
***********************************************************************
003790 003830
*
003800 003840
*
Procedure:
Underline.

Page 10

SAP Procedure

...
004020
004030
004040

...
004060
004070
004080

...
Move sy-uline to w__repline+w__offset(p_width).
Write / w__repline.
ENDFORM.
"UNDERLINE

The following lines were added:


004090
*eject
Contents unchanged:
004050 004100
***********************************************************************
004060 004110
*
004070 004120
*
Procedure:
Tableline.
...
...
...
004290 004340
Perform UnderLine
004300 004350
using ReportTable-StartPos w__maxwidth.
004310 004360
ENDFORM.
The following lines were added:
004370
*eject
Contents unchanged:
004320 004380
***********************************************************************
004330 004390
*
004340 004400
*
Procedure:
BuildReport.
...
...
...
005220 005280
endloop.
005230 005290
Append ReportTable.
005240 005300
ENDFORM.
"BUILDREPORT.
The following lines were added:
005310
*eject
Contents unchanged:
005250 005320
***********************************************************************
005260 005330
*
005270 005340
*
Procedure:
FormatReport.
...
...
...
005940 006010
Modify ReportTable.
005950 006020
Endloop.
005960 006030
ENDFORM.
"FORMATREPORT
The following lines were added:
006040
*eject
Contents unchanged:
005970 006050
***********************************************************************
005980 006060
*
005990 006070
*
Procedure:
WriteLine
...
...
...
006720 006800
Write sy-vline no-gap.
006730 006810
Move True to w__lineprinted.
006740 006820
EndForm.
The following lines were added:
006830
*eject
Contents unchanged:
006750 006840
***********************************************************************
006760 006850
*
006770 006860
*
Procedure:
SetColour
...
...
...
007070 007160
When Col_Group.
Format Color Col_Group.
007080 007170
Endcase.
007090 007180
EndForm.
The following lines were added:
007190
*eject
Contents unchanged:
007100 007200
***********************************************************************
007110 007210
*
007120 007220
*
Procedure:
WriteCentre.
...
...
...
007340 007440
Move p_text to w__repline+w__offset.
007350 007450
Write /001 w__repline.
007360 007460
ENDFORM.

Page 11

SAP Procedure

The following lines were added:


007470
*eject
Contents unchanged:
007370 007480
***********************************************************************
007380 007490
*
007390 007500
*
Procedure:
FindSupplier.
...
...
...
008410 008520
endif.
008420 008530
endif.
008430 008540
ENDFORM.
" FINDSUPPLIER
The following lines were added:
008550
*eject
Contents unchanged:
008440 008560
***********************************************************************
008450 008570
*
008460 008580
*
Procedure:
GiveLine.
...
...
...
009090 009210
move space to p_text.
009100 009220
endif.
009110 009230
ENDFORM.
The following lines were added:
009240
*eject
Contents unchanged:
009120 009250
***********************************************************************
009130 009260
*
009140 009270
*
Procedure:
StripString.
...
...
...
009570 009700
EndWhile.
009580 009710
EndDo.
009590 009720
EndForm.
The following lines were changed:
009600
*
009730
*eject
Contents unchanged:
009610 009740
***********************************************************************
009620 009750
*
009630 009760
*
Procedure:
SortRep
...
...
...
010030 010160
EndCase.
010040 010170
Endif.
010050 010180
EndForm.
The following lines were changed:
010060
*
010190
*eject
Contents unchanged:
010070 010200
***********************************************************************
010080 010210
*
010090 010220
*
Procedure:
SubTitle
...
...
...
010730 010860
Endif.
010740 010870
Perform WriteCentre using w__subtitle.
010750 010880
EndForm.
The following lines were added:
010890
*eject
Contents unchanged:
010760 010900
***********************************************************************
010770 010910
*
010780 010920
*
Procedure:
InitBreak
...
...
...
011190 011330
Move t__cols[] to ReportBreaks-Totals[].
011200 011340
Append ReportBreaks.
011210 011350
EndForm.
The following lines were added:
011360
*eject

Page 12

SAP Procedure

Contents unchanged:
011220 011370
***********************************************************************
011230 011380
*
011240 011390
*
Procedure:
Checkbreaks
...
...
...
012240 012390
EndWhile.
012250 012400
EndIf.
012260 012410
EndForm.
The following lines were changed:
012270
*
012420
*eject
Contents unchanged:
012280 012430
***********************************************************************
012290 012440
*
012300 012450
*
Procedure:
PrintTotals
...
...
...
013000 013150
Position w__pos.
013010 013160
Write: sy-vline.
013020 013170
EndForm.
The following lines were added:
013180
*eject
Contents unchanged:
013030 013190
***********************************************************************
013040 013200
*
013050 013210
*
Procedure:
RunTotals
...
...
...
013500 013660
EndLoop.
013510 013670
Perform TableLine.
013520 013680
EndForm.

Figure 2 - SAP Change Report


Revisions can be retrieved at will with the proviso that they will over write the current version
unless it is copied somewhere else.

3.1.

In-House programs.
In view of the fact that SAP possesses full version control, changes to in-house
programs should be documented in the revision history block at the head of the
program, or within the relevant procedure.
In order to maintain readability, lines that should be deleted should be and not
commented out. Lines that are changed should be changed and not copied and
commented out. This maintains readability throughout the code and in any case, the
previous version can always be retrieved if required.

3.2.

SAP Standard Programs.


Where a SAP standard program is to be changed, the change details should be
documented in a comment at the head of the program.
The comments should form a history of the changes made in the program and should
contain the following details:
* Chnge Date

Who

Reason

Access Key

3.2.1. Chnge
This column should contain a consecutive change number (1 2 3.... etc)

Page 13

SAP Procedure

3.2.2. Date
The date the change commenced

3.2.3. Who
Who is responsible for the change.

3.2.4. Reason
The reason for the change.

3.2.5. Access Key


The Access Key obtained from OSS.

3.2.6. Tracking Changes.


Any lines changed should have the comment Interim change No appended
to them.
To delete a line, place an asterisk in the first column, changing that line
into a comment, again marking that line with Interim change No.
To change a line, copy the line to the clipboard, mark the current line with
an asterisk and Interim change No. Paste the original line back in below
the old line and make the necessary changes. Again, mark the line with
Interim change No.
Whilst this is not the way to maintain programs and keep them readable and tidy,
this is apparently the way that Origin maintain programs...... However.

Page 14

SAP Procedure

4.

Modularisation.
Programs should be modularised so that effects of changes and damage limitation can be
contained.
Modularisation Units available within ABAP are:

4.1.

Include Programs.
Where a Form or function is shared between two or more programs it may be called
using the statement:
Perform Procedure
Tables
Using
Changing

In programName If Found
TableList
Using List
ChangeList.

However, a better way of doing this is to group all the common procedures for an
application into an Include file which is Included in the main program using the
Include statement

4.2.

Forms (Procedures).
A subroutine with formal parameters which should be used to isolate the different
functional routines used within the program.

4.3.

Functions.
A Procedure with a value.

4.4.

Macros.
These are defined once at the head of the program and are then used as though they
are intrinsic commands within the ABAP language. An example of a macro can be
found in PROC032, PSUB.

Page 15

SAP Procedure

Appendix A
SAP System Variables.
Variable Name
SY-ABCDE
SY-APPLI
SY-BATCH
SY-BATZD
SY-BATZM
SY-BATZO
SY-BATZS
SY-BATZW
SY-BINPT
SY-BREP4
SY-BSPLD
SY-CALLD
SY-CALLR
SY-CCURS
SY-CCURT
SY-CDATE
SY-CFWAE
SY-CHWAE
SY-COLNO
SY-CPAGE
SY-CPROG
SY-CTABL
SY-CTYPE
SY-CUCOL
SY-CUROW
SY-DATAR
SY-DATLO
SY-DATUM
SY-DATUT
SY-DAYST
SY-DBCNT
SY-DBNAM
SY-DBSYS
SY-DCSYS
SY-DEBUG
SY-DSNAM
SY-DYNGR
SY-DYNNR
SY-ENTRY
SY-FDAYW
SY-FDPOS
SY-FFILE
SY-FLENG
SY-FMKEY
SY-FODEC
SY-FOLEN

Page 16

Type
CHAR
RAW
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
DEC
DEC
DATS
CUKY
CUKY
INT4
INT4
CHAR
CHAR
CHAR
INT4
INT4
CHAR
DATS
DATS
DATS
CHAR
INT4
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
INT1
INT4
CHAR
INT4
CHAR
INT4
INT4

C
X
C
C
C
C
C
C
C
C
C
C
C
P
P
D
C
C
X
X
C
C
C
X
X
C
D
D
D
C
X
C
C
C
C
C
C
C
C
X
X
C
X
C
X
X

Length
Contents
26 CONSTANT: ALPHABET (A,B,C)
2 SAP APPLICATIONS
1 BACKGROUND ACTIVE (X)
1 BACKGROUND SUBMIT: DAILY
1 BACKGROUND SUBMIT: MONTHL
1 BACKGROUND SUBMIT: ONCE
1 BACKGROUND SUBMIT: IMMEDI
1 BACKGROUND SUBMIT: WEEKLY
1 BATCH INPUT ACTIVE (X)
4 BACKGROUND SUBMIT: ROOT N
1 BACKGROUND SUBMIT: LIST O
1 CALL MODE ACTIVE (X)
8 PRINT: ID FOR PRINT DIALO
5 RATE SPECIFICATION/RESULT
5 TABLE RATE FROM CURRENCY
8 DATE OF RATE FROM CURRENC
5 INTERNAL USE
5 INTERNAL USE
4 CURRENT COLUMN DURING LIS
4 CURRENT PAGE NUMBER
8 RUNTIME: MAIN PROGRAM
4 EXCHANGE RATE TABLE FROM
1 EXCHANGE RATE TYPE 'M'
4 CURSOR POSITION (COLUMN)
4 CURSOR POSITION (LINE)
1 FLAG: DATA RECEIVED
8 LOCAL DATE FOR USER
8 SYSTEM: DATE
8 GLOBAL DATE RELATED TO UT
1 SUMMERTIME ACTIVE ? ('day
4 NUMBER OF ELEMENTS IN EDI
2 LOGICAL DATABASE FOR ABAP
10 SYSTEM: DATABASE SYSTEM
4 SYSTEM: DIALOG SYSTEM
1 INTERNAL USE
8 RUNTIME: NAME OF DATASET
4 SCREEN GROUP OF CURRENT S
4 NUMBER OF CURRENT SCREEN
72 INTERNAL USE
1 FACTORY CALENDAR WEEKDAY
4 LOCATION OF A STRING
8 INTERNAL: FLAT FILE (USIN
4 INTERNAL USE (FIELD LENGT
3 CURRENT FUNCTION CODE MEN
4 INTERNAL USE (FIELD DECIM
4 INTERNAL USE (FIELD OUTPU

SAP Procedure

Variable Name
SY-FTYPE
SY-GROUP
SY-HOST
SY-INDEX
SY-INPUT
SY-LANGU
SY-LDBPG
SY-LILLI
SY-LINCT
SY-LINNO
SY-LINSZ
SY-LISEL
SY-LISTI
SY-LOCDB
SY-LOCOP
SY-LOOPC
SY-LPASS
SY-LSIND
SY-LSTAT
SY-MACDB
SY-MACOL
SY-MANDT
SY-MARKY
SY-MAROW
SY-MODNO
SY-MSGID
SY-MSGLI
SY-MSGNO
SY-MSGTY
SY-MSGV1
SY-MSGV2
SY-MSGV3
SY-MSGV4
SY-NEWPA
SY-NRPAG
SY-ONCOM
SY-OPSYS
SY-PAART
SY-PAGCT
SY-PAGNO
SY-PAUTH
SY-PDEST
SY-PEXPI
SY-PFKEY
SY-PLAYO
SY-PLAYP
SY-PLIST
SY-PNWPA
SY-PRABT

Page 17

Type
CHAR
CHAR
CHAR
INT4
CHAR
LANG
CHAR
INT4
INT4
INT4
INT4
CHAR
INT4
CHAR
CHAR
INT4
CHAR
INT4
CHAR
CHAR
INT4
CLNT
CHAR
INT4
CHAR
CHAR
CHAR
NUMC N
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
INT4
INT4
NUMC
CHAR
NUMC
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR

Length
Contents
1 INTERNAL USE (FIELD TYPE)
1 INTERNAL: BUNDLING
8 HOST
4 NUMBER OF LOOP PASSES
1 INTERNAL USE
1 SAP LOGON LANGUAGE KEY
8 PROGRAM: ABAP/4 DATABASE
4 NUMBER OF CURRENT LIST LI
4 NUMBER OF LIST LINES
4 CURRENT LINE FOR LIST CRE
4 LINE SIZE OF LIST
255 INTERACT.: SELECTED LINE
4 NUMBER OF CURRENT LIST LI
1 LOCAL DATABASE EXISTS
1 LOCAL DATABASE OPERATION
4 NUMBER OF LOOP LINES AT S
4 INTERNAL USE
4 NUMBER OF SECONDARY LIST
16 INTERACT.: STATUS INFORMA
4 PROGRAM: NAME OF FILE FOR
4 NUMBER OF COLUMNS FROM SE
3 CLIENT NUMBER FROM SAP LO
1 CURRENT LINE CHARACTER FO
4 NO. OF LINES FROM SET MAR
1 NUMBER OF ALTERNATIVE MOD
2 MESSAGE ID
60 INTERACT.: MESSAGE LINE (
3
MESSAGE NUMBER
C
1 MESSAGE TYPE (E,I,W)
C
50 MESSAGE VARIABLE
C
50 MESSAGE VARIABLE
C
50 MESSAGE VARIABLE
C
50 MESSAGE VARIABLE
C
1 INTERNAL USE
C
1 INTERNAL USE
C
1 INTERNAL: ON COMMIT FLAG
C
10 SYSTEM: OPERATING SYSTEM
C
16 PRINT: FORMAT
X
4 PAGE SIZE OF LIST FROM RE
X
4 RUNTIME: CURRENT PAGE IN
N
2 INTERNAL USE
C
4 PRINT: OUTPUT DEVICE
N
1 PRINT: SPOOL RETENTION PE
C
8 RUNTIME: CURRENT F KEY ST
C
5 INTERNAL USE
C
1 INTERNAL USE
C
12 PRINT: NAME OF SPOOL REQU
C
1 INTERNAL USE
C
12 PRINT: DEPARTMENT ON COVE
C
C
C
X
C
C
C
X
X
X
X
C
X
C
C
X
C
X
C
C
X
C
C
X
C
C
C

SAP Procedure

Variable Name
SY-PRBIG
SY-PRCOP
SY-PRDSN
SY-PREFX
SY-PRI40
SY-PRIMM
SY-PRINI
SY-PRLOG
SY-PRNEW
SY-PRREC
SY-PRREL
SY-PRTXT
SY-REPI2
SY-REPID
SY-RSTRT
SY-RTITL
SY-SAPRL
SY-SCOLS
SY-SFNAM
SY-SFOFF
SY-SLSET
SY-SPONO
SY-SPONR
SY-SROWS
SY-STACO
SY-STARO
SY-STEPL
SY-SUBCS
SY-SUBRC
SY-SUBTY
SY-SYSID
SY-TABID
SY-TABIX
SY-TCODE
SY-TFDSN
SY-TFILL
SY-TIMLO
SY-TIMUT
SY-TITLE
SY-TLENG
SY-TLOPC
SY-TMAXL
SY-TNAME
SY-TOCCU
SY-TPAGI
SY-TSTIS
SY-TSTLO
SY-TSTUT
SY-TTABC

Page 18

Type
CHAR
NUMC N
CHAR
CHAR
CHAR
CHAR
NUMC
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
INT4
CHAR
INT4
CHAR
NUMC
NUMC
INT4
INT4
INT4
INT4
CHAR
INT4
RAW
CHAR
CHAR
INT4
CHAR
CHAR
INT4
TIMS
TIMS
CHAR
INT4
INT4
INT4
CHAR
INT4
INT4
INT4
NUMC
NUMC
INT4

Length
Contents
1 PRINT: SELECTION COVER SH
3
PRINT: NUMBER OF COPIES
C
6 PRINT: NAME OF SPOOL DATA
C
3 ABAP/4 PREFIX FOR BACKGRO
C
1 INTERNAL USE
C
1 PRINT: PRINT IMMEDIATELY
N
1 INTERNAL USE
C
1 INTERNAL USE
C
1 PRINT: NEW SPOOL REQUEST
C
12 PRINT: RECIPIENT
C
1 PRINT: DELETE AFTER PRINT
C
68 PRINT: TEXT FOR COVER SHE
C
8 INTERNAL USE
C
8 PROGRAM: NAME OF ABAP/4 P
C
1 INTERNAL USE
C
70 PRINT: REPORT TITLE OF PR
C
4 SYSTEM: SAP RELEASE
X
4 COLUMNS ON SCREEN
C
30 NO LONGER USED
X
4 INTERNAL USE
C
14 NAME OF SELECTION SET
N
5 RUNTIME: SPOOL NUMBER FOR
N
5 RUNTIME: SPOOL NUMBER FRO
X
4 LINES ON SCREEN
X
4 INTERACT.: LIST DISPLAYED
X
4 INTERACT.: PAGE DISPLAYD
X
4 NUMBER OF LOOP LINE AT SC
C
1 INTERNAL: CALL STATUS OF
X
4 RETURN VALUE AFTER SPECIF
X
1 ABAP/4: CALL TYPE FOR SUB
C
8 SYSTEM: SAP SYSTEM ID
C
8 INTERNAL USE
X
4 RUNTIME: CURRENT LINE OF
C
4 SESSION: CURRENT TRANSACT
C
8 RUNTIME: DATASET FOR DATA
X
4 CURRENT NUMBER OF ENTRIES
T
6 LOCAL TIME FOR USER
T
6 GLOBAL TIME RELATED TO UT
C
70 TITLE OF ABAP/4 PROGRAM
X
4 LINE WIDTH OF AN INTERNAL
X
4 INTERNAL USE
X
4 MAXIMUM NUMBER OF ENTRIES
C
30 NAME OF INTERNAL TABLE AF
X
4 OCCURS PARAMETER WITH INT
X
4 FLAG INDICATING ROLL-OUT
X
4 INTERNAL USE
N
14 TIMESTAMP (DATE AND TIME)
N
14 TIMESTAMP (DATE AND TIME)
X
4 NUMBER OF LINE LAST READ
C

SAP Procedure

Variable Name
SY-TTABI
SY-TVAR0
SY-TVAR1
SY-TVAR2
SY-TVAR3
SY-TVAR4
SY-TVAR5
SY-TVAR6
SY-TVAR7
SY-TVAR8
SY-TVAR9
SY-TZONE
SY-UCOMM
SY-ULINE
SY-UNAME
SY-UZEIT
SY-VLINE
SY-WAERS
SY-WILLI
SY-WINCO
SY-WINDI
SY-WINRO
SY-WINSL
SY-WINX1
SY-WINX2
SY-WINY1
SY-WINY2
SY-WTITL
SY-XCODE
SY-XFORM
SY-XPROG
SY-ZONLO

Type
INT4
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
CHAR
INT4
CHAR
CHAR
CHAR
TIMS
CHAR
CUKY
INT4
INT4
INT4
INT4
CHAR
INT4
INT4
INT4
INT4
CHAR
CHAR
CHAR
CHAR
CHAR

X
C
C
C
C
C
C
C
C
C
C
X
C
C
C
T
C
C
X
X
X
X
C
X
X
X
X
C
C
C
C
C

Length
Contents
4 OFFSET OF INTERNAL TABLE
20 RUNTIME: TEXT VARIABLE FO
20 RUNTIME: TEXT VARIABLE FO
20 RUNTIME: TEXT VARIABLE FO
20 RUNTIME: TEXT VARIABLE FO
20 RUNTIME: TEXT VARIABLE FO
20 RUNTIME: TEXT VARIABLE FO
20 RUNTIME: TEXT VARIABLE FO
20 RUNTIME: TEXT VARIABLE FO
20 RUNTIME: TEXT VARIABLE FO
20 RUNTIME: TEXT VARIABLE FO
4 TIME DIFFERENCE FROM 'Gre
70 INTERACT.: COMMAND FIELD
255 CONSTANT: UNDERLINE (4444
12 SESSION: SAP USER FROM SA
6 SYSTEM: TIME
1 CONSTANT: VERTICAL BAR
5 T001: COMPANY CODE CURREN
4 NUMBER OF CURRENT WINDOW
4 CURSOR POSITION IN WINDOW
4 INDEX OF CURRENT WINDOW L
4 CURSOR POSITION IN WINDOW
79 INTERACT.: SELECTED WINDO
4 WINDOW COORDINATE (COLUMN
4 WINDOW COORDINATE (COLUMN
4 WINDOW COORDINATE (LINE L
4 WINDOW COORDINATE (LINE R
1 STANDARD PAGE HEADER INDI
70 EXTENDED COMMAND FIELD
30 INTERNAL USE (SYSTEM-EXIT
8 INTERNAL USE (SYSTEM-EXIT
6 TIME ZONE OF USER

Table 2 - SAP System Variables By Name

Page 19

You might also like