Programming Basics

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

PROGRAMMING BASICS

coding steps

Choice between ‘PROGRAM’ & ‘SUBROUTINE’

Most programs in T24 must be coded to be ‘SUBROUTINE’.


In case it is required to call a program from the UniVerse/jBASE prompt or call the
program using an EXECUTE statement, then program
must be coded as a ‘PROGRAM’. In case the program has been coded as
‘PROGRAM’ the statement
used to exit the program must be coded as ‘STOP’ and not ‘RETURN’ since
‘RETURN’ is associated with a ‘SUBROUTINE’ in jBASE.

PROGRAMMING LANGUAGE -INFOBASIC


SUBROUTINE - jbc will call the program
COMPONENT -component name should be created with the
product -(EB.)
$PACKAGE -mandatory(for higher versions)

RETURN -NOT MANDATORY


DEBUG -line by line it will decode

Global Variables

Global variables are defined in I_COMMON. This insert is included in every T24
program and
therefore this common block is available to all programs. The prefix of C$ has
been adopted for global
variables, however there are many variables in I_COMMON that were defined
before this standard
was adopted and consequently do not use this prefix.

Subroutine Level Variables


These variables are only used in the subroutine in which they are defined. They
have no prefix and
can only be passed to another subroutine as an argument in the CALL statement.

Standard Variables
Files and records
Example
File Variable F.filename F.ACCOUNT
File name FN.filename FN.ACCOUNT
Record variable R.filename R.ACCOUNT

Standard Subroutines

Operation Routines
Read, writes etc. F.READ, F.WRITE ...
File opens OPF

Application
An application records the data entered and stores it in an associated file, field by
field

--------------------------------------
steps
1] include insert files
2]open the files using OPF
3]read the application using call.f.read
--------------------------------------

$INSERT I_COMMON
$INSERT I_EQUATE -these are included for all common variables
$INSERT I_F.CUSTOMER -open customer file and read all records

FM(field marker) 1.1.1


VM(value marker) 1.1.2 1.2.1
SM(sub value marker) 2.1.1
FN.CUSTOMER,F.CUSTOMER -standard variables(based on which
application you want to use)

CALL OPF(FN.CUSTOMER,F.CUSTOMER) -open files and pass std variables as


arguments
-once OPF is called it will prefix the
company

CALL F.READ - to call any core routine/read any


record
SYNTAX: CALL F.READ(FILE_NAME,APPLICATION_NAME,ID_OF
RECORD,DYNAMIC_ARRAY,FILE_VARIABLE,ERROR)

R.CUSTOMER -in order to read the records

-----------------------------------CREATING AN APPLICATION-------------------------------------
[STEPS deciding on application name,
Product information,
Type,Classification,
What functions are permitted,
Deciding fields,
Business logic]

STEP 1 NAMING
The name of the application must be meaningful, should give some indication as
to its purpose and should be prefixed by the product code of the application,
where the product code should exist on EB.PRODUCT

e.g. CR.CAMPAIGN.DEFINITION, PW.ACTIVITY, etc.


Note: The file name cannot exceed 40 characters, to allow for the addition of the
company mnemonic and the $NAU or $HIS suffix
STEP 2 PROPERTIES OF APPLICATION
Having decided on the product and name of the application, the first
step is to define the high level properties of the application PRODUCT.SUB
PRODUCT,CLASSIFICATION(cus,fin,int),TYPE(H,U,L/W)

Type Description Application

(H or U) Used for all standard input programs to maintain a live,


unauthorised and history file.

This template is also used for type ‘U’ programs that


have a live and unauthorised file but do not have a
history file.

Display (L) Used for the display of a 'non-inputtable / live’ file

Utility (W) Used to allow standard input without an unauthorised


file and the verify function to execute special procedures

Classifications
There are three primary classifications of application:

INT Installation - This covers files like COMPANY, USER, LANGUAGE,


where
only one version of the file will exist
regardless of the number of companies

CUS Customer - for files where the data can be shared


between companies.
Primarily static information and
tables.

FIN Financial - for files that hold financial level details


(amounts, balances etc.)
where the data cannot be shared
with other companies.
STEP 3 DEFINING FIELDS

Having defined the high level properties of the application, the next
step is to define the fields that make up the application. Every application MUST
have a corresponding field definitions subroutine. The name of this subroutine is
the full name of the application with the suffix “.FIELDS”, e.g.
CR.CAMPAIGN.OPPORTUNITY.FIELDS. Your new .FIELDS subroutine should be
based on the TEMPLATE.FIELDS template that is shipped as part of the release.
Once defined, save and compile your .FIELDS subroutine.

Standard APIs Table has the following methods to define the fields:
 Table.addField Add a field with standard data types
 Table.addFieldDefinition Add a field using F, N and T style
 Table.addFieldWithEbLookup Add a field with a virtual table
 Table.defineId Define the ID field
 Field.setCheckFile Add a check file to a field
 Table.setAuditPosistion Defines the last field position

STEP 4 Artefact Creation using EB.DEV.HELPER

EB.DEV.HELPER is a standard utility that creates all of the artefacts that are required to run an
application in T24. The key to the record is application that you are working on, and once verified will
perform a number of actions if relevant field is flagged

 PGM.FILE Creates a PGM.FILE record based on the information set in the properties array
 FILE.CONTROL Creates a FILE.CONTROL record based on the information set in the properties
array INSERT Creates the insert file (I_F.MY.APPLICATION) that holds the equated field
names. Uses the prefix defined in the EQUATE.PREFIX property
 CREATE.FILE Creates the physical database files using EBS.CREATE.FILES
 UPDATE.SS Updates / Creates the STANDARD.SELECTION record via OFS and sets the
REBUILD.SYS.FIELDS flag to ‘Y’

STEP 5 Adding Business Logic to the Application


T24 allows extensions to be added to customise the application. This section details the extension points
that are available, and their purpose.

You might also like