ABAP Prog Standard
Transcript of ABAP Prog Standard
7/23/2019 ABAP Prog Standard
http://slidepdf.com/reader/full/abap-prog-standard 1/19
SAP Procedure
Reference: SERVER1\SYS1:\COMMON\SAPPROJE\SETUP\PROC037.DOC (Word 7.0a)
Title: ABAP/4 Programming Standard
Author: Richard Harper
Date: June ’98
Version: 1.0
SAP Version: 3E
Table Of Contents.
1. INTRODUCTION........................................................... ............................................................. .. 2
1.1. PURPOSE........................................... ........................................................... .............................. 2
1.2. SCOPE..................................... ........................................................... ........................................ 2
1.3. AUDIENCE. ........................................................... ........................................................... .......... 2
1.4. R ELATED DOCUMENTS. ............................................................ ................................................. 2
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. I N-HOUSE PROGRAMS................................. ........................................................... .................. 13
3.2. SAP STANDARD PROGRAMS. ................................................... ............................................... 13
3.2.1. Chnge........................................... ........................................................... ........................ 133.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. I NCLUDE PROGRAMS. ..................................................... ......................................................... 15
4.2. FORMS (PROCEDURES). ............................................... ....................................................... ..... 15
4.3. FUNCTIONS................... ............................................................ ............................................... 15
4.4. 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
7/23/2019 ABAP Prog Standard
http://slidepdf.com/reader/full/abap-prog-standard 2/19
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
UK’s 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
7/23/2019 ABAP Prog Standard
http://slidepdf.com/reader/full/abap-prog-standard 3/19
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:
************************************************************************* Pr ogr am: ZSO0630* Ti t l e: Or der I nt ake Anal ysi s By Profi t Cent r es* Anal yst: Ceci l i a Chan* Pr ogrammer : Ri chard Harper* Date: 12/ 05/ 98* Doc. I d: 31- 10010013- 06************************************************************************** Change Hi st ory* Dat e Reason Who*REPORT ZSO0630 Message- I d 38
Li ne- Count 64( 1)
Li ne-Si ze 132No Standar d Page Headi ng.
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: Begi n Of t _r epdata Occur s 0,** Data common across al l r epor t s
* vkorg l i ke vbak- vkorg, " Sal es orgvtweg l i ke vbak- vtweg, " Di st r i but i on Chnlspar t l i ke vbak-spart , " Di vi si on
Page 3
7/23/2019 ABAP Prog Standard
http://slidepdf.com/reader/full/abap-prog-standard 4/19
SAP Procedure
vkbur l i ke vbak-vkbur , " Sal es Of f i cevkgr p l i ke vbak- vkgr p, " Sal es Gr ouperdat l i ke vbak- erdat , " Or der Dat e
***********************************************************************
** ZSO0600 - For Management*
vbel n l i ke vbak- vbel n, " P/ O No.kunnr l i ke vbak- kunnr, " Cust omer Numbermatkl l i ke vbap- matkl , " Modelkwmeng l i ke vbap- kwmeng, " Or der Qt ywaer k l i ke vbak- waer k, " Curr encykzwi 6 l i ke vbap- kzwi 6, " Or der Di scountkzwi 6c l i ke vbap- kzwi 6, " Conver t ed val uechnge l i ke vbak- net wr , " Net Changechngec l i ke vbak- net wr , " Conver t ed val uenet wr l i ke vbak- net wr , " Tot al order val uenet wr c l i ke vbak- net wr , " Conver t ed val ue.bezei l i ke t vaut - bezei , " Change I ndi cat or
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 Prefix
Constants c_
Internal Tables t_
Select Option Tables s_
Parameters p_
Form Parameters – Using Pu_Form Parameters – Changing Pc_
Form Parameters - Tables Pt_
Field Groups g_
Field Symbols f_
Ranges r_
Working storage 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 aworking storage version of mar a- mat nr could be defined as w_mat nr .
Where possible always declare a variable using the l i ke 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
7/23/2019 ABAP Prog Standard
http://slidepdf.com/reader/full/abap-prog-standard 5/19
SAP Procedure
Apart from that variable names should be clear, meaningful abbreviations
of what they actually represent. Over long variable names (such as
w_vat onsal es) 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 Fi el d123 t o Fi el d2.Move Fi el d3 t o Fi el d4.
Do not concatenate statements as this obscures the logic of the
program:
Perf orm Procedure Usi ng: ‘ A’ , ‘ B’ , ‘ C’ , ‘ D’ .
Instead separate these into separate statements:
Per f orm Procedur e Usi ng ‘ A’ . Per f orm Procedur e Usi ng ‘ B’ . Per f orm Procedur e Usi ng ‘ C’ . Per f orm Procedur e Usi ng ‘ D’ .
Do not use multiple assignments:
w_r esul t =w_var 1=w_var 2. ( How would you interpret this ?)
This should be coded as:
Move w_var 2 t o w_var 1.Move w_var2 to w_r esul t .
Page 5
7/23/2019 ABAP Prog Standard
http://slidepdf.com/reader/full/abap-prog-standard 6/19
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_var 2 type i .
Loop At Vbak.Per f or m Rout i ne1.
EndLoop.
I f w_materi al <> ‘ ‘ .Per f or m ProcessMat er i al .Case w_mater i al .
When ‘ 1’ ..
.When ‘ 2’ .
.
.
.EndCase.
EndI f .
The Select clause should be indented as follows:
Sel ect * f rom table up t o 1 rowsWher e condition1 and
condition2 andcondition3 and. . . . and. . . . or. . . .
Gr oup by group condition Or der 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 ABAP’s 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 ?*
i f w_model f ound = True.** Report Dependant Sel ecti on.*
Cl ear t _Repdata.Move- Cor r espondi ng vbak t o t_r epdat a.Case w_r epi d.
When c_zso0600.Per f orm GetOr derDi scount
usi ng vbak- vbel nChangi ng w_kzwi 6.
*
Page 6
7/23/2019 ABAP Prog Standard
http://slidepdf.com/reader/full/abap-prog-standard 7/19
SAP Procedure
* Get t he change r eason.*
2.3.3. Forms And Functions.A Form (SAP’s 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 changi ng
keyword that allows the variable passed to be changed rather that retaining
it’s 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 Stat i c 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 thereadability 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:
*ej ect************************************************************************ Procedur e:** Pur pose:** Ent ry:** Exi t :*
* Cal l ed By:** Cal l s :
Page 7
7/23/2019 ABAP Prog Standard
http://slidepdf.com/reader/full/abap-prog-standard 8/19
SAP Procedure
** Modi f i cat i on Hi story:** Dat e Reason Ver si on Who*
Form ProcedureName Tabl es TableList
...
... Usi ng ParameterList
...
...
Changi ng ChangeList.
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. The
action that it carries out.
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 generalroutine 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. Modif ication History.
Any changes to the routine after the initial write, entered under
the appropriate headings.
Page 8
7/23/2019 ABAP Prog Standard
http://slidepdf.com/reader/full/abap-prog-standard 9/19
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
Lef t - hand col umn:Report sour ce: ZBOSSINC Version 00008
Request : M01K902911 22. 05. 1998 RHARPER Text : ZSO Repor t ser i es changes.
Ri ght - hand col umn:Report sour ce: ZBOSSINC active version
Request : M01K903193 01. 06. 1998 RHARPER Text : ZBOSSI NC modi f i cat i on/ upgr ade.
Contents unchanged:
Page 9
7/23/2019 ABAP Prog Standard
http://slidepdf.com/reader/full/abap-prog-standard 10/19
SAP Procedure
000010 000010 ***I NCLUDE ZBOSSI NC.000020 000020 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *000030 000030 *. . . . . . . . .000460 000460 Data: w__grouphdr t ype i , " I n group header r out i ne
000470 000470 w__l i nepr i nt ed t ype i , " Li ne pr i nt ed f l ag000480 000480 w__r unt ot al t ype i . " Run t ot al r ec needed
The following lines were changed:
000490 *
000490 *eject
Contents unchanged:
000500 000500 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *000510 000510 *000520 000520 * macr o: Psub.. . . . . . . . .000740 000740 &1- l ow &1- hi gh.000750 000750 EndLoop.000760 000760 End- Of - Def i ni t i on.
The following lines were changed:
000770 *000770 *eject
Contents unchanged:
000780 000780 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *000790 000790 *000800 000800 * Pr ocedure: Repheader .. . . . . . . . .001490 001490 Move Fal se t o w__ grouphdr.001500 001500 Move Fal se t o w__ l i nepri nted.001510 001510 ENDFORM.
The following lines were added:
001520 *eject
Contents unchanged:
001520 001530 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *
001530 001540 *001540 001550 * Pr ocedure: WLi ne.. . . . . . . . .002230 002240 wr i t e ' ' no- gap.002240 002250 enddo.002250 002260 ENDFORM.
The following lines were added:
002270 *eject
Contents unchanged:
002260 002280 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *002270 002290 *002280 002300 * Pr ocedure: Gr oupHdr .. . . . . . . . .002810 002830 Move f al se t o w__ l i nepri nted.002820 002840 Endi f .002830 002850 ENDFORM. " Gr oup Header .
The following lines were added:
002860 *eject
Contents unchanged:
002840 002870 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *002850 002880 *002860 002890 * Procedure: Pri nt Ti t l es.. . . . . . . . .003750 003780 EndWhi l e.003760 003790 Endi f .003770 003800 ENDFORM. " Pr i ntTi t l es
The following lines were added:
003810 *eject
Contents unchanged:
003780 003820 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *003790 003830 *003800 003840 * Procedur e: Under l i ne.
Page 10
7/23/2019 ABAP Prog Standard
http://slidepdf.com/reader/full/abap-prog-standard 11/19
SAP Procedure
. . . . . . . . .004020 004060 Move sy- ul i ne t o w__ r epl i ne+w__of f set ( p_wi dth).004030 004070 Wr i t e / w__ r epl i ne.004040 004080 ENDFORM. "UNDERLI NE
The following lines were added:004090 *eject
Contents unchanged:
004050 004100 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *004060 004110 *004070 004120 * Procedur e: Tabl el i ne.. . . . . . . . .004290 004340 Perf or m UnderLi ne004300 004350 usi ng Repor t Tabl e- Start Pos w__maxwi dth.004310 004360 ENDFORM.
The following lines were added:
004370 *eject
Contents unchanged:
004320 004380 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *
004330 004390 *004340 004400 * Procedur e: Bui l dRepor t .. . . . . . . . .005220 005280 endl oop.005230 005290 Append Report Tabl e.005240 005300 ENDFORM. "BUI LDREPORT.
The following lines were added:
005310 *eject
Contents unchanged:
005250 005320 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *005260 005330 *005270 005340 * Pr ocedure: For mat Repor t .. . . . . . . . .005940 006010 Modi f y Repor t Tabl e.005950 006020 Endl oop.
005960 006030 ENDFORM. "FORMATREPORTThe following lines were added:
006040 *eject
Contents unchanged:
005970 006050 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *005980 006060 *005990 006070 * Pr ocedure: Wr i t eLi ne. . . . . . . . .006720 006800 Wr i t e sy- vl i ne no- gap.006730 006810 Move Tr ue t o w__ l i nepri nted.006740 006820 EndFor m.
The following lines were added:
006830 *eject
Contents unchanged:
006750 006840 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *006760 006850 *006770 006860 * Pr ocedure: Set Col our. . . . . . . . .007070 007160 When Col _Group. For mat Col or Col _Group.007080 007170 Endcase.007090 007180 EndFor m.
The following lines were added:
007190 *eject
Contents unchanged:
007100 007200 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *007110 007210 *007120 007220 * Pr ocedure: Wr i t eCent r e.. . . . . . . . .007340 007440 Move p_t ext t o w__ r epl i ne+w__of f set .007350 007450 Wr i t e / 001 w__r epl i ne.007360 007460 ENDFORM.
Page 11
7/23/2019 ABAP Prog Standard
http://slidepdf.com/reader/full/abap-prog-standard 12/19
SAP Procedure
The following lines were added:
007470 *eject
Contents unchanged:
007370 007480 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *
007380 007490 *007390 007500 * Procedur e: Fi ndSuppl i er.. . . . . . . . .008410 008520 endi f .008420 008530 endi f .008430 008540 ENDFORM. " FI NDSUPPLI ER
The following lines were added:
008550 *eject
Contents unchanged:
008440 008560 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *008450 008570 *008460 008580 * Pr ocedure: Gi veLi ne.. . . . . . . . .009090 009210 move space t o p_t ext .009100 009220 endi f .
009110 009230 ENDFORM.
The following lines were added:
009240 *eject
Contents unchanged:
009120 009250 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *009130 009260 *009140 009270 * Procedure: St r i pSt r i ng.. . . . . . . . .009570 009700 EndWhi l e.009580 009710 EndDo.009590 009720 EndFor m.
The following lines were changed:
009600 *
009730 *eject
Contents unchanged:
009610 009740 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *009620 009750 *009630 009760 * Pr ocedure: Sort Rep. . . . . . . . .010030 010160 EndCase.010040 010170 Endi f .010050 010180 EndFor m.
The following lines were changed:
010060 *
010190 *eject
Contents unchanged:
010070 010200 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *010080 010210 *
010090 010220 * Pr ocedure: SubTi t l e. . . . . . . . .010730 010860 Endi f .010740 010870 Per f orm Wr i t eCent r e usi ng w__subt i t l e.010750 010880 EndFor m.
The following lines were added:
010890 *eject
Contents unchanged:
010760 010900 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *010770 010910 *010780 010920 * Procedur e: I ni t Br eak. . . . . . . . .011190 011330 Move t __col s[ ] t o Report Br eaks- Tot al s[ ] .011200 011340 Append Report Breaks.011210 011350 EndFor m.
The following lines were added:
011360 *eject
Page 12
7/23/2019 ABAP Prog Standard
http://slidepdf.com/reader/full/abap-prog-standard 13/19
SAP Procedure
Contents unchanged:
011220 011370 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *011230 011380 *011240 011390 * Pr ocedure: Checkbreaks. . . . . . . . .
012240 012390 EndWhi l e.012250 012400 EndI f .012260 012410 EndFor m.
The following lines were changed:
012270 *
012420 *eject
Contents unchanged:
012280 012430 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *012290 012440 *012300 012450 * Procedur e: Pr i ntTot al s. . . . . . . . .013000 013150 Posi t i on w__ pos.013010 013160 Wr i t e: sy- vl i ne.013020 013170 EndFor m.
The following lines were added:013180 *eject
Contents unchanged:
013030 013190 **** ***** **** **** ***** **** ***** ***** ***** ***** **** ***** ***** ***** ***** *013040 013200 *013050 013210 * Pr ocedure: RunTotal s. . . . . . . . .013500 013660 EndLoop.013510 013670 Per f orm Tabl eLi ne.013520 013680 EndFor m.
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 Dat e Who Reason Access Key
3.2.1. Chnge
This column should contain a consecutive change number (1 2 3.... etc)
Page 13
7/23/2019 ABAP Prog Standard
http://slidepdf.com/reader/full/abap-prog-standard 14/19
SAP Procedure
3.2.2. Date
The date the change commenced
3.2.3. WhoWho 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 appendedto 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
7/23/2019 ABAP Prog Standard
http://slidepdf.com/reader/full/abap-prog-standard 15/19
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:
Perf or m Procedure I n programName I f Found Tabl es TableList Usi ng Using List
Changi ng 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
I ncl ude 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
7/23/2019 ABAP Prog Standard
http://slidepdf.com/reader/full/abap-prog-standard 16/19
SAP Procedure
Appendix A
SAP System Variables.
Variable Name Type Length Contents
SY-ABCDE CHAR C 26 CONSTANT: ALPHABET (A,B,C)
SY-APPLI RAW X 2 SAP APPLICATIONS
SY-BATCH CHAR C 1 BACKGROUND ACTIVE (X)
SY-BATZD CHAR C 1 BACKGROUND SUBMIT: DAILY
SY-BATZM CHAR C 1 BACKGROUND SUBMIT: MONTHL
SY-BATZO CHAR C 1 BACKGROUND SUBMIT: ONCE
SY-BATZS CHAR C 1 BACKGROUND SUBMIT: IMMEDI
SY-BATZW CHAR C 1 BACKGROUND SUBMIT: WEEKLY
SY-BINPT CHAR C 1 BATCH INPUT ACTIVE (X)
SY-BREP4 CHAR C 4 BACKGROUND SUBMIT: ROOT N
SY-BSPLD CHAR C 1 BACKGROUND SUBMIT: LIST O
SY-CALLD CHAR C 1 CALL MODE ACTIVE (X)
SY-CALLR CHAR C 8 PRINT: ID FOR PRINT DIALO
SY-CCURS DEC P 5 RATE SPECIFICATION/RESULT
SY-CCURT DEC P 5 TABLE RATE FROM CURRENCY
SY-CDATE DATS D 8 DATE OF RATE FROM CURRENC
SY-CFWAE CUKY C 5 INTERNAL USE
SY-CHWAE CUKY C 5 INTERNAL USE
SY-COLNO INT4 X 4 CURRENT COLUMN DURING LIS
SY-CPAGE INT4 X 4 CURRENT PAGE NUMBER
SY-CPROG CHAR C 8 RUNTIME: MAIN PROGRAM
SY-CTABL CHAR C 4 EXCHANGE RATE TABLE FROM
SY-CTYPE CHAR C 1 EXCHANGE RATE TYPE 'M'SY-CUCOL INT4 X 4 CURSOR POSITION (COLUMN)
SY-CUROW INT4 X 4 CURSOR POSITION (LINE)
SY-DATAR CHAR C 1 FLAG: DATA RECEIVED
SY-DATLO DATS D 8 LOCAL DATE FOR USER
SY-DATUM DATS D 8 SYSTEM: DATE
SY-DATUT DATS D 8 GLOBAL DATE RELATED TO UT
SY-DAYST CHAR C 1 SUMMERTIME ACTIVE ? ('day
SY-DBCNT INT4 X 4 NUMBER OF ELEMENTS IN EDI
SY-DBNAM CHAR C 2 LOGICAL DATABASE FOR ABAP
SY-DBSYS CHAR C 10 SYSTEM: DATABASE SYSTEM
SY-DCSYS CHAR C 4 SYSTEM: DIALOG SYSTEMSY-DEBUG CHAR C 1 INTERNAL USE
SY-DSNAM CHAR C 8 RUNTIME: NAME OF DATASET
SY-DYNGR CHAR C 4 SCREEN GROUP OF CURRENT S
SY-DYNNR CHAR C 4 NUMBER OF CURRENT SCREEN
SY-ENTRY CHAR C 72 INTERNAL USE
SY-FDAYW INT1 X 1 FACTORY CALENDAR WEEKDAY
SY-FDPOS INT4 X 4 LOCATION OF A STRING
SY-FFILE CHAR C 8 INTERNAL: FLAT FILE (USIN
SY-FLENG INT4 X 4 INTERNAL USE (FIELD LENGT
SY-FMKEY CHAR C 3 CURRENT FUNCTION CODE MEN
SY-FODEC INT4 X 4 INTERNAL USE (FIELD DECIMSY-FOLEN INT4 X 4 INTERNAL USE (FIELD OUTPU
Page 16
7/23/2019 ABAP Prog Standard
http://slidepdf.com/reader/full/abap-prog-standard 17/19
SAP Procedure
Variable Name Type Length Contents
SY-FTYPE CHAR C 1 INTERNAL USE (FIELD TYPE)
SY-GROUP CHAR C 1 INTERNAL: BUNDLING
SY-HOST CHAR C 8 HOSTSY-INDEX INT4 X 4 NUMBER OF LOOP PASSES
SY-INPUT CHAR C 1 INTERNAL USE
SY-LANGU LANG C 1 SAP LOGON LANGUAGE KEY
SY-LDBPG CHAR C 8 PROGRAM: ABAP/4 DATABASE
SY-LILLI INT4 X 4 NUMBER OF CURRENT LIST LI
SY-LINCT INT4 X 4 NUMBER OF LIST LINES
SY-LINNO INT4 X 4 CURRENT LINE FOR LIST CRE
SY-LINSZ INT4 X 4 LINE SIZE OF LIST
SY-LISEL CHAR C 255 INTERACT.: SELECTED LINE
SY-LISTI INT4 X 4 NUMBER OF CURRENT LIST LI
SY-LOCDB CHAR C 1 LOCAL DATABASE EXISTS
SY-LOCOP CHAR C 1 LOCAL DATABASE OPERATION
SY-LOOPC INT4 X 4 NUMBER OF LOOP LINES AT S
SY-LPASS CHAR C 4 INTERNAL USE
SY-LSIND INT4 X 4 NUMBER OF SECONDARY LIST
SY-LSTAT CHAR C 16 INTERACT.: STATUS INFORMA
SY-MACDB CHAR C 4 PROGRAM: NAME OF FILE FOR
SY-MACOL INT4 X 4 NUMBER OF COLUMNS FROM SE
SY-MANDT CLNT C 3 CLIENT NUMBER FROM SAP LO
SY-MARKY CHAR C 1 CURRENT LINE CHARACTER FO
SY-MAROW INT4 X 4 NO. OF LINES FROM SET MAR
SY-MODNO CHAR C 1 NUMBER OF ALTERNATIVE MOD
SY-MSGID CHAR C 2 MESSAGE ID
SY-MSGLI CHAR C 60 INTERACT.: MESSAGE LINE (
SY-MSGNO NUMC N 3 MESSAGE NUMBER
SY-MSGTY CHAR C 1 MESSAGE TYPE (E,I,W)
SY-MSGV1 CHAR C 50 MESSAGE VARIABLE
SY-MSGV2 CHAR C 50 MESSAGE VARIABLE
SY-MSGV3 CHAR C 50 MESSAGE VARIABLE
SY-MSGV4 CHAR C 50 MESSAGE VARIABLE
SY-NEWPA CHAR C 1 INTERNAL USE
SY-NRPAG CHAR C 1 INTERNAL USE
SY-ONCOM CHAR C 1 INTERNAL: ON COMMIT FLAG
SY-OPSYS CHAR C 10 SYSTEM: OPERATING SYSTEM
SY-PAART CHAR C 16 PRINT: FORMAT
SY-PAGCT INT4 X 4 PAGE SIZE OF LIST FROM RE
SY-PAGNO INT4 X 4 RUNTIME: CURRENT PAGE IN
SY-PAUTH NUMC N 2 INTERNAL USE
SY-PDEST CHAR C 4 PRINT: OUTPUT DEVICE
SY-PEXPI NUMC N 1 PRINT: SPOOL RETENTION PE
SY-PFKEY CHAR C 8 RUNTIME: CURRENT F KEY ST
SY-PLAYO CHAR C 5 INTERNAL USE
SY-PLAYP CHAR C 1 INTERNAL USE
SY-PLIST CHAR C 12 PRINT: NAME OF SPOOL REQU
SY-PNWPA CHAR C 1 INTERNAL USESY-PRABT CHAR C 12 PRINT: DEPARTMENT ON COVE
Page 17
7/23/2019 ABAP Prog Standard
http://slidepdf.com/reader/full/abap-prog-standard 18/19
SAP Procedure
Variable Name Type Length Contents
SY-PRBIG CHAR C 1 PRINT: SELECTION COVER SH
SY-PRCOP NUMC N 3 PRINT: NUMBER OF COPIES
SY-PRDSN CHAR C 6 PRINT: NAME OF SPOOL DATASY-PREFX CHAR C 3 ABAP/4 PREFIX FOR BACKGRO
SY-PRI40 CHAR C 1 INTERNAL USE
SY-PRIMM CHAR C 1 PRINT: PRINT IMMEDIATELY
SY-PRINI NUMC N 1 INTERNAL USE
SY-PRLOG CHAR C 1 INTERNAL USE
SY-PRNEW CHAR C 1 PRINT: NEW SPOOL REQUEST
SY-PRREC CHAR C 12 PRINT: RECIPIENT
SY-PRREL CHAR C 1 PRINT: DELETE AFTER PRINT
SY-PRTXT CHAR C 68 PRINT: TEXT FOR COVER SHE
SY-REPI2 CHAR C 8 INTERNAL USE
SY-REPID CHAR C 8 PROGRAM: NAME OF ABAP/4 P
SY-RSTRT CHAR C 1 INTERNAL USE
SY-RTITL CHAR C 70 PRINT: REPORT TITLE OF PR
SY-SAPRL CHAR C 4 SYSTEM: SAP RELEASE
SY-SCOLS INT4 X 4 COLUMNS ON SCREEN
SY-SFNAM CHAR C 30 NO LONGER USED
SY-SFOFF INT4 X 4 INTERNAL USE
SY-SLSET CHAR C 14 NAME OF SELECTION SET
SY-SPONO NUMC N 5 RUNTIME: SPOOL NUMBER FOR
SY-SPONR NUMC N 5 RUNTIME: SPOOL NUMBER FRO
SY-SROWS INT4 X 4 LINES ON SCREEN
SY-STACO INT4 X 4 INTERACT.: LIST DISPLAYED
SY-STARO INT4 X 4 INTERACT.: PAGE DISPLAYD
SY-STEPL INT4 X 4 NUMBER OF LOOP LINE AT SC
SY-SUBCS CHAR C 1 INTERNAL: CALL STATUS OF
SY-SUBRC INT4 X 4 RETURN VALUE AFTER SPECIF
SY-SUBTY RAW X 1 ABAP/4: CALL TYPE FOR SUB
SY-SYSID CHAR C 8 SYSTEM: SAP SYSTEM ID
SY-TABID CHAR C 8 INTERNAL USE
SY-TABIX INT4 X 4 RUNTIME: CURRENT LINE OF
SY-TCODE CHAR C 4 SESSION: CURRENT TRANSACT
SY-TFDSN CHAR C 8 RUNTIME: DATASET FOR DATA
SY-TFILL INT4 X 4 CURRENT NUMBER OF ENTRIES
SY-TIMLO TIMS T 6 LOCAL TIME FOR USERSY-TIMUT TIMS T 6 GLOBAL TIME RELATED TO UT
SY-TITLE CHAR C 70 TITLE OF ABAP/4 PROGRAM
SY-TLENG INT4 X 4 LINE WIDTH OF AN INTERNAL
SY-TLOPC INT4 X 4 INTERNAL USE
SY-TMAXL INT4 X 4 MAXIMUM NUMBER OF ENTRIES
SY-TNAME CHAR C 30 NAME OF INTERNAL TABLE AF
SY-TOCCU INT4 X 4 OCCURS PARAMETER WITH INT
SY-TPAGI INT4 X 4 FLAG INDICATING ROLL-OUT
SY-TSTIS INT4 X 4 INTERNAL USE
SY-TSTLO NUMC N 14 TIMESTAMP (DATE AND TIME)
SY-TSTUT NUMC N 14 TIMESTAMP (DATE AND TIME)SY-TTABC INT4 X 4 NUMBER OF LINE LAST READ
Page 18
7/23/2019 ABAP Prog Standard
http://slidepdf.com/reader/full/abap-prog-standard 19/19
SAP Procedure
Variable Name Type Length Contents
SY-TTABI INT4 X 4 OFFSET OF INTERNAL TABLE
SY-TVAR0 CHAR C 20 RUNTIME: TEXT VARIABLE FO
SY-TVAR1 CHAR C 20 RUNTIME: TEXT VARIABLE FOSY-TVAR2 CHAR C 20 RUNTIME: TEXT VARIABLE FO
SY-TVAR3 CHAR C 20 RUNTIME: TEXT VARIABLE FO
SY-TVAR4 CHAR C 20 RUNTIME: TEXT VARIABLE FO
SY-TVAR5 CHAR C 20 RUNTIME: TEXT VARIABLE FO
SY-TVAR6 CHAR C 20 RUNTIME: TEXT VARIABLE FO
SY-TVAR7 CHAR C 20 RUNTIME: TEXT VARIABLE FO
SY-TVAR8 CHAR C 20 RUNTIME: TEXT VARIABLE FO
SY-TVAR9 CHAR C 20 RUNTIME: TEXT VARIABLE FO
SY-TZONE INT4 X 4 TIME DIFFERENCE FROM 'Gre
SY-UCOMM CHAR C 70 INTERACT.: COMMAND FIELD
SY-ULINE CHAR C 255 CONSTANT: UNDERLINE (4444
SY-UNAME CHAR C 12 SESSION: SAP USER FROM SA
SY-UZEIT TIMS T 6 SYSTEM: TIME
SY-VLINE CHAR C 1 CONSTANT: VERTICAL BAR
SY-WAERS CUKY C 5 T001: COMPANY CODE CURREN
SY-WILLI INT4 X 4 NUMBER OF CURRENT WINDOW
SY-WINCO INT4 X 4 CURSOR POSITION IN WINDOW
SY-WINDI INT4 X 4 INDEX OF CURRENT WINDOW L
SY-WINRO INT4 X 4 CURSOR POSITION IN WINDOW
SY-WINSL CHAR C 79 INTERACT.: SELECTED WINDO
SY-WINX1 INT4 X 4 WINDOW COORDINATE (COLUMN
SY-WINX2 INT4 X 4 WINDOW COORDINATE (COLUMN
SY-WINY1 INT4 X 4 WINDOW COORDINATE (LINE L
SY-WINY2 INT4 X 4 WINDOW COORDINATE (LINE R
SY-WTITL CHAR C 1 STANDARD PAGE HEADER INDI
SY-XCODE CHAR C 70 EXTENDED COMMAND FIELD
SY-XFORM CHAR C 30 INTERNAL USE (SYSTEM-EXIT
SY-XPROG CHAR C 8 INTERNAL USE (SYSTEM-EXIT
SY-ZONLO CHAR C 6 TIME ZONE OF USER
Table 2 - SAP System Variables By Name