Sie sind auf Seite 1von 65

Public attributes

Public attributes are defined in the PUBLIC section and can be viewed and
changed from outside the class. There is direct access to public attributes. As a
general rule, as few public attributes should be defined as possible.
PUBLIC SECTION.
DATA: Counter type i.

Private attributes
Private attributes are defined in the PI!AT" section. The can onl# be viewes
and changed from within the class. There is no direct access from outside the
class.
PRIVATE SECTION.
DATA: name(2! T"PE #$
p%anetype LI&E 'ap%ane(p%anetyp$
Instance attributes
There e$ist one instance attribute for each instance of the class, thus the# e$ist
seperatel# for each ob%ect. Instance attributes are declared with the &ATA
'e#word.
Static attributes
(tatic attributes e$ist onl# once for each class. The data are the same for all
instances of the class, and can be used e.g. for instance counters. (tatic
attributes are defined with the 'e#word CLA(()&ATA.
PI!AT" ("CTI*+
CLA(()&ATA, counter t#pe i,
Public methods
Can called from outside the class
PUBLIC ("CTI*+.
-"T.*&(, set/attributes I-P*TI+0 p/name1234 T5P" c,
p/planet#pe LI6" saplane)planet#p,
Private methods
Can onl# be called from inside the class. The# are placed in the PI!AT" section
of the class.

Constructor method
Implicitl#, each class has an instance constructor method with the reserved name
constructor and a static constructor method with the reserved name
class/constructor.
The instance constructor is e$ecuted each time #ou create an ob%ect 1instance4
with the C"AT" *B7"CT statement, while the class constructor is e$ecuted
e$actl# once before #ou first access a class.
The constructors are alwa#s present. .owever, to implement a constructor #ou
must declare it e$plicitl# with the -"T.*&( or CLA(()-"T.*&( statements.
An instance constructor can have I-P*TI+0 parameters and e$ceptions. 5ou
must pass all non)optional parameters when creating an ob%ect. (tatic
constructors have no parameters.
Static constructor
The static constructor is alwa#s called CLA((/C*+(TUCT", and is called
autmaticall# before the clas is first accessed, that is before an# of the following
actions are e$ecuted,
Creating an instance using C"AT"/*B7"CT
Adressing a static attribute using 8classname9)98attrbute9
Calling a ststic attribute using CALL -"T.*&
egistering a static event handler
egistering an evetm handler method for a static event
The static constructor cannot be called e$plicitl#.
Protected components
:hen we are tal'ing sub classing and inheritance there is one more component
than Public and Private, the Protected component. Protected components can be
used b# the super class and all of the subclasses. +ote that (ubclasses cannot
access Private components.
Polymorphism
Pol#morphism, :hen the same method is implemented differentl# in different
classes. This can be done using enheritance, b# redefining a method from the
superclass in subclasses and implement it differentl#.

Define, implement and use simple class
***INCLUDE ZBC404_HF_LCL_AIRPLANE .
))))))))))))))))))))))))))))))))))))))))))
) De*inition part
))))))))))))))))))))))))))))))))))))))))))
CLASS %#%+airp%ane DE,INITION.
)((((((((((((((((((((((((((((((
) Pu-%i# 'e#tion
)((((((((((((((((((((((((((((((
PUBLIC SECTION.
T"PES: t+name(2! T"PE #.
.ET/ODS:
#on'tru#tor$
'et+attri-ute' I.PORTIN0 p+name T"PE t+name
p+p%anetype T"PE 'ap%ane(p%anetype$
1i'p%ay+attri-ute'$
1i'p%ay+n+o+airp%ane'.
)((((((((((((((((((((((((((((((
) Pri2ate 'e#tion
)((((((((((((((((((((((((((((((
PRIVATE SECTION.
) Pri2ate attri-ute'
DATA: name(2! T"PE #$
p%anetype T"PE 'ap%ane(p%anetype.
) Pri2ate 'tati# attri-ute
CLASS(DATA n+o+airp%ane' T"PE i.
ENDCLASS.
))))))))))))))))))))))))))))))))))))))))))
) Imp%ementation part
))))))))))))))))))))))))))))))))))))))))))
CLASS %#%+airp%ane I.PLE.ENTATION.
.ET/OD #on'tru#tor.
) Count' num-er o* in'tan#e'
n+o+airp%ane' 3 n+o+airp%ane' 4 5.
END.ET/OD.
.ET/OD 'et+attri-ute'.
name 3 p+name.
p%anetype 3 p+p%anetype.
END.ET/OD.
.ET/OD 1i'p%ay+attri-ute'.
6RITE:7 8Name:8$ name$ 8P%anetype:8$ p%anetype.
END.ET/OD.
.ET/OD 1i'p%ay+n+o+airp%ane'.
6RITE: 7 8No. p%ane':8$ n+o+airp%ane'.
END.ET/OD.
ENDCLASS.
REPORT zbc404_hf_mainain_ai!"#an$% .
INCLUDE 9-#:;:+<*+%#%+airp%ane.
) Create re*eren#e to #%a'' %#%+airp%ane
DATA: airp%ane5 T"PE RE, TO %#%+airp%ane$
airp%ane2 T"PE RE, TO %#%+airp%ane.
START(O,(SELECTION.
) Create in'tan#e
CREATE OB=ECT airp%ane5.
CALL .ET/OD: airp%ane5(>1i'p%ay+n+o+airp%ane'.
CREATE OB=ECT airp%ane2.
) Settin? attri-ute' u'in? a met<o1 @it< parameter'
CALL .ET/OD airp%ane5(>'et+attri-ute' EAPORTIN0 p+name 3 8&urt8
p+p%anetype 3 8.DB;8.
END(O,(SELECTION.
) U'in? met<o1'
CALL .ET/OD: airp%ane5(>1i'p%ay+n+o+airp%ane'$
airp%ane5(>1i'p%ay+attri-ute'.


The resulting report:
-aintain airplanes

+o. planes, ;
+o. planes, 2
+ame, 6urt Planet#pe, -&<=
Use constructor to create an object with parameters
CLASS %#%+airp%ane DE,INITION.
PUBLIC SECTION.
T"PES: t+name(2! T"PE #.
.ET/ODS:
#on'tru#tor importin? p2+name type t+name
p2+p%anetype T"PE 'ap%ane(p%anetype$
..... more #o1e .......
CLASS %#%+airp%ane I.PLE.ENTATION.
.ET/OD #on'tru#tor.
name 3 p2+name.
p%anetype 3 p2+p%anetype.
..... more #o1e .......

START(O,(SELECTION.
CREATE OB&ECT ai!"#an$' $(")!in* "+_nam$ , -Han%$man.-
"+_"#an$/"$ , -B)in* 040-.

Subclassing
This e$ample uses a superclass LCL/AIPLA+" and subclasses it into
LCL/PA(("+0"/AIPLA+" and LCL/CA0*/PLA+".
LCL/AIPLA+" has a method display_n_o_airplanes that displa#s the number
of ob%ect instances.
LCL/PA(("+0"/AIPLA+" has the private instance attribute n_o_seats, and
redefines the superclass method display_attributes, so it also displa#s
n_o_seats.
LCL/CA0*/PLA+" has the private instance attribute cargomax, and redefines
the superclass method display_attributes, so it also displa#s cargomax.
All instance attributes are provided b# the cunstructor method.
Superclass LCL!I"PL!#$
)))INCLUDE CBC:;:+/,+LCL+AIRPLANE .
))))))))))))))))))))))))))))))))))))))))))
) De*inition part
))))))))))))))))))))))))))))))))))))))))))
CLA11 #c#_ai!"#an$ DEFINITION.
)((((((((((((((((((((((((((((((
) Pu-%i# 'e#tion
)((((((((((((((((((((((((((((((
PUBLIC SECTION.
T"PES: t+name(2! T"PE #.
.ET/ODS:
#on'tru#tor I.PORTIN0 im+name T"PE t+name
im+p%anetype T"PE 'ap%ane(p%anetype$
1i'p%ay+attri-ute'.
) Stati# met<o1'
CLASS(.ET/ODS:
1i'p%ay+n+o+airp%ane'.
)((((((((((((((((((((((((((((((
) Prote#te1 'e#tion
)((((((((((((((((((((((((((((((
PROTECTED SECTION.
) Pri2ate attri-ute'
DATA: name(2! T"PE #$
p%anetype T"PE 'ap%ane(p%anetype.
) Pri2ate 'tati# attri-ute
CLASS(DATA n+o+airp%ane' T"PE i.
ENDCLASS.
))))))))))))))))))))))))))))))))))))))))))
) Imp%ementation part
))))))))))))))))))))))))))))))))))))))))))
CLASS %#%+airp%ane I.PLE.ENTATION.
.ET/OD #on'tru#tor.
name 3 im+name.
p%anetype 3 im+p%anetype.
) Count' num-er o* in'tan#e'
n+o+airp%ane' 3 n+o+airp%ane' 4 5.
END.ET/OD.
.ET/OD 1i'p%ay+attri-ute'.
6RITE:7 8Name:8$ name$ 8P%anetype:8$ p%anetype.
END.ET/OD.
.ET/OD 1i'p%ay+n+o+airp%ane'.
6RITE: 7 8No. p%ane':8$ n+o+airp%ane'.
END.ET/OD.
ENDCLA11.
Sub class LCLP!SS$#%$"!I"PL!#$
)))INCLUDE CBC:;:+/,+LCL+PASSEN0ER+PLANE .
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
) T<i' i' a 'u-#%a'' o* #%a'' %#%+airp%ane
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
CLA11 #c#_"a%%$n*$!_ai!"#an$ DEFINITION INHERITIN2 FRO3 #c#_ai!"#an$.
PUBLIC SECTION.
) T<e #on'tru#tor #ontain' t<e parameter' *rom t<e 'uper#%a''
) p%u' t<e parameter' *rom t<e 'u-#%a''
.ET/ODS:
#on'tru#tor I.PORTIN0 im+name T"PE t+name
im+p%anetype T"PE 'ap%ane(p%anetype
im+n+o+'eat' T"PE '*%i?<t('eat'maD$
) Re1e*inition o* 'uper#%a'' met<o1 1i'p%ay+attri-ute'
1i'p%ay+attri-ute' REDE,INITION.
PRIVATE SECTION.
DATA: n+o+'eat' T"PE '*%i?<t('eat'maD.
ENDCLA11.
CLA11 #c#_"a%%$n*$!_ai!"#an$ I3PLE3ENTATION.
.ET/OD #on'tru#tor.
) T<e #on'tru#tor met<o1 o* t<e 'uper#%a'' .UST -e #a%%e1 @it<in? t<e
) #on'trutor
CALL .ET/OD 'uper(>#on'tru#tor
EAPORTIN0 im+name 3 im+name
im+p%anetype 3 im+p%anetype.
n+o+'eat' 3 im+n+o+'eat'.
END.ET/OD.
) T<e re1e*ine1 1i'p%ay+attri-ute' met<o1
.ET/OD 1i'p%ay+attri-ute'.
CALL .ET/OD 'uper(>1i'p%ay+attri-ute'.
6RITE: 7 8No. 'eat':8$ n+o+'eat'.
END.ET/OD.
ENDCLA11.
Sub class LCLC!"%&PL!#$
)))INCLUDE CBC:;:+/,+LCL+CAR0O+PLANE .
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
) T<i' i' a 'u-#%a'' o* #%a'' %#%+airp%ane
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
CLA11 #c#_ca!*)_"#an$ DEFINITION INHERITIN2 FRO3 #c#_ai!"#an$.
PUBLIC SECTION.
.ET/ODS:
) T<e #on'tru#tor #ontain' t<e parameter' *rom t<e 'uper#%a''
) p%u' t<e parameter' *rom t<e 'u-#%a''
#on'tru#tor I.PORTIN0 im+name T"PE t+name
im+p%anetype T"PE 'ap%ane(p%anetype
im+#ar?omaD type '#p%ane(#ar?omaD$
) Re1e*inition o* 'uper#%a'' met<o1 1i'p%ay+attri-ute'
1i'p%ay+attri-ute' REDE,INITION.
PRIVATE SECTION.
DATA:#ar?omaD T"PE '#p%ane(#ar?omaD.
ENDCLA11.
CLA11 #c#_ca!*)_"#an$ I3PLE3ENTATION.
.ET/OD #on'tru#tor.
) T<e #on'tru#tor met<o1 o* t<e 'uper#%a'' .UST -e #a%%e1 @it<in? t<e
) #on'tru#tor
CALL .ET/OD 'uper(>#on'tru#tor
EAPORTIN0 im+name 3 im+name
im+p%anetype 3 im+p%anetype.
#ar?omaD 3 im+#ar?omaD.
END.ET/OD.
.ET/OD 1i'p%ay+attri-ute'.
) T<e re1e*ine1 1i'p%ay+attri-ute' met<o1
CALL .ET/OD 'uper(>1i'p%ay+attri-ute'.
6RITE: 7 8Car?o maD:8$ #ar?omaD.
END.ET/OD.
ENDCLASS.

'he (ain program that uses the classes
REPORT 9-#:;:+<*+main .
) Super #%a''
INCLUDE 9-#:;:+<*+%#%+airp%ane.
) Su- #%a''e'
INCLUDE 9-#:;:+<*+%#%+pa''en?er+p%ane.
INCLUDE 9-#:;:+<*+%#%+#ar?o+p%ane.
DATA:
) Type re* to 'u- #%a''e'. Note: It i' not ne#e'''ary to maEe typere* to
t<e 'uper#%a''
o+pa''en?er+airp%ane T"PE RE, TO %#%+pa''en?er+airp%ane$
o+#ar?o+p%ane T"PE RE, TO %#%+#ar?o+p%ane.
START(O,(SELECTION.
) Di'p%ay initia% num-er o* in'tan#e' 3 ;
CALL .ET/OD %#%+airp%ane3>1i'p%ay+n+o+airp%ane'.
) Create o-Fe#t'
CREATE OB=ECT o+pa''en?er+airp%ane
EAPORTIN0
im+name 3 8L/;8
im+p%anetype 3 8Boin? G:G8
im+n+o+'eat' 3 H;.
CREATE OB=ECT o+#ar?o+p%ane
EAPORTIN0
im+name 3 8AR5H8
im+p%anetype 3 8DC H8
im+#ar?omaD 3 H.
) Di'p%ay attri-ute'
CALL .ET/OD o+pa''en?er+airp%ane(>1i'p%ay+attri-ute'.
CALL .ET/OD o+#ar?o+p%ane(>1i'p%ay+attri-ute'.
) Ca%% 'tati# met<o1 1i'p%ay+n+o+airp%ane'
) Note: T<e 'yntaD *or #a%%in? a 'uper#%a'' met<o1$ 1i**er' *rom t<e
'yntaD @<en #a%%in? a 'u-#%a'' met<o1.
) 6<en #a%%in? a 'uper#%a'' ,4 mu't -e u'e1 in'tea1 o* 54
CALL .ET/OD %#%+airp%ane3>1i'p%ay+n+o+airp%ane'.
"esult)
+o. planes, =
+ame, L.3=3 Planet#pe, Boing >?>
+o. seats, @3=
+ame, A;@ Planet#pe, &C @
Cargo ma$, @3,====
+o. planes, 2

Polymorphism
Pol#morphism, :hen the same method is implemented differentl# in different
classes. This can be done using enheritance, b# redefining a method from the
superclass in subclasses and implement it differentl#.
Classes,
lcl/airplane (uperclass
lcl/cargo/airplane (ubclass
lcl/passenger/airplane (ubclass
The method estimate_fuel_consumption is implemented differentl# in the @
classes, as it depends on the airplane t#pe.
*b%ect from different classes are stored in an internal table 1plane/list4
consisting of references to the superclass, and the processed
identicall# for all the classes.
:hat coding for the estimate_fuel_consumption method taht is actuall#
e$ecuted, depends on the d#namic t#pe of the plane reference variable,
that is, depends on which ob%ect plane points to.
&ATA, cargo/plane T5P" "A to lcl/cargo/airplane,
passenger/plane T5P" "A to lcl/passenger/airplane,
plane/list T5P" TABL" *A "A T* lcl/airplane.
B Creating the list of references
C"AT" *B7"CT cargo/plane.
APP"+& cargo/plane to plane/list.
C"AT" *B7"CT passenger/plane
APP"+& passenger/plane to plane list.
B 0eneric method for calucalting reCuired fuel
-"T.*& calculate reCuired/fuel.
&ATA, plane T5P" "A T* lcl/airplane.
L**P AT plane/list I+T* plane.
re/fuel D re/fuel E plane)9estimate/fuel/consumption1 distance 4.
"+&L**P.
"+&-"T.*&.
*or+ing e,ample)
This e$ample assumes that the classes lcl/airplane,
lcl/passnger/airplane and lcl/cargo plane 1(e (ubcallsing4 e$ists.
Create ob%ects of t#pe lcl/cargo/plane and lcl/passenger/airplane,
adds them to a list in lcl/carrier, and displa#s the list.
)I((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
)I In#%u1e CBC:;:+/,+LCL+CARRIER )
)I )
)I((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
) CLASS %#%+#arrier DE,INITION )
)(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
CLA11 #c#_ca!!i$! DEFINITION.
PUBLIC SECTION.
T"PES: BE0IN O, *%i?<t+%i't+type$
#onni1 T"PE '*%i?<t(#onni1$
*%1ate T"PE '*%i?<t(*%1ate$
airp%ane T"PE RE, TO %#%+airp%ane$
'eat'o## T"PE '*%i?<t('eat'o##$
#ar?o(! T"PE p DECI.ALS H$
END O, *%i?<t+%i't+type.
.ET/ODS: #on'tru#tor I.PORTIN0 im+name T"PE 'trin?$
?et+name RETURNIN0 2a%ue(eD+name! T"PE 'trin?$
a11+a+ne@+airp%ane I.PORTIN0
im+airp%ane T"PE RE, TO %#%+airp%ane$
#reate+a+ne@+*%i?<t importin?
im+#onni1 type '*%i?<t(#onni1
im+*%1ate type '*%i?<t(*%1ate
im+airp%ane type re* to %#%+airp%ane
im+'eat'o## type '*%i?<t('eat'o##
optiona%
im+#ar?o type p optiona%$
1i'p%ay+airp%ane'.
PRIVATE SECTION.
DATA: name T"PE 'trin?$
%i't+o*+airp%ane' T"PE TABLE O, RE, TO %#%+airp%ane$
%i't+o*+*%i?<t' T"PE TABLE O, *%i?<t+%i't+type.
ENDCLA11.
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
) CLASS %#%+#arrier I.PLE.ENTATION
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
CLA11 #c#_ca!!i$! I3PLE3ENTATION.
.ET/OD #on'tru#tor.
name 3 im+name.
END.ET/OD.
.ET/OD ?et+name.
eD+name 3 name.
END.ET/OD.
.ET/OD #reate+a+ne@+*%i?<t.
DATA: @a+%i't+o*+*%i?<t' T"PE *%i?<t+%i't+type.
@a+%i't+o*+*%i?<t'(#onni1 3 im+#onni1.
@a+%i't+o*+*%i?<t'(*%1ate 3 im+*%1ate.
@a+%i't+o*+*%i?<t'(airp%ane 3 im+airp%ane.
I, im+'eat'o## IS INITIAL.
@a+%i't+o*+*%i?<t'(#ar?o 3 im+#ar?o.
ELSE.
@a+%i't+o*+*%i?<t'('eat'o## 3 im+'eat'o##.
ENDI,.
APPEND @a+%i't+o*+*%i?<t' TO %i't+o*+*%i?<t'.
END.ET/OD.
.ET/OD a11+a+ne@+airp%ane.
APPEND im+airp%ane TO %i't+o*+airp%ane'.
END.ET/OD.
.ET/OD 1i'p%ay+airp%ane'.
DATA: %+airp%ane T"PE RE, TO %#%+airp%ane.
LOOP AT %i't+o*+airp%ane' INTO %+airp%ane.
CALL .ET/OD %+airp%ane(>1i'p%ay+attri-ute'.
ENDLOOP.
END.ET/OD.
ENDCLA11.

REPORT zbc404_hf_main .
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
) T<i' reprort u'e' #%a'' LCL+AIRPLNAE an1 'u-#%a''e'
) LCL+CAR0O+PLANE an1 LCL+PASSEN0ER+AIRPLANE an1 #%a'' LCL+CARRIER
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
) Super #%a'' *or airp%ane'
INCLUDE 9-#:;:+<*+%#%+airp%ane.
) Su- #%a''e' *or airp%ane'
INCLUDE 9-#:;:+<*+%#%+pa''en?er+p%ane.
INCLUDE 9-#:;:+<*+%#%+#ar?o+p%ane.
) Carrier #%a''
INCLUDE 9-#:;:+<*+%#%+#arrier.
DATA:
) Type re* to #%a''e'
o+pa''en?er+airp%ane T"PE RE, TO %#%+pa''en?er+airp%ane$
o+pa''en?er+airp%ane2 T"PE RE, TO %#%+pa''en?er+airp%ane$
o+#ar?o+p%ane T"PE RE, TO %#%+#ar?o+p%ane$
o+#ar?o+p%ane2 T"PE RE, TO %#%+#ar?o+p%ane$
o+#arrier T"PE RE, TO %#%+#arrier.
START(O,(SELECTION.
) Create o-Fe#t'
CREATE OB=ECT o+pa''en?er+airp%ane
EAPORTIN0
im+name 3 8L/;8
im+p%anetype 3 8Boin? G:G8
im+n+o+'eat' 3 H;.
CREATE OB=ECT o+pa''en?er+airp%ane2
EAPORTIN0
im+name 3 8S&HHH8
im+p%anetype 3 8.DB;8
im+n+o+'eat' 3 55;.
CREATE OB=ECT o+#ar?o+p%ane
EAPORTIN0
im+name 3 8AR5H8
im+p%anetype 3 8DC H8
im+#ar?omaD 3 H.
CREATE OB=ECT o+#ar?o+p%ane2
EAPORTIN0
im+name 3 8A,L52:8
im+p%anetype 3 8I%Fut'in 28
im+#ar?omaD 3 H;;;.
CREATE OB=ECT o+#arrier
EAPORTIN0 im+name 3 8Spriti'#< Air@ay'8.
) A11 pa''en?er an1 #ar?o p%ane' to t<e %i't o* airp%ane'
CALL .ET/OD o+#arrier(>a11+a+ne@+airp%ane
EAPORTIN0 im+airp%ane 3 o+pa''en?er+airp%ane.
CALL .ET/OD o+#arrier(>a11+a+ne@+airp%ane
EAPORTIN0 im+airp%ane 3 o+pa''en?er+airp%ane2.
CALL .ET/OD o+#arrier(>a11+a+ne@+airp%ane
EAPORTIN0 im+airp%ane 3 o+#ar?o+p%ane.
CALL .ET/OD o+#arrier(>a11+a+ne@+airp%ane
EAPORTIN0 im+airp%ane 3 o+#ar?o+p%ane2.
) Di'p%ay %i't o* airp%ane'
#a%% met<o1 o+#arrier(>1i'p%ay+airp%ane'.
"esult)
+ame, L.3=3 Planet#pe, Boing >?>
+o. seats, @3=
+ame, (6@@@ Planet#pe, -&<=
+o. seats, ;;=
+ame, A;@ Planet#pe, &C @
Cargo ma$, @3,====
+ame, AAL;2? Planet#pe, Il%utsin 2
Cargo ma$, @3.===,====
$vents
Below is a simple e$ample of how to implement an event.
REPORT 9-#:;:+<*+e2ent'+.
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
) CLASS %#%+1o? DE,INITION
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
CLA11 #c#_.)* DEFINITION.
PUBLIC SECTION.
) De#%are e2ent'
EVENTS:
1o?+i'+<un?ry
EAPORTIN0 2a%ue(eD+time+'in#e+%a't+mea%! T"PE i.
.ET/ODS:
#on'tru#tor
I.PORTIN0 im+name T"PE 'trin?$
'et+time+'in#e+%a't+mea%
I.PORTIN0 im+time T"PE i$
on+1o?+i'+<un?ry ,OR EVENT 1o?+i'+<un?ry O, %#%+1o?
I.PORTIN0 eD+time+'in#e+%a't+mea%.
ENDCLA11.
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
) CLASS %#%+1o? I.PLE.ENTATION
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
CLA11 #c#_.)* I3PLE3ENTATION.
.ET/OD #on'tru#tor.
6RITE: 7 8I am a 1o? an1 my name i'8$ im+name.
END.ET/OD.
.ET/OD 'et+time+'in#e+%a't+mea%.
I, im+time J :.
S&IP 5.
6RITE: 7 8"ou *oo%$ I am not <un?ry yet8.
ELSE.
) Su-'r#ri-e *or e2ent:
) 'et <an1%er JE2ent <an1%er met<o1>
) ,OR Jre*+'en1er>K,OR ALL INSTANCES LACTIVATION J2ar>M
SET /ANDLER on+1o?+i'+<un?ry ,OR ALL INSTANCES ACTIVATION 8A8.
) Rai'e e2ent
RAISE EVENT 1o?+i'+<un?ry
EAPORTIN0 eD+time+'in#e+%a't+mea% 3 im+time.
ENDI,.
END.ET/OD.
.ET/OD on+1o?+i'+<un?ry.
) E2ent met<o1$ #a%%e1 @<en t<e e2ent 1o?+i'+<un?ry i' rai'e1
S&IP 5.
6RITE: 7 8"ou 'on o* a -it#<. I <a2e not eaten *or more t<an8$
eD+time+'in#e+%a't+mea%$ 8 <our'8.
6RITE: 7 80i2e me 'omet<in? to eat NO6K8.
END.ET/OD.
ENDCLA11.
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
) R E P O R T
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
DATA: o+1o?5 T"PE RE, TO %#%+1o?.
START(O,(SELECTION.
CREATE OB=ECT o+1o?5 EAPORTIN0 im+name 3 8Bee*eater8.
CALL .ET/OD o+1o?5(>'et+time+'in#e+%a't+mea%
EAPORTIN0 im+time 3 2.
) T<i' met<o1 #a%% @i%% rai'e t<e e2ent 1o?+i'+<un?y
) -e#au'e time > H
CALL .ET/OD o+1o?5(>'et+time+'in#e+%a't+mea%
EAPORTIN0 im+time 3 .
esult,
I am a dog and m# name is Beefeater
5ou fool, I am not hungr# #et
5ou son of a bitch. I have not eaten for more than 3 hours
0ive me something to eat +*:F
-ac+ to main menu
This e$ample is a step b# step e$ample, moving from a simple clas to more
sophisticated classes, and covers inheritance, interfaces and events.
1. Simple class
2. Inheritance and ploymorphism
3. Interfaces
4. $vents

;. (imple class
This e$ample shows how to create a simple emplo#ee class. The constructor
method is used to initialiGe number and name of th%e emplo#ee when the ob%ect
is created. A displa#/emplo#ee method can be called to show the attributes of
the emplo#ee, and CLA(()-"T.*& dospla#/no/of/emplo#ees can be called to
show the total number of emplo#ees 1+umber of instances of the emplo#ee
class4.

REPORT 9-#:;:+<*+e2ent'+5.
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
) L C L + E . P L O " E E
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)(((( LCL Emp%oyee ( De*inition
CLASS %#%+emp%oyee DE,INITION.
PUBLIC SECTION.
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
) T<e pu-%i# 'e#tion i' a##e'i-%e *rom out'i1e
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
T"PES:
BE0IN O, t+emp%oyee$
no T"PE i$
name T"PE 'trin?$
END O, t+emp%oyee.
.ET/ODS:
#on'tru#tor
I.PORTIN0 im+emp%oyee+no T"PE i
im+emp%oyee+name T"PE 'trin?$
1i'p%ay+emp%oyee.
) C%a'' met<o1' are ?%o-a% *or a%% in'tan#e'
CLASS(.ET/ODS: 1i'p%ay+no+o*+emp%oyee'.
PROTECTED SECTION.
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
) T<e prote#et1 'e#tion i' a##e'i-%e *rom t<e #%a'' an1 it' 'u-#%a''e'
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
) C%a'' 1ata are ?%o-a% *or a%% in'tan#e'
CLASS(DATA: ?+no+o*+emp%oyee' T"PE i.
PRIVATE SECTION.
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
) T<e pri2ate 'e#tion i' on%y a##e'i-%e *rom @it<in t<e #%a'''
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
DATA: ?+emp%oyee T"PE t+emp%oyee.
ENDCLASS.
)((( LCL Emp%oyee ( Imp%ementation
CLASS %#%+emp%oyee I.PLE.ENTATION.
.ET/OD #on'tru#tor.
?+emp%oyee(no 3 im+emp%oyee+no.
?+emp%oyee(name 3 im+emp%oyee+name.
?+no+o*+emp%oyee' 3 ?+no+o*+emp%oyee' 4 5.
END.ET/OD.
.ET/OD 1i'p%ay+emp%oyee.
6RITE:7 8Emp%oyee8$ ?+emp%oyee(no$ ?+emp%oyee(name.
END.ET/OD.
.ET/OD 1i'p%ay+no+o*+emp%oyee'.
6RITE: 7 8Num-er o* emp%oyee' i':8$ ?+no+o*+emp%oyee'.
END.ET/OD.
ENDCLASS.
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
) R E P O R T
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
DATA: ?+emp%oyee5 T"PE RE, TO %#%+emp%oyee$
?+emp%oyee2 T"PE RE, TO %#%+emp%oyee.
START(O,(SELECTION.
CREATE OB=ECT ?+emp%oyee5
EAPORTIN0 im+emp%oyee+no 3 5
im+emp%oyee+name 3 8=o<n =one'8.
CREATE OB=ECT ?+emp%oyee2
EAPORTIN0 im+emp%oyee+no 3 2
im+emp%oyee+name 3 8Sa%%y Summer8.
CALL .ET/OD ?+emp%oyee5(>1i'p%ay+emp%oyee.
CALL .ET/OD ?+emp%oyee2(>1i'p%ay+emp%oyee.
CALL .ET/OD ?+emp%oyee2(>1i'p%ay+no+o*+emp%oyee'.

./ Inheritance and polymorphism
This e$ample uses a superclass lcl_company_employees and two subclasses
lcl_bluecollar_employee and lcl_whitecollar_employee to add emplo#ees to a list
and then displa# a list of emplo#ees and there wages. The wages are calcu'ated
in the method add_employee, but as the wages are calculated differentl# for blue
collar emplo#ees and white collar empl#ees, the superclass method
add_employee is redeifined in the subclasses.
Principles,
Create super class LCL/Compan#"mplo#ees.
The class has the methods,
Constructor
Add/"mplo#ee ) Adds a new emplo#ee to the list of emplo#ees
&ispla#/"mplo#ee/List ) &ispla#s all emplo#ees and there wage
&ispla#/no/of/emplo#ees ) &ispla#s total number of emplo#ees
+ote the use of CLA(()&ATA to 'eep the list of emplo#ees and number of
emplo#ees the same from instance to instance.
Create subclasses lcl_bluecollar_employee and lcl_whitecollar_employee. The
calsses are identical, e$cept for the redifinition of the add/emplo#ee method,
where the caclculation of wage is different.
-ethodes,
Constructor. The constructor is used to initialiGe the attributes of the
emplo#ee. +ote that the constructor in the supclasss has to be called from
within the constructor of the subclass.
Add/"mplo#ee. This is a redinition of the same method in the superclass.
In the redefined class the wage is calcuated, and the superclass method is
called to add the emplo#ees to the emploee list.,
The program

REPORT 9-#:;:+<*+e2ent'+2 .
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
) Super #%a'' LCL+CompanyEmp%oyee'
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
CLA11 #c#_c)m"an/_$m"#)/$$% DEFINITION.
PUBLIC SECTION.
T"PES:
BE0IN O, t+emp%oyee$
no T"PE i$
name T"PE 'trin?$
@a?e T"PE i$
END O, t+emp%oyee.
.ET/ODS:
#on'tru#tor$
a11+emp%oyee
I.PORTIN0 im+no T"PE i
im+name T"PE 'trin?
im+@a?e T"PE i$
1i'p%ay+emp%oyee+%i't$
1i'p%ay+no+o*+emp%oyee'.
PRIVATE SECTION.
CLASS(DATA: i+emp%oyee+%i't T"PE TABLE O, t+emp%oyee$
no+o*+emp%oyee' T"PE i.
ENDCLA11.
)(( CLASS LCL+CompanyEmp%oyee' I.PLE.ENTATION
CLA11 #c#_c)m"an/_$m"#)/$$% I3PLE3ENTATION.
.ET/OD #on'tru#tor.
no+o*+emp%oyee' 3 no+o*+emp%oyee' 4 5.
END.ET/OD.
.ET/OD a11+emp%oyee.
) A11' a ne@ emp%oyee to t<e %i't o* emp%oyee'
DATA: %+emp%oyee T"PE t+emp%oyee.
%+emp%oyee(no 3 im+no.
%+emp%oyee(name 3 im+name.
%+emp%oyee(@a?e 3 im+@a?e.
APPEND %+emp%oyee TO i+emp%oyee+%i't.
END.ET/OD.
.ET/OD 1i'p%ay+emp%oyee+%i't.
) Di'p%ay' a%% emp%oyee' an1 t<ere @a?e
DATA: %+emp%oyee T"PE t+emp%oyee.
6RITE: 7 8Li't o* Emp%oyee'8.
LOOP AT i+emp%oyee+%i't INTO %+emp%oyee.
6RITE: 7 %+emp%oyee(no$ %+emp%oyee(name$ %+emp%oyee(@a?e.
ENDLOOP.
END.ET/OD.
.ET/OD 1i'p%ay+no+o*+emp%oyee'.
) Di'p%ay' tota% num-er o* emp%oyee'
S&IP H.
6RITE: 7 8Tota% num-er o* emp%oyee':8$ no+o*+emp%oyee'.
END.ET/OD.
ENDCLA11.
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
) Su- #%a'' LCL+B%ueCo%%ar+Emp%oyee
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
CLA11 #c#_b#6$c)##a!_$m"#)/$$ DEFINITION
INHERITIN2 FRO3 #c#_c)m"an/_$m"#)/$$%.
PUBLIC SECTION.
.ET/ODS:
#on'tru#tor
I.PORTIN0 im+no T"PE i
im+name T"PE 'trin?
im+<our' T"PE i
im+<our%y+payment T"PE i$
a11+emp%oyee REDE,INITION.
PRIVATE SECTION.
DATA:no T"PE i$
name T"PE 'trin?$
<our' T"PE i$
<our%y+payment T"PE i.
ENDCLA11.
)(((( CLASS LCL+B%ueCo%%ar+Emp%oyee I.PLE.ENTATION
CLA11 #c#_b#6$c)##a!_$m"#)/$$ I3PLE3ENTATION.
.ET/OD #on'tru#tor.
) T<e 'uper#%a'' #on'tru#tor met<o1 mu't -e #a%%e1 *rom t<e 'u-#%a''
) #on'tru#tor met<o1
CALL .ET/OD 'uper(>#on'tru#tor.
no 3 im+no.
name 3 im+name.
<our' 3 im+<our'.
<our%y+payment 3 im+<our%y+payment.
END.ET/OD.
.ET/OD a11+emp%oyee.
) Ca%#u%ate @a?e an #a%% t<e 'uper#%a'' met<o1 a11+emp%oyee to a11
) t<e emp%oyee to t<e emp%oyee %i't
DATA: %+@a?e T"PE i.
%+@a?e 3 <our' ) <our%y+payment.
CALL .ET/OD 'uper(>a11+emp%oyee
EAPORTIN0 im+no 3 no
im+name 3 name
im+@a?e 3 %+@a?e.
END.ET/OD.
ENDCLASS.
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
) Su- #%a'' LCL+6<iteCo%%ar+Emp%oyee
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
CLA11 #c#_7hi$c)##a!_$m"#)/$$ DEFINITION
INHERITIN2 FRO3 #c#_c)m"an/_$m"#)/$$%.
PUBLIC SECTION.
.ET/ODS:
#on'tru#tor
I.PORTIN0 im+no T"PE i
im+name T"PE 'trin?
im+mont<%y+'a%ary T"PE i
im+mont<%y+1e1u#tion' T"PE i$
a11+emp%oyee REDE,INITION.
PRIVATE SECTION.
DATA:
no T"PE i$
name T"PE 'trin?$
mont<%y+'a%ary T"PE i$
mont<%y+1e1u#tion' T"PE i.
ENDCLA11.
)(((( CLASS LCL+6<iteCo%%ar+Emp%oyee I.PLE.ENTATION
CLA11 #c#_7hi$c)##a!_$m"#)/$$ I3PLE3ENTATION.
.ET/OD #on'tru#tor.
) T<e 'uper#%a'' #on'tru#tor met<o1 mu't -e #a%%e1 *rom t<e 'u-#%a''
) #on'tru#tor met<o1
CALL .ET/OD 'uper(>#on'tru#tor.
no 3 im+no.
name 3 im+name.
mont<%y+'a%ary 3 im+mont<%y+'a%ary.
mont<%y+1e1u#tion' 3 im+mont<%y+1e1u#tion'.
END.ET/OD.
.ET/OD a11+emp%oyee.
) Ca%#u%ate @a?e an #a%% t<e 'uper#%a'' met<o1 a11+emp%oyee to a11
) t<e emp%oyee to t<e emp%oyee %i't
DATA: %+@a?e T"PE i.
%+@a?e 3 mont<%y+'a%ary ( mont<%y+1e1u#tion'.
CALL .ET/OD 'uper(>a11+emp%oyee
EAPORTIN0 im+no 3 no
im+name 3 name
im+@a?e 3 %+@a?e.
END.ET/OD.
ENDCLA11.
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
) R E P O R T
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
DATA:
) O-Fe#t re*eren#e'
o+-%ue#o%%ar+emp%oyee5 T"PE RE, TO %#%+-%ue#o%%ar+emp%oyee$
o+@<ite#o%%ar+emp%oyee5 T"PE RE, TO %#%+@<ite#o%%ar+emp%oyee.
START(O,(SELECTION.
) Create -%ue#o%%ar emp%oyee o-eFe#t
CREATE OB=ECT o+-%ue#o%%ar+emp%oyee5
EAPORTIN0 im+no 3 5
im+name 3 80y%%e &aren8
im+<our' 3 HB
im+<our%y+payment 3 G.
) A11 -%ue#o%%ar emp%oyee to emp%oyee %i't
CALL .ET/OD o+-%ue#o%%ar+emp%oyee5(>a11+emp%oyee
EAPORTIN0 im+no 3 5
im+name 3 80y%%e &aren8
im+@a?e 3 ;.
) Create @<ite#o%%ar emp%oyee o-eFe#t
CREATE OB=ECT o+@<ite#o%%ar+emp%oyee5
EAPORTIN0 im+no 3 2
im+name 3 8=o<n Di#Een'8
im+mont<%y+'a%ary 3 5;;;;
im+mont<%y+1e1u#tion' 3 2;;.
) A11 -%ue#o%%ar emp%oyee to emp%oyee %i't
CALL .ET/OD o+@<ite#o%%ar+emp%oyee5(>a11+emp%oyee
EAPORTIN0 im+no 3 5
im+name 3 8&aren =o<n'on8
im+@a?e 3 ;.
) Di'p%ay emp%oyee %i't an1 num-er o* emp%oyee'. Note t<at t<e re'u%t
) @i%% -e t<e 'ame @<en #a%%e1 *rom o+@<ite#o%%ar+emp%oyee5 or
) o+-%ue#o%ar#o%%ar+emp%oyee5$ -e#au'e t<e met<o1' are 1e*ine1
) a' 'tati# (CLASS(.ET/ODS!
CALL .ET/OD o+@<ite#o%%ar+emp%oyee5(>1i'p%ay+emp%oyee+%i't.
CALL .ET/OD o+@<ite#o%%ar+emp%oyee5(>1i'p%ay+no+o*+emp%oyee'.
The resulting report
List of "mplo#ees
; 6aren 7ohnson 2.<3=
2 7ohn &ic'ens >.3==
Total number of emplo#ees, 2
0/ Interfaces
This e$ample is similiar to th eprevious e$ample, however an interface is
implemented with the method add_employee. +ote that the interface is onl#
implemented in the superclass 1 The I+T"AAC" stament4, but also used in the
subclasses.
The interface in the e$ample onl# contains a method, but an iterface can also
contain attrbutes, constants, t#pes and alias names.
The output from e$ample @ is similiar to the output in e$ample 2.
All changes in the program compared to e$ample 2 are mar'ed with red.
REPORT 9-#:;:+<*+e2ent'+H .
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
) INTER,ACE %i*+emp%oyee
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
INTER,ACE %i*+emp%oyee.
.ET/ODS:
a11+emp%oyee
I.PORTIN0 im+no T"PE i
im+name T"PE 'trin?
im+@a?e T"PE i.
ENDINTER,ACE.
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
) Super #%a'' LCL+CompanyEmp%oyee'
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
CLA11 #c#_c)m"an/_$m"#)/$$% DEFINITION.
PUBLIC SECTION.
INTER,ACES %i*+emp%oyee.
T"PES:
BE0IN O, t+emp%oyee$
no T"PE i$
name T"PE 'trin?$
@a?e T"PE i$
END O, t+emp%oyee.
.ET/ODS:
#on'tru#tor$
) a11+emp%oyee NRemo2e1
I.PORTIN0 im+no T"PE i
im+name T"PE 'trin?
im+@a?e T"PE i$
1i'p%ay+emp%oyee+%i't$
1i'p%ay+no+o*+emp%oyee'.
PRIVATE SECTION.
CLASS(DATA: i+emp%oyee+%i't T"PE TABLE O, t+emp%oyee$
no+o*+emp%oyee' T"PE i.
ENDCLA11.
)(( CLASS LCL+CompanyEmp%oyee' I.PLE.ENTATION
CLA11 #c#_c)m"an/_$m"#)/$$% I3PLE3ENTATION.
.ET/OD #on'tru#tor.
no+o*+emp%oyee' 3 no+o*+emp%oyee' 4 5.
END.ET/OD.
.ET/OD %i*+emp%oyeeOa11+emp%oyee.
) A11' a ne@ emp%oyee to t<e %i't o* emp%oyee'
DATA: %+emp%oyee T"PE t+emp%oyee.
%+emp%oyee(no 3 im+no.
%+emp%oyee(name 3 im+name.
%+emp%oyee(@a?e 3 im+@a?e.
APPEND %+emp%oyee TO i+emp%oyee+%i't.
END.ET/OD.
.ET/OD 1i'p%ay+emp%oyee+%i't.
) Di'p%ay' a%% emp%oyee' an1 t<ere @a?e
DATA: %+emp%oyee T"PE t+emp%oyee.
6RITE: 7 8Li't o* Emp%oyee'8.
LOOP AT i+emp%oyee+%i't INTO %+emp%oyee.
6RITE: 7 %+emp%oyee(no$ %+emp%oyee(name$ %+emp%oyee(@a?e.
ENDLOOP.
END.ET/OD.
.ET/OD 1i'p%ay+no+o*+emp%oyee'.
) Di'p%ay' tota% num-er o* emp%oyee'
S&IP H.
6RITE: 7 8Tota% num-er o* emp%oyee':8$ no+o*+emp%oyee'.
END.ET/OD.
ENDCLA11.
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
) Su- #%a'' LCL+B%ueCo%%ar+Emp%oyee
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
CLA11 #c#_b#6$c)##a!_$m"#)/$$ DEFINITION
INHERITIN2 FRO3 #c#_c)m"an/_$m"#)/$$%.
PUBLIC SECTION.
.ET/ODS:
#on'tru#tor
I.PORTIN0 im+no T"PE i
im+name T"PE 'trin?
im+<our' T"PE i
im+<our%y+payment T"PE i$
%i*+emp%oyeeOa11+emp%oyee REDE,INITION..
PRIVATE SECTION.
DATA:no T"PE i$
name T"PE 'trin?$
<our' T"PE i$
<our%y+payment T"PE i.
ENDCLA11.
)(((( CLASS LCL+B%ueCo%%ar+Emp%oyee I.PLE.ENTATION
CLA11 #c#_b#6$c)##a!_$m"#)/$$ I3PLE3ENTATION.
.ET/OD #on'tru#tor.
) T<e 'uper#%a'' #on'tru#tor met<o1 mu't -e #a%%e1 *rom t<e 'u-#%a''
) #on'tru#tor met<o1
CALL .ET/OD 'uper(>#on'tru#tor.
no 3 im+no.
name 3 im+name.
<our' 3 im+<our'.
<our%y+payment 3 im+<our%y+payment.
END.ET/OD.
.ET/OD %i*+emp%oyeeOa11+emp%oyee.
) Ca%#u%ate @a?e an #a%% t<e 'uper#%a'' met<o1 a11+emp%oyee to a11
) t<e emp%oyee to t<e emp%oyee %i't
DATA: %+@a?e T"PE i.
%+@a?e 3 <our' ) <our%y+payment.
CALL .ET/OD 'uper(>%i*+emp%oyeeOa11+emp%oyee
EAPORTIN0 im+no 3 no
im+name 3 name
im+@a?e 3 %+@a?e.
END.ET/OD.
ENDCLASS.
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
) Su- #%a'' LCL+6<iteCo%%ar+Emp%oyee
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
CLA11 #c#_7hi$c)##a!_$m"#)/$$ DEFINITION
INHERITIN2 FRO3 #c#_c)m"an/_$m"#)/$$%.
PUBLIC SECTION.
.ET/ODS:
#on'tru#tor
I.PORTIN0 im+no T"PE i
im+name T"PE 'trin?
im+mont<%y+'a%ary T"PE i
im+mont<%y+1e1u#tion' T"PE i$
%i*+emp%oyeeOa11+emp%oyee REDE,INITION.
PRIVATE SECTION.
DATA:
no T"PE i$
name T"PE 'trin?$
mont<%y+'a%ary T"PE i$
mont<%y+1e1u#tion' T"PE i.
ENDCLA11.
)(((( CLASS LCL+6<iteCo%%ar+Emp%oyee I.PLE.ENTATION
CLA11 #c#_7hi$c)##a!_$m"#)/$$ I3PLE3ENTATION.
.ET/OD #on'tru#tor.
) T<e 'uper#%a'' #on'tru#tor met<o1 mu't -e #a%%e1 *rom t<e 'u-#%a''
) #on'tru#tor met<o1
CALL .ET/OD 'uper(>#on'tru#tor.
no 3 im+no.
name 3 im+name.
mont<%y+'a%ary 3 im+mont<%y+'a%ary.
mont<%y+1e1u#tion' 3 im+mont<%y+1e1u#tion'.
END.ET/OD.
.ET/OD %i*+emp%oyeeOa11+emp%oyee.
) Ca%#u%ate @a?e an #a%% t<e 'uper#%a'' met<o1 a11+emp%oyee to a11
) t<e emp%oyee to t<e emp%oyee %i't
DATA: %+@a?e T"PE i.
%+@a?e 3 mont<%y+'a%ary ( mont<%y+1e1u#tion'.
CALL .ET/OD 'uper(>%i*+emp%oyeeOa11+emp%oyee
EAPORTIN0 im+no 3 no
im+name 3 name
im+@a?e 3 %+@a?e.
END.ET/OD.
ENDCLA11.
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
) R E P O R T
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
DATA:
) O-Fe#t re*eren#e'
o+-%ue#o%%ar+emp%oyee5 T"PE RE, TO %#%+-%ue#o%%ar+emp%oyee$
o+@<ite#o%%ar+emp%oyee5 T"PE RE, TO %#%+@<ite#o%%ar+emp%oyee.
START(O,(SELECTION.
) Create -%ue#o%%ar emp%oyee o-eFe#t
CREATE OB=ECT o+-%ue#o%%ar+emp%oyee5
EAPORTIN0 im+no 3 5
im+name 3 80y%%e &aren8
im+<our' 3 HB
im+<our%y+payment 3 G.
) A11 -%ue#o%%ar emp%oyee to emp%oyee %i't
CALL .ET/OD o+-%ue#o%%ar+emp%oyee5(>%i*+emp%oyeeOa11+emp%oyee
EAPORTIN0 im+no 3 5
im+name 3 8&aren =o<n'on8
im+@a?e 3 ;.
) Create @<ite#o%%ar emp%oyee o-eFe#t
CREATE OB=ECT o+@<ite#o%%ar+emp%oyee5
EAPORTIN0 im+no 3 2
im+name 3 8=o<n Di#Een'8
im+mont<%y+'a%ary 3 5;;;;
im+mont<%y+1e1u#tion' 3 2;;.
) A11 -%ue#o%%ar emp%oyee to emp%oyee %i't
CALL .ET/OD o+@<ite#o%%ar+emp%oyee5(>%i*+emp%oyeeOa11+emp%oyee
EAPORTIN0 im+no 3 5
im+name 3 80y%%e &aren8
im+@a?e 3 ;.
) Di'p%ay emp%oyee %i't an1 num-er o* emp%oyee'. Note t<at t<e re'u%t
) @i%% -e t<e 'ame @<en #a%%e1 *rom o+@<ite#o%%ar+emp%oyee5 or
) o+-%ue#o%ar#o%%ar+emp%oyee5$ -e#au'e t<e met<o1' are 1e*ine1
) a' 'tati# (CLASS(.ET/ODS!
CALL .ET/OD o+@<ite#o%%ar+emp%oyee5(>1i'p%ay+emp%oyee+%i't.
CALL .ET/OD o+@<ite#o%%ar+emp%oyee5(>1i'p%ay+no+o*+emp%oyee'.

