abap programming standards document
TRANSCRIPT
-
8/13/2019 ABAP Programming Standards Document
1/119
SAP R/3 Implementation
ABAP Programming Standards
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
2/119
TABLE OF CONTENTS
3.3.5.2.1 Menu Standards............................................................................................................................263.3.5.2.2 Tabstrips in SAP Release 4.X......................................................................................................26.5.1.!.1 Inner "oin......................................................................................................................................!26.5.1.!.2 #e$t %uter "oin..............................................................................................................................!3
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
3/119
-
8/13/2019 ABAP Programming Standards Document
4/119
$. %ntro&uction
T*is do&ument is a &ompilation o$ possible A-AP pro+rammin+and e$$i&ien&, standards and ill proide +uidan&e in &reatin+readable maintainable &ode. It is intended $or all deelopers int*e SAP R/3 Implementation Proe&t 7iamond at 0oartis 8SA.
T*e A-AP lan+ua+e is an 9eent drien: 9top;don:pro+rammin+ lan+ua+e. T*e A-AP pro&essor &ontrols t*eee&ution o$ an eent. or eample t*e eent AT S
-
8/13/2019 ABAP Programming Standards Document
5/119
'. (enera) *ro"rammin" Stan&ar&s
'.1 Namin" Conventions o+ ABA* Deve)oments
All &ustom A-AP pro+ram names s*ould $ollo t*e namin+
standards stated belo.
-
8/13/2019 ABAP Programming Standards Document
6/119
%( ontrollin+MM ( Materials Mana+ement
S7 ( Sales and 7istributionPP( Produ&tion Plannin+PM( Plant Maintenan&ePS( Proe&t S,stemsS( ustomer Seri&eD0 ( DeneralT*is ill be deried $rom &*ara&ter 3 and 4 o$ t*e un&tionalspe&i$i&ation.
Reuirement Num -c!aracter 23 4/(
T*e Re>uirement 0umberC ill be t*e runnin+ serial numberit*in a SAP Module. T*e SAP Module and t*e re>uirementnumber to+et*er ill *elp as an inde in &ollation all
deelopment obe&ts su&* as un&tional spe&i$i&ation Te&*ni&alspe&i$i&ation 8nit test Plan A-AP deelopment obe&ts Epro+ram/tables/et&.
n&erscore?&*ara&ter F@(
T*e GC s,mbol ill be de$ined as separator.
Brie+ Descrition?&*ara&ters ; 3)@(
*ara&ters E 3) &an be used to brie$l, des&ribe t*e$un&tionalit, T*is &an also be used to distin+uis* seeral obe&ts
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
7/119
To be determined and in&luded in t*is do&ument later in t*e netersion.
'.1.1 %nterna) &ata &ec)aration78
?see se&tion 4@
'.1.$ Deve)oment C)asses
7eelopment &lasses +roup to+et*er deelopment obe&ts ?e.+.pro+rams tables $un&tion modules@ *i&* &an be &orre&ted andmi+rated to+et*er a&ross instan&es. A deelopment &lass &an $oreample &onsist o$ a transa&tion or a +roup o$ related transa&tions
alon+ it* pro+rams 77I obe&ts menu painters s&reen painterslo&= obe&ts messa+e &lasses mat&* &odes et&.All &ustom deelopment s*ould be assi+ned to a &ustom deelopment&lass. Temporar, obe&ts ma, be assi+ned to &lass HTMPC. %be&tsde$ined under t*e HTMP deelopment &lass ill not be mi+rated.7eelopment &lasses $ollo t*e namin+ &onention(
Deve)omentC)ass
Descrition
B7M
-
8/13/2019 ABAP Programming Standards Document
8/119
Deve)omentC)ass
Descrition
B0 0oartis onsumer ealt* ; SS ; ualit,Assuran&e
B0S 0oartis onsumer ealt* ; -asisB0T 0oartis onsumer ealt* ; Temp. 7e.
?onersion pro+rams@B0' 0oartis onsumer ealt* ; Sales J
7istributionB0X 0oartis onsumer ealt* ; Material Master7ata Mana+ement
B0B 0oartis onsumer ealt* ; ross appli&ation
'.1.' Function (rous
un&tion +roups allo $or +roupin+ related $un&tion modules and t*eir&omponents into a &ommon area. Also &ommon ariables ma, bes*ared b, all $un&tion modules it*in a $un&tion +roup.
un&tion +roups s*ould ad*ere to t*e $olloin+ namin+ &onention(
,9CCa555555555555555555555 E ountr, odea ; Appli&ation I7
%pen
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
9/119
un&tion modules are similar to pro+rams t*e primar, di$$eren&e ist*e, &an be &alled usin+ remote $un&tion &alls $rom t*e operatin+
s,stem &an be &alled ariabl, it*in and a&ross pro+rams and are nott,pi&all, built $or reportin+ usin+ sele&tion &riteria.
un&tion module names &an be a maimum o$ 3) &*ara&ters. T*e$olloin+ namin+ &onention s*ould be used(
,9CCa9555555555555555555555555
E ountr, odea ; Appli&ation I7 ; %pen ?separate ords it* unders&ores@
Remarks: All $un&tion modules s*ould $ollo pro+rammin+ standardsoutlined in t*is do&ument. T*ere is no di$$eren&e beteen pro+rams
and $un&tion modules *en &onsiderin+ lo+i& $los s,nta unittestin+ and ariable namin+.
'.1.2 Functions :o&u)es Ta)es Dec)aration
Tables must be de&lared in D#%-A# 7ATA
'.1.4 Layout Sets
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
10/119
'.1.; Stan&ar& Te5t
T*ese are standard pie&es o$ tet t*at &an be slotted into a la,out setand &an &ontain pie&es o$ standard tet t*at &an be &alled b, an, la,outset. An eample *ere standard tet ould be used ould be to *oldan address $or an inoi&e approal slip. T*e address is &ontained
it*in t*e standard tet and &an be &alled in t*e la,out set to displa,t*e address *en re>uired. I$ t*e address &*an+es onl, t*e standardtet needs to be modi$ied $or t*e &*an+es to be e$$e&tie immediatel,*ere it is &alled. T*e menu pat* $or standard tet is Tools/LordPro&essin+/Standard Tet or transa&tion S%1). T*e transport
pro&edure is sli+*tl, di$$erent a+ain in t*at ,ou *ae to &reate a blan=&orre&tion or repair and atta&* t*e standard tet to it. T*e
&orre&tion/repair &an t*en be released in t*e normal a,.
'.1.< :essa"es
T*e abilit, to displa, messa+es s*ould also $ollo t*e prin&iples o$
maintainabilit, and be stored as indiidual messa+es. Messa+e &lasseseist it* messa+es alread, in t*em. T*ere are alread, an etensienumber o$ messa+es in ea&* o$ t*e &lasses t*ere$ore more t*an li=el,,ou ill $ind t*e messa+e ,ou re>uire Nou &an also &reate a ne
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
11/119
uential number and &alled b, t*at number$rom t*e pro+ram it* t*e seerit, o$ t*e arnin+ bein+ de&ided ea&*
time t*e messa+e is &alled.
'.1.1=Loc> O6ect
L*en &reatin+ a #o&= %be&t t*e $ile name must be+in it*E,and
&an be a maimum o$ 14&*ara&ters lon+.E,CCa9tttttttttttt E ountr, odeA E Appli&ation I7t ; primar, table name ?*ere multiple #o&= %be&ts are re>uired$or t*e same primar, table assi+n a uni>ue di+it to t*e $inal
position@.
'.1.11 Transaction Co&es
ue transa&tion &ode *i&*is listed in to SAP tables. Table TST &ontains t*e attributes o$ t*e
transa&tion *ile table TSTT &ontains t*e s*ort tet asso&iated it*t*e transa&tion. Transa&tion &odes s*ould ad*ere to t*e $olloin+namin+ &onention(
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
12/119
-
8/13/2019 ABAP Programming Standards Document
13/119
2. *oose #o+i&al $ile name de$inition &ross;&lient
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
14/119
3. reate ne entr, $or ,our pro+ram as $olloin+ E#o+i&al $ile ( Opro+ram nameGI#
-
8/13/2019 ABAP Programming Standards Document
15/119
4. 8se t*e $olloin+ un&.Module in ,our pro+ram to +et t*e p*,si&al $ilename.
A## 80TI%0 QI#
-
8/13/2019 ABAP Programming Standards Document
16/119
Pro+ram attributes are set $rom t*e 9Attributes: option on t*e initialA-AP editor s&reen. All pro+ram attributes $or an A-AP are to be set
as $ollos( Title
T*e title s*ould be a s*ort &on&ise des&ription. T*is is t*e title *i&*appears in t*e *eader se&tion o$ a report *en it is ee&uted.
E5am)e(
Create BDC Session +or Transaction ::=1 8 Create :ateria):aster
'.$.$ Tye
T*e $olloin+ t,pes are aailable(
-
8/13/2019 ABAP Programming Standards Document
17/119
In SAP implementation all pro+rams are deeloped as ustomer
Produ&tion Pro+rams.C
'.$.0 A)ication
T*e A-AP Appli&ation s*ould be set as mentioned in t*e $un&tionalspe&i$i&ation name.
'.$.2 Aut!ori?ation (rou
8sed to restri&t a&&ess to users it*out a mat&*in+ aut*oriation +roupin t*eir pro$ile. *e&=s are per$ormed be$ore report ee&ution and
be$ore a&&ess to utilit, $un&tions report attributes and t*e A-APeditor.
'.$.4 Lo"ica) Dataase
Assi+ns t*e lo+i&al database to be ealuated b, t*e pro+ram. T*eor=ben&* proides a&&ess to all lo+i&al database pro+rams deliered
b, SAP.
'.$.; From A)ication
8sed in &onun&tion it* t*e lo+i&al database $ield. T*e tablesretrieed to a&&ess t*e parti&ular lo+i&al database depend upon t*isentr,.
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
18/119
'.$.1= Fi5e& *oint Arit!metic
I$ $la++ed all &al&ulations in t*e pro+ram are done usin+ $ied pointarit*meti&. I$ t*e $ield is not &*e&=ed de&imal pla&es are onl, ta=eninto &onsideration $or output not $or &al&ulations. All pro+rams s*ould*ae t*is $la+ &*e&=ed.
'.$.11 Start via Variant
I$ &*e&=ed t*e pro+ram &an onl, be ee&uted ia a ariant.
'.' &ate ro"rams3 Comments3 Formattin"3Structure
'.'.1 &ate ro"rams
All transa&tion update pro+rams are to o$$er t*e user t*e option o$runnin+ t*e A-AP eit*er in -7 Session or all Transa&tion modeunless a spe&i$i& mode or a &ombination o$ t*em li=e all Transa&tion$or all re&ords and -7 Session $or $ailed re&ords is spe&i$ied in t*eTe&*ni&al Re>uirement Spe&i$i&ation.
-
8/13/2019 ABAP Programming Standards Document
19/119
o$ t*e pro+ram s*ould be +ien at t*e top o$ t*e pro+ram ands*ould *ae t*e $olloin+ $ormat(
-
8/13/2019 ABAP Programming Standards Document
20/119
%F S8SBRC NE =.
E%T.
END%F.
En& o+ Dev@====02
A-AP &ode s*ould be ritten modular rat*er t*an in line
para+rap* or $orm st,le.
omple and lar+e &odin+ stru&tures s*ould be &ommented
b, usin+ a blo&=ed o$$ &omment se&tion pre&edin+ t*estru&ture.
-
8/13/2019 ABAP Programming Standards Document
21/119
-
8/13/2019 ABAP Programming Standards Document
22/119
-
8/13/2019 ABAP Programming Standards Document
23/119
Te5t8Symo)s 8 All tet s,mbols used $or *eaders s*ould
*ae numbers )1 )2 )3U.et&. As $ar as possible use
one tet $or one report *eader line. All Tet S,mbols used $ormessa+es s*ould *ae numbers M)1 M)2 M)3Uet&.
-
8/13/2019 ABAP Programming Standards Document
24/119
-
8/13/2019 ABAP Programming Standards Document
25/119
%0STA0TS7ATA
RA0D
-
8/13/2019 ABAP Programming Standards Document
26/119
*ROCESS AFTER %N*T.:ODLE E%T911;= AT E%T8CO::AND.
:ODLE *A%911;=.
8se I
-
8/13/2019 ABAP Programming Standards Document
27/119
-
8/13/2019 ABAP Programming Standards Document
28/119
t*e $ield to t*e ne transa&tion. 9-a&=: ill return to t*e ori+inaltransa&tion it* all $ields populated as t*e, ere be$ore leain+
it.Variants
All s&reens &ontainin+ lists s*ould be &apable o$ sain+ displa,ariants t*at ma, be retrieed b, t*e user in t*e normal a, and
be &apable o$ alloin+ t*e user to de$ine a de$ault ariant.
All report sele&tion must be &apable o$ &reatin+ and retriein+report sele&tion ariants.
Layout
Transa&tions t*at ill be used etensiel, must be >ui&= andeas, to use it* a minimum o$ s&reen &*an+es button &li&=s or=e,stro=es. S&reens s*ould be laid out to present a &lear
un&luttered ie it* data presented in lo+i&al +roups it*inseparate $rames.
'.'.2.$.1 :enu Stan&ar&s
A menu must be de$ined $or ea&* s&reen t*at $ollos t*estandard SAP st,le o$ menus in&ludin+ all o$ t*e appropriatemenu elements.
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
29/119
;op, ;;;;;;;;
;;;;;;;
8tilitie
s
Relea
senotes
;;;;;;;;;;;;;;;
ut #ist ;;;;;;;;;;;;;;;
Sae op, Lor=$lo
SAP0et
;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;
#in=s ;;;;;;;;;;;;;;;
Print Paste Priatenotes
eedba&=
;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;
%nspool
re>uests
;;;;;;;;;;;;;;
;
7elete Insertline
%nobs
Settin+s
-
8/13/2019 ABAP Programming Standards Document
30/119
-
8/13/2019 ABAP Programming Standards Document
31/119
Related tables &an be in&orporated in a lo&= obe&t instead o$*ain+ lo&= obe&ts per table.
A)yin" t!e Loc>
all t*e
-
8/13/2019 ABAP Programming Standards Document
32/119
Numerin" Jey
*rocess Loc> J (et No7
-
8/13/2019 ABAP Programming Standards Document
33/119
'.'.2.0 Dataase &ate Tec!niues
T*e main update te&*ni>ue $or bundlin+ database&*an+es in a sin+le database #8L is to use A## 80TI%0... I0 8P7ATuired as SAPautomati&all, does R%##-AK in &ase o$ errors and sends an
-
8/13/2019 ABAP Programming Standards Document
34/119
%n all initial entr, s&reens be sure t*e -AK A0
-
8/13/2019 ABAP Programming Standards Document
35/119
Bac> E5it Cance)
E++ect s Nes Nes 0o
Seuenceo+saveJc!ec>
*e&=s $irst saeoption later Sae option$irst&*e&=s later ;;;
E5am)etit)e o+
&ia)o"uein&o
-a&=
-
8/13/2019 ABAP Programming Standards Document
36/119
-
8/13/2019 ABAP Programming Standards Document
37/119
'.'.2.; :essa"es
Messa+es &an be used to &ommuni&ate it* users. T*e, aremostl, used $or error *andlin+ durin+ pro&essin+ o$ ot*er userdialo+s
Nou send messa+es usin+ t*e A-AP statement M
-
8/13/2019 ABAP Programming Standards Document
38/119
terminations it* a s*ort dump normall,onl, o&&ur *en a runtime error o&&urs.
Messa+e t,pe X allos ,ou to $or&e apro+ram termination. T*e s*ort dump&ontains t*e messa+e I7.
(ui&e)ines +or :essa"e !an&)in"
-AK /
-
8/13/2019 ABAP Programming Standards Document
39/119
DATABASE SELECT%ON
0o re&ord?s@ $ound mat&*in+ t*e sele&tion &riteria
TABLE CONTROL L%NE SELECT%ON
Position t*e &ursor on a alid entr,Sele&t a re&ord $rom t*e listSele&t a J re&ord $rom t*e list J ?s
SAP messa+e s*ould &ome *ereer $orei+n =e, is de$ined
t*rou+* &*e&= table.
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
40/119
rom date is in $uture
*ro"ram seci+ic
-
8/13/2019 ABAP Programming Standards Document
41/119
Do to t*e %be&t
-
8/13/2019 ABAP Programming Standards Document
42/119
S!ort te5to+ DataE)ement
:e&ium
te5t o+DataE)ement
Lon" te5to+ DataE)ement
Hea&in"
Outut inALV Reort
+or +ie)&cata)o" +ie)&co)&&ict5t
*rint
*revieo+ ALVreort
N #on+ Tet #on+ Tet
N N NAs set ?# MS @ S*ort
N N N N
Set R ;
eadin+ eadin+
N NAs set ?# MS @ Medium
Ala,s use di&tionar, stru&ture?s@ as per output re>uirement
o$ A#' report. T*is ill proide a &lean &ode. Stru&ture
des&ription s*ould sa, to be used onl, $or t*e spe&i$iedpro+ram.C
%nl, a maimum o$ ! &olumns &an be sorted in an A#'
Report.
olumn *eadin+ o$ A#' report &omes $rom t*e $ield label o$
data element. T*e $olloin+ are $our t,pes o$ $ield labelsasso&iated it* a data element
S* M di # d di
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
43/119
I$ 9eadin+: and 9s*ort: bot* do not eist t*en de$ault
&olumn *eadin+ ill be 9Medium: tet o$ $ield label .
I$ not*in+ else eists 9#on+: ill be used.
'.2 Core :o&i+ications
Prior to ma=in+ SAP sour&e &ode modi$i&ations a Sour&e ode*an+e Pro&ess must be in pla&e and re>uirements s*ould beapproed. As a standard onl, SAP aut*oried repairs s*ould bealloed to t*e SAP &ode.
L*en ma=in+ modi$i&ations to SAP &ore pro+rams it is er,
important to do&ument t*e &*an+es made it*in t*e pro+ram.
Lit*in t*e &omments se&tion at t*e be+innin+ o$ t*e pro+ramin&lude t*e $olloin+ as part o$ a modi$i&ation lo+(
Repair number o$ t*e modi$i&ation ?s,stem assi+ned@
0ame/initials o$ person ma=in+ t*e modi$i&ation
7ate
7es&ription o$ t*e modi$i&ation
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
44/119
number initials date and des&ription o$ add/&*an+e. 0o &odes*ould be deleted $rom an, SAP &ore pro+ram. #ines o$ &ode
t*at are no lon+er used s*ould be &ommented out.
-
8/13/2019 ABAP Programming Standards Document
45/119
-
8/13/2019 ABAP Programming Standards Document
46/119
4. ABAP Internal Names
0.1 Data Tyes
All data t,pes used b, a pro+ram s*ould be $irst de$ined to t*e
A-AP 7i&tionar, as a TNP
-
8/13/2019 ABAP Programming Standards Document
47/119
A-AP ariable names &an be a maimum o$ 3) &*ara&ters
lon+ $or 7ATA $ields
S
-
8/13/2019 ABAP Programming Standards Document
48/119
DRG or DridIG or lass Instan&e
RG or Ran+eldG or ieldntG or ountersl+ or la+s
3V reel,7e$inable
use abbreiations $or&lear and&on&ise names.
0.' Areviations
L*en de$inin+ 7ata ields use &lear and understandable names.In &ases *ere abbreiations are used utilie an a+reed upon seto$ standard abbreiations. It is important t*at abbreiations areused &onsistentl, in all names.
To determine an abbreiation $or ords not listed belo stripout all oels and insi+ni$i&ant &*ara&ters. 0ames *i&* be+init* a oel retain t*e oel in t*e abbreiation. Add oels
ba&= in *en abbreiations $or to di$$erent names are ali=e.Abbreiations ill be based on
-
8/13/2019 ABAP Programming Standards Document
49/119
All pro+rams t*at produ&e reports ?ie/ Reports Inter$a&esonersions@ s*ould use a Standard eader and ooter.
T*e Standard eader s*ould be as $ollos(Co)or7&olG*eadin+ intensi$ied onComany Name7S*ould be in upper &ase ; enteredReort Descrition7
-
8/13/2019 ABAP Programming Standards Document
50/119
2. ABA* D%CT%ONAR
L*en &reatin+ a &ustom table &are$ull, plan its desi+n andstru&ture. 7e$ine t*e table $ields appropriatel,. Ala,s pla&e t*e=e, $ields startin+ it* MA07T ?&lient@ $ield at t*e $ront o$ t*ere&ord la,out. 8se t*e SAP database administrator to *elp desi+nt*e table and its attributes inde and bu$$er settin+s.
2.1 Ta)es
L*en de$inin+ &ustom tables ala,s pla&e t*e =e, $ields at t*e$ront o$ t*e re&ord stru&ture.
2.1.1 Transarent Ta)es
L*en &reatin+ &ustom tables Transparent Tables s*ould be used
in most &ases. A Transparent table is a table it* s,stemstru&ture *i&* +ies an identi&al stru&ture inside SAP asoutside. T*ere$ore t*e table &an be a&&essed b, bot* internal andeternal appli&ations. All updates to SAP Tables s*ould be
per$ormed it*in SAP.
2.1.$ Vies
or reportin+ purposes use 'I
-
8/13/2019 ABAP Programming Standards Document
51/119
Indees ma, be deeloped *en t*e re>uired a&&ess to a
database table is based on $ields ot*er t*an t*e primar, =e, o$
t*e table.
%nl, in&lude $ields in an inde i$ t*e, redu&e t*e sele&ted
data si+ni$i&antl,.
As indees are adusted ea&* time table &ontents are &*an+ed
&reate se&ondar, indees dis&ernin+l, to minimie t*e impa&t
on t*e s,stem.
L*en S
-
8/13/2019 ABAP Programming Standards Document
52/119
Multiple indees o$ one table s*ould be disoint ?*ae $e
&ommon $ields@ in order not to &on$use t*e optimier *i&*
inde to use.
uentl, updated tables s*ould *ae onl, $e indees *ile
$re>uentl, sele&ted tables mi+*t *ae more.
Remoe unused indees or ones t*at &*an+e due to report
desi+n &*an+es.
aution(
T*e &reation o$ an inde &an a$$e&t per$orman&e adersel,. T*emost suitable inde $or t*e sele&t &riteria mi+*t not be t*e inde&*osen $or use b, t*e database optimier. reatin+ Indeess*ould be done &are$ull, and ointl, it* t*e SAP 7atabaseAdministrator. 'alidate t*e use o$ table indees b, per$ormin+ aS# Tra&e.
1.$ Structures
Identi$, t*e $ields t*at are used in &onstru&tin+ a s&reen in
7i l
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
53/119
In A-AP pro+rams ,ou &an a&&ess t*e $ields dire&tl, it*-
All s&reen and A#' Reports ?$or meetin+ t*e re>uirement o$
ield atalo+@ s*ould use 7i&tionar, stru&tures $or s&reen$ields instead o$ usin+ table de$initions or pro+ram ariables
2.' Data E)ements
A data element de$ines t*e des&ription $or t*e $ield. T*esemanti& in$ormation ?des&ription and $ield labels@ is assi+ned tot*e data element alon+ it* an, on;line do&umentation. I$
possible use t*e standard SAP 7ata
-
8/13/2019 ABAP Programming Standards Document
54/119
&onert mat&*&odes and *elp ies to sear&* *elps. ?T*eeistin+ mat&*&odes and *elp ies ill 0%T be deleted.@
A S
-
8/13/2019 ABAP Programming Standards Document
55/119
0atie S#. T*ese &ommands ala,s b,pass t*e bu$$er and
a&&ess t*e database dire&tl,. I$ natie S# as to update a
bu$$ered table dire&tl, t*e bu$$er status is not &*an+ed t*is&ould result in in&onsisten&ies beteen data in t*e bu$$er andt*e database.
2.; Data Tye Conversion
8nderstandin+ and usin+ data t,pe &omparisons and &onersions
is er, important in A-AP. olloin+ is a list $rom SAP R/3s,stem t*at lists *o eternal data t,pes are mapped to t*eA-AP data t,pes usin+ standard domains.
E5terna)DataTye
ABA* Data Tye Descrition
AP 0?6@ Postin+ period NNNNMMAR n ?n@ *ara&ter strin+s
#0T ?3@ lient
8KN ?5@ urren&, =e, re$eren&ed b,8RR $ields
8RR nms P??nV2@/2@7
-
8/13/2019 ABAP Programming Standards Document
56/119
E5terna)Data
Tye
ABA* Data Tye Descrition
pre&edin+ I0T2 $ield
08M n 0?n@ *ara&ter $ield it* onl, di+its
8A0 nms
P??nV2@/2@7
-
8/13/2019 ABAP Programming Standards Document
57/119
need to be tested $or e>ualit, t*at t*e di$$eren&e is er,small.
Reports *ae been made t*at errors o&&ur *en a $ield *ain+
de&imal pla&es is &ompared to )C be&ause SAP interprets an,number less t*an ).5 as e>ual to ). As a standard &reate a&onstant( GB
-
8/13/2019 ABAP Programming Standards Document
58/119
4. ABA* COD%N( TECHN%PES
4.1 %NTERNAL TABLES
An Internal Table is a +roup o$ re&ords &reated at runtime.
It is re&ommended to de$ine all internal tables usin+ user;de$ineddata t,pes and it*out a *eader line.
-
8/13/2019 ABAP Programming Standards Document
59/119
I$ an Internal Table is to be &reated dire&tl, $rom database tablesand t*e &ontents &urrentl, in t*e Internal Table need to be =ept
add t*e APP
-
8/13/2019 ABAP Programming Standards Document
60/119
8se t*e #
-
8/13/2019 ABAP Programming Standards Document
61/119
4.1.$ Retrievin" +rom an %nterna) Ta)e
4.1.$.1 Rea& Ta)eR
-
8/13/2019 ABAP Programming Standards Document
62/119
:ore E++icient
ey access it! LOO*JCHEC
LOO* AT TAB.
CHEC TAB8 VAL.
...
ENDLOO*.
Ma=e t*e &omparison operators s*are a &ommon t,pe as it*
an, lo+i&al epression t*e per$orman&e is better i$ t*e operandso$ a &omparison s*are a &ommon t,pe.
Per$orman&e &an be $urt*er en*an&ed i$ t*e #%%P L
-
8/13/2019 ABAP Programming Standards Document
63/119
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
64/119
4.1.' :o&i+yin" an %nterna) Ta)e
4.1.'.1 Co))ectT*e %##
-
8/13/2019 ABAP Programming Standards Document
65/119
A$ter t*e %##
-
8/13/2019 ABAP Programming Standards Document
66/119
onsiderations(
To delete all ros in an Internal Table use t*e R
-
8/13/2019 ABAP Programming Standards Document
67/119
-uildin+ S%RT
-
8/13/2019 ABAP Programming Standards Document
68/119
LOO* AT %9TAB.
I9LNE9CNTR I9LNE9CNT 1.
ENDLOO*
4.1.2.$ RAN(ES
T*e RA0D
-
8/13/2019 ABAP Programming Standards Document
69/119
7ATA( -
-
8/13/2019 ABAP Programming Standards Document
70/119
:ore E++icient
COLLECT IA9 %NTO %TAB.
Less E++icient
:OVE IA9 TO %TAB.
COLLECT %TAB.
8se t*e R
-
8/13/2019 ABAP Programming Standards Document
71/119
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
72/119
4.1.< Dis)ay o+ Tra++ic Li"!ts
Tra$$i& li+*ts ?Red Nello and Dreen@ mi+*t *ae to bedispla,ed $or di$$erent error situations i.e. Red $or
-
8/13/2019 ABAP Programming Standards Document
73/119
er+orm +9"et9)i"!ts usin" 9statc!an"in" 9icon9stat.
i9mo&u)e8statusicon 9icon9stat.
+orm +9"et9)i"!ts usin" 99stat c!an"in" 99icon9stat.
&ata7 )9stat )i>e ?cramo&!&8corrstat3 )9icon9stat tye icons8te5t3
)9icon9name-4=/ tye c.
)9stat 99stat.)9icon9stat 99icon9stat.
i+ )9stat c9e. )9icon9name c9re&.
e)sei+ )9stat c9. )9icon9name c9ye))o. e)sei+ )9stat sace. )9icon9name c9"reen. en&i+.
T!is +unction mo&u)e i)) return t!e icon
-)9icon9stat/ca)) +unction W%CON9CREATEW
e5ortin"
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
74/119
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
75/119
E5am)e
(et t!e )ast use& va)ue o+ )ant reci& +or)ant an& &ate se)ect ma5- )ntreci& / into9)anti& +rom Js)ssvJc)ntrec !ere )ant 9)ant an& )&&ate 9&ate.
9)anti& 9)anti& 1. %mme&iate)y enueue 9)anti&.
4.1.1= se o+ *ac>e& Numers
8se &aution *en per$ormin+ arit*meti& it* pa&=ed numbers.-e aare t*at i$ t*e numbers are de$ined it* a di$$erent numbero$ de&imal pla&es ,ou ma, +et unepe&ted results. A-AP
per$orms t*e arit*meti& i+norin+ t*e de&imal pla&es and insertst*e de&imal on t*e anser. are$ul testin+ is essential.
All Pa&=ed $ields are treated as *ole numbers. al&ulationsinolin+ de&imal pla&es re>uire additional pro+rammin+ toin&lude multipli&ation or diision b, 1) 1)) 1))) et& T*e
http://www.alstom.com/http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
76/119
%0'
-
8/13/2019 ABAP Programming Standards Document
77/119
elements o$ unli=e t,pes $or ,ou t*e end result ma, not be *att*e pro+rammer epe&ts.
L*en &omparin+ >uantit, $ields ma=e sure t*e >uantities are int*e same unit o$ measure. 0ote t*at t*is is normall, done b,loo=in+ at *i&* $ield is used 0%T b, &odin+ in a unit&onersion or alidation.
4.$ %nterna) Ta)es 8 SA* Re)ease 0.5
Ta)e Dec)aration an& :emory A))ocation
T,pes( -
-
8/13/2019 ABAP Programming Standards Document
78/119
TNP
-
8/13/2019 ABAP Programming Standards Document
79/119
4.$.1 :emory A))ocation +or %nterna) Ta)es in SA* 0.5
7ue to all o$ t*e internal table nestin+ t*at o&&urs SAP *asneeded to ta=e better &ontrol o$ t*e memor, allo&ation pro&ess$or internal tables. In Release 3.X t*e memor, $or internaltables as allo&ated in K- blo&=s. In Release 4.X t*ere ill bea ne al+orit*m to allo&ate memor,.
uation ill berepeated up to 3 times. A$ter t*at initial allo&ation *as beene&eeded 3 times memor, is simpl, allo&ated in 12K- blo&=s.#i=eise i$ no initial sie is spe&i$ied SAP 9+uesses: ?i.e. usesan undis&losed al+orit*m@.
4.' Co&e to a&& Function ey to Reorts
8se t*e $olloin+ &ode to add un&tion =e,s to Reports. T*e
&ode *elps in &reatin+ $un&tion buttons in a report it*out t*euse o$ P;STAT8S.
http://www.alstom.com/http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
80/119
((
I0ITIA#IBATI%0. prepare SM35 button ss&r$ields;$un&ttG)1 Q'ie SM35Q. $or =e, 1((at sele&tion;s&reen. i$ ss&r$ields;u&omm Q)1Q.
7)1));MAP0 PAGDR%8P. S
-
8/13/2019 ABAP Programming Standards Document
81/119
Sele&tion s&reen and $ilterin+ o$ t*e data
Aut*oriation &*e&=in+
I$ a #7- is &*osen t*e most e$$i&ient lo+i&al database possibles*ould be used. Stud, t*e sele&tion &riteria and *i&* se&ondar,indees are used $or t*at ie. Proide t*e appropriate sele&tion&riteria to limit t*e number o$ database reads. or&e users to
proide sele&tion &riteria b, ealuatin+ t*e sele&tion &riteria
entered on t*e sele&tion s&reen durin+ AT S
-
8/13/2019 ABAP Programming Standards Document
82/119
7etermine i$ some o$ t*e sele&tion s&reen $ields &an be
re>uired $ields. T*is ould $or&e t*e users to put in a alue
into t*ese $ields limitin+ t*e number o$ ros retrieed it*int*e lo+i&al database pro+ram. T*e sele&tion s&reen &an bed,nami&all, modi$ied b, t*e pro+ram usin+ t*e lo+i&aldatabase and usin+ AT S
-
8/13/2019 ABAP Programming Standards Document
83/119
4.0.1 Forms
%RMS are subroutines t*at allo a pro+rammer to de$ine a
pro&ess on&e in a pro+ram and &all t*at routine $rom di$$erentpla&es it*in t*e pro+ram or $rom ot*er pro+rams. A %RMs*ould be used $or lar+e &odin+ blo&=s. ommon se&tions o$&ode a&&essed $rom seeral points in an A-AP s*ould also be
put into %RMS.
I$ a blo&= o$ &ode is ee&uted more t*an on&e it s*ould be
pla&ed in a subroutine at t*e bottom o$ t*e &ode. T*is ma=es t*e&ode more readable re>uires less indentation and is easier todebu+ sin&e t*e debu++er &an ump t*rou+* an entire subroutineia a P =e,.
or +ood modulariation t*e de&ision o$ *et*er or not toP
-
8/13/2019 ABAP Programming Standards Document
84/119
-
8/13/2019 ABAP Programming Standards Document
85/119
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
86/119
it! sy8ms"v1 sy8ms"v$ sy8ms"v' sy8ms"v0.en&i+.
T*e s,stem ariables in t*e messa+e in t*e eample aboe arepopulated in t*e $un&tion module. It &an *oeer it*substituted it* a pro+ram spe&i$i& messa+e.
4.0.0 Sumit3 Ca))3 Leave To
T*e &ommands S8-MIT and S8-MIT A07 R
-
8/13/2019 ABAP Programming Standards Document
87/119
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
88/119
:ore e++icient +or Transarent X *oo) ta)esSELECT FRO: ,,LT$
IHERE RLDNR I9LD(R AND RRCT =G AND RVERS ==1G AND REAR I9R AND BRS I9C:*N AND RACCT I9ACCT AND RCNTR I9CNTR.
KK.ENDSELECT
Ii)) or>3 ut reuires more memory X u++ers
SELECT FRO: ,,LT$ IHERE RLDNR I9LD(R AND RRCT =G AND RVERS ==1G
AND REAR I9R. CHEC I9C:*N.
CHEC I9ACCT. CHEC I9CNTR.
KKKENDSELECT.
4.2.1.$ Data Se)ection +rom C)uster Ta)es
http://www.alstom.com/http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
89/119
ey +ie)&s in
t!e IHERE c)ause
SELECT FRO: BSE(IHERE BELNR BS%8BELNRAND BRS BS%8BRSAND L%FNR BS%8L%FNRAND SH,( SGAND OART G. KK..ENDSELECT.
Lill or= but re>uires a lot o$ aailable memor,
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
90/119
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
91/119
4.2.1.0 SELECT it! BFFER suort.
I$ bu$$erin+ is alloed $or a table in t*e A-AP 7i&tionar, t*e
Suentl, used and read;onl,. Addin+ t*e -NPASSI0D-8
-
8/13/2019 ABAP Programming Standards Document
92/119
Se)ect an& t!e aen& statement
REFRESH %9T==4.
SELECT FRO: T==4 %NTO %9T==4. A**END %9T==4.ENDSELECT.
Lill or= but i$ possible use I0T% TA-# CityG TO 9:C.CONCATENATE :rs.G
9:A 9:B+romG9:C %NTO CHA SE*ARATED B
S*ACE.
:rs. Mane :i))er +rom Ne or> City is t!e +ina)va)ue o+ CHA
More
-
8/13/2019 ABAP Programming Standards Document
99/119
se o+ t!e CONCATENATE Statement
CONCATENATE T1==8ARB(B T1==8:S(NR T1==8TET %NTO 9CLA.
Standard in Release 3.)se o+ a CONCATENATE +unction mo&u)e
CALL FNCT%ON STR%N(9CONCATENATE9'G
E*ORT%N( STR%N(1 T1==8ARB(B STR%N($ T1==8:S(NR STR%N(' T1==8TET %:*ORT%N( STR%N( 9CLA ECE*T%ONS
TOO9S:ALL =1.
%bsolete in Release 3.)
4.4.$ Removin" Lea&in" Saces
I$ leadin+ spa&es in a strin+ are to be deleted use t*e A-APstatement
SH%FT K LEFT DELET%N( LEAD%N(
http://www.alstom.com/http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
100/119
I9CLA contains t!e stin" E&itor )ine nG.
%F I9CLA CN S*ACE. END%F.SH%FT I9CLA B S8FD*OS *LACES LEFT.
#ess
-
8/13/2019 ABAP Programming Standards Document
101/119
4.4.0 STRLEN
T*e A-AP $un&tion STR#
-
8/13/2019 ABAP Programming Standards Document
102/119
-
8/13/2019 ABAP Programming Standards Document
103/119
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
104/119
8se spe&ial operators % ?ontains %nl,@ A ?ontains
An,@ S ?ontains Strin+@ instead o$ pro+rammin+ t*e
operations ,oursel$. I$ A-AP statements are ee&uted per&*ara&ter on lon+ strin+s P8 &onsumption &an risesubstantiall,.
-
8/13/2019 ABAP Programming Standards Document
105/119
4.@ SA* Re)ease 0.= O6ect Oriente& *ro"rammin"
E5am)e7R
-
8/13/2019 ABAP Programming Standards Document
106/119
Publi& E &omponents are isible outside t*e &lassProte&ted E &omponents are isible to sub&lasses o$ t*at &lassPriate E &omponents are onl, isible it*in t*e &lass itsel$.
Attriutes an& :et!o&sE Assi+ned to a se&tion
AttriutesE de$ine t*e internal state o$ an obe&t de$ined usin+a 7ATA statement.
Store an obe&ts properties
Re$eren&e ot*er obe&ts'irtual &ontrolled b, set/+et met*ods and Read %nl,
:et!o&sE %perations t*at are applied to obe&ts.Inter$a&e is similar to $un&tion modules.Import and eport parametersPass a return alue and &an raise e&eptions.
O6ectsE Instan&es o$ lasses
%be&ts belon+ to &lasses and *ae t*e same attributes andrespond to t*e same met*ods as ot*er obe&ts in t*at &lass.
%be&ts *ae( State as des&ribed b, its attributes be*aior
des&ribed b, its met*ods and an identit,.
%be&ts ma, intera&t( b, a&&essin+ publi& attributes b, &allin+
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
107/119
;. Hints an& Tis
Nou &an use t*e E&itand *attern Statement to set up
statements $or eample LRIT< or AS
-
8/13/2019 ABAP Programming Standards Document
108/119
de&larin+ o&&urren&e o$ 1))) and t*e s,stem allo&atesmemor, $or 1))) but ,ou onl, use a $e.
L*en de&larin+ a $ield tr, to use t*e #IK< statement to +ie,our ariable t*e same &*ara&teristi&s o$ an alread, de$inedariable.
Ala,s &*e&= A-AP statements return alue SN;S8-R
*et*er an operation as su&&ess$ul. an be used inR
-
8/13/2019 ABAP Programming Standards Document
109/119
Aen&i5
1J Conversion *rocess
T*e purpose o$ t*is Appendi is to proide &lear +uidelines $orbuildin+ onersion Pro+rams and onersion Reportin+.
1. Bui)&in" Conversion *ro"rams
SAP proides a number o$ Standard 8pload onersionpro+rams. I$ no Standard onersion pro+ram eists a ustomA-AP pro+ram ill be built.
L*ere a Standard onersion pro+ram does eist t*e pro+ramre>uires t*e input data in a spe&i$ied stru&ture/$ormat.onse>uentl, a &ustom A-AP pro+ram must be built tomanipulate and map t*e data. T*ere$ore t*e standard pro&essill be t*e deelopment o$ a ustom A-AP pro+ram to produ&ea $ile t*at meets t*e SAP Standard 8pload pro+ramCsre>uirements. T*e ne $ile ill be passed into t*e StandardA-AP. A list o$ standard SAP pro+rams $or data upload is
proided later.
1.1 Fi)e )oa&
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
110/119
L*en a trans$er o$ t*e $ile $rom or=station to appli&ation sereris re>uired t*en trans$er mode s*ould ala,s be ASII onl,.L*en t*e $ile is opened $or readin+ t*e data $rom appli&ationserer t*en use 9in tet mode:.
-
8/13/2019 ABAP Programming Standards Document
111/119
1.' Te5t +i)e +or .CSV Fi)e
L*ile uploadin+ t*e $ile ?.S' omma separated $ile@ ininter$a&e ob i$ &ontents o$ an, o$ t*e tet $ield in t*e input $ile&ontains &omma :: it must be separatel, ta=en &are o$?automati&all, ta=en &are in MS uotes is data itsel$and not a $ield separator.
0ote( Recor& no. 'doesnCt &ontain >uotes $or s&*eduledes&ription. As a result s,stem ill &onsider 9Monda,: as
Sc!e&u)e Descritionand 9Tuesda, 9 as Date.
-
8/13/2019 ABAP Programming Standards Document
112/119
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
113/119
$J ED% :o&i+ications
L*en modi$,in+ SAP supplied
-
8/13/2019 ABAP Programming Standards Document
114/119
Minimal up+rade impa&t.ustomer $un&tion modules illremain un&*an+ed. ; no &*an&e o$oerrite.
Mi+ration o$ up+radeden*an&ements in SAP standard$un&tion modules to &ustomer$un&tion modules.
Per$orman&e &an be $ine;tunedmore easil, b, remoin+unne&essar, +eneri& loo=ups?depends on &ustomer;spe&i$i&needs@.
'J Correction an& Transort System -CTS/ Namin" Stan&ar&s
1. %ntro&uction
T*e purpose o$ t*is do&ument is to outline t*e namin+&onention t*at s*ould be $olloed $or t*e &reation o$ Transports
$or A-AP deelopment obs in t*e deelopment enironment.
A ri+orous namin+ &onention is t*e &ornerstone o$ e$$e&tieersion mana+ement and &*an+e &ontrol in an SAP lands&ape.T*e Transport des&ription ill allo t*e te&*ni&al team to audit /tra&= / +roup &*an+es in t*e s,stem. It ill also allo t*ete&*ni&al team to identi$, and &orre&t errors *en t*e, o&&ur.
In s*ort a +ood namin+ standard ill allo t*e te&*ni&al teamand t*e -asis en+ineers to better support t*e proe&t.
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
115/119
Sample Transport 0o( 7%3K))342
T*e $irst 3 letters re$er to t*e Instan&e *ere t*e transport isbein+ &reated ?transport noCs are &lient independent@. K7elimiter. inall, a se>uential 6 di+it number t*at identi$ies t*etransport.
or in$o. SAP supplied transports e.+. $or Seri&e Pa&=s/ otPa&=ets $ollo t*e SAP namin+ &onention i.e. T*ese are not
pre$ied it* our s,stem Id
S!ort Descrition
T*is $ield is t*e main $o&us o$ t*is do&ument. T*e s*ortdes&ription is a 6) &*ara&ter $ree tet $ield *i&* is &ompleted
b, t*e &reator o$ t*e transport re>uest. T*is is one o$ t*e primar,
$ields used b, t*e te&*ni&al team $or reportin+.%utlined belo is t*e stru&ture *i&* must be $olloed *en&reatin+ a Transport re>uest.
Position Tet1;3 'alid 3;&*ara&ter pre$i e.+. 04 7as* ;
5.6 SAP module name ?Pi&= $rom un&tional spe&name@
F 7as*
-
8/13/2019 ABAP Programming Standards Document
116/119
-
8/13/2019 ABAP Programming Standards Document
117/119
-
8/13/2019 ABAP Programming Standards Document
118/119
Business O6ect *ro"ramJTransaction Co&e
http://www.alstom.com/ -
8/13/2019 ABAP Programming Standards Document
119/119
Business O6ect *ro"ramJTransaction Co&e
Plant Maintenan&e un&tional lo&ation tas= list RII-IP))/I-IP
*ro&uction :aster Data reate bill o$ material RS-I)1)
Produ&tion Master 7ata *an+e bill o$ material RS-I)2)Produ&tion Master 7ata reate ariant bill o$ material RS-I)3)Produ&tion Master 7ata reate bill o$ material it* lon+
tetsRS-I)4)
Produ&tion Master 7ata Routin+s/tas= lists7o&umentation in$o re&ord
RPTRA)1R'-I)1)
*ro&uction *)annin" 7emand mana+ement RMMM6)-I ?-at&* Input@RM6)I0)) ?7ire&t Input@
SA*8E%S Seeral re&ords $or SAP;