WORKSHOP ON TEMPLATE PROGRAMMING
EXERCISE I
1) Create
Create a templa
template
te for
for the
the follo
followin
wing
g
Requirements -
Field No. Field Name Type Details
0 ID Order No. 16,A Standard Globus format
1 Customer No 10 , C U S Mandatory
2 Order Date 11 , D Mandatory
3 XX<Item 35 , A Mandatory
4 XX-Quantity 16, AMT Mandatory
5 XX>confirmed Only Yes or No
6 Local 10,A No input
Solution :
Defi
Define
ne the
the fiel
field
d name
namess alon
along
g with
with the
the char
charac
acte
teri
rist
stic
icss usin
using
g the
the temp
templa
late
te rout
routin
inee
[Link]
>ED BP [Link]
Then save the routine in BP by replacing XX with ORDZZ where ZZ is your initials.
----: Save BP [Link].
[Link].
Quit.
----:Q
Now open the new routine copied
cop ied and make the necessary
necess ary changes for the above
abo ve template.
>ED BP [Link]
[Link]
Here define parameters for the field as under.
[Link]:
0020:
0021: ID.F = "[Link]" ; ID.N = "16" ; ID.T = "A" ; ID.T<4> =
"#####/#####/#####"
0022: *
0023: Z=0
0024: *
0025: Z+=1 ; F(Z) = "[Link]" ; N(Z) = "10.1" ; T(Z) = "CUS"
0026:
0027: Z+=1 ; F(Z) = "[Link]" ; N(Z) = "11" ; T(Z) = "D"
0028: Z+=1 ; F(Z) = "XX<ITEM" ; N(Z) = "35.1" ; T(Z) = "A"
0029: Z+=1 ; F(Z) = "XX_QUANTITY" ; N(Z) = "16.1" ; T(Z) = ""
0030: Z+=1 ; F(Z) = "XX>CONFIRMED" ; N(Z) = "3" ; T(Z)<2> = "YES_NO"
0031: Z+=1 ; F(Z) = "LOCAL"
"LOCAL" ; N(Z)
N(Z) = "10" ; T(Z) = "A"
"A" ; T(Z)<3> = "NOIN
"NOIN PUT"
Compile the routine.
STEP 2
>ED BP TEMPLATE
Page 1 of 7
----:SAVE BP [Link]
----:Q
ED BP [Link]
In the para GOSUB [Link] remove the REM statement, and insert the name of the
field definitions as [Link]
[Link]:* SEE 'I_RULES' FOR DESCRIPTIONS *
0393:
0394: CALL [Link]
0395:
0396: RETURN
Next for the purpose of standard Globus format for ID, we call the subroutine
[Link] in the paragraph GOSUB [Link]
[Link]:
Validation and changes of the ID entered. Set ERROR to 1 if in error.
CALL [Link] ("ORDZZ")
IF E THEN
ERROR = 1
CALL ERR
END
RETURN
Compile the routine.
STEP 3
In Globus create a record in [Link] with the name [Link] as under. Authorise the
record.
[Link]
--------------------------------------------------------------------------
1 TYPE.............. H
2.1 GB [Link] ORDERS TRAINING TEMPLATE
3 [Link]...
4.1 [Link]......
5 PRODUCT........... EB
6 [Link].......
H type indicates the inclusion of all 3 files namely LIVE/UNAUTH/HIS
STEP 4
To create a file control, we will open an existing [Link] as under -
>ED [Link] ACCOUNT
21 lines long.
----: SAVE [Link] [Link]
"[Link]" filed in file "[Link]".
Page 2 of 7
----: Q
Now open the file control file and make the following changes.
>ED [Link] [Link]
21 lines long.
----:
0001: THE ACCOUNT FILE
----: C/ACCOUNT/[Link]
0001: THE [Link] FILE
0002: AC
----: C/AC/EB ------------ As mentioned in [Link]
0002: EB
0003: $HISÿ$NAU -------- For a H type file in [Link]
0004: 2
0005: 17
0006: FIN
0007:
----: FI
"[Link]" filed in file "[Link]".
STEP 5
Run the [Link] to create the I_<file> as under
>[Link]
FILE LAYOUT - CREATING I_F FILE
NAME OF THE FILE (E.g. BP, [Link]):
?
At this system prompt, mention the file as BP
At the next prompt Enter Program/File(s) :
Give the program name [Link]
The system prompts as under
Build Insert from File (D)ictionarys or (P)rograms or (Q)uit
<CR = (P)rograms> :
Mention P
At the next prompt
Enter output Name - <CR> = I_F.Entryname:
Enter return
Next prompt by the system is
Enter PREFIX or <CR> = NONE :
Mention an appropriate prefix ORDTR
The system then Processes the matrix entries for [Link] program
STEP 6
In Globus run the application [Link] at the command prompt. The system prompts
for
COMPANY NAME
Page 3 of 7
Mention the Bank name (by its Mnemonic)
CREATE FILES FOR Globus Demo Account
It next prompts for
LIST NAME
Give return
It prompts for
FILE NAME – [Link]
USING FILE NAME(S) INPUT
CONTINUE (Y/N) Y
The following message will be flashed stating that the dict & data files are being created as
per the file control details regarding modulo/separation given therein and also files for $NAU
& $HIS types.
Creating dictionary for [Link]
Creating file "D_F.[Link]" as Type 3, Modulo 1, Separation 2.
Added "@ID", the default record for RetrieVe, to "D_F.[Link]".
Copying to ../[Link]/D_F.[Link]
Deleting local dictionary D_F.[Link]
Creating file [Link]
WARNING: An operating system file will be created with a truncated name.
Creating file "FBNK.ORDE000" as Type 2, Modulo 17, Separation 4.
Copying to ../[Link]/eb/FBNK.ORDE000
Deleting local file FBNK.ORDE000
Creating file [Link]$HIS
WARNING: An operating system file will be created with a truncated name.
Creating file "FBNK.ORDE000" as Type 2, Modulo 17, Separation 4.
Copying to ../[Link]/eb/FBNK.ORDE001
Deleting local file FBNK.ORDE000
Creating file [Link]$NAU
WARNING: An operating system file will be created with a truncated name.
Creating file "FBNK.ORDE000" as Type 2, Modulo 17, Separation 4.
Copying to ../[Link]/eb/FBNK.ORDE002
Deleting local file FBNK.ORDE000
STEP 7
In GLOBUS open the application STANDARD SELECTION in the name [Link] and
set [Link].28 to Y. The system automatically generates the DICT file for the fields
which can be referenced later on.
[Link] application is now ready for input.
EXERCISE 2
Introduce a CHECKFILE for the input of the customer ID and enrichment displayed for the
same. Also we will introduce automatic ID generation.
Page 4 of 7
Solution :
Open the routine [Link] and include the following CHECKFILE
0027: Z += 1 ; F(Z) = "[Link]" ; N(Z) = 10.1."; T(Z) = "CUS”
0028: CHECKFILE(Z) = [Link]
Insert the following line after the [Link]
[Link] = "CUSTOMER":FM:[Link]:FM:'.A'
Compile the routine.
Now while inputting a record into the [Link] application in Globus the system checks
the input made into the customer field for the existence in the CUSTOMER application and
thereupon display the enrichment of the short name.
For ID generation in Globus open the application [Link]
Auto ID Start INPUT
KEY............... [Link]
--------------------------------------------------------------
1. 1 DESCRIPTION.... ORDERS TRAINING TEMPLATE
2. 1 APPLICATION.... [Link]
3. 1 [Link]....... ORDTR0005300001
4 [Link].....
Open the COMPANY record and include the template under [Link] field.
[Link]...... GB-001-0001 Great Britain ----------------
13.29 [Link]... [Link]
Now the template can be run with an automatic ID generation
EXERCISE 3
Add a routine using CHECKFIELD to populate the order date with the current date.
Solution :
>ED BP [Link]
113 lines long.
----: SAVE BP [Link]
"[Link]" filed in file "BP".
----: Q
In [Link] make the following changes
Include $INSERT I_F.[Link]
Page 5 of 7
Include the condition for populating the field with current day by using the condition COMI
= TODAY as under
[Link]:
0072: *
0073: BEGIN CASE
0074: CASE AF = [Link]
0075: COMI = TODAY
0076:
0077: END CASE
0078:
0079: CALL [Link](AF,'')
0080:
0081: RETURN
Compile the routine.
Open the routine [Link] and include the following in the N
parameter and compile it.
0028: Z += 1 ; F(Z) = “[Link]” ; N(Z) = “10.1.C” ; T(Z) = “D”
Open [Link] and remove the REM statement in GOSUB [Link] and call
[Link].
[Link]:
CALL [Link]
IF E THEN
[Link] = "IFLD"
CALL ERR
END
RETURN
Compile the routine.
Now the routine can execute the requirement.
EXERCISE 4
Include a routine to cross validate that the input of quantity above 1000 needs to be
confirmed.
Solution :
>ED BP [Link]
127 lines long.
----: SAVE BP [Link]
"[Link]" filed in file "BP".
----: Q
>ED BP [Link]
Page 6 of 7
0030:[Link]:
0031: *
0032: * Real cross validation goes here....
0033: *
0034: AF = [Link]
0035: [Link] = DCOUNT([Link](AF),VM)
0036: FOR AV = 1 TO [Link]
0037: IF [Link]([Link])<1,AV> > 1000 AND
[Link]([Link])<1,AV> = "NO" THEN
0038: AF = [Link]
0039:
0040: ETEXT = "QNTY ABOVE 1000 NEEDS CONFIRMATION"
0041: CALL [Link]
0042: END
0043: NEXT AV
0044: RETURN
0045: *
Compile the routine.
Reopen the template [Link] and remove the REM statement in the GOSUB CROSS
VALIDATION.
In the paragraph [Link] call [Link].
Compile the template.
Now the application will meet the requirement.
Page 7 of 7