1/ $vents
This is the same e$ample as e$ample ?. All changes are mar'ed with red. There
have been no canges to the subclasses, onl# to the superclass and the report, sp
the code for th esubclasses is not shown.
Aor a simple e$ample refer to "vents in "$amples.
REPORT 9-#:;:+<*+e2ent'+: .
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
) INTER,ACE %i*+emp%oyee
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
INTER,ACE %i*+emp%oyee.
.ET/ODS:
a11+emp%oyee
I.PORTIN0 im+no T"PE i
im+name T"PE 'trin?
im+@a?e T"PE i.
ENDINTER,ACE.
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
) Super #%a'' LCL+CompanyEmp%oyee'
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
CLA11 #c#_c)m"an/_$m"#)/$$% DEFINITION.
PUBLIC SECTION.
T"PES:
BE0IN O, t+emp%oyee$
no T"PE i$
name T"PE 'trin?$
@a?e T"PE i$
END O, t+emp%oyee.
) De#%are e2ent. Note t<at 1e#%aration #ou%1 a%'o -e p%a#e1 in t<e
) inter*a#e
EVENTS: emp%oyee+a11e1+to+%i't
EAPORTIN0 2a%ue(eD+emp%oyee+name! T"PE 'trin?.
) CLASS(EVENTS: E2ent' #an a%'o -e 1e*ine1 a' #%a''(e2ent'
INTER,ACES %i*+emp%oyee.
.ET/ODS:
#on'tru#tor$
1i'p%ay+emp%oyee+%i't$
1i'p%ay+no+o*+emp%oyee'$
) De#%are e2ent met<o1
on+emp%oyee+a11e1+to+%i't ,OR EVENT emp%oyee+a11e1+to+%i't O,
%#%+#ompany+emp%oyee'
I.PORTIN0 eD+emp%oyee+name 'en1er.
PRIVATE SECTION.
CLASS(DATA:
i+emp%oyee+%i't T"PE TABLE O, t+emp%oyee$
no+o*+emp%oyee' T"PE i.
ENDCLA11.
)(( CLASS LCL+CompanyEmp%oyee' I.PLE.ENTATION
CLA11 #c#_c)m"an/_$m"#)/$$% I3PLE3ENTATION.
.ET/OD #on'tru#tor.
no+o*+emp%oyee' 3 no+o*+emp%oyee' 4 5.
END.ET/OD.
.ET/OD %i*+emp%oyeeOa11+emp%oyee.
) A11' a ne@ emp%oyee to t<e %i't o* emp%oyee'
DATA: %+emp%oyee T"PE t+emp%oyee.
%+emp%oyee(no 3 im+no.
%+emp%oyee(name 3 im+name.
%+emp%oyee(@a?e 3 im+@a?e.
APPEND %+emp%oyee TO i+emp%oyee+%i't.
) Rai'e e2ent emp%oyee+a11e1+to+%i't
RAISE EVENT emp%oyee+a11e1+to+%i't
EAPORTIN0 eD+emp%oyee+name 3 %+emp%oyee(name.
END.ET/OD.
.ET/OD 1i'p%ay+emp%oyee+%i't.
) Di'p%ay' a%% emp%oyee' an1 t<ere @a?e
DATA: %+emp%oyee T"PE t+emp%oyee.
6RITE: 7 8Li't o* Emp%oyee'8.
LOOP AT i+emp%oyee+%i't INTO %+emp%oyee.
6RITE: 7 %+emp%oyee(no$ %+emp%oyee(name$ %+emp%oyee(@a?e.
ENDLOOP.
END.ET/OD.
.ET/OD 1i'p%ay+no+o*+emp%oyee'.
) Di'p%ay' tota% num-er o* emp%oyee'
S&IP H.
6RITE: 7 8Tota% num-er o* emp%oyee':8$ no+o*+emp%oyee'.
END.ET/OD.
.ET/OD on+emp%oyee+a11e1+to+%i't.
) E2ent met<o1
6RITE: 7 8Emp%oyee a11e1 to %i't8$ eD+emp%oyee+name.
END.ET/OD.
ENDCLA11.
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
) Su- #%a'' LCL+B%ueCo%%ar+Emp%oyee
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
CLA11 #c#_b#6$c)##a!_$m"#)/$$ DEFINITION
INHERITIN2 FRO3 #c#_c)m"an/_$m"#)/$$%.
See #o1e in eDamp%e H...
ENDCLA11.
CLA11 #c#_b#6$c)##a!_$m"#)/$$ I3PLE3ENTATION.
See #o1e in eDamp%e H...
ENDCLA11.
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
) Su- #%a'' LCL+6<iteCo%%ar+Emp%oyee
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
CLA11 #c#_7hi$c)##a!_$m"#)/$$ DEFINITION
See #o1e in eDamp%e H...
ENDCLA11.
CLA11 #c#_7hi$c)##a!_$m"#)/$$ I3PLE3ENTATION.
See #o1e in eDamp%e H...
ENDCLA11.
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
) R E P O R T
)))))))))))))))))))))))))))))))))))))))))))))))))))))))
DATA:
) O-Fe#t re*eren#e'
o+-%ue#o%%ar+emp%oyee5 T"PE RE, TO %#%+-%ue#o%%ar+emp%oyee$
o+@<ite#o%%ar+emp%oyee5 T"PE RE, TO %#%+@<ite#o%%ar+emp%oyee.
START(O,(SELECTION.
) Create -%ue#o%%ar emp%oyee o-eFe#t
CREATE OB=ECT o+-%ue#o%%ar+emp%oyee5
EAPORTIN0 im+no 3 5
im+name 3 8&aren =o<n'on8
im+<our' 3 HB
im+<our%y+payment 3 G.
) Re?i'ter e2ent *or o+-%ue#o%%ar+emp%oyee5
SET /ANDLER o+-%ue#o%%ar+emp%oyee5(>on+emp%oyee+a11e1+to+%i't
,OR o+-%ue#o%%ar+emp%oyee5.
) A11 -%ue#o%%ar emp%oyee to emp%oyee %i't
CALL .ET/OD o+-%ue#o%%ar+emp%oyee5(>%i*+emp%oyeeOa11+emp%oyee
EAPORTIN0 im+no 3 5
im+name 3 80y%%e &aren8
im+@a?e 3 ;.
) Create @<ite#o%%ar emp%oyee o-eFe#t
CREATE OB=ECT o+@<ite#o%%ar+emp%oyee5
EAPORTIN0 im+no 3 2
im+name 3 8=o<n Di#Een'8
im+mont<%y+'a%ary 3 5;;;;
im+mont<%y+1e1u#tion' 3 2;;.
) Re?i'ter e2ent *or o+@<ite#o%%ar+emp%oyee5
SET /ANDLER o+@<ite#o%%ar+emp%oyee5(>on+emp%oyee+a11e1+to+%i't
,OR o+@<ite#o%%ar+emp%oyee5.P
) A11 -%ue#o%%ar emp%oyee to emp%oyee %i't
CALL .ET/OD o+@<ite#o%%ar+emp%oyee5(>%i*+emp%oyeeOa11+emp%oyee
EAPORTIN0 im+no 3 5
im+name 3 80y%%e &aren8
im+@a?e 3 ;.
) Di'p%ay emp%oyee %i't an1 num-er o* emp%oyee'. Note t<at t<e re'u%t
) @i%% -e t<e 'ame @<en #a%%e1 *rom o+@<ite#o%%ar+emp%oyee5 or
) o+-%ue#o%ar#o%%ar+emp%oyee5$ -e#au'e t<e met<o1' are 1e*ine1
) a' 'tati# (CLASS(.ET/ODS!
CALL .ET/OD o+@<ite#o%%ar+emp%oyee5(>1i'p%ay+emp%oyee+%i't.
CALL .ET/OD o+@<ite#o%%ar+emp%oyee5(>1i'p%ay+no+o*+emp%oyee'.
esult,
"mplo#ee added to list 6aren 7ohnson
"mplo#ee added to list 7ohn &ic'ens
List of "mplo#ees
; 6aren 7ohnson 2.<3=
2 7ohn &ic'ens >.3==
Total number of emplo#ees, 2


***********************************************************************
-ac+ to main menu
2ow to)
%eneral
Synchroni3ation45lush
Set up event handling for controls
Declare a reference variable before the class has been defined
Set focus to a control
%eneral
Control 5ramewor+ and enheritance hierarchy
The control framewor' consists of 2 parts,
CL/0UI/CA: contains methods that provide services for communication
with the frontend, and can be used both b# control wrapper calsses and b#
control progtrammers
The CL/0UI/*B7"CT encapsulates ActiveH or 7avaBeans methods,
while CL/0UI/C*+T*L is responsible for displa#ing the control on the
screen.
CL/0UI/*B7"CT )9 CL/0UI/C*+T*L )9 CL/0UI/B 1:rapper class4
These classes contains methods that are enherited b# subseCuent classes in the
enheritance tree.
Synchroni3ation45lush
AC calls is used to s#nchroniGe the front and bac'end. This s#nchroniGation
ta'es palce at some predifined points in the program flow. .owever #ou should
not rel# entirel# on automatic s#nchroniGation, but force s#nchroniGation with the
Alush method when necessar#.
Bear in mind that the s#nchroniGationIAC calls represenmts a bottlenec', so
#ou should 'eep the not use the Alush method to a minimum.
(#nta$,
CALL -"T.*& cl/gui/cfwD9ALU(.

Set up event handling for controls
There are two t#pes of events,
Application events. T
The flow logic of the screen is processed after the event 1The PAI module is
processed4.
In the events table the event must be registred as an application event b# setting
then field appl/event to JHJ,
wa/events)eventid D cl/gui/te$teditD9event/double/clic'.
wa/events)applevent 6 787.
append wa/events to i/events.
Important) The dispatch method of cl/gui/cfw must be called in the PAI module,
CALL -"T.*& cl/gui/cfwD9dispatch.
(#stem events.
Aor s#stem events the flow)logic of the screen is not e$ecuted. That means that
the PAI and PB* modules are not processed.
In the events table the the field appl/event must be set to (APC",
wa/events)eventid D cl/gui/te$teditD9event/double/clic'.
wa/events)applevent 6 space.
append wa/events to i/events.
The dispatch method of cl/gui/cfw must #&' be called.
"$ample
It is presumed that a (AP toolbar control named go_toolbar of class
cl_gui_toolbar has been defined. To see a complete e$ample of how to handle
events, refer to The (AP toolbar control.
&ata,
9 :/ Define and instance of the eventhandler class.
B If the event handler class is defined after the data decalaration
B the class must be declared as &"A""& in the top of the program,
CLA(( cls/event/handler &"AI+ITI*+ &"A""&.
go/event/handler T5P" "A T* cls/event/handler,
9 ./ Define table for registration of events/
B +ote that a T5P" "A to cls/event/handler must be created before #ou
can
B reference t#pes cntl/simple/events and cntl/simple/event
gi/events T5P" cntl/simple/events,
B :or'space for table gi/events
g/event T5P" cntl/simple/event.
9 0/ Define and implement eventhandler class
CLA(( cls/event/handler &"AI+ITI*+.
PUBLIC ("CTI*+.
-"T.*&(,
B (#nta$,
B 8method name9 A* "!"+T 8event of control ) see the control
documentation9
B *A 8class of ob%ect9 8importing parameters l ) see the control
documentation9
on/function/selected
A* "!"+T function/selected *A cl/gui/toolbar
I-P*TI+0 fcode,
"+&CLA((.
CLA(( cls/event/handler I-PL"-"+TATI*+.
-"T.*& on/function/selected.
B &o something when the event is raised
"+&-"T.*&.
"+&CLA((.
9 1/ !ppend events to the events table
B The "vent Id can be found in the control documentation. +ote that The event
below is registred as an application event
g/event)eventid D go/toolbar)9m/id/function/selected.
g/event)appl/event D JHJ. KThis is an application event
APP"+& g/event T* gi/events.
.... append more events i necessar#...
9 ;/ Use the events table to register events for the control
CALL -"T.*& go/toolbar)9set/registered/events
"HP*TI+0
events D gi/events.
9 </ Create event handler
C"AT" *B7"CT go/event/handler.
B (#nta$,
B ("T .A+&L" 8event handler class9 )9 8"vent handler method9
B A* 8control9
("T .A+&L" go/event/handler)9on/function/selected
A* go/toolbar.


Declare a reference variable before the class has been defined
(cenario,
&ATA, o/m#/class T5P" "A T* lcl/m#class.
CLA(( lcl/m#class.....
"+&CLA((.
This will cause an error because the definition of class lcl/m#class is after the
declaration.
(olution,
&efine the class in the beginning of the program with DEFINITIN DEFE!!ED,
CLA(( lcl/m#class &"AI+ITI*+ &"A""&.
&ATA, o/m#/class T5P" "A T* lcl/m#class.
CLA(( lcl/m#class.....
"+&CLA((.

(et focus to a control
(et the focus to a control named go/grid,
CALL -"T.*& cl/gui/controlD9set/focus
"HP*TI+0 control D go/grid.

$,ample :) Creating the 'e,t$dit control
$,ample .) $vent handling = !pplication event
$,ample 0) $vent handling = System event
$,ample 1) Calling a methods of the control
$,ample ;) "esponding to an event
$,ample <) Protect a line in the 'e,t$dit control and the importance of
5LUS2
$,ample >) Using multiple controls
See the whole program code

$,ample :) Creating the 'e,t$dit control
This is a simple e$ample of how to implement a te$t edit control.
Steps
;. Create a report
2. In the start of selection event add, ("T (C""+ J;==J.
@. Create screen ;==
4. Place a custom control on the screen b# choosing the custom control icon
which can be recogniGed b# the letter JCJ, and give it the name
"#$NT%INE!&.
3. To be able to e$it the program, add a pushbutton with the function code
"HIT.
L. In the elements list enter the name *6/C*&" for the element of t#pe *6.
'he code
REPORT %a"mz_hf_c)n!)#%' .
CONSTANTS:
%ine+%en?t< T"PE i VALUE 2:.
DATA: oE+#o1e LI&E 'y(u#omm.
DATA:
) Create re*eren#e to t<e #u'tom #ontainer
#u'tom+#ontainer T"PE RE, TO #%+?ui+#u'tom+#ontainer$
) Create re*eren#e to t<e TeDtE1it #ontro%
e1itor T"PE RE, TO #%+?ui+teDte1it$
repi1 LI&E 'y(repi1.
START(O,(SELECTION.
SET SCREEN 85;;8.
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
) .ODULE USER+CO..AND+;5;; INPUT )
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
.ODULE u'er+#omman1+;5;; INPUT.
CASE oE+#o1e.
6/EN 8EAIT8.
LEAVE TO SCREEN ;.
ENDCASE.
END.ODULE. N USER+CO..AND+;5;; INPUT
)I((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
)I .o1u%e STATUS+;5;; OUTPUT
)I((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
.ODULE 'tatu'+;5;; OUTPUT.
) T<e TeDtE1it #ontro% '<ou% on%y -e initia%i9e1 t<e *ir't time t<e
) PBO mo1u%e eDe#ute'
I, e1itor IS INITIAL.
repi1 3 'y(repi1.
) Create o-eF#t *or #u'tom #ontainer
CREATE OB=ECT #u'tom+#ontainer
EAPORTIN0
#ontainer+name 3 8."CONTAINER58
EACEPTIONS
#nt%+error 3 5
#nt%+'y'tem+error 3 2
#reate+error 3 H
%i*etime+error 3 :
%i*etime+1ynpro+1ynpro+%inE 3
ot<er' 3 Q
.
I, 'y('u-r# J> ;.
.ESSA0E ID 'y(m'?i1 T"PE 8I8 NU.BER 'y(m'?no
6IT/ 'y(m'?25 'y(m'?22 'y(m'?2H 'y(m'?2:.
ENDI,.
) Create o-eF#t *or t<e TeDtE1itor #ontro%
CREATE OB=ECT e1itor
EAPORTIN0
@or1@rap+mo1e 3
#%+?ui+teDte1it3>@or1@rap+at+*iDe1+po'ition
@or1@rap+po'ition 3 %ine+%en?t<
@or1@rap+to+%ine-reaE+mo1e 3 #%+?ui+teDte1it3>true
parent 3 #u'tom+#ontainer
EACEPTIONS
error+#nt%+#reate 3 5
error+#nt%+init 3 2
error+#nt%+%inE 3 H
error+1p+#reate 3 :
?ui+type+not+'upporte1 3
ot<er' 3 Q
.
I, 'y('u-r# J> ;.
.ESSA0E ID 'y(m'?i1 T"PE 8I8 NU.BER 'y(m'?no
6IT/ 'y(m'?25 'y(m'?22 'y(m'?2H 'y(m'?2:.
ENDI,.
ENDI,.
END.ODULE. N STATUS+;5;; OUTPUT
'he result


$,ample .) $vent handling = !pplication event
There are 2 t#pes of events,
'ystem e(ents. These events are triggerede irrespective of the screen
flow)logic.
%pplication e(ents. The PAI module is processed after an event. The
method $)_*+I_$F,-.DI'/%T$0 must be called to initiate event
handling
In this e$ample an application event is added to the program in e$ample ;. +ew
code is mar'ed with red.
Steps,
;. Create an inputIoutput field on screen ;==, where the event t#pe can be
output. +ame it "!"+T/T5P"
'he code)

REPORT %a"mz_hf_c)n!)#%' .
CONSTANTS:
%ine+%en?t< T"PE i VALUE 2:.
DATA: oE+#o1e LI&E 'y(u#omm.
DATA:
) Create re*eren#e to t<e #u'tom #ontainer
#u'tom+#ontainer T"PE RE, TO #%+?ui+#u'tom+#ontainer$
) Create re*eren#e to t<e TeDtE1it #ontro%
e1itor T"PE RE, TO #%+?ui+teDte1it$
repi1 LI&E 'y(repi1.
**********************************************************************
* Im"m$nin* $8$n%
**********************************************************************
DATA:
e2ent+type(2;! T"PE #$
) Interna% ta-%e *or e2ent' t<at '<ou%1 -e re?i'tre1
i+e2ent' T"PE #nt%+'imp%e+e2ent'$
) Stru#ture *or one%ine o* t<e ta-%e
@a+e2ent' T"PE #nt%+'imp%e+e2ent.
*555555555555555555555555555555555555555555555555555555555555555555555*
* CLA11 #c#_$8$n_han.#$! DEFINITION
*555555555555555555555555555555555555555555555555555555555555555555555*
CLASS %#%+e2ent+<an1%er DE,INITION.
PUBLIC SECTION.
CLASS(.ET/ODS:
#at#<+1-%#%i#E ,OR EVENT 1-%#%i#E
O, #%+?ui+teDte1it I.PORTIN0 'en1er.
ENDCLASS.
CLASS %#%+e2ent+<an1%er I.PLE.ENTATION.
.ET/OD #at#<+1-%#%i#E.
e2ent+type 3 8E2ent DBLCLIC& rai'e18.
END.ET/OD.
ENDCLASS.
START(O,(SELECTION.
CLEAR @a+e2ent'. re*re'< i+e2ent'.
SET SCREEN 85;;8.
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
) .ODULE USER+CO..AND+;5;; INPUT )
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
.ODULE u'er+#omman1+;5;; INPUT.
CASE oE+#o1e.
6/EN 8EAIT8.
LEAVE TO SCREEN ;.
6/EN OT/ERS.
* Ca## h$ Di%"ach m$h). ) iniia$ a""#icai)n $8$n han.#in*
#a%% met<o1 #%+?ui+#*@3>Di'pat#<.
ENDCASE.
END.ODULE. N USER+CO..AND+;5;; INPUT
)I((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
)I .o1u%e STATUS+;5;; OUTPUT
)I((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
.ODULE 'tatu'+;5;; OUTPUT.
) T<e TeDtE1it #ontro% '<ou% on%y -e initia%i9e1 t<e *ir't time t<e
) PBO mo1u%e eDe#ute'
I, e1itor IS INITIAL.
repi1 3 'y(repi1.
) Create o-eF#t *or #u'tom #ontainer
CREATE OB=ECT #u'tom+#ontainer
EAPORTIN0
#ontainer+name 3 8."CONTAINER58
EACEPTIONS
#nt%+error 3 5
#nt%+'y'tem+error 3 2
#reate+error 3 H
%i*etime+error 3 :
%i*etime+1ynpro+1ynpro+%inE 3
ot<er' 3 Q
.
I, 'y('u-r# J> ;.
.ESSA0E ID 'y(m'?i1 T"PE 8I8 NU.BER 'y(m'?no
6IT/ 'y(m'?25 'y(m'?22 'y(m'?2H 'y(m'?2:.
ENDI,.
) Create o-eF#t *or t<e TeDtE1itor #ontro%
CREATE OB=ECT e1itor
EAPORTIN0
@or1@rap+mo1e 3
#%+?ui+teDte1it3>@or1@rap+at+*iDe1+po'ition
@or1@rap+po'ition 3 %ine+%en?t<
@or1@rap+to+%ine-reaE+mo1e 3 #%+?ui+teDte1it3>true
parent 3 #u'tom+#ontainer
EACEPTIONS
error+#nt%+#reate 3 5
error+#nt%+init 3 2
error+#nt%+%inE 3 H
error+1p+#reate 3 :
?ui+type+not+'upporte1 3
ot<er' 3 Q
.
I, 'y('u-r# J> ;.
.ESSA0E ID 'y(m'?i1 T"PE 8I8 NU.BER 'y(m'?no
6IT/ 'y(m'?25 'y(m'?22 'y(m'?2H 'y(m'?2:.
ENDI,.
* Lin9 h$ $8$n han.#$! m$h). ) h$ $8$n an. h$
* T$(E.i c)n!)#
SET /ANDLER %#%+e2ent+<an1%er3>#at#<+1-%#%i#E ,OR e1itor.
* R$*i%$! h$ $8$n in h$ in$!na# ab#$ i_$8$n%
@a+e2ent'(e2enti1 3 #%+?ui+teDte1it3>e2ent+1ou-%e+#%i#E.
@a+e2ent'(app%+e2ent 3 8A8. NT<i' i' an app%i#ation e2ent
appen1 @a+e2ent' to i+e2ent'.
* Pa%% h$ ab#$ ) h$ T$(E.i c)n!)# 6%in* m$h).
* %$_!$*i%!$._$8$n%
#a%% met<o1 e1itor(>'et+re?i'tere1+e2ent'
eDportin? e2ent' 3 i+e2ent'.
ENDI,.
END.ODULE. N STATUS+;5;; OUTPUT
"esult)
:hen #ou double clic' on the Te$t"dit control, the inputIouput field should show
the te$t, E(ent D1)$)I$2
$,ample 0) $vent handling = System event
(#stem events are passed irrespective of the flow)logic of the screen. To
implement a s#stem event change the code from e$ample 2 as follows,
C).$:
CLASS %#%+e2ent+<an1%er I.PLE.ENTATION.
.ET/OD #at#<+1-%#%i#E.
)((( e2ent+type 3 8E2ent DBLCLIC& rai'e18.
) Rea#tin? to t<e 'y'tem e2ent
#a%% met<o1 #%+?ui+#*@3>'et+ne@+oE+#o1e
eDportin? ne@+#o1e 3 8S/O68.

.ODULE u'er+#omman1+;5;; INPUT.
CASE oE+#o1e.
#o1e.........
6/EN 8S/O68.
e2ent+type 3 8Sy'tem 1-%#%i#E8.
6/EN OT/ERS.
*5555 #a%% met<o1 #%+?ui+#*@3>Di'pat#<.
ENDCASE.
END.ODULE. N USER+CO..AND+;5;; INPUT

.ODULE 'tatu'+;5;; OUTPUT.
Co1e ................
)((( @a+e2ent'(app%+e2ent 3 8A8. NT<i' i' an app%i#ation e2ent
@a+e2ent'(app%+e2ent 3 'pa#e. NT<i' i' a 'y'tem e2ent
ENDI,.
END.ODULE. N STATUS+;5;; OUTPUT
"esult)
:hen #ou double clic's on the Te$t"dit control nothing happens, since the flow)
logic of the screen an dthe fielde transport is ignore.
$,ample 1) Calling methods of the control
In this e$ercise a function that loads the te$ts of an internal table into the te$t
window, is implemented.
Steps)
&efine anoterh pushbutton on the screen, that activates the method that fills the
Te$t"dit control. 0ive itname /+'01+TTN_I"/!T and function code I"/.
&efine a form C"AT"/T"HT( that carries out the te$t import.
*nl# changes to the code in e$ample 2 is show.
Code)
-*&UL" user/command/=;== I+PUT.
CA(" o'/code.
code.........
:."+ JI-PJ.
perform load/te$ts.
"+&CA(".
"+&-*&UL". K U("/C*--A+&/=;== I+PUT
)I((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
)I ,orm %oa1+teDt'
)I((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
) T<i' *orm #reate' an interna% ta-%e @it< teDt'. T<e t<e #ontent' o*
) t<e ta-%e i' in'tere1 into t<e TeDtE1it #ontro% u'in? met<o1
) 'et+teDt+a'+rHta-%e
)(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
,OR. %oa1+teDt'.
T"PES:
BE0IN O, t+teDtta-%e$
%ine(%ine+%en?t<! T"PE #$
END O, t+teDtta-%e.
DATA
i+teDtta-%e T"PE TABLE O, t+teDtta-%e.
) Create interna% ta-%e @it< teDt'
APPEND 8T<i' a met<o1 t<at *i%%' t<e TeDtE1it #ontro%8 TO i+teDtta-%e.
APPEND 8@it< a teDt.8 TO i+teDtta-%e.
DO 5; TI.ES.
APPEND 8<a%%o @or%1 K8 TO i+teDtta-%e.
ENDDO.
) Loa1 TeDtE1it #ontro% @it< teDt'
CALL .ET/OD e1itor(>'et+teDt+a'+rHta-%e
EAPORTIN0 ta-%e 3 i+teDtta-%e.
I, 'y('u-r# > ;.
) Di'p%ay an error me''a?e
EAIT.
ENDI,.
) A%% met<o1' t<at operate' on #ontro%' are tran'*erre1 to t<e *ronten1
) -y a R,C #a%%'. t<e met<o1 ,LUS/ i' u'e1 to 1etermine @<en t<i' i'
1one.
CALL .ET/OD #%+?ui+#*@3>*%u'<.
I, 'y('u-r# > ;.
) Di'p%ay an error me''a?e
ENDI,.
END,OR.. N #reate+teDt'

$,ample ;) "esponding to an event
:hen #ou double clic' on a te$t line in the Te$t"dit control, #ou want it to be
prefi$ed with a J9J.
The line number of the Te$t"dit control that is double clic'ed, is retreived using
method 0"T/("L"CTI*+/P*(. The internal te$t table is reloaded froim the
Te$t"dit control with method 0"T/T"HT/A(/@TABL". The position of the
double clic' in the Te$t"dit control is used to find the entr# in the table, and the
entr# is prefi$ed with JBJ and loaded into the Te$t"dit control again.
The program should be changed so that the internal table i/te$ttable is global,
and a global flag g/loaded added. The load of the table should be moved to the
PB* module. The changes in th%e code are mar'ed with red. The whole program
now loo's li'e this,
Code
REPORT %a"mz_hf_c)n!)#%' .
CONSTANTS:
%ine+%en?t< T"PE i VALUE 2:.
DATA: oE+#o1e LI&E 'y(u#omm.
DATA:
) Create re*eren#e to t<e #u'tom #ontainer
#u'tom+#ontainer T"PE RE, TO #%+?ui+#u'tom+#ontainer$
) Create re*eren#e to t<e TeDtE1it #ontro%
e1itor T"PE RE, TO #%+?ui+teDte1it$
repi1 LI&E 'y(repi1.
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
) Uti%%ity ta-%e to %oa1 teDt'
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
T"PES:
BE0IN O, t+teDtta-%e$
%ine(%ine+%en?t<! T"PE #$
END O, t+teDtta-%e.
DATA:
i+teDtta-%e T"PE TABLE O, t+teDtta-%e$
?+%oa1e1(5! T"PE #.
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
) Impmentin? e2ent'
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
DATA:
e2ent+type(2;! T"PE #$
) Interna% ta-%e *or e2ent' t<at '<ou%1 -e re?i'tre1
i+e2ent' T"PE #nt%+'imp%e+e2ent'$
) Stru#ture *or one%ine o* t<e ta-%e
@a+e2ent' T"PE #nt%+'imp%e+e2ent.
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
) CLASS %#%+e2ent+<an1%er DE,INITION
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
CLASS %#%+e2ent+<an1%er DE,INITION.
PUBLIC SECTION.
CLASS(.ET/ODS:
#at#<+1-%#%i#E ,OR EVENT 1-%#%i#E
O, #%+?ui+teDte1it I.PORTIN0 'en1er.
ENDCLASS.
CLASS %#%+e2ent+<an1%er I.PLE.ENTATION.
.ET/OD #at#<+1-%#%i#E.
DATA:
*rom+%ine T"PE i$
*rom+po' T"PE i$
to+%ine T"PE i$
to+po' T"PE i$
@a+teDtta-%e T"PE t+teDtta-%e.
) U'e1 *or t<e 'ytem e2ent
#a%% met<o1 #%+?ui+#*@3>'et+ne@+oE+#o1e
eDportin? ne@+#o1e 3 8S/O68.
) Rea1 t<e po'ition o* t<e 1ou-%e #%i#E
CALL .ET/OD 'en1er(>?et+'e%e#tion+po'
I.PORTIN0
*rom+%ine 3 *rom+%ine
*rom+po' 3 *rom+po'
to+%ine 3 to+%ine
to+po' 3 to+po'.
) TeDt' in t<e TeDtE1it #ontro% #an <a2e -een #<an?e1$ 'o
) *ir't re%oa1 teDt *rom t<e #ontro% into t<e interna%
) ta-%e t<at #ontain' teDt
I, NOT ?+%oa1e1 IS INITIAL.
CALL .ET/OD 'en1er(>?et+teDt+a'+rHta-%e
I.PORTIN0 ta-%e 3 i+teDtta-%e.
) Rea1 t<e %ine o* t<e interna% ta-%e t<at @a' #%i#Ee1
READ TABLE i+teDtta-%e INDEA *rom+%ine INTO @a+teDtta-%e.
I, 'y('u-r# J> ;.
EAIT.
ENDI,.
I, @a+teDtta-%e4;(5! CS 8)8.
S/I,T @a+teDtta-%e.
ELSEI, @a+teDtta-%e4;(5! NS 8)8.
S/I,T @a+teDtta-%e RI0/T.
@a+teDtta-%e4;(5! 3 8)8.
ENDI,.
mo1i*y i+teDtta-%e *rom @a+teDtta-%e in1eD *rom+%ine.
) Re%oa1 teDt' *rom < einterna% ta-%e
per*orm %oa1+teDt'.
ENDI,.
END.ET/OD.
ENDCLASS.
START(O,(SELECTION.
CLEAR @a+e2ent'.
RE,RES/: i+e2ent'.
SET SCREEN 85;;8.
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
) .ODULE USER+CO..AND+;5;; INPUT )
)((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
.ODULE u'er+#omman1+;5;; INPUT.
CASE oE+#o1e.
6/EN 8EAIT8.
LEAVE TO SCREEN ;.
6/EN 8S/O68.
e2ent+type 3 8Sy'tem 1-%#%i#E8.
6/EN 8I.P8.
PER,OR. Loa1+teDt'.
6/EN OT/ERS.
) CALL .ET/OD #%+?ui+#*@3>1i'pat#<. NNot u'e1 *or 'y'tem e2ent'
ENDCASE.
END.ODULE. N USER+CO..AND+;5;; INPUT
)I((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
)I .o1u%e STATUS+;5;; OUTPUT
)I((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
.ODULE 'tatu'+;5;; OUTPUT.
) T<e TeDtE1it #ontro% '<ou% on%y -e initia%i9e1 t<e *ir't time t<e
) PBO mo1u%e eDe#ute'
I, e1itor IS INITIAL.
repi1 3 'y(repi1.
) Create o-Fe#t *or #u'tom #ontainer
CREATE OB=ECT #u'tom+#ontainer
EAPORTIN0
#ontainer+name 3 8."CONTAINER58
EACEPTIONS
#nt%+error 3 5
#nt%+'y'tem+error 3 2
#reate+error 3 H
%i*etime+error 3 :
%i*etime+1ynpro+1ynpro+%inE 3
ot<er' 3 Q
.
I, 'y('u-r# J> ;.
.ESSA0E ID 'y(m'?i1 T"PE 8I8 NU.BER 'y(m'?no
6IT/ 'y(m'?25 'y(m'?22 'y(m'?2H 'y(m'?2:.
ENDI,.
) Create o-eF#t *or t<e TeDtE1itor #ontro%
CREATE OB=ECT e1itor
EAPORTIN0
@or1@rap+mo1e 3
#%+?ui+teDte1it3>@or1@rap+at+*iDe1+po'ition
@or1@rap+po'ition 3 %ine+%en?t<
@or1@rap+to+%ine-reaE+mo1e 3 #%+?ui+teDte1it3>true
parent 3 #u'tom+#ontainer
EACEPTIONS
error+#nt%+#reate 3 5
error+#nt%+init 3 2
error+#nt%+%inE 3 H
error+1p+#reate 3 :
?ui+type+not+'upporte1 3
ot<er' 3 Q
.
I, 'y('u-r# J> ;.
.ESSA0E ID 'y(m'?i1 T"PE 8I8 NU.BER 'y(m'?no
6IT/ 'y(m'?25 'y(m'?22 'y(m'?2H 'y(m'?2:.
ENDI,.
) LinE t<e e2ent <an1%er met<o1 to t<e e2ent an1 t<e
) TeDtE1it #ontro%
SET /ANDLER %#%+e2ent+<an1%er3>#at#<+1-%#%i#E ,OR e1itor.
) Re?i'ter t<e e2ent in t<e interna% ta-%e i+e2ent'
@a+e2ent'(e2enti1 3 #%+?ui+teDte1it3>e2ent+1ou-%e+#%i#E.
) @a+e2ent'(app%+e2ent 3 8A8. NT<i' i' an app%i#ation e2ent
@a+e2ent'(app%+e2ent 3 'pa#e. NT<i' i' a 'y'tem e2ent
APPEND @a+e2ent' TO i+e2ent'.
) Pa'' t<e ta-%e to t<e TeDtE1it #ontro% u1in? met<o1
) 'et+re?i'tre1+e2ent'
CALL .ET/OD e1itor(>'et+re?i'tere1+e2ent'
EAPORTIN0 e2ent' 3 i+e2ent'.
) Create interna% ta-%e @it< teDt' ta<t #an -e up%oa1e1 to
) t<e TeDtE1it #ontro%
APPEND 8T<i' a met<o1 t<at *i%%' t<e TeDtE1it #ontro%8 TO i+teDtta-%e.
APPEND 8@it< a teDt.8 TO i+teDtta-%e.
DO 5; TI.ES.
APPEND 8<a%%o @or%1 K8 TO i+teDtta-%e.
ENDDO.
ENDI,.
END.ODULE. N STATUS+;5;; OUTPUT
)I((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
)I ,orm Loa1+teDt'
)I((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
) T<i' *orm %oa1' t<e %ine' o* t<e interna% ta-%e i+teDtta-%e into
) t<e TeDtE1it #ontro%
)(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
,OR. Loa1+teDt'.
) Loa1 TeDtE1it #ontro% @it< teDt'
CALL .ET/OD e1itor(>'et+teDt+a'+rHta-%e
EAPORTIN0 ta-%e 3 i+teDtta-%e.
I, 'y('u-r# > ;.
) Di'p%ay an error me''a?e
EAIT.
ENDI,.
) A%% met<o1' t<at operate' on #ontro%' are tran'*erre1 to t<e *ronten1
) -y a R,C #a%%'. t<e met<o1 ,LUS/ i' u'e1 to 1etermine @<en t<i' i'
) 1one.
CALL .ET/OD #%+?ui+#*@3>*%u'<.
I, 'y('u-r# > ;.
) Di'p%ay an error me''a?e
ENDI,.
?+%oa1e1 3 8A8.
END,OR.. N #reate+teDt'
$,ample <) Protect a line in the 'e,t$dit control and the
importance of 5LUS2
All methods that operates on controls are transfered to the fronend b# AC calls.
The F)+'0 method is used to s#nchroniGe control e$ecution and the frontend.
This is ver# important when wor'ing e.g. with e$port parameters from a method,
as the parmeters will not be correct before the F)+'0 method has been called.
The e$ample below portects selected lines in the Te$t"dit and uses ALU(. to
ensure that the correct parameters are returned from method
*ET_'E)E$TIN_/'.
+ote, Instead of using method /!TE$T_)INE', the method
/!TE$T_'E)E$TIN could be used. This method does not need line
numbers or a ALU(. statement
Steps
Add a new pushbutton to the screen with the function code /!TE$T.
Code
Add the following code to the e$ample,
B 0lobal variables
&ATA,
from/id$ T5P" i,
to/id$ T5P" i,
inde$ T5P" i.
-*&UL" user/command/=;== I+PUT.
CA(" o'/code.
code.......................
:."+ JP*T"CTJ.
P"A*- protect.
. .......................
"+&CA(".
)I((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
)I ,orm prote#t
)I((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
) Prote#t' marEe1 %ine' in a TeDtE1it #ontro%
)(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()
,OR. prote#t.
) Determine t<e area 'e%e#te1 -y t<e u'er
CALL .ET/OD e1itor(>?et+'e%e#tion+po'
I.PORTIN0
*rom+%ine 3 *rom+i1D
to+%ine 3 to+i1D
EACEPTIONS
error+#nt%+#a%%+met<o1 3 5.
) Syn#<roni9e eDe#ution in t<e #ontro% @it< t<e ABAP pro?ram.
) 6it<out t<i' 'yn#<roni9ation t<e 2aria-%e' *rom+i1D an1
) to+i1D @i%% <a2e o-'o%utete 2a%ue' (T<e initia% 2a%ue *or
) -ot<$ are ;!
CALL .ET/OD #%+?ui+#*@3>*%u'<.
I, 'y('u-r# > ;.
) Errorme''a?e: Error in *%u'<
ENDI,.
) Prote#t t<e 'e%e#te1 %ine'
I, to+i1D > *rom+i1D.
to+i1D 3 to+i1D ( 5.
ENDI,.
CALL .ET/OD e1itor(>prote#t+%ine'
EAPORTIN0
*rom+%ine 3 *rom+i1D
to+%ine 3 to+i1D.
) T<e PROTECT+SELECTION met<o1 #ou%1 -e u'e1 in'tea1$ e%iminatin? t<e
) nee1 o* %ine num-er' an1 t<e %a't ,LUS/
) #a%% met<o1 e1itor(>prote#t+'e%e#tion.
) ,%u'< a?ain to prote#t immi1iate%y
CALL .ET/OD #%+?ui+#*@3>*%u'<.
I, 'y('u-r# > ;.
) Errorme''a?e: Error in *%u'<
ENDI,.
END,OR.. N prote#t

"$ample >, Using multiple controls
In this e$ample a second Te$t"dit control will be added to the screen. The new
Te$t"dit control will be designed to act as a clipboard for short te$ts.
Steps,
Add a new container to the screen and name it "#$NT%INE!3.

Code)
Insert global datadeclaration,
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
B Implementing a second (cratch Te$t"dit control
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
&ATA,
scratch T5P" "A T* cl/gui/te$tedit,
custom/container2 T5P" "A T* cl/gui/custom/container.
Insert the following code in the PB* module,
)((((((((((((((((((((((((((((((((((((((((((((((((((((((
) T<e SCRATC/ TeDtE1it #ontro%
)((((((((((((((((((((((((((((((((((((((((((((((((((((((
I, '#rat#< IS INITIAL.
) Create o-eF#t *or #u'tom #ontainer2
CREATE OB=ECT #u'tom+#ontainer2
EAPORTIN0
#ontainer+name 3 8."CONTAINER28
EACEPTIONS
#nt%+error 3 5
#nt%+'y'tem+error 3 2
#reate+error 3 H
%i*etime+error 3 :
%i*etime+1ynpro+1ynpro+%inE 3
ot<er' 3 Q
.
I, 'y('u-r# J> ;.
.ESSA0E ID 'y(m'?i1 T"PE 8I8 NU.BER 'y(m'?no
6IT/ 'y(m'?25 'y(m'?22 'y(m'?2H 'y(m'?2:.
ENDI,.
) Create o-eF#t *or t<e SCRATC/ TeDtE1itor #ontro%
CREATE OB=ECT '#rat#<
EAPORTIN0
parent 3 #u'tom+#ontainer2
@or1@rap+mo1e 3
#%+?ui+teDte1it3>@or1@rap+at+@in1o@-or1er
@or1@rap+to+%ine-reaE+mo1e 3 #%+?ui+teDte1it3>true.
) Remo2e t<e 'tau' -ar
CALL .ET/OD '#rat#<(>'et+'tatu'-ar+mo1e
EAPORTIN0 'tatu'-ar+mo1e 3 #%+?ui+teDte1it3>*a%'e.
ENDI,.
"esult)



***********************************************************************
************
Preface
Examples
Simple example of how to implement an ALV grid
Complete code for the ALV grid example

Howto
Allow the uer to a!e and reue the la"out
#ntegrate uer defined function in the grid tool$ar
Set focu to the grid
Set the title of the grid
Cutomi%e the appearence of the grid
Setting and getting elected row &Column' and read line content
(a)e an *xception field & + ,raffic light'
Color a line-
.efreh grid dipla"

Preface
+ote that practical ea$mples of using the AL! grid can be found in development
class (LI(.
"$ample of the fdispla# of an AL! grid,


Simple e,ample of how to implement an !L? grid
+ote that this e$ample uses table M(ALI0.T. The table is eCuivalent to the table
(ALI0.T.
(teps,
;. Create an e$ecutable program 1eport4
2. Create a screen 1;==4 and palce a custom container named
AL!/C*+TAI+" on the screen
@. Create a Pushbutton. 0ive it the te$t "$it and the functioncode "HIT

REPORT %a"mz_hf_a#8_*!i. .
TABLES: 9'*%i?<t.

*--------------------------------------------------------------------
* G L O B A L I N T E R N A L T A B L E S

*--------------------------------------------------------------------
DATA: ?i+'*%i?<t T"PE STANDARD TABLE O, '*%i?<t.

*--------------------------------------------------------------------
* G L O B A L D A T A

*--------------------------------------------------------------------
DATA: oE+#o1e LI&E 'y(u#omm$
?+@a+'*%i?<t LI&E '*%i?<t.
* Declare reference variables to the ALV gri an the container
DATA:
?o+?ri1 T"PE RE, TO #%+?ui+a%2+?ri1$
?o+#u'tom+#ontainer T"PE RE, TO #%+?ui+#u'tom+#ontainer.

*--------------------------------------------------------------------
* S T A R T - O ! - S E L E " T I O N#

*--------------------------------------------------------------------
START(O,(SELECTION.
SET SCREEN 85;;8.

*$---------------------------------------------------------------------
*
*$ %o&le 'SER("O%%AND()*)) IN+'T

*$---------------------------------------------------------------------
*
.ODULE u'er+#omman1+;5;; INPUT.
CASE oE+#o1e.
6/EN 8EAIT8.
LEAVE TO SCREEN ;.
ENDCASE.
END.ODULE. N USER+CO..AND+;5;; INPUT

*$---------------------------------------------------------------------
*
*$ %o&le STAT'S()*)) O'T+'T

*$---------------------------------------------------------------------
*
.ODULE 'tatu'+;5;; OUTPUT.
* "reate ob,ects
I, ?o+#u'tom+#ontainer IS INITIAL.
CREATE OB=ECT ?o+#u'tom+#ontainer
EAPORTIN0 #ontainer+name 3 8ALV+CONTAINER8.
CREATE OB=ECT ?o+?ri1
EAPORTIN0
i+parent 3 ?o+#u'tom+#ontainer.
PER,OR. %oa1+1ata+into+?ri1.
ENDI,.
END.ODULE. N STATUS+;5;; OUTPUT

*$---------------------------------------------------------------------
*
*$ !or- loa(ata(into(gri

*$---------------------------------------------------------------------
*
* te.t

*----------------------------------------------------------------------
*
* --/ 0* te.t
* 1-- 02 te.t

*----------------------------------------------------------------------
*
,OR. %oa1+1ata+into+?ri1.
* Rea ata fro- table S!LIG3T
SELECT )
,RO. 9'*%i?<t
INTO TABLE ?i+'*%i?<t.
* Loa ata into the gri an is0la4 the-
CALL .ET/OD ?o+?ri1(>'et+ta-%e+*or+*ir't+1i'p%ay
EAPORTIN0 i+'tru#ture+name 3 8S,LI0/T8
C/AN0IN0 it+outta- 3 ?i+'*%i?<t.
END,OR.. N %oa1+1ata+into+?ri1

!llow the user to save and reuse the layout
A button can be shown on the grid toolbar, allowing the user to save and reuse a
la#out. The button loo's li'e this,
(ee also e$ample in (AP standard program BCAL!/0I&/=N.
To do this use the parameters I'_4%!I%NT and I_'%4E of the
set_table_for_first_display method. +ote that the I(/!AIA+T parameter must
have the structure DI'4%!I%NT.
The I/(A!" K*ptions for saving la#outsK parameter can have the following
values,
U *nl# user specific la#outs can be saved
8 *nl# global la#outs can be saved
! Both user specific and global la#outs can be saved
Space La#outs can not be saved
Add the following code to the e$ample,
A*- load/data/into/grid.
&ATA,
B Aor parameter I(/!AIA+T
l/la#out T5P" disvariant.

Code..........
B Load data into the grid and displa# them
l/la#out)report D s#)repid.
CALL -"T.*& go/grid)9set/table/for/first/displa#
"HP*TI+0 i/structure/name D J(ALI0.TJ
is/variant D l/la#out
i/save D JAJ
C.A+0I+0 it/outtab D gi/
Integrate user defined functions in the grid toolbar
Posibillities,
eplace e$isting functions in the toolbar or conte$t men with user defined
functions
Add new functions to the toolbar or conte$t menu
+ote that the whole toolbar can be removed using the
IT/T**LBA/"HCLU&I+0 parameter of the set_table_for_first_display
method.
(ee also e$ample in (AP standard program BCAL!/0I&/=3
:@ To get access to the icons insert the following statement in the top of the
program,
T5P")P**L(, icon.
.@ To allow the declaration of o/event/receiver before the lcl/event/receiver
class is defined, declare it as deferred in the
start of the program
B To allow the declaration of o/event/receiver before the lcl/event/receiver class
is defined, declare it as deferred in the
B start of the program
CLA(( lcl/event/receiver &"AI+ITI*+ &"A""&.
0@ &eclare reference to the event handler class
&ATA,
o/event/receiver T5P" "A T* lcl/event/receiver.
1@ Class for event receiver. This class adds the new button to the toolbar
and handles the event when the button is pushed
CLA(( lcl/event/receiver &"AI+ITI*+.
PUBLIC ("CTI*+.
-"T.*&(,
handle/toolbar A* "!"+T toolbar *A cl/gui/alv/grid
I-P*TI+0
e/ob%ect e/interactive,
handle/user/command A* "!"+T user/command *A
cl/gui/alv/grid
I-P*TI+0 e/ucomm.
"+&CLA((.
B)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))B
B CLA(( lcl/event/receiver I-PL"-"+TATI*+
B)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))B
CLA(( lcl/event/receiver I-PL"-"+TATI*+.
-"T.*& handle/toolbar.
B "vent handler method for event toolbar.
C*+(TA+T(,
B Constants for button t#pe
c/button/normal T5P" i !ALU" =,
c/menu/and/default/button T5P" i !ALU" ;,
c/menu T5P" i !ALU" 2,
c/separator T5P" i !ALU" @,
c/radio/button T5P" i !ALU" ?,
c/chec'bo$ T5P" i !ALU" 3,
c/menu/entr# T5P" i !ALU" L.
&ATA,
ls/toolbar T5P" stb/button.
B Append seperator to the normal toolbar
CL"A ls/toolbar.
-*!" c/separator T* ls/toolbar)butn/t#pe..
APP"+& ls/toolbar T* e/ob%ect)9mt/toolbar.
B Append a new button that to the toolbar. Use "/*B7"CT of
B event toolbar. "/*B7"CT is of t#pe
CL/AL!/"!"+T/T**LBA/("T.
B This class has one attribute -T/T**LBA which is of table t#pe
B TTB/BUTT*+. The structure is (TB/BUTT*+
CL"A ls/toolbar.
-*!" JC.A+0"J T* ls/toolbar)function.
-*!" icon/change T* ls/toolbar)icon.
-*!" JChange flightJ T* ls/toolbar)Cuic'info.
-*!" JChangeJ T* ls/toolbar)te$t.
-*!" J J T* ls/toolbar)disabled.
APP"+& ls/toolbar T* e/ob%ect)9mt/toolbar.
"+&-"T.*&.
-"T.*& handle/user/command.
B .andle own functions defined in the toolbar
CA(" e/ucomm.
:."+ JC.A+0"J.
L"A!" T* (C""+ =.
"+&CA(".
"+&-"T.*&.
"+&CLA((.
;@ In the PB* module, crate ob%ect for event handler and set handler
C"AT" *B7"CT o/event/receiver.
("T .A+&L" o/event/receiver)9handle/user/command A*
go/grid.
("T .A+&L" o/event/receiver)9handle/toolbar A* go/grid.
<@ In the PB* module after t<e CALL .ET/OD ?o+?ri1(
>'et+ta-%e+*or+*ir't+1i'p%ay$ rai'e e2ent too%-ar to
'<o@ t<e mo1i*ie1 too%-ar

CALL .ET/OD ?o+?ri1(>'et+too%-ar+intera#ti2e.
(et focus to the grid
After $%)) "ET0D go_grid5.set_table_for_first_display insert the following
stament,
CALL -"T.*& cl/gui/controlD9set/focus "HP*TI+0 control D go/grid.
Set the title of the grid
Aill the grid_title field of structure l(c_s_layo.
+ote that the structure l(c_s_layo can be used for to customiGe the grid
appearance in man# wa#s.
&ATA,
B AL! control, La#out structure
gs/la#out T5P" lvc/s/la#o.
B (et grid title
gs/la#out)grid/title D JAlightsJ.
CALL -"T.*& go/grid)9set/table/for/first/displa#
"HP*TI+0 i/structure/name D J(ALI0.TJ
islayout 6 gslayout
C.A+0I+0 it/outtab D gi/sflight.
Customi3e the appearence of the grid
The structure l(c_s_layo contains fields for setting graphical properties,
displa#ing e$ceptions, calculating totals and enabling specific interaction options.
Aill the apporpiate fields of structure l(c_s_layo and insert it as a parametrer in
the CALL -"T.*& go/grid)9set/table/for/first/displa#. (ee the e$ample under
(et the title of the grid.
If #ou want to change apperance after list output, use the methods
get_frontend_layout and set_frontend_layout.
"$amples of fields in structure l(c_s_layo:
%"ID'I'L$ (etting the title of the grid
S$L(&D$. (election mode, determines how rows can be selected. Can have
the follwing values,
! -ultiple columns, multiple rows with selection buttons.
- (imple selection, listbo$, (ingle rowIcolumn
C -ultiple rows without buttons
D -ultiple rows with buttons and select all IC*+
Setting and getting selected rows AColumns@ and read line
contents
5ou can read which rows of the grid that has been selected, and d#namic select
rows of the grid using methods get_selected_rows and set_selected_rows. There
are similiar methods for columns.
+ote that the grid table alwa#s has the rows in the same seCuence as displa#ed
in the grid, thus #ou can use the inde$ of the selected row1s4 to read the
information in the rows fronm the table. In the e$amples below the grid table is
named gi/sflight.
&ata declaratrion,
&ATA,
B Internal table for inde$es of selected rows
gi/inde$/rows T5P" lvc/t/row,
B Information about ; row
g/selected/row LI6" lvc/s/row.
"$ample ;, eading inde$ of selected row1s4 and using it to read the grid table
CALL -"T.*& go/grid)9get/selected/rows
I-P*TI+0
et/inde$/rows D gi/inde$/rows.
&"(CIB" TABL" gi/inde$/rows LI+"( l/lines.
IA l/lines D =.
CALL AU+CTI*+ JP*PUP/T*/&I(PLA5/T"HTJ
"HP*TI+0
te$tline; D J5ou must choose a valid lineJ.
"HIT.
"+&IA.
L**P AT gi/inde$/rows I+T* g/selected/row.
"A& TABL" gi/sflight I+&"H g/selected/row)inde$ I+T*
g/wa/sflight.
"+&IA.
"+&L**P.
"$ample 2, (et selected row1s4.
&"(CIB" TABL" gi/inde$/rows LI+"( l/lines.
IA l/lines 9 =.
CALL -"T.*& go/grid)9set/selected/rows
e$porting
it/inde$/rows D gi/inde$/rows.
"+&IA.
(a+e an $,ception field A 6 'raffic lights@
There can be defined a column in the grid for displa# of traffic lights. This field is
of t#pe Char ;, and canb contain the following values,
: ed
. 5ellow
0 0reen
The name of the traffic light field is supplied inh the gs_layout5excp_fname used
b# method set_table_for_first_display.
"$ample
T5P"(, B"0I+ *A st/sflight.
I+CLU&" (TUCTU" Gsflight.
T5P"(, traffic/light T5P" c.
OT5P"(, "+& *A st/sflight.
T5P"(, tt/sflight T5P" (TA+&A& TABL" *A st/sflight.
&ATA, gi/sflight T5P" tt/sflight.
B (et the e$ception field of the table
L**P AT gi/sflight I+T* g/wa/sflight.
IA g/wa/sflight)pa#mentsum 8 ;=====.
g/wa/sflight)traffic/light D J;J.
"L("IA g/wa/sflight)pa#mentsum D9 ;===== A+&
g/wa/sflight)pa#mentsum 8 ;======.
g/wa/sflight)traffic/light D J2J.
"L(".
g/wa/sflight)traffic/light D J@J.
"+&IA.
-*&IA5 gi/sflight A*- g/wa/sflight.
"+&L**P.
B +ame of the e$ception field 1Traffic light field4
gs/la#out)e$cp/fname D JTAAAIC/LI0.TJ.
B 0rid setup for first displa#
CALL -"T.*& go/grid)9set/table/for/first/displa#
"HP*TI+0 i/structure/name D J(ALI0.TJ
is/la#out D gs/la#out
C.A+0I+0 it/outtab D gi/sflight.
Color a line
The steps for coloring a line i the grid is much the same as ma'ing a traffic light.
B To color a line the structure of the table must include a Char ? field
for color properties
T5P"(, B"0I+ *A st/sflight.
I+CLU&" (TUCTU" Gsflight.
B Aield for line color
t#pes, line/color1?4 t#pe c.
T5P"(, "+& *A st/sflight.
T5P"(, tt/sflight T5P" (TA+&A& TABL" *A st/sflight.
&ATA, gi/sflight T5P" tt/sflight.
B Loop trough the table to set the color properties of each line. The color
properties field is
B Char ? and the characters is set as follows,
B Char ; D C D This is a color propert#
B Char 2 D L D Color code 1; ) >4
B Char @ D Intensified onIof D ; D on
B Char ? D Inverse displa# D = D of
L**P AT gi/sflight I+T* g/wa/sflight.
IA g/wa/sflight)pa#mentsum 8 ;=====.
g/wa/sflight)line/color D JCL;=J.
"+&IA.
-*&IA5 gi/sflight A*- g/wa/sflight.
"+&L**P.
B +ame of the color field
gs/la#out)info/fname D JLI+"/C*L*J.
B 0rid setup for first displa#
CALL -"T.*& go/grid)9set/table/for/first/displa#
"HP*TI+0 i/structure/name D J(ALI0.TJ
is/la#out D gs/la#out
C.A+0I+0 it/outtab D gi/sflight.
"efresh grid display
Use the grid method !EF!E'0_T%1)E_DI'/)%#
"$ample,
CALL -"T.*& go/grid)9refresh/table/displa#.
Complete code for the !L? grid e,ample
This e$ample shows and AL! grid with flights. After selecting a line a change
button can be pushed to displa# a change screen. After the changes have been
saved, the AL! grid screen is displa#ed again, and the grid is updated with the
changes.
The e$ample shows,
.ow to setup the AL! grid
.ow to ste focus to the grid
.ow to set the title of the grid
.ow to allow a user to save and resue a grid la#out 1!ariant4
.ow to customiGe the AL! grid toolbar
efresh the grid
(et and get row selection and read ine contents
-a'e and e$ception field 1Traffic light4
Coloring a line
(teps,
Create screen ;== with the AL! grid. emeber to include an e$it button
Add a change button to the AL! grid toolbar
Create screen 2== the Change screen
The screens,

The code,
REPORT 'apm9+<*+a%2+?ri1 .
* T40e 0ool for icons - &se in the toolbar
T"PE(POOLS: i#on.
TABLES: 9'*%i?<t.
* To allo5 the eclaration of o(event(receiver before the
* lcl(event(receiver class is efine6 ecale it as eferre in the
* start of the 0rogra-
CLASS %#%+e2ent+re#ei2er DE,INITION DE,ERRED.

*--------------------------------------------------------------------
* G L O B A L I N T E R N A L T A B L E S

*--------------------------------------------------------------------
*DATA7 gi(sflight T8+E STANDARD TABLE O! sflight#
* To incl&e a traffic light an9or color a line the str&ct&re of
the
* table -&st incl&e fiels for the traffic light an9or the color
T"PES: BE0IN O, 't+'*%i?<t.
INCLUDE STRUCTURE 9'*%i?<t.
* !iel for traffic light
T"PES: tra**i#+%i?<t T"PE #.
* !iel for line color
type': %ine+#o%or(:! type #.
T"PES: END O, 't+'*%i?<t.
T"PES: tt+'*%i?<t T"PE STANDARD TABLE O, 't+'*%i?<t.
DATA: ?i+'*%i?<t T"PE tt+'*%i?<t.

*--------------------------------------------------------------------
* G L O B A L D A T A

*--------------------------------------------------------------------
DATA: oE+#o1e LI&E 'y(u#omm$
* :or; area for internal table
?+@a+'*%i?<t T"PE 't+'*%i?<t$
* ALV control7 La4o&t str&ct&re
?'+%ayout T"PE %2#+'+%ayo.
* Declare reference variables to the ALV gri an the container
DATA:
?o+?ri1 T"PE RE, TO #%+?ui+a%2+?ri1$
?o+#u'tom+#ontainer T"PE RE, TO #%+?ui+#u'tom+#ontainer$
o+e2ent+re#ei2er T"PE RE, TO %#%+e2ent+re#ei2er.
DATA:
* :or; area for screen 2))
?+'#reen2;; LI&E 9'*%i?<t.
* Data for storing infor-ation abo&t selecte ro5s in the gri
DATA:
* Internal table
?i+in1eD+ro@' T"PE %2#+t+ro@$
* Infor-ation abo&t * ro5
?+'e%e#te1+ro@ LI&E %2#+'+ro@.

*--------------------------------------------------------------------
* " L A S S E S

*--------------------------------------------------------------------
CLASS %#%+e2ent+re#ei2er DE,INITION.
PUBLIC SECTION.
.ET/ODS:
<an1%e+too%-ar ,OR EVENT too%-ar O, #%+?ui+a%2+?ri1
I.PORTIN0
e+o-Fe#t e+intera#ti2e$
<an1%e+u'er+#omman1 ,OR EVENT u'er+#omman1 O, #%+?ui+a%2+?ri1
I.PORTIN0 e+u#omm.
ENDCLASS.

*---------------------------------------------------------------------*
* "LASS lcl(event(receiver I%+LE%ENTATION

*---------------------------------------------------------------------*
CLASS %#%+e2ent+re#ei2er I.PLE.ENTATION.
.ET/OD <an1%e+too%-ar.
* Event hanler -etho for event toolbar#
CONSTANTS:
* "onstants for b&tton t40e
#+-utton+norma% T"PE i VALUE ;$
#+menu+an1+1e*au%t+-utton T"PE i VALUE 5$
#+menu T"PE i VALUE 2$
#+'eparator T"PE i VALUE H$
#+ra1io+-utton T"PE i VALUE :$
#+#<e#E-oD T"PE i VALUE $
#+menu+entry T"PE i VALUE Q.
DATA:
%'+too%-ar T"PE 't-+-utton.
* A00en se0erator to the nor-al toolbar
CLEAR %'+too%-ar.
.OVE #+'eparator TO %'+too%-ar(-utn+type..
APPEND %'+too%-ar TO e+o-Fe#t(>mt+too%-ar.
* A00en a ne5 b&tton that to the toolbar# 'se E(OB<E"T of
* event toolbar# E(OB<E"T is of t40e "L(ALV(EVENT(TOOLBAR(SET#
* This class has one attrib&te %T(TOOLBAR 5hich is of table t40e
* TTB(B'TTON# The str&ct&re is STB(B'TTON
CLEAR %'+too%-ar.
.OVE 8C/AN0E8 TO %'+too%-ar(*un#tion.
.OVE i#on+#<an?e TO %'+too%-ar(i#on.
.OVE 8C<an?e *%i?<t8 TO %'+too%-ar(Rui#Ein*o.
.OVE 8C<an?e8 TO %'+too%-ar(teDt.
.OVE 8 8 TO %'+too%-ar(1i'a-%e1.
APPEND %'+too%-ar TO e+o-Fe#t(>mt+too%-ar.
END.ET/OD.
.ET/OD <an1%e+u'er+#omman1.
* 3anle o5n f&nctions efine in the toolbar
CASE e+u#omm.
6/EN 8C/AN0E8.
PER,OR. #<an?e+*%i?<t.
* LEAVE TO S"REEN )#
ENDCASE.
END.ET/OD.
ENDCLASS.

*--------------------------------------------------------------------
* S T A R T - O ! - S E L E " T I O N#

*--------------------------------------------------------------------
START(O,(SELECTION.
SET SCREEN 85;;8.

*$---------------------------------------------------------------------
*
*$ %o&le 'SER("O%%AND()*)) IN+'T

*$---------------------------------------------------------------------
*
.ODULE u'er+#omman1+;5;; INPUT.
CASE oE+#o1e.
6/EN 8EAIT8.
LEAVE TO SCREEN ;.
ENDCASE.
END.ODULE. N USER+CO..AND+;5;; INPUT

*$---------------------------------------------------------------------
*
*$ %o&le STAT'S()*)) O'T+'T

*$---------------------------------------------------------------------
*
.ODULE 'tatu'+;5;; OUTPUT.
DATA:
* !or 0ara-eter IS(VARIANT that is s&e to set &0 o0tions for
storing
* the gri la4o&t as a variant in -etho
set(table(for(first(is0la4
%+%ayout T"PE 1i'2ariant$
* 'tillit4 fiel
%+%ine' T"PE i.
* After ret&rning fro- screen 2)) the line that 5as selecte before
* going to screen 2))6 sho&l be selecte again# The table
gi(ine.(ro5s
* 5as the o&t0&t table fro- the GET(SELE"TED(RO:S -etho in for-
* "3ANGE(!LIG3T
DESCRIBE TABLE ?i+in1eD+ro@' LINES %+%ine'.
I, %+%ine' > ;.
CALL .ET/OD ?o+?ri1(>'et+'e%e#te1+ro@'
EAPORTIN0
it+in1eD+ro@' 3 ?i+in1eD+ro@'.
CALL .ET/OD #%+?ui+#*@3>*%u'<.
RE,RES/ ?i+in1eD+ro@'.
ENDI,.
* Rea ata an create ob,ects
I, ?o+#u'tom+#ontainer IS INITIAL.
* Rea ata fro- atbase table
PER,OR. ?et+1ata.
* "reate ob,ects for container an ALV gri
CREATE OB=ECT ?o+#u'tom+#ontainer
EAPORTIN0 #ontainer+name 3 8ALV+CONTAINER8.
CREATE OB=ECT ?o+?ri1
EAPORTIN0
i+parent 3 ?o+#u'tom+#ontainer.
* "reate ob,ect for event(receiver class
* an set hanlers
CREATE OB=ECT o+e2ent+re#ei2er.
SET /ANDLER o+e2ent+re#ei2er(><an1%e+u'er+#omman1 ,OR ?o+?ri1.
SET /ANDLER o+e2ent+re#ei2er(><an1%e+too%-ar ,OR ?o+?ri1.
* La4o&t =Variant> for ALV gri
%+%ayout(report 3 'y(repi1. NLayout *o report
*---------------------------------------------------------------
* Set&0 the gri la4o&t &sing a variable of str&ct&re lvc(s(la4o
*---------------------------------------------------------------
* Set gri title
?'+%ayout(?ri1+tit%e 3 8,%i?<t'8.
* Selection -oe - Single ro5 5itho&t b&ttons
* =This is the efa&lt -oe
?'+%ayout('e%+mo1e 3 8B8.
* Na-e of the e.ce0tion fiel =Traffic light fiel> an the color
* fiel ? set the e.ce0tion an color fiel of the table
?'+%ayout(eD#p+*name 3 8TRA,,IC+LI0/T8.
?'+%ayout(in*o+*name 3 8LINE+COLOR8.
LOOP AT ?i+'*%i?<t INTO ?+@a+'*%i?<t.
I, ?+@a+'*%i?<t(payment'um J 5;;;;;.
* Val&e of traffic light fiel
?+@a+'*%i?<t(tra**i#+%i?<t 3 858.
* Val&e of color fiel7
* " @ "olor6 A@"olor *@Intesifie on6 )7 Inverse is0la4 off
?+@a+'*%i?<t(%ine+#o%or 3 8CQ5;8.
ELSEI, ?+@a+'*%i?<t(payment'um 3> 5;;;;; AND
?+@a+'*%i?<t(payment'um J 5;;;;;;.
?+@a+'*%i?<t(tra**i#+%i?<t 3 828.
ELSE.
?+@a+'*%i?<t(tra**i#+%i?<t 3 8H8.
ENDI,.
.ODI," ?i+'*%i?<t ,RO. ?+@a+'*%i?<t.
ENDLOOP.
* Gri set&0 for first is0la4
CALL .ET/OD ?o+?ri1(>'et+ta-%e+*or+*ir't+1i'p%ay
EAPORTIN0 i+'tru#ture+name 3 8S,LI0/T8
i'+2ariant 3 %+%ayout
i+'a2e 3 8A8
i'+%ayout 3 ?'+%ayout
C/AN0IN0 it+outta- 3 ?i+'*%i?<t.
*-- En of gri set&0 -------------------------------------------
* Raise event toolbar to sho5 the -oifie toolbar
CALL .ET/OD ?o+?ri1(>'et+too%-ar+intera#ti2e.
* Set foc&s to the gri# This is not necessar4 in this
* e.a-0le as there is onl4 one control on the screen
CALL .ET/OD #%+?ui+#ontro%3>'et+*o#u' EAPORTIN0 #ontro% 3
?o+?ri1.
ENDI,.
END.ODULE. N STATUS+;5;; OUTPUT

*$---------------------------------------------------------------------
*
*$ %o&le 'SER("O%%AND()2)) IN+'T

*$---------------------------------------------------------------------
*
* te.t

*----------------------------------------------------------------------
*
.ODULE u'er+#omman1+;2;; INPUT.
CASE oE+#o1e.
6/EN 8EAIT2;;8.
LEAVE TO SCREEN 5;;.
6/EN8SAVE8.
PER,OR. 'a2e+#<an?e'.
ENDCASE.
END.ODULE. N USER+CO..AND+;2;; INPUT

*$---------------------------------------------------------------------
*
*$ !or- get(ata

*$---------------------------------------------------------------------
*
* te.t

*----------------------------------------------------------------------
*
,OR. ?et+1ata.
* Rea ata fro- table S!LIG3T
SELECT )
,RO. 9'*%i?<t
INTO TABLE ?i+'*%i?<t.
END,OR.. N %oa1+1ata+into+?ri1

*$---------------------------------------------------------------------
*
*$ !or- change(flight

*$---------------------------------------------------------------------
*
* Reas the contents of the selecte ro5 in the gri6 ans transfers
* the ata to screen 2))6 5here it can be change an save#

*----------------------------------------------------------------------
*
,OR. #<an?e+*%i?<t.
DATA:%+%ine' T"PE i.
RE,RES/ ?i+in1eD+ro@'.
CLEAR ?+'e%e#te1+ro@.
* Rea ine. of selecte ro5s
CALL .ET/OD ?o+?ri1(>?et+'e%e#te1+ro@'
I.PORTIN0
et+in1eD+ro@' 3 ?i+in1eD+ro@'.
* "hec; if an4 ro5 are selecte at all# If not
* table gi(ine.(ro5s 5ill be e-0t4
DESCRIBE TABLE ?i+in1eD+ro@' LINES %+%ine'.
I, %+%ine' 3 ;.
CALL ,UNCTION 8POPUP+TO+DISPLA"+TEAT8
EAPORTIN0
teDt%ine5 3 8"ou mu't #<oo'e a %ine8.
EAIT.
ENDI,.
* Rea ine.es of selecte ro5s# In this e.a-0le onl4 one
* ro5 can be selecte as 5e are &sing gs(la4o&t-sel(-oe @ BBB6
* so it is onl4 ncessar4 to rea the first entr4 in
* table gi(ine.(ro5s
LOOP AT ?i+in1eD+ro@' INTO ?+'e%e#te1+ro@.
I, 'y(ta-iD 3 5.
READ TABLE ?i+'*%i?<t INDEA ?+'e%e#te1+ro@(in1eD INTO
?+@a+'*%i?<t.
ENDI,.
ENDLOOP.
* Transfer ata fro- the selecte ro5 to screen- 2)) an sho5
* screen 2))
CLEAR ?+'#reen2;;.
.OVE(CORRESPONDIN0 ?+@a+'*%i?<t TO ?+'#reen2;;.
LEAVE TO SCREEN 82;;8.
END,OR.. N #<an?e+*%i?<t

*$---------------------------------------------------------------------
*
*$ !or- save(changes

*$---------------------------------------------------------------------
*
* "hanges -ae in screen 2)) are 5ritten to the atbase table
* Csflight6 an to the gri table gi(sflight6 an the gri is
* &0ate 5ith -etho refresh(table(is0la4 to is0la4 the changes

*----------------------------------------------------------------------
*
,OR. 'a2e+#<an?e'.
DATA: %+tra**i#+%i?<t T"PE #.
* '0ate traffic light fiel
* '0ate atabase table
.ODI," 9'*%i?<t ,RO. ?+'#reen2;;.
* '0ate gri table 6 traffic light fiel an color fiel#
* Note that it is necessar4 to &se str&ct&re g(5a(sflight
* for the &0ate6 as the screen str&ct&re oes not have a
* traffic light fiel
.OVE(CORRESPONDIN0 ?+'#reen2;; TO ?+@a+'*%i?<t.
I, ?+@a+'*%i?<t(payment'um J 5;;;;;.
?+@a+'*%i?<t(tra**i#+%i?<t 3 858.
* " @ "olor6 A@"olor *@Intesifie on6 )7 Inverse is0la4 off
?+@a+'*%i?<t(%ine+#o%or 3 8CQ5;8.
ELSEI, ?+@a+'*%i?<t(payment'um 3> 5;;;;; AND
?+@a+'*%i?<t(payment'um J 5;;;;;;.
?+@a+'*%i?<t(tra**i#+%i?<t 3 828.
#%ear ?+@a+'*%i?<t(%ine+#o%or.
ELSE.
?+@a+'*%i?<t(tra**i#+%i?<t 3 8H8.
#%ear ?+@a+'*%i?<t(%ine+#o%or.
ENDI,.
.ODI," ?i+'*%i?<t INDEA ?+'e%e#te1+ro@(in1eD ,RO. ?+@a+'*%i?<t.
* Refresh gri
CALL .ET/OD ?o+?ri1(>re*re'<+ta-%e+1i'p%ay.
CALL .ET/OD #%+?ui+#*@3>*%u'<.
LEAVE TO SCREEN 85;;8.
END,OR.. N 'a2e+#<an?e'

Das könnte Ihnen auch gefallen