Sunteți pe pagina 1din 23

An Introduction to OOPS Concepts with Hands-

on for ALV
Author(s) : Sandeep Sreekumar, Paris Baskaran.
Reviewer(s) : Santhosh Narayanan(santhosh.narayanan@adidas.de)
ate written : 08-04-2005
ec!aration
e here!y de"#are that this do"ument is !ased on our persona# e$perien"es. %o the
!est o& our kno'#ed(e, this do"ument does not "ontain any materia# that in&rin(es
the "opyri(hts o& any other indi)idua# or or(ani*ation in"#udin( the "ustomers o&
+n&osys.

,e)ie'er -ate ,emarks
Pro"ect etai!s

.#ient/s Name0 1didas
Pro2e"t .ode0 21-S1P
Intended Audience
1B1P -e)e#opers
#a$!e of contents
% Introduction&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&'
( Overview of OOPs Concepts&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&'
' )h* O$"ect-Oriented A+AP,&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&'
3.4 5N61N.5- 75857 9: -1%1 5N.1PS;71%+9N.........................................4
3.2 <;7%+P75 +NS%1N%+1%+9N...................................................................4
3.3 .9-5 ,5;S5......................................................................................4
3.4 +N65,+%1N.5.....................................................................................4
3.5 1-81N.5- 585N% 61N-7+N= .9N.5P%S..............................................4
3.> S?575%9N 9: 1B1P .71SS..................................................................>
- A+AP O$"ect restrictions&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&.
4.4 69 %9 ;S5 1 =79B17 .71SS.............................................................@
4.2 =79B17 .71SS0 .7A=;+A178A=,+-......................................................B
4.2.1 Commonly used methods..............................................................9
4.2.4.4 setAta!#eA&orA&irstAdisp#ay......................................................B
4.2.4.2 :ree...................................................................................40
4.2.4.3 =etAse#e"tedAro's...............................................................44
4.2.4.4 re&reshAta!#eAdisp#ay...........................................................44
4.2.2 Commonly Used Events...............................................................12
4.2.2.4 .onte$tAmenuAreCuest........................................................42
4.2.2.2 -ataA"han(ed.....................................................................43
4.2.2.3 -ou!#eA"#i"k........................................................................44
4.2.2.4 %oo#!ar...............................................................................45
4.2.2.5 ;ser "ommand....................................................................4>
4.2.2.> 6otspotA"#i"k.......................................................................4@
4.2.3 Coloring a row:..........................................................................18
4.2.4 Coloring a column:.....................................................................19
4.2.5 Coloring a cell:...........................................................................19
-&' SAP/S CO0#AI01R..........................................................................20
4.3.1 C!"": C#$U%#"&%''E(#C)*'!%*E(........................................2+
4.3.4.4 Commonly used methods:....................................................20
(etA"ontainer...................................................................................20
setAro'Ahei(ht.................................................................................24
2 Conc!usion&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&((
. Reference:&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&('
3 Appendi4&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&('
% Introduction
D#he 5rowth of a pro5ra66er depends not on fo!!owin5 a techno!o5* $ut on
6ovin5 with the techno!o5* and drea6in5 $e*ond the techno!o5*E.
%his statement &its e$a"t#y into the (ro'th pro&i#e o& an 1B1P de)e#oper.
1s a part o& ,e#ease 4.5, S1P introdu"ed 1B1P 9!2e"ts - the 99 e$tension o& 1B1P -
!y e$tendin( the 1B1P pro(rammin( #an(ua(e 'ith .#asses and +nter&a"es and the
a!i#ity to "reate o!2e"ts &rom "#asses. S1P Basis ,e#ease 4.> de#i)ered the "omp#ete
)ersion o& 1B1P 9!2e"ts !y ena!#in( +nheritan"e - the key &eature o& 99 te"hno#o(y.
%hen "ame re#ease >.4 and >.2, 'ith hi(h#y ad)an"ed 99 "on"epts #ike F:riendship/
!et'een "#asses and FShared 9!2e"t/ "on"epts. 1#thou(h S1P has (i)en a "#ear-"ut
idea o& mo)in( to'ards a "omp#ete#y 9!2e"t-9riented 'or#d, ho' many o& us (1B1P
de)e#opers) are tryin( to keep aside the "on)i"tion that the pro"edura# approa"h o&
1B1P de)e#opment 'orks &ine and that there is no need to mi(rate to a ne'
pro(rammin( method.
%he 1B1P 9!2e"ts "an "onsidera!#y impro)e the produ"ti)ity !y speedin( the
de)e#opment time and in"reasin( the app#i"ation maintaina!i#ity. %his statement
mi(ht not arouse the interest o& most o& the pro(rammers (indi)idua##y) as 'e ha)e
a#ready set a #on( #ist o& pro"edures and too#s to maintain the pro(rams - 8ersion
mana(ement too#s, Gua#ity assuran"e systems et".
,e(ardin( the de)e#opment time, our idea is #ike this0
DPro(rammers are )ery &ast and i& they are not, 'ho is in a hurryHE
7et me take the e$amp#e o& !usiness s"enario pro(rammers (espe"ia##y those in
support pro2e"ts) 'ho (et a #ot o& "han(e reCuests. %hese 'i## in)o#)e addin( a ne'
&un"tiona#ity to the se#e"tion s"reen or remo)in( &un"tiona#ity. hat 'e 1B1P
de)e#opers usua##y do is, 'e 'i## (o and add Ide#ete the )aria!#es and su!routines
in)o#)ed. 9ne &ine mornin(, the "ustomer may ask &or some "han(es or the o#der
)ersion itse#&. No' 'e ha)e to remo)e a## the modi&i"ations doneJ sear"h &or unused
)aria!#es, stru"tures and 'ork areas, make a "omparison 'ith the o#der )ersion (i&
'e ha)e not mistaken#y done a pretty print)... + hope you "an )ery 'e## (et the #e)e#
o& dis"ip#ine that pro"edura# pro(rammin( demand. Sti## 'e sti"k on to that mere#y
!e"ause that is the 'ay in 'hi"h 'e ha)e a#'ays done it, and 'e don/t &ind any
reason to "han(e &rom the "on)entiona# method adopted.
1B1P 9!2e"ts 'ere ne)er intended to "omp#ete#y rep#a"e the "#assi"a# 1B1PI4. 1B1P
9!2e"ts is a &u##y )ia!#e o!2e"t-oriented e$tension o& 1B1P, addin( &u##-!#o'n o!2e"t-
oriented &eatures to the #atter. %his do"ument is 2ust meant to (i)e an o)er)ie' o&
1B1P 9!2e"ts - an attempt to tap some o& the myriad merits o& the sti## une$p#ored
99 te"hno#o(y and to (i)e an opportunity &or a## &e##o' pro(rammers to Fmo)e on
'ith the te"hno#o(y/.
( )h* O$"ect-Oriented A+AP,
Sin"e ,e#ease 4.>, 1B1P has !een a hy!rid #an(ua(e, 'ith 'hi"h you "an "hoose
'hether you 'ant to stay 'ith the pro"edura# pro(rammin( mode# - !ased on
&un"tion modu#es, su!routines, and the hand#in( o& e)ents &rom the runtime
en)ironment K or, you 'ant to use the o!2e"t-oriented pro(rammin( mode#, 'hi"h
&eatures0
(&% 1nhanced !eve! of ata 1ncapsu!ation
%he 1B1P 9!2e"ts impro)e the maintaina!i#ity and sta!i#ity o& the pro(rams. +n
pro"edura# pro(rammin(, a## the data o!2e"ts, the )aria!#es and the 'ork areas that
'e use (et popu#ated in a (#o!a# data area. +n a #ar(e app#i"ation, predi"tin( the
state o& ea"h o!2e"t is near#y impossi!#e. 9ne &un"tion mi(ht "han(e the app#i"ation
state in su"h a 'ay that many other &un"tions are a&&e"ted. ?eepin( the state sta!#e
thus reCuire a #ot o& dis"ip#ine. +n 9!2e"t-9riented pro(rammin(, the state is kept in
o!2e"ts and the state o& an app#i"ation is de&ined !y its attri!utes. %his maintains the
sta!i#ity o& the app#i"ation. +n this "ase, e)en i& a method &ai#s, the app#i"ation 'i##
"ontinue to run su""ess&u##y.
(&( 7u!tip!e Instantiation
<u#tip#e instantiation is one amon( the uniCue &eature o& 9!2e"t-9riented
pro(rammin(. +n pro"edura# pro(rammin(, you "an instantiate a &un"tiona#ity on#y
on"e, &or e(., 'hen 'e "a## a &un"tion modu#e, it (ets #oaded into the (#o!a#
memory(instantiated). +& the same or another pro(ram in the same interna# session
"a##s the &un"tion a(ain it 'ont (et re-instantiated. +nstead, it 'i## 'ork 'ith the
(#o!a# data that is a#ready a)ai#a!#e in the e$istin( &un"tion poo#.
(&' Code Reuse
<odu#ari*ations o& a pro(ram and "ode reuse are possi!#e in pro"edura# pro(rammin(
!y the use o& su!routines and &un"tion modu#es. ith the pro"edura# method o& "ode
reuse, the (reatest disad)anta(e is that it a##o's the Fa## or none/ "on"ept. 5ither you
ha)e a pie"e o& "ode that per&orms the &un"tiona#ity or e#se you need to 'rite a ne'
one.
(&- Inheritance
%his &eature permits the "reation o& o!2e"ts 'ith re&eren"e to an e$istin( (#o!a# "#ass.
e "an inherit some or a## the "hara"teristi"s o& a (enera# (or (#o!a#) "#ass to
spe"ia#i*ed "#asses simp#y !y pro(rammin( the di&&eren"e !et'een the t'o. %his is
possi!#e throu(h a sta!#e stand-a#one inter&a"e. +n pro"edura# pro(rammin(, 'e
make use o& parameter inter&a"e &or su!routines and pro"edura# inter&a"es &or the
&un"tion modu#es. 1B1P 9!2e"ts ena!#e the pro(rammers to 'ork 'ith an 9!2e"ts
Business 7o(i" throu(h standa#one inter&a"es, rather than 'orkin( 'ith the o!2e"ts
dire"t#y, 'hi"h re#ie)es the pro(rammer &rom kno'in( e$a"t#y ho' the &un"tiona#ity is
imp#emented.
(&2 Advanced 1vent hand!in5 concepts
1B1P 9!2e"ts make it easy to imp#ement the e)ent-dri)en pro(rammin( mode#. e
are 'e##-a"Cuainted 'ith the e)ent "on"epts in pro"edura# pro(rammin( #ike 1%-
S575.%+9N-S.,55N, 1%-;S5, .9<<1N-, 1%-7+N5 S575.%+9N et". %he main
pro!#em 'ith these methods is their imp#i"itness. %he pro(rammer has to kno' the
parti"u#ar pro(ram pro"esses (reportin(, dia#o(, se#e"tion-s"reen or #ist pro"ess) in
the 1B1P runtime en)ironment in order to understand the pro(ram &#o' and hand#e
the e)ents proper#y. 1#so, in pro"edura# pro(rammin(, it is not possi!#e to dea"ti)ate
an e)ent on"e it is imp#emented and 'e "annot de&ine and tri((er our o'n e)ents. +n
1B1P 9!2e"ts, the e)ents are e$p#i"it#y de"#ared as "omponents in a "#ass. %his (i)es
the &reedom to the pro(rammer to e$p#i"it#y "a## an e)ent !y the "ommand ,1+S5
585N%. e "an a#so pass some additiona# parameters that are interested in rea"tin(
to the e)ent. e "an a"ti)ate and dea"ti)ate the e)ents as reCuired and a#so "an set
up mu#tip#e hand#ers &or an e)ent.
<ost o& the a!o)e-mentioned &eatures are "ommon in a## the 9!2e"t-9riented
pro(rammin( #an(ua(es. 1B1P 9!2e"ts is espe"ia##y a #an(ua(e &or !usiness
app#i"ations. +t 'as desi(ned to !e simp#er than La)a and .MM and it omits "omp#e$
"on"epts that #a"k in !ene&its (su"h as mu#tip#e inheritan"e or destru"tors). 9n the
other hand, &or the po'er&u# "on"ept o& e)ents and e)ent hand#in(, 'hi"h are
a)ai#a!#e on#y )ia inter&a"es in other #an(ua(es, it 'as a "ons"ious de"ision to rea#i*e
them dire"t#y as #an(ua(e e#ements o& 1B1P 9!2e"ts.
%he (reatest !ene&it o& 1B1P 9!2e"ts #ies in the &a"t that they are an e$tension o& the
&ormer 1B1P pro(rammin( "on"epts.
Pro"edura#Ie)ent-!ased 1B1PI4 #an(ua(e runs in the same #e(a"y system and has
the &o##o'in( &eatures0
,uns on the S1P 1pp#i"ation Ser)er in the 1B1P runtime en)ironment
+s do'n'ard-"ompati!#e 'ith the e$istin( "odin(
+s inter-opera!#e 'ith the pro"edura# "odin(
5m!ra"es the !ene&its o& "#assi"a# 1B1P - &or e$amp#e, 9pen SG7
%hese &a"ts o&&er an e)o#utionary approa"h to o!2e"t-orientation, 'hi"h #e)era(es
S1P/s o'n and its "ustomers/ in)estments in e$istin( !usiness pro"esses,
&un"tiona#ity, and data. 1part &rom a## these, &rom the point o& )ie' o& a de)e#oper,
+t &rees the pro(rammer o& the 1B1P/s runtime imp#i"it "ontro# o& pro(ram &#o'.
1B1P 9!2e"ts o&&er !etter synta$ and semanti" ru#es. <ost o& the error prone
"on"epts (e.(.0- header, &or a## entries "ommand) are not permitted in the
1B1P "#asses.
1B1P 9!2e"ts is the on#y p#at&orm on 'hi"h 'e "an use the ne' S1P
te"hno#o(ies #ike Netea)er, and a## the ne' ad)an"ed =;+ "on"epts #ike -9+
(-esktop 9&&i"e +nte(ration), BSP (Business Ser)er Pa(es), .: (S1P .ontro#
:rame orks) et".
:rom a !usiness perspe"ti)e, mi(ration to 9!2e"t-9riented 1B1P pro(rammin( 'i##
sure#y impress the "#ients due to its enhan"ed pro"essin( speed. (1 separate kerne#
has !een set up &or the 1B1P 9!2e"ts that si(ni&i"ant#y impro)es the pro"essin(
"apa!i#ities) ,e(ardin( the maintenan"e, it 'i## redu"e the person hours a!out N
times 'hen "ompared to pro"edura# pro(rammin( 'here the &a"tor FN/ depends on
the e$pertise #e)e# and ho' 'e## the o!2e"t desi(n has !een made.
1s mentioned ear#ier, it is a s"rupu#ous 2o! &or a pro(rammer to make "han(es on a
standard "ode or a !i( "ustom app#i"ation pro(ram. %he main reason !ein(, in order
to make e)en a sma## "han(e, one shou#d kno' the a"tua# pro(ram &#o'. 1na#y*in(
the impa"t o& "han(es takes a ma2or amount o& de)e#opment time. But 'hi#e dea#in(
'ith "#asses, the de)e#oper "an a"ti)ate and dea"ti)ate the &un"tiona#ity or "reate a
ne' &un"tiona#ity simp#y !y "ommentin( the method "a##s or imp#ementin( a ne'
method inside the "#ass. %here is no need to manua##y de#ete the )aria!#es or
stru"tures or 'ork spa"es as the automati" (ar!a(e "o##e"tor 'i## "#ear the entire
memory 'hene)er an o!2e"t is de-re&eren"ed.
(&. S8e!eton of a$ap c!ass
' A+AP O$"ect restrictions
Synta$ restri"tions on 1B1P 9!2e"ts0-
-e"#arations 7ike re&eren"e to -ata o!2e"ts on#y, No imp#i"it
#en(ths or de"ima# p#a"es in %ypes. No #en(th
spe"i&i"ations on data types +,:,- or
%J:+57-S,,1N=5S
+N:9%NP5S, %1B75S, N9-5S, .9<<9NP1,%S,
9..;,S, +%6 651-5,, N9N-79.17 not
permitted
.on)ersions %,1NS71%5...9-5P1=5 and %,1NS71%5 O
N;<B5, :9,<1% not permitted
9perations0 .#earO'ith N;77,1---
.9,,5SP9N-+N=,-+8+-5-
.9,,5SP9N-+N=,S;BS%,1.%-
.9,,5SP9N-+N=,<;7%+P7NA.9,,5SP9N-+N=
not a##o'ed.
Strin( pro"essin(0 Not permitted on numeri" data o!2e"tsJ
pro"edura# pro(rammin( permits this 'hi"h
sometimes sho's surprisin( imp#i"it !eha)iors.
:+57--SN<B97S No imp#i"it types in :ie#d sym!o#s0 :+57--
SN<97SOOS%,;.%;,5,1SS+=NO%NP5,1SS+=N
%1B75 :+57- not permitted.
7o(i" 5$pression PQ ,RP,RQ not a##o'ed .
.ontro# stru"tures No operationa# statements !et'een
.1S5..65N..
+nterna# ta!#es No header #inesJ No imp#i"it 'ork areas, no
redundant key, "ompati!#e 'ork areas,
.9775.%, S9,%5- BN, ,+%5 %9 +%1B not
permitted.
Pro"edures No imp#i"it type assi(nment, .ompati!#e initia#
)a#ues on#y, passin( o& SN-S;B,. and raisin(
o& unde&ined e$"eptions not a##o'ed.
Pro(ram "a##s0
No 2oint use o& ;sin( and S?+P :+,S% S.,55N
in "a##in( transa"tions,
Passin( &orma# parameters imp#i"it#y in .177
-+179= not permitted.
-ata!ase a""ess0 N9 imp#i"it 'ork areas, ,51-, 799P and
,5:,5S6 &rom on -ata!ase ta!#es Not
permitted.
1## these synta$ restri"tions imposed on the 9!2e"t-9riented pro(rammin( prohi!it
many o!so#ete statements and additions, dete"ts and pre)ents many potentia##y
in"orre"t data hand#in( and redu"es the imp#i"itness o& the "odin(. :or e(., "onsider
the de"#aration o& an interna# ta!#e. +n pro"edura# pro(rammin(, 'e make use o&
ta!#es 'ith header #ines. hi#e doin( so, in addition to an interna# ta!#e, a se"ond
data o!2e"t is imp#i"it#y "reated 'ith the same name. %his is a si(ni&i"ant sour"e o&
"on&usion as the de)e#oper has to identi&y 'hether it re&ers to a header or a ta!#e,
'hi"h o&ten #eads to pro(rammin( errors. %he synta$-en&or"ed 9!2e"t-9riented 1B1P
a##o's de&inin( a ta!#e 'ithout the imp#i"it de&inition o& a header-#ine on#y.
'&% How to use a 9!o$a! C!ass
1#thou(h "odin( seems to !e a !it "on&usin( in the ear#y sta(e, pro(rammin( usin(
9!2e"ts is mu"h easier than the pro"edura# method. 7et us take the "ase o& an 178
(rid pro(rammin(. +n pro"edura# "on"epts, 'e "reate an e)ent-dri)en report and "a##
the &un"tion modu#e ,5;S5A178A=,+-A-+SP71N 'ith &ie#d "ata#o(ue, #ayout and
interna# ta!#es. 7et us see ho' the same &un"tiona#ity is attained usin( 1B1P 9!2e"ts.
Step !y step approa"h0
178 (rid instan"e needs a "ontainer to !e #inked 'ith the s"reen. ;sua##y instan"e o&
the "#ass F.7A=;+A.;S%9<A.9N%1+N5,/ is used &or this purpose. %o "reate a "ustom
"ontainer instan"e, you need to p#a"e a "ustom "ontro# area on the s"reen.
4. .reate a s"reen P400Q.
2. P#a"e the "ustom "ontro# on the s"reen and (i)e the proper name &or the
"ontro# (e(. .9N%4)..
3. -e"#are a## the reCuired (#o!a# &ie#ds.
-e&ine a )aria!#e in the pro(ram o& type s"r&name and )a#ue F.9N%4/.
4. -1%10 P(oA"ont4Q %NP5 s"r&name )a#ue F.9N%4/.
-1%10 P(oA(rid Q %NP5 ,5: to "#A(uiAa#)A(rid.
-1%1 0P(oA"ontainerQ %NP5 ,5: to "#A(uiA"ustomA"ontainer.
5. -e"#are an interna# ta!#e to ho#d the output #ist. (e(.P(tAoutta!Q ).
>. .a## the s"reen P400Q
+n the PB9 o& the s"reen, "reate an instan"e &or the "ontainer
((oA"ontainer) passin( the "ontainer name as the s"r&name/s
)aria!#e((oA"ont4). .reate the instan"e &or the a#) (rid e$portin( the
parent "ontainer say (oA"ontainer.
@. .a## s"reen 400.
a. <9-;75 statusA0400 9;%P;%.
!. +: (oA"ontainer +S +N+%+17.
2. .reate instan"e &or the "ontainer
a. .,51%5 9BL5.% P(oA"ontainerQ
i. 5SP9,%+N=
ii. "ontainerAname R TP.9N%4QT.
3. .reate instan"e &or the (rid
i. .,51%5 9BL5.% P(oA(ridQ
ii. 5SP9,%+N=
iii. iAparent R P(oA"ontainerQ.
4. 5N-+:.
5. 5N-<9-;75.
>. 9n"e you ha)e "reated the instan"es &or the "ontainer and (rid, you 'i## !e
a!#e to )ie' the (rid !y usin( the method setAta!#e-&orA&irstAdispa#y o& the
"#ass "#A(uiAa#)A(rid('hi"h is e$p#ained in detai# #ater in this !ok).
@. +n the P1+ o& the s"reen, you "an hand#e a## the (enera# user "ommands.
-e&inin( 7o"a# .#asses
7o"a# "#asses "onsist o& 1B1P sour"e "ode, en"#osed in the 1B1P statements
.71SS ... 5N-.71SS. 1 "omp#ete "#ass de&inition "onsists o& a de"#aration part and, i&
reCuired, an imp#ementation part. %he de"#aration part o& a "#ass P"#assQ is a
statement !#o"k0
.71SS P"#assQ -5:+N+%+9N.
...
5N-.71SS.
+t "ontains the de"#aration &or a## "omponents (attri!utes, methods, e)ents) o& the
"#ass. hen you de&ine #o"a# "#asses, the de"#aration part !e#on(s to the (#o!a#
pro(ram data. Nou shou#d there&ore p#a"e it at the !e(innin( o& the pro(ram.
+& you de"#are methods in the de"#aration part o& a "#ass, you must a#so 'rite an
imp#ementation part &or it. %his "onsists o& a &urther statement !#o"k0
.71SS P"#assQ +<P75<5N%1%+9N.
...
5N-.71SS.
%he imp#ementation part o& a "#ass "ontains the imp#ementation o& a## methods o& the
"#ass. %he imp#ementation part o& a #o"a# "#ass is a pro"essin( !#o"k. Su!seCuent
"odin( that is not itse#& part o& a pro"essin( !#o"k is there&ore not a""essi!#e.
'&( 9LO+AL CLASS: CL:9;I:ALV:9RI
=#o!a# "#ass that "ontains a## the methods, attri!utes and e)ents that are ne"essary
to
disp#ay a #ist in the 178 (rid. Nou "an "reate FN/ num!er o& instan"es o& a "#ass. ith
the
he#p o& the instan"es, you "an "a## a method 'ith 'hi"h you "an de&ine and "han(e
the
property o& the (rid "ontro#.
3.2.1 Commonly used methods
3.2.1.1 setAta!#eA&orA&irstAdisp#ay

+t/s a pu!#i" method that is used to disp#ay an output ta!#e in the spe"i&ied
(rid "ontro#.
Parameters0
Some o& the parameters shou#d !e passed 'hen u "a##
this method are .
Name %ype :un"tion
+SA71N9;% 78.ASA71N9 :or settin( the (enera#
(raphi"a# #ayout &or the
(rid.
+%A%997B1,A5S.7;-+N= ;+A:;N.%+9N .ontains &un"tion "odes o&
the too#!ar to !e e$"#uded
&rom the #ist (&un"tion
"odes are attri!utes
pre&i$ed 'ith m"A&"A).
+%A:+57-.1%179= 78.ASA:.1% +nterna# ta!#e o& type
#)"AsA&"at,.arries the &ie#d
"ata#o(ue in&ormations.
+%A9;%%1B +nterna# ta!#e "ontains the
data to !e #isted in the (rid
"am,le code:

-!'!:go#test '.&E (E/ ') cl#gui#avl#grid.
-!'!:gs#layout '.&E lvc#s#layo
-!'!:gt#e0cl '.&E ui#1unction 2%'3 3E!-E( %*E.
-!'!:gt#outta4 '.&E "'!*-!(- '!5E )/ 6t#outta47 2%'3
3E!-E( %*E.
-!'!:gt#1ieldcat '.&E lvc#s#1cat 2%'3 3E!-E( %*E.
C! 8E'3)- go#test97set#ta4le#1or#1irst#dis,lay
E:&)('%*$
%s#layout ; gs#layout
%t#tool4ar#e0cluding ; gt#e0cl<=
C3!*$%*$
%t#outta4 ; gt#outta4<=
%t#1ieldcatlog ; gt#1ieldcat<=.
3.2.1.2 :ree
Pu!#i" method used to &ree up the re&eren"e )aria!#es and a#on( 'ith this
method use "#ear "ommand to "#ear a## the inter&a"es and attri!utes o& the
o!2e"t.
"am,le code:
.177 <5%69-0
$o#test971ree.
CE!(: $o#test.
3.2.1.3 =etAse#e"tedAro's
Pu!#i" method used to (et the inde$es o& the se#e"ted ro' &rom the (rid
in "ase o& se#e"tin( more than one ro' &rom the (rid.
Parameters0
Name %ype :un"tion
5%A+N-5SA,9S 78.A%A,9 .ontains the inde$es o& the
se#e"ted ro's.
"am,le code:
-ata: lt#rows ty,e lvc#t#row.
C! 8E'3)-:
go#test97get#selected#rows
%8&)('%*$
et#inde0#rows ; lt#rows.
3.2.1.4 re&reshAta!#eAdisp#ay
Pu!#i" method used to re&resh the output ta!#e in the (rid "ontro#.
"am,le code:

.177 <5%69-0
$o#test97re1resh#ta4le#dis,lay.
3.2.2 Commonly Used Events
3.2.2.1 .onte$tAmenuAreCuest
+n this e)ent you "an add your o'n de&ined &un"tions to the e$istin( "onte$t
menu and you "an a#so hideIdisa!#e the e$istin( "onte$t menu &un"tions.
Parameters0
Name %ype :un"tion
5A9BL5.% (,e& )aria!#e) .7A.%<5N; Standard "onte$t menu o&
the 178 (rid "ontro#.
"am,le code:

'o add your own o,tions to the e0isting conte0t menu use the method >add
1unction?.
C! 8E'3)- e#o4@ect97add#1unction
E:&)('%*$
1code ; >U&-!'E?
te0t ; >U,date details?.
!1ter adding the 1unction code you can code 1or the 1unction code AU&-!'EB in
the event user command.
!nd i1 u want to hideCshowCdisa4leCena4le the e0isting o,tions u can use these
methods
i. disa4le#1unctions
ii. ena4le#1unctions
iii. hide#1unctions.
iv. show#1unctions.
1or im,lementing the a4ove 1unctions what you need to do is @ust ,ass the
constant attri4utes that ,recedes with mc#1c#A1unction codesB o1 the class
cl#gui#alv#grid to a ta4le that is o1 ty,e ui#1unctions.
!nd call the a,,ro,riate method and e0,ort the 1unction codes to the ta4le.
"am,le code 1or hiding the o,tions
-!'!: lt#1codes '.&E ui#1unctions.
CE!( lt#1codes.
!&&E*- go#test97mc#1c#loc#co,y ') lt#1code.
!&&E*- go#test97mc#1c#col#o,timiDe ') lt#1code.
!&&E*- go#test97mc#1c#hel, ') lt#1code.
!&&E*- go#test97mc#1c#1ind ') lt#1code.
!&&E*- go#test97mc#1c#loc#cut ') lt#1code.
!&&E*- go#test97mc#1c#loc#insert#row ') lt#1code.
!&&E*- go#test97mc#1c#1i0#columns ') lt#1code.
C! 8E'3)- e#o4@ect97hide#1unctions
E:&)('%*$
1codes ; lt#1code.
3.2.2.2 -ataA"han(ed

%his e)ent (ets tri((ered 'hen the user tries to "han(e any data present in the
(rid. :or "ontro##in( the data "han(es on the (rid, 178 uses the instan"e o& the
.#ass .7A178A.61N=5-A-1%1AP,9%9.97 and passess it as an attri!ute to the
e)ent -ataA.han(e.By usin( this method user "an (et )a#ue o& the modi&ied "e##.
7ist o& methods used in the "#ass "#Aa#)A"han(edAdataAproto"o#&
<ethod name :un"tion
=etA"e##A)a#ue ;sed to (et the "e## )a#ue
<odi&yA"e## ;sed to modi&y the "e## "ontent
8a#ues o& the "han(ed data are stored in the attri!utes o& this instan"e.
#ist o& attri!utes 0
1ttri!ute name :un"tion
<tAmodA"e##s .ontains the input )a#ue o& the modi&ied
"e## 'ith ro'-ids and &ie#dnames( :ie#d
)a#idations doesn/t happen at this point)
<tA(oodA"e##s .ontains proper )a#ues o& the "e##.
Parameters0
Name %ype :un"tion
5,A-1%1A.61N=5-
(re&eren"e )aria!#e)
.7A178A.61N=5-A-1%1AP,9%9.97 Pu!#i" "#ass that
"ontains the
attri!utes
,methods and
e)ents hand#in(
the data A"han(e
e)ent.
"am,le code:

-!'!: er#data#changed '.&E (E/ ') cl#alv#changed#data#,rotocol.
-!'!: wa#test '.&E lvc#s#modi.
-!'! : row#inde0 '.&E lvc9inde0.
-!'! : wa#curr '.&E & -EC%8!" 2.
))& !' er#data#changed97mt#mod#cells %*') wa#test.
.1S50/PP,+.5 QF.
C! 8E'3)- er#data#changed97get#cell#value.
E:&)('%*$
i#row#id ; wa#test9row#id
i#1ieldname ; wa#test91ieldname
%8&)('%*$
e#value ; wa#curr.
C! 8E'3)- ,#er#data#changed97modi1y#cell
E:&)('%*$
i#row#id ; wa#test9row#id
i#1ieldname ; wa#test91ieldname
i#value ; wa#curr.
row#inde0 ; wa#test9row#id .
(E!- '!5E 6gt#outta47 %*-E: row#inde0.
%/ ".9"U5(C ; +.
6gt#outta49,rice7 ; wa#curr .
E*-%/.
6gt#outta49,aymentsum7 ; 6gt#outta49,rice7 E 6gt#outta49seatsocc7.
8)-%/. 6gt#outta47 %*-E: row#inde0.
E*-C!"E.
E*-))&.
3.2.2.3 -ou!#eA"#i"k
%his e)ent (ets tri((ered 'hen the user dou!#e "#i"ks on a "e## o& the "ontro#.
Parameters0

Name %ype :un"tion
5A,9 78.ASA,9 .ontains the ro'-id o& the
"#i"ked "e##.
5A.97;<N 78.ASA.97 .ontains the "o#umn
name o& the "#i"ked "e##.
5SA,9AN9 78.ASA,9+- .ontains the numeri" ro'-
id o& the "#i"ked "e##.

"am,le code:

-!'!: e#row#id '.&E lvc#s#rowF
e#column#id '.&E lvc#s#colF
es#row#id '.&E lvc#s#roidF
6lt#outta47 '.&E 6gt#outta47.

(E!- '!5E 6gt#outta47 into 6gs#struct7
%*-E: lvc#s#row9row#id.
%/ ".9"U5(C ; +
!*- e#column#id91ieldname ; > C!((%-?.
6lt#outta47 ; 6gt#outta47.
!&&E*- lt#outta4.
E*-%/.
3.2.2.4 %oo#!ar
%his e)ent is used to add se#& de&ined &un"tions to the e$istin( too# !ar. this e)ent
(ets tri((ered 'hen ea"h time the too#!ar o& the "ontro# needs to (et
re(enerated .
%he &ie#ds o& the stru"ture that norma##y "ontains.
:ie#d -es"ription
:un"tion :un"tion "ode &or the &un"tion
ButnAtyp 7ist o& !utton types
8a#ue .onstant <eanin(
0 "nt!A!typeA!utton
Button
(norma#)
4 "nt!A!typeAdropdo'n
Push!utton
'ith menu
2 "nt!A!typeAmenu <enu
3 "nt!A!typeAsep Seperator
4 "nt!A!typeA(roup
Push!utton
(roup
5 "nt!A!typeA"he"k .he"k!o$
> <enu entry
+"on +"on &or the !utton(optiona#)
%e$t %e$t &or the !utton (optiona#)
Gui"kin&o %oo# tip &or the !utton(optiona#)
-isa!#ed. 1dds the !utton as disa!#ed
Para6eters:
Name %ype :un"tion
5A9BL5.% .7A178A585N%A%997B1,AS5% .ontains an
attri!ute(mtAtoo#!ar) 'ith the
ta!#e &or &un"tions o& the
standard too#!ar.
"am,le code:

/ollowing ste, de,icts how to add a user de1ined 4utton on the e0isting
tool4ar.
a. -e1ine a event handler method 1or the tool4ar event.
4. -eclare a structure 1or adding a tool4ar element.
c. 8ove the relevant values into the structure 1ields.
d. Use the event ,arameter e#o4@ect to a,,end the attri4utes
1or the newly added 4utton in the tool4ar.
"ayF
-!'! :ls#tool4ar '.&E st4#4uttonF EE structure 1or adding a
EE tool4ar element.
e#o4@ect '.&E (E/ ') C#!G#EGE*'#'))5!(#"E'.
CE!( ls#tol4ar.
8)GE >+? ') ls#tool4ar94utn#ty,e. EEEE,ush4utton.
8)GE >-E'? ') ls#tool4ar91unction.
8)GE >-E'!%"? ') ls#tool4ar9te0t.
8)GE >/light details? ') ls#tool4ar9HuicIin1o.
!&&E*- ls#tool4ar ') e#o4@ect97mt#tool4ar.
%n the event handler method user#commandF user can ,lace his own logic into the
corres,onding 1unction code which is moved into 1unction 1ield o1 the ta4le.
*ote: you can hide the entire tool 4ar 4y adding >*)#'))5!(J 1ield to the layout
structure.
3.2.2.5 ;ser "ommand
%his e)ent (ets tri((ered 'hen the user de&ines his o'n &un"tion "ode.you "an 'rite
your o'n &un"tion under this &un"tion "ode and u "an "a## this &un"tion under this
e)ent.
Parameters0

Name %ype :un"tion
5A;.9<< SNA;.9<< :un"tion "ode used &or
se#&-de&ined &un"tion
"am,le code:
User can Huery the 1unction codes o1 the sel1 de1ined 1unctions under this event.
3ere is the code that de,icts how to Huery 1or selecting the details 1or more than
one row 1rom the alv grid.
-!'!: e#ucomm '.&E sy9ucomm.
-!'!:lt#rows '.&E lvc#t#row.
-!'!:ls#selected#line '.&E lvc#s#rowF
-!'!:ls#row#inde0 '.&E lvc#inde0.
-!'!:6lt#outta47 '.&E 6gt#outta47.
C!"E: e#ucomm.
23E* >6-E'7?.
C! 8E'3)- go#test97get#selected#rows
%8&)('%*$
et#inde0#rows ; lt#rows.
Clear: lt#outta4.
))& !' lt#rows %*') ls#selected#line.
CE!(: lt#outta4F
gt#outta4.
ls#row#inde0 ; ls#selected#line9inde0.
(E!- '!5E gt#outta4 into 6gt#wa7 %*-E: ls#row#inde0.
%/ ".9"U5(C ; +.
!&&E*- lt#outta4.
E*-%/.
E*-))&.
E*-C!"E.
3.2.2.6 6otspotA"#i"k
%his e)ent is simi#ar to the dou!#e "#i"k e)ent o& the "#ass "#A(uiAa#)A(rid. +ts
tri((ered 'hen the user "#i"ks on a "o#umn 'hi"h is desi(nated as a hotspot "o#umn
'hi"h is identi&ied !y hand stret"h mouse pointer.(you "an desi(nate hotspot "o#umn
'hen u !ui#d the &ie#d-"ata#o( !y settin( the &ie#d Fhotspot/ to FS/ ) .
Parameters0

Name %ype :un"tion
5A,9A+- 78.ASA,9 .ontains the ro'-id o& the
"#i"ked "e##.
5A.97;<NA+- 78.ASA.97 .ontains the "o#umn name
o& the "#i"ked "e##.
5SA,9AN9 78.ASA,9+- .ontains the numeri" ro'-
id o& the "#i"ked "e##.
"am,le code:
-!'!: e#row#id '.&E lvc#s#rowF
e#column#id '.&E lvc#s#colF
es#row#id '.&E lvc#s#roidF
6lt#outta47 '.&E 6gt#outta47.

(E!- '!5E 6gt#outta47 into 6gt#wa7
%*-E: lvc#s#row9row#id.
%/ ".9"U5(C ; +
!*- e#column#id91ieldname ; > C!((%-?.
6lt#outta47 ; 6gt#outta47.
!&&E*- lt#outta4.
E*-%/.
'&(&' Co!orin5 a row:
:or "o#orin( an entire ro' you need to add one more &ie#d in your output #ist ta!#e
stru"ture, 'hi"h is a 4 "hara"ter &ie#d that one is used to &i## the "o#or "ode &or the
ro'. Be&ore (oin( &urther #et us dis"uss ho' to "onstru"t a "o#or "ode.
.o#or "ode is a 4 "hara"ter &ie#d that is o& the &ormat.
:ormat0 .$y*.
here $-Q .o#or num!er.
y-Q 4 0r 0 (F4/ &or in)erse 9N and F0/ &or in)erse 9::)
*-Q4 or 0 ( F4/ &or intensi&ied 9N and /0/ &or intensi&ied 9::).
.o#or num!ers are #isted out in the !e#o' ta!#e.

4 Co!or Intended for
4 (ray-!#ue headers
2 #i(ht (ray #ist !odies
3 ye##o' tota#s
4 !#ue-(reen key "o#umns
5 (reen positi)e thresho#d )a#ue
> red ne(ati)e thresho#d )a#ue
@ oran(e .ontro# #e)e#s
1&ter mo)in( the "o#or "ode to the &ie#d "reated on the output ta!#e stru"ture ,you
need to pass this &ie#d name to the &ie#d F+N:9A:N1<5/ o& the #ayout stru"ture
"am,le code:
!dd 6col#rowA4B7 ty,e c in the gt#outta4.
8ove >C31+? to 6gt#outta4796col#row7. Ecol#row is a 4 character 1ield
E in the ta4le gt#outta4.
8ove >6C)#()27? to 6gs#layout79in1o#1name.

'&(&- Co!orin5 a co!u6n:
.o#orin( an entire "o#umn is )ery simp#e .'hat you need to do is 'hen you
!ui#d the &ie#d "ata#o( make the option F5<P61S+U5/ to FS/
&or the "o#umn you need make "o#or.
'&(&2 Co!orin5 a ce!!:
.o#orin( an "e## is simi#ar to "o#orin( a ro' . you need to add a deep
stru"ture &ie#d o& type 78.A%AS.97 to the output ta!#e stru"ture . this
deep stru"ture ta!#e used to &i## the "o#or datas.
%o "o#or an indi)idua# "e## , &or ea"h "e## "o#umn append a #ine to this deep
stru"ture ta!#e 'hi"h inturn a#so "ontains the "o#umn name at &ie#d F&name/
and some "o#or )a#ues in the F"o#/ &ie#d and 4 or 0 in the &ie#d Fint/ , Fin)/.
"am,le code:
1. %nclude a 1ield 6color#cell7 o1 ty,e lvc#t#scol to the out,ut list ta4le structure.
-!'! : wa#color '.&E lvc#s#scol.
-!'! : gt#color '.&E '!5E o1 lvc#s#scol.
-!'!: row#inde0 '.&E lvc#inde0.
8)GE >"E!'")CC? ') wa#color91name.
8)GE >K? ') wa#color9col.
8)GE >1? ') wa#color9int.
8)GE >1? ') wa#color9inv.
!,,end wa#color to gt#color.
6$t#outta4796color#cell7 <= ; gt#color<=.
8odi1y gt#outta4 inde0 6row#inde07
'&' SAP/s CO0#AI01R
1 "ustom "ontro# is an area on a s"reen. Nou "reate them in the S"reen Painter, and,
#ike a## other s"reen o!2e"ts, they ha)e a uniCue name. Nou use "ustom "ontro#s to
em!ed "ontro#s. 1 "ontro# is a so&t'are "omponent on the presentation ser)er, 'hi"h
"an !e either an 1"ti)eS "ontro# or a La)aBean, dependin( on the S1P(ui you are
usin(. %hey a##o' you to per&orm tasks, su"h as editin( te$ts, #o"a##y on the
presentation ser)er. %he "ontro# is dri)en !y the app#i"ation #o(i", 'hi"h sti## runs on
the app#i"ation ser)er.
'&'&% CLASS: CL:9;I:SPLI##1R:CO0#AI01R
%his "#ass is used to minimi*e the memory area o""upied !y the norma#
"ontainer. 6ere 'e "an "reate a sin(#e "ustom "ontro# area in the s"reen, and sp#it
the "ontainer as 'e reCuire. e "an pass these su!-"ontainers to the a#) (rid.
3.3.1.1 Commonly used methods:
get#container
;sed to (et the su! "ontainer that is (ot spitted &rom parent "ontainer.

Parameters0
Name :un"tion
,9(e$portin() Numeri" )a#ue that is used to represent
the ro' id o& the su! "ontainer.
.o#umn(e$portin() Numeri" )a#ue that is used to represent
the "o#umn id o& the su! "ontainer.
.ontainer(re"ei)in() Su! "ontainer name that is o& re&ern"e
type "#A(uiA"ontainer.
"am,le code:

-!'!:6go#cont17 '.&E (E/ ') cl#gui#container.
-!'!: go#s,litter '.&E (E/ ') l#gui#s,litter#container.
C! 8E'3)- 6go#s,litter7 97get#container
E:&)('%*$
row ; 1
column ; 1
(ECE%G%*$
container ; 6go#cont17.

set#row#height
;sed to set the hei(ht o& the su!-"ontainer.
Parameters0

Name :untion
+d Su! "ontainer/s id
6ei(ht Numeri"s )a#ue that spe"ies the hei(ht o&
the su! "ontainer.
"am,le code:


C! 8E'3)- 6go#s,litter797set#row#height
E:&)('%*$
id ; 1
height ; 25.

:or those pro(rammers 'ho &ind it di&&i"u#t to "reate the "ustom "ontainers o)er the
s"reens, S1P pro)ides a method that does the "ontainer-p#a"in( &or them.
hat you ha)e to do is to de&ine a "#ass o& type "#A(uiAa#)A(rid. hi#e "reatin( the
o!2e"t, pass the attri!ute "#A(uiA"ontainerRQs"reen0 as the parent "ontainer. hen
'e use "#A(uiA"ontainerRQs"reen0 as parent, the 178=rid "ontro# 'i## automati"a##y
use the &u## s"reen to disp#ay the (rid. N9 .9N%1+N5, -5:+N+%+9N +S ,5G;+,5-.
-1%10 "#Aa#) %NP5 ,5: %9 "#A(uiAa#)A(rid
.,51%5 9BL5.% "#Aa#)
5SP9,%+N=
iAparent R "#A(uiA"ontainerRQs"reen0
- Conc!usion
+n this Bo?, 'e ha)e 2ust e$p#ained ho' to make use o& some o& the (#o!a# "#asses
pro)ided !y S1P as a part o& S1P "ontro#s (S1P(ui.app#i"ation 4.>)..reatin( #o"a#
"#asses and imp#ementin( methods and e)ents 'i## he#p the de)e#opers to (o !eyond
the 6y!rid mode# to a "omp#ete#y enhan"ed 9!2e"t-9riented mode#. %hese are not
"o)ered in this Bo?.
9ur 'ho#e-hearted e&&ort has !een to arouse the 1B1P de)e#oper/s interest in the
9!2e"t-9riented "on"epts, as 'e stron(#y !e#ie)e that a mi(ration to'ards the
9!2e"t-9riented pro(rammin( 'i## not on#y he#p the pro(rammer to (ro' indi)idua##y
!ut a#so it 'i## in turn he#p the !usiness and there!y the "ompany to a"hie)e (reater
hei(hts.
1&ter (oin( throu(h the do"umentJ i& you &ee# that it is hi(h time &or you to (i)e a
serious thou(ht to your "urrent approa"h to 1B1P de)e#opment, + !e#ie)e + ha)e
a"hie)ed 'hat + ha)e tried &orO.
?ind#y send you pre"ious &eed!a"ks to0
SandeepsreekumarAS@in&osys."om
ParisABaskaran@in&osys."om
2 Reference:
4. S1P he#p.
2. .omp#ete 1B1P 9!2e"t ,e&eren"e.
3. 178 =rid .ontro#s.
. Appendi4
Co6p!ete test pro5ra6

S-ar putea să vă placă și