Professional Documents
Culture Documents
T24 Componentisation
T24 Componentisation
Doc u m e n t Hist o r y
Revi si o
Dat e Ame n d e d Na m e De s c r i p t i o n
n
30 th Octob e r
1 T. Aube r t Initial version
2015
15 th Nove m b e r
2 T. Aube r t Upda t e s
2015
4 th Dece m b e r
3 H. Aube r t Form a t & Review
2015
Bash e e r
8 12 th April 2021 R21 AMR review
Aham e d
2
T24 Co m pon e n tisation
Copyri g h t
Pleas e includ e your na m e , comp a n y, addr e s s, and telep h o n e and fax num b e r s , and email add r e s s if
applica bl e. TAFJdev@t e m e n o s . c o m
4
T24 Co m pon e n tisation
Intro d u c t i o n
A compo n e n t is a logical and tech nic al groupi n g of jBC artef a c t s. By ”jBC art efa c t s” we mea n
subr o u t i n e s, functions, com m o n s and table s. This groupi n g was alre a dy existing, but by nami n g
conve n t ion s only. As an exam pl e, the routi n e EB.ACCOUNTING was part of « EB » by it's nam e. But what
abou t EXCHRATE?
Since version R15, a new type of file has bee n relea s e d: the .com po n e n t .
This file will cont ai n a list of all the artef ac t s mentio n e d earlie r. This file will be compiled as a nor m al jBC
routin e and will be used durin g the develop m e n t .
This .com po n e n t is the façad e to the unde rlying imple m e n t a t i o n s. This acts as a king of « inte rf a c e ».
The be n e f i t s
Befor e going in details into the compo n e n t world, let's talk about the ben efits of it.
- Groupi n g code mea n s that the inter- depe n d e n c i e s bet w e e n the differ e n t grou p s beco m e s visible and
man a g e a b l e .
- COMMO N variabl e acce s s is done thro u g h gett e r s and sett e r s. No more side- effect s of cha n gi n g a
com m o n variabl e without knowi ng it.
- Tables acce ss are rest ric t e d . Canno t writ e in a table in a differe n t compo n e n t
- Const a n t s (EQU) are define d in the com po n e n t and not copied across like a $INSERT does. So Ther e
are no risk to clash with differe n t versions.
- A compo n e n t is self- desc ri bin g. Prot e c t use r to have to know the und e r n e a t h imple m e n t a t i o n s
- Auto- compl e tio n in jBC Editor
- Scopi ng allow met ho d, prope r t i e s, … to be hidde n from the exte r n a l world (an othe r compo n e n t )
- Defining Compo n e n t orien t e d Unit Tests (UnitTe st Fra m e w o r k )
This pictur e pre s e n t s the sam e kind of code, withou t and with a « com po n e n t i s a ti o n ». It clea rly shows
that, once the com po n e n t s are well define d, the inter- actions betw e e n the m beco m e s obvious and
man a g e a b l e .
6
T24 Co m pon e n tisation
Creat i n g a ne w Com p o n e n t
In EDS, cre a ti n g a new com po n e n t is done the sam e way as crea ti n g a new SUBROUTINE.
In the TAFJ Pers p e c t ive
Right- click on the direc to ry you want the compo n e n t to be, choose New → T24 routin e / compo n e n t /
testc a s e , ent e r a nam e for your compo n e n t and click finish.
The noti o n of
« mo d u l e »
The Design S t u di o/E clips e Compon e n t editor come s with auto- com pl e tion facilities. ¨
TO do so, pres s Ctrl + < S PACE > . You will have som et hi n g like this:
8
T24 Co m pon e n tisation
The last for options are the tem pl a t e . So choosin g, as an exam pl e, “New M e t h o d ” will auto m a t i c a lly add
this code ...
With the focus to the scope. You can naviga t e from one field to anot h e r one with the <t a b > / <S hift > +
<Ta b > .
Befor e going in details on the 4 availabl e options, lets discuss the Scopin g.
The Sco p i n g
The Scop e is a man d a t o r y infor m a t io n for ALL the compo n e n t art ef a c t s (Const a n t , Met ho d, Prope r t y and
Table). It can have 4 differe n t value s :
publi c
The art efa c t is visible from everyw h e r e (othe r module, othe r com po n e n t )
mo d u l e
The art efa c t is visible only for the compo n e n t being part of the sam e modul e
privat e
Only visible in the sam e < m o d ul e > . < c o m p o n e n t >
ext e r n a l
This option is for futur e relea s e and is usele ss for now.
This is import a n t to consid e r the scoping with car e, and not make everyt hi n g public. By default the
scopin g is « modul e », but redu ci n g it to « privat e » and chan g e it only if nece s s a r y is cert ai nly a good
prac ti c e.
The Met h o d
10
T24 Co m pon e n tisation
The para m e t e r s
Exam pl e:
A Full Met ho d :
or
12
T24 Co m pon e n tisation
The Con s t a n t
The const a n t is quit e easy to imple m e n t s; it is compo s e d of the scope, a nam e and a value. Optionally, we
can specify a jBC na m e which is only nece s s a r y for auto- incor po r a t i o n (see specific chap t e r )
Exam pl e:
The Tabl e
The table is compos e d of the scope, an alias (the table N a m e ) , the real jBC table nam e (without the prefix)
and a list of fields.
The fields are sepa r a t e d by com a and wrap p e d in a fields:{ } grou p. Not e that the fields can have, for the
sam e rea so n s as const a n t s , the JBC nam e in brack e t s .
Note that ther e is no com a sepa r a t o r betw e e n the fields.
Exam pl e:
The prop e r t y
If the COMMON is a DIMm e d arr ay, the jBC varia bl e nam e must be followe d by the num b e r of
dim e n sio n s in- betw e e n brac k e t . Notice that we are talking about the NUMBER of dime n si on s, not the
size!
R.NEW(50 0) has 1 dime n si on
MY.ARRAY(10,20) has 2 dime n si o n s
Exam pl e:
14
T24 Co m pon e n tisation
A prop e r t y can also not have any JBC: imple m e n t a t i o n. In this case, the unde rlyi ng COMMO N is only
acces si bl e from the prope r t y. This will be the favourit e option for new compo n e n t s .
Exam pl e:
There is no such suppo r t for DIMm e d arr ay for the prop e r t i e s not having a “jBC:” inform a t i o n.
Com p i l i n g a co m p o n e n t
A compo n e n t , like any othe r jBC file must be compile d. In EDS, simply saving it will invoke the jBC
com pile r so you should not have to worry about it. You always can right- click on the file and do a
« com pile Basic file »
Once your com po n e n t has bee n saved and com pile, you can direc tly sta rt using it. Of cours e, if the jBC
imple m e n t a t i o n has not been done, this will fail at runti m e , but not at compile time, and most import a n t ,
not for Unitt e s t s.
This m e a n that you can defi n e a co m p o n e n t , cre a t e tes t s for it, an d impl e m e n t
afte r havi n g cre a t e d th e tes t !
This is a very impor t a n t point, and we will quickly make a step- by- step proc e d u r e to illust r a t e it.
1) Cre a t e a new com po n e n t , call it MY.Compo n e n t
2) Ctrl + <S p a c e > add a new met ho d, keep the defaul t value s, save
Here you have crea t e d a met ho d MY.Compo n e n t . O p e r a t i o n N a m e (…) with one par a m e t e r . This met ho d is
suppo s e d to invoke the jBC routin e « Routin e N a m e »
3) Cre a t e a
4) Save right- click on TestOp e r a t i o n N a m e . t u t (the test file) and run as … Basic UnitTes t
Obviously, the test is failing. Now chan g e hat, take the develop e r one, and imple m e n t the met ho d
« Routin e N a m e »
16
T24 Co m pon e n tisation
5) Cre a t e a new SUBROUTINE, call it Rou ti n e N a m e , and edit it like this :
don't have to reco m pile anyt hin g, just re- run it.
Usi n g a Com p o n e n t
The Met h o d s
In orde r to use a compo n e n t , you have to define it with the $USING keywor d
As an exam pl e to use the compo n e n t we cre a t e d in the previou s chap t e r , cre a t e a new PROGRAM, call it
MAIN, and star t editing it like this :
First you will notice the auto- compl e tion right after you typed $USING ….
Then, you can type MY. …. and the auto.co m pl e t io n is proposi n g you « Compon e n t », and then . ….. and
nothi ng any- more !!!!
Why?
Look car efully at the compo n e n t . It has only one met ho d, and its scope is « modul e ». This mea n s that
only piece s of code in the sam e module can acce s s the met ho d.
So 3 solution s in our exam pl e:
1) Make your met h o d public (edit the .com po n e n t , save, com e back on your code, type MY.Com po n e n t .
…. and you will see
18
T24 Co m pon e n tisation
2) Put back « modul e » and use the 2nd option : make your prog r a m being part of the « MY » Module.
To do so, add the $PACKAGE at the top of your prog r a m , and specify a nam e having « at least » the sam e
modul e then your com po n e n t . You can rem ove the $USING claus e.
I mention e d a 3rd option …. well, not exactly. You can try to type Oper a ti o n N a m e yours elf, finally, this is
just auto- com pl e tion, right ? Wrong ! The com pile r will refus e it, and this small exercis e is descri bin g
how we are enforci n g the scopin g and why this is so impor t a n t to define a prope r scope. This feat u r e is
not only in Eclipse (EDS) but also for console compila tion. No way to bypas s it.
This me a n s that for futur e rele a s e s, you only have to car e abou t back- comp a ti bility of public (evt modul e)
met ho d s.
But say you won't aba n d o n so easily, and decide to call the unde r n e a t h routin e direc tly …. no no !
The only way is to remov e the $USING, but in that case you are back in the « old world » and the r e is no
com po n e n t involved any- mor e.
Now that you unde r s t o o d how the compo n e n t is invoke d, and how the Editor is helpin g you to auto-
com pl e t e , let’s explor e the 3 rem ai ni n g artef a c t s:
1. Const a n t s
2. Prop e r ti e s
3. Tables.
This is quite obvious, and in orde r to illust r a t e it, just add a const a n t decla r a t i o n in MY.Com po n e n t , make
it public !, get back to your MAIN progr a m , and type
MY.Com po n e n t . ... And you will see your const a n t !
Nothin g else to add, apa r t maybe that if you chan g e the value of your const a n t , you do not need to
reco m pil e your progr a m to have the new value. This is a big differe n c e comp a ri n g to the EQU in jBC.
20
T24 Co m pon e n tisation
The Prop e r t i e s
As mention e d previously, a prop e r t y is map pi n g a com m o n varia bl e. The small differe n c e is that you do
not have a « point e r » to the variabl e, but the value itself.
Let's crea t e a prope r t y.
First, crea t e a I_ File (new File) (let's call it I_TEST.INS ERT) and edit it like this:
If a prope r t y is define d with arr ay size, the get t e r s and sett e r s will act accor di n gly and new helpe r
met ho d s will be made availabl e. To desc ri b e it, first, crea t e a I_ File (new File) (let's call it
I_TEST.INS ERT) and edit it like this :
We have to do it beca u s e , as specified in the “The Prope r t y” chap t e r , a prop e r t y withou t the “jBC:” block
canno t be a DIMm e d arr ay. Then cha n g e your com po n e n t to some t hi n g like this:
22
T24 Co m pon e n tisation
If you get back to your MAIN progr a m :
We can find our get t e r and sett e r , but also 3 new met h o d s :
cl e a r < p r o p e r t y_ n a m e > is the JBC Equivale n t to MAT MY.COMMO N = ''
ge t Dy n Arr ayFr o m < p r o p e r t y_ n a m e > is ret u r ni n g « ret » after some t hi n g like this : MATBUILD ret
FROM MY.COMMO N
se t D y n Arr ayT o < p r o p e r t y_ n a m e > is the JBC Equivale n t to MATPARSE MY.COMMO N FROM dynArr ay
!! WARNI NG !!
This is not possible to mix the sam e prop e r t y with and withou t the “jBC:” settin g.
This code is INVALID . The rea so n for it is that the gett e r (prop e r t y rea d) points to som e t hi n g else than
the sett e r (prop e r t y writ e)
The Tabl e s
Back to MAIN prog r a m . You will notice your table nam e. Also, a met ho d called « tabl e » + your table
nam e. Ignor e this last one, it is her e just for back- com p a ti bility. Select your table nam e:
24
T24 Co m pon e n tisation
Note that the fields (define d as const a n t ) are always public. This mea n s that you can make a table
privat e, cre a t e a met ho d which ret u r n a part of the recor d only, and the use r of your met ho d will still be
able to acce s s the fields using the <MOD > . < C o m p o n e n t > . < T a b l e N a m e > . < F i e l d N a m e > met h o d olo gy.
Interfa c e s are use d to invoke met h o d s « by nam e » (sam e as the old « CALL @ »)
Basically, and interfa c e is nothi ng else than a met ho d, but withou t the { … jBC : … } body.
Once an interf ac e is define d, you can invoke it the sam e way as a met ho d with one major differ e n c e : You
specify the nam e of the met ho d you want to invoke.
Do descri b e it, let's imagin e this full exam pl e :
26
T24 Co m pon e n tisation
Doc u m e n t a t i o n
This is import a n t to docu m e n t your com po n e n t . The use r of it won't have it. All the auto- compl e tio n
featu r e s are coming from the compile d com po n e n t , not from the sourc e .
Docu m e n t i n g is not only impor t a n t for the public artef a c t s, but also for the privat e, the module, etc …
Here is a fully docu m e n t e d compo n e n t :
component MY.Component
metamodelVersion 1.6
/*
* This is a very important method
* doubing the value passed
*/
module method OperationName
(
/*
* This argument is quite important
* This should be a number.
*/
IN ArgumentName string [0..1]
)
{
jBC: RoutineName
}
/*
* The value of this constant is 10
*/
public constant ConstantName = 10
/*
* This property is just here for fun.
* This is a double dimentioned array
* absolutely useless.
*/
public property readwrite PropertyName : string
{
jBC: I_TEST.INSERT -> MY.COMMON(2)
}
/*
* This table is a 2 column table
Impl e m e n t i n g me t h o d s
The com po n e n t editor has a speci al cont ext u al menu to help develop e r s to imple m e n t a met h o d.
This men u is only availa bl e whe n the curso r is locat e d in a met ho d.
To illust r a t e it, position your curso r in a met ho d, and right- click.
The following men u will offer you the possibility to imple m e n t the met ho d:
28
T24 Co m pon e n tisation
2. The secon d possibility is that the met ho d alre a dy exists in the sourc e. In that case, if the sourc e is
locat e d som e w h e r e else than the place whe r e the compo n e n t is, a warni n g will be given, the
sour c e file will be open e d. If the sour c e is locat e d at the sam e place, the file is simply open e d .
3. The last possibility is that the compile d file is locat e d in your class e s / jars, but no sour c e can be
found. In that case, and error is shown like this:
Once a met h o d has been imple m e n t e d using this facility. The code of the met ho d is highlight e d . You can
un- highlight it with the “R
30