[go: up one dir, main page]

0% found this document useful (0 votes)
393 views64 pages

Infobasic - 3

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1/ 64

Infobasic

Technical Courses
Agenda & Objective
Session-wise plan

 Session – I & II
• T24 routines – File Operations
 Session – III
• T24 routines – Sequential File Access

3 Thesys TRAINING Practice


Objective

 At the end of this session, participants will


• Appreciate features of file operations in T24 routines
• Appreciate features of sequential file access in T24 routines

4 Thesys TRAINING Practice


T24 routines – File operations
Why File Operations?

 Records of T24 application needs to be written/read


 Programming made easier

6 Thesys TRAINING Practice


Various File Operation

 OPF
 F.READ
 F.WRITE
 EB.READLIST
 READ
 WRITE

7 Thesys TRAINING Practice


File Operations Usage Procedure

 Write the code i.e. program/subroutine in jEditor


 Compile the program/subroutine in jshell prompt, using
EB.COMPILE <Filename> <Program/Subroutinename>
 Make a PGM entry with M or S as type, and EB as product
 Run the subroutine in T24 prompt

8 Thesys TRAINING Practice


OPF

 Used to open a file for reading/writing purpose


 Has 2 parameters passed
 Syntax:
• CALL OPF(Filename,Filepointer)
• Where,

– Filename : Name of the file E.g. FBNK.CUSTOMER


– Filepointer : Pointer/Path to the file

9 Thesys TRAINING Practice


OPF

 Programming Flow
<Initialize variables FN.CUSTOMER,F.CUSTOMER,….>
<Open the file using OPF>
i.e. CALL OPF(FN.CUSTOMER,F.CUSTOMER)

10 Thesys TRAINING Practice


F.READ

 Used to read record from file that is already opened using


OPF
 Has 5 parameters passed

11 Thesys TRAINING Practice


F.READ

 Syntax:
CALL F.READ(Filename,record.id,dynamic.array,File.var,Error.var)
Where,
Filename : File Name
Record.id : ID of the record to be read
Dynamic.array : Dynamic array that will hold read record
File.var : File Path
Error.var : Error Variable

12 Thesys TRAINING Practice


F.READ

 Programming Flow
<Initialize variables FN.CUSTOMER,F.CUSTOMER,….>
<Open the file using OPF>
<Read the record using F.READ>
i.e. CALL F.READ
(FN.CUSTOMER,Y.CUSTOMER.ID,R.CUSTOMER,
F.CUSTOMER,Y.CUS.ERR)

13 Thesys TRAINING Practice


F.WRITE

 Used to write details onto a record of a file


 Before writing, open a file and read the record
 Has 3 parameters

14 Thesys TRAINING Practice


F.WRITE

 Syntax:
CALL F.WRITE(Filename, Record.id, Dynamic array)
Where,
Filename : File Name
Record.id : Record to be written
Dynamic array : Array holding the values to be written on record

15 Thesys TRAINING Practice


F.WRITE

 Programming Flow
<Initialize variables FN.CUSTOMER,F.CUSTOMER,….>
<Open the file using OPF>
<Read the record using F.READ>
<Assign the value to the dynamic array which we are going to
write>
i.e. CALL F.WRITE
(FN.CUSTOMER,Y.CUSTOMER.ID,R.CUSTOMER)

16 Thesys TRAINING Practice


Example

 Write a subroutine that will display the details


• (Id, Mnemonic and Nationality) of a customer
• whose id is 100037

17 Thesys TRAINING Practice


Solution

 Write a subroutine as shown:

Insert file

18 Thesys TRAINING Practice


Solution (cont..)

 Compile the subroutine


 On successful compilation, make a PGM entry of the
subroutine

19 Thesys TRAINING Practice


Solution (cont..)

 On execution, the Customer record is opened, read and


displayed

20 Thesys TRAINING Practice


Error Handling

21 Thesys TRAINING Practice


Error Handling

 Error appears as shown, when PGM entry is not available


for the subroutine

22 Thesys TRAINING Practice


EB.READLIST

 To read a set of records from a file we use this core routine


 It has 5 parameters passed

23 Thesys TRAINING Practice


EB.READLIST

 Syntax:
CALL EB.READLIST(1,2,3,4,5 )
Where,
1 : Select Query
2 : List variable that contains only the ID of the selected records
3 : Id of the SAVEDLISTS file (Optional)
4 : No of Records selected (Total Count)
5 : Return code

24 Thesys TRAINING Practice


EB.READLIST

 Example
<Initialize File name FN.CUSTOMER>
SEL.CMD = “SELECT “:FN.CUSTOMER
CALL
EB.READLIST(SEL.CMD,SEL.LIST,’’,NO.OF.RECORDS,RET.
CODE)

25 Thesys TRAINING Practice


Error Handling

26 Thesys TRAINING Practice


REMOVE

 Function that is used to extract a value from a dynamic array

27 Thesys TRAINING Practice


REMOVE

 SYNTAX:
REMOVE <var> FROM <array> SETTING <set var>
Var : variable which holds the extracted string
Array : Dynamic array from which the string is to be extracted.
Set var : Delimiter by which string is extracted from array.
(2 – FM, 3 – VM, 4 – SM, 0 – End of array)

28 Thesys TRAINING Practice


Example

 Write a subroutine that will changes the Account officer from


2 to 1 and display the details (Customer, Mnemonic, Old
Acct officer and New Acct officer) for all customers

29 Thesys TRAINING Practice


Solution (cont..)

30 Thesys TRAINING Practice


Solution (cont..)

31 Thesys TRAINING Practice


Solution (cont..)

 Compile & catalog the subroutine


 Make an entry in Program file for the subroutine

32 Thesys TRAINING Practice


Solution (cont..)

 Customer records are read from list, and Account Officer


field value is changed and displayed

33 Thesys TRAINING Practice


READ

 Used to read a record from a file


 Syntax:
READ variable1 FROM { variable2,} expression {SETTING
setvar} {ON
ERROR statements} THEN|ELSE statements
Where,
Variable1 – Identifier into which record will be read
variable2 – jBC variable that is previously opened to a file using
OPEN statement

34 Thesys TRAINING Practice


Difference b/w FREAD and READ

FREAD READ
Reads the buffer first and executes if the Directly checks for the required data in
required data is in buffer, else checks for the server all the time, without checking
the required data in the server and buffer and executes
executes

35 Thesys TRAINING Practice


Example

 Write a program to read a customer record based on input


customer ID, and to print message “Record read
successfully” or “Record not on file”

36 Thesys TRAINING Practice


Solution

37 Thesys TRAINING Practice


Solution (cont..)

38 Thesys TRAINING Practice


Solution (cont..)

 Customer record is read and displayed

39 Thesys TRAINING Practice


WRITE

 Allows a program to write a record into a previously opened


file
 Syntax:
WRITE variable1 ON|TO { variable2,} expression {SETTING
setvar} {ON ERROR statements}
Where,
variable1 – Identifier containing the record to write
variable2 – jBC variable previously opened to a file using the
OPEN statement

40 Thesys TRAINING Practice


Difference b/w FWRITE and WRITE

FWRITE WRITE
Writes date into the buffer first, that's why Writes data directly into the server
sometimes we have to use
JOURNAL.UPDATE

41 Thesys TRAINING Practice


Example

 Write a program
• To check whether field ‘Town Country’ in Customer application
has a value
• If ‘Town Country’ has no value, then update it with ‘INDIA’

42 Thesys TRAINING Practice


Solution

 Write a program as shown

43 Thesys TRAINING Practice


Solution (cont..)

 Compile the program


 Run the program & input customer number which is having
NULL value in the field ‘Town country’

44 Thesys TRAINING Practice


Solution (cont..)

 TOWN.COUNTRY field of Customer record is updated


automatically, as shown

45 Thesys TRAINING Practice


Solution (cont..)

 Input Customer number having value in Town Country

46 Thesys TRAINING Practice


Solution (cont..)

 Message appears as shown, as Town.Country field is


updated already

47 Thesys TRAINING Practice


T24 routines – Sequential file access
Sequential File Access Commands

 OPENSEQ – Opens a file for sequential writing or reading


 READSEQ – Reads from file opened for sequential access
 WRITESEQ – Writes data to file opened for sequential
access

49 Thesys TRAINING Practice


OPENSEQ

 Syntax:
OPENSEQ Path{,File} {READONLY} TO FileVar { LOCKED
statements } THEN | ELSE statements
Where,
Path: Specifies relative or absolute path of target file/directory
File: Specifies additional path information of target file
FileVar: Contains file descriptor of the file opened successfully
Statement: Conditional jBC statements

50 Thesys TRAINING Practice


WRITESEQ

 Syntax:
WRITESEQ Expression {APPEND} TO FileVar THEN | ELSE
statements
(Or)
WRITESEQF Expression {APPEND} TO FileVar THEN | ELSE
statements
Where,
Expression: Specifies the variable to contain next record from
sequential file

51 Thesys TRAINING Practice


Example:

 Write a sequential processing to create a text file from a


jBase non-hashed file

52 Thesys TRAINING Practice


Solution

53 Thesys TRAINING Practice


Solution (cont..)

 Text file is created from jBase non-hashed file (TRNG.BP),


using sequential processing

54 Thesys TRAINING Practice


READSEQ

 Syntax:
READSEQ Variable FROM FileVar THEN | ELSE statements
Where,
Variable: Specific variable to contain next record from sequential
file
FileVar: Specific file descriptor of file opened successfully
Statement: Conditional jBC statement

55 Thesys TRAINING Practice


Example

 Write a program that uses sequential processing to a read


an ASCII text file and write to a jBase non-hashed file

56 Thesys TRAINING Practice


Solution

57 Thesys TRAINING Practice


Solution (cont..)

 An ASCII text file is read and written to a jBase non-hashed


file

58 Thesys TRAINING Practice


Workshop

 Write a program using sequential processing to write a text


file containing customer details and to read the text file from
jBase non-hashed file

59 Thesys TRAINING Practice


Solution

60 Thesys TRAINING Practice


Solution (cont..)

 Sequential file is created and data is written into the file and
read from jBase non-hashed file

61 Thesys TRAINING Practice


Summary

 We have learnt the


• Features of file operations in T24 routines through
– OPF -> Opens a file for reading/writing purpose
– F.READ & F.WRITE -> Used to read & write record from & to file
that is already opened using OPF, respectively
– EB.READLIST -> To read a set of records from a file we use this
core routine
– READ & WRITE -> Used to read & write a record from & to a file,
respectively

62 Thesys TRAINING Practice


Summary

• Features of sequential file access in T24 routines through


– OPENSEQ – Opens a file for sequential writing or reading
– READSEQ – Reads from file opened for sequential access
– WRITESEQ – Writes data to file opened for sequential access

63 Thesys TRAINING Practice


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.

FOR MORE INFORMATION


Visit : www.thesys.co.in
email : marketing@thesys.co.in

You might also like