Programming Standards - T24: Technical Courses
Programming Standards - T24: Technical Courses
3
Introduction
4
Why coding conventions?
5
Program structure:
6
Program structure:
7
Program structure:
8
Program structure:
When calling API interfaces or user defined subroutines, Do Not
Use the program as the flag as this is replaced by a direct memory
address for the routine once it is called.
E.g. IF USER.ROUTINE THEN
CALL @USER.ROUTINE
END
The above code will fail if executed second time, as
USER.ROUTINE will be memory address not a string.
Additionally the API should be checked to ensure that the call will
not fail, using the standard routine CHECK.ROUTINE.EXIST.
This check should be performed once only as the check takes
some time to execute, especially in jBASE.
9 Thesys Training Centre
9
Comments in Programs:
10
Naming convention:
11
Constants and Variables:
Global Variables
• Defined in I_COMMON
• Inserted in every T24 programs
• Prefixed with C$ e.g. C$EB.PHANTOM.ID
Product level Variables
• Defined in product level common block e.g. I_RP.COMMON
• Inserted in all subroutines
• Prefixed with XX$ e.g. RP$ for repo
Subroutine level Variables
• Defined only in subroutine in which it is to be used
• Can be passed to another subroutine as argument in CALL
12 Thesys Training Centre
statement 12
Subroutine name and variables:
14
Field names and numbers:
15
Commons and Inserts:
16
Commons and Inserts:
17
Standard subroutine:
18
GUI/Desktop/Browser/STP/OFS
Compatibility:
GUI is a standard client server architecture that relies on
structured message for its communication, hence it cannot
respond to direct ‘screen’ input and output commands.
Dont’s:
• Direct
input through TXTINP or REM should not be used, as
OFS and browser are completely stateless.
• Donot use INPUT, PRINT and CRT commands in
routine/program, as PRINT and CRT will not display anything in
GUI, whereas INPUT will have severe implications and causes
session to hang and terminate abnormally.
• Neveruse INPUT.BUFFER variable for defaulting data or
19 navigation commands. Thesys Training Centre
19
GUI/Desktop/Browser/STP/OFS
Compatibility:
Do:
• Use DISPLAY.MESSAGE and UPDATE.HEADER routines, else
code wont work with T24 graphical user interface.
• Usestandard mechanisms of T.SEQU, REFRESH.FIELD and
REBUILD.SCREEN to refresh the screen.
• STP uses OFS to generate transaction without user
intervention.
The ‘standard’ methods for determining whether an
application or subroutine is running in any specified
environment:
• For OFS the common variable GTSACTIVE will be set.
20 Thesys Training Centre
• For GUI the common variable TTYPE will contain20
the text GUI.
GUI/Desktop/Browser/STP/OFS
Compatibility:
If an application is to execute any code specific to OFS, then the relevant
call is made if GTSACTIVE is set as follows:
IF GTSACTIVE THEN
*Do OFS specific processing
END
Functionality only applicable to the GUI interface is executed as follows:
IF INDEX(TTYPE,”GUI”,1) THEN
* do GUI functions
END
Browser is identified as follows:
IF OFS$SOURCE.REC<OFS.SRC.SOURCE.TYPE> = 'SESSION' THEN
* do Browser functions
END
21
jBASE compatibility issues:
22
Function and Display:
23
Ambiguous THEN & ELSE Statements:
The above code is wrong as ELSE is common to READ and IF, hence the right
code will be:
IF condition THEN
READ record FROM F.FILE, ID THEN
ID.OK = 1
END
END ELSE
* Do something else
END
24
CHAR, CHARS, SEQ and SEQS:
25
CHAR, CHARS, SEQ and SEQS:
26
SUBROUTINE<name>:
28
WRITE.ON.ERROR or
DELETE.ON.ERROR
These commands should be used when bypass of T24
subroutines is required to perform delete (F.DELETE) &
write (F.WRITE).
The syntax in these statements must avoid the ELSE &
THEN verbs.
29
DYNAMIC ARRAY USAGE:
The dynamic array must always be used with single ‘<‘ and
single ‘>’ symbol.
The dynamic array is inefficient to store data, when the
number of multi-value becomes large
30
DIMENSIONED ARRAY USAGE:
31
KEYWORD USAGE:
32
EQU LIT Usage:
33
EQU Usage:
jBASE will allow the EQU statement to be used more than once
for the same variable. E.g.
EQU VAR1 TO ‘abc’
EQU VAR1 TO ‘def’
Therefore, care must be taken to ensure that such mistakes are
not made, as the jBASE compiler will not report these errors.
34
Warnings in Jbase:
35
UV Special Routines:
36
LOCATE Statement:
37
ON GOSUB/ON GOTO:
E.g.
FOR X = -1 TO 6
ON X GOSUB A,B,C,D
NEXT X
The above code will result in error in jBASE at two conditions,
when x < 1 and when x > 4.
Whereas the above code will run in UniVerse.
38
TOOLBARS IN BROWSER:
• BROWSER.TOOLS
» Defines button to be used in any toolbar.
» Each button is described by a number of fields in table.
• BROWSER.TOOLBAR
» Defines toolbar as a grouping of individual buttons
» Each toolbar is made of multi-value of tools.
39
API for Building Toolbar in application:
40
EB.ADD.TOOLBAR(TOOLBAR.ID,TOOL
BAR.LOCATION) :
This routine is passed the key to record on
BROWSER.TOOLBAR table.
Loads toolbar into memory.
1st parameter -> TOOLBAR.ID sets text for toolbar or
override the text from BROWSER.TOOLBAR file.
2nd parameter -> TOOLBAR.LOCATION sets location at
which tool will be displayed.
• If
value is HEADER –> displays toolbar at the top of contract
below the main function toolbar.
• Ifvalue is CONTEXT.TOOLBAR -> displays toolbar upon
commit.
41 Thesys Training Centre
41
EB.ADD.TOOL(TOOLBAR.ID,TOOL.ID):
42
EB.CHANGE.TOOL (TOOLBAR, TOOL,
FIELD, NEW.VALUE)
This routine is passed:
• The key of a toolbar that is already in memory and
• The key of a tool that is currently on the toolbar in memory.
• It is also passed a field number and a new value to set that field.
Equates in BROWSER.TOOLS e.g. BRTL.TEXT or
BRTL.ENABLED insert should be used for the field number.
If toolbar is not in memory, or if the tool is not on toolbar that
is in memory, then the routine will pass no value.
43
Handling Context Workflow:
When trying to run a new task in T24 or when giving the user
a new option of new task to run based on current context,
two functions should be called. They are:
• EB.SET.NEXT.TASK(NEXT.TASK)
• EB.CREATE.CONTEXT.WORKFLOW(DISPLAY.TEXT,INPUT.O
PTIONS,OPTION.COMMANDS)
44
EB.SET.NEXT.TASK(NEXT.TASK):
45
EB.CREATE.CONTEXT.WORKFLOW(DI
SPLAY.TEXT,INPUT.OPTIONS,OPTION.
COMMANDS):
This subroutine is passed the options to be given to the user,
when committing deal, and then action is run depending on
choice.
The steps for input are:
• Display for options is set in DISPLAY.TEXT.
• Captions for different options should be set in a dynamic array
delimited by field markers in INPUT.OPTIONS parameter.
• The corresponding action to run should be in a correlating
dynamic array in OPTIONS.COMMANDS.
• Format of command should be from command line.
• Key to toolbar can be passed in the first parameter, when
46 Thesys Training Centre
running in browser. 46
Close Of Business Routines:
Batch Records:
• All
new batch records should have an equivalent record in
BATCH.NEW.COMPANY application.
Code Requirements:
• All
new batch processes should be written to use multi-
threading.
• CloseOf Business routines must be structured using “close of
business routines” section in “development guide”.
• A flag
RUNNING.UNDER.BATCH should be tested, when a
routine requires to know that it has been called during COB
procedure.
47
• Do Not test the SPF status, as it will be set when the COB is
Thesys Training Centre
47
Code Requirements:
48
Summary of Standard Multi – Thread
process
It is mandatory to write multi-threaded batch jobs, so that
there is minimal impact on the performance, and the usage
of processing capabilities of hardware is optimal.
Multi-threading of routines is mandatory to ensure that
transaction management is provided by the system.
49
Summary of Standard Multi – Thread
process
Main Process:
• Name : xxxx(list_record_id)
where
• xxxx is a name defined in PGM.FILE and used in BATCH record.
• list_record_id is key extracted from last record which is keyed in
sequence.
• The field BATCH.JOB in PGM.FILE for standard multi-thread
process should be @BATCH.JOB.CONTROL. If the field is left null,
then the system defaults it to @BATCH.JOB.CONTROL.
• The above routine should process single piece of transaction of
job, thus ensuring better split between different agents.
• It is invoked by system with transaction management wrapped
around it.
• It should not perform heavy load and should avoid select/clearfiles.
50
Summary of Standard Multi – Thread
process
List file
• Name : xxxx.LIST
– This mandatory file is used to drive the multi-threaded processing.
– The records in this file are built by the SELECT routine
Load process
• Name : xxxx.LOAD
– This mandatory process is required to set up common area used by
the main process.
– A local common is created for each main process.
– This routine is invoked once per agent.
– It should avoid any locks and any writes to database.
51 Thesys Training Centre
51
Summary of Standard Multi – Thread
process
Select process
• Name : xxxx.SELECT
– It is a mandatory process to build LIST file that will be handled by
main process.
– It is called after LOAD routine.
– List file is built by calling
BATCH.BUILD.LIST(ListParameters,IdList)
– List file is allocated based on availability of pool.
– This routine is invoked per job.
– The CONTROL.LIST common variable is populated and system
invokes SELECT routine for n number of times, based on the
requirement for performing different operations in sequence with
every operation having ability to run in parallel.
– Thus ensuring that every stage of job has parallel processing.
52
BATCH.BUILD.LIST(ListParameters,IdList
)
ListParameters<1> - It is name of list file
ListParameters<2> - Extracts file name. It is file holding Ids.
ListParameters<3> - Extracts selection. It is a list of
selection criteria to be supplied to select and build from
extract file. This command supplies SELECT or SSELECT
when ordering is important.
ListParameter<4> - It is no. of record Ids written to work list
record. The value is increased to reduce overhead of
building work file.
IdList – It is a list of Ids prepared by SELECT program to
53
build the list file. Thesys Training Centre
53
Summary of Standard Multi – Thread
process
Post process
• Name : XXXX.POST
– It is an optional process for handling processing required after list
file and all multi-threading is over.
– This process is defined in BATCH.
54
Template Programs:
55
PERFORMANCE CONSIDERATION:
56
PERFORMANCE CONSIDERATION:
57
PERFORMANCE CONSIDERATION:
58
PERFORMANCE CONSIDERATION:
59
PERFORMANCE CONSIDERATION:
60
EB.COMPILE – ONSITE
DEVELOPMENT
In G12.2.00, EB.COMPILE has been amended for jBASE
users, to automatically set JBCDEV_BIN and JBCDEV_LIB
when cataloging programs. The following rules are applied:
• If JBCDEV_BIN/LIB is currently set to globusbin/lib (the default):
62
ERROR MESSAGE HANDLING:
EB.ERROR
• This table defines the T24 error messages
• Field Definitions:
– FIELD: KEY (Product code-Abbreviated Description) – Record key
– Maximum 35 alphanumeric characters.
– The key to the record is used to identify the required error
message. This field consists of 2 parts:
» PRODUCT code e.g. OF
» An abbreviated description of error message. E.g. “Mandatory
for IB user”, that is produced by OFS.SOURCE application.
63
ERROR MESSAGE HANDLING:
64
ERROR MESSAGE HANDLING:
65
ERROR MESSAGE HANDLING:
66
ERROR MESSAGE HANDLING:
67
ERROR MESSAGE HANDLING:
68
TRIGGERING AN ERROR MESSAGE:
1. Error code
2. Data to replace & in element 1.
3. Name of program/subroutine.
4. Developers comment.
5. XX.LL.ERROR.INFO – Error message definition.
69
6. XX.LL.ERROR.SOL – Error message solution. Thesys Training Centre
69
TRIGGERING AN ERROR MESSAGE:
• Set
common variables AF, AV and AS with field, multi-value and
sub-value positions.
• Make CALL to ERR. Where ERR will establish if the user is
working in Globus Browser or Classic.
70
Minimum Testing Requirements:
71
jBASE testing:
72
Code Coverage:
73
•
All product names and other company names used herein are for identification
purposes only and may be trademarks or registered trademarks of their respective owners. Errors and
omissions excepted,
all specifications are subject to change without notice.
•
© 2009 Thesys Technologies Incorporated. All rights reserved.