Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

SPM TPFDF1

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 124

TPFDF Application Programming

&
Structured Programming macros

2nd Edition

Mohan Chandar. J
Pre-Requisites to this Course

 Thorough Knowledge of Programming using the IBM ESA/390 assembly language and TPF Macros

 Working Knowledge of VMESA/CMS and XEDIT.

 Basic Knowledge of MVS and JCLs.

Course Objectives
The course introduces the participants to the TPFDF Database management system and to enable him/her to develop
TPF applications using SPM'S and TPFDF.

The lab exercises are intended to give the participants the feel of coding TPF programs using SPM'S and TPFDF.

TPFDF Application Programming page 2 of 12421


© Aviation Software Development Consultancy India Ltd.
Copyright Statement

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any
form or by any means, without the prior written permission of the company, ASDC.

Address for Communication:

The Training Coordinator,


Aviation Software Development Consultancy India Ltd,
Unit 21/22, 2nd Floor, Elnet Software City,
TS 140 Block 2 & 9, CPT Road,
Taramani,
Chennai-600 113.
INDIA.

 (91-44) - 2541015 , 2541097, 2541598


 Fax: (91-44) - 2541016
 ceo@asdc.co.in

Trademarks

TPFDF - Transaction Processing Facility Database Facility and TPF - Transaction Processing Facility are licensed
Program Products of International Business Machines Corporation. All other product names mentioned are
acknowledged to be the trademarks of their producing companies.

Edition Information

First Edition
April 1999.

This publication deals with the Transaction Processing Facility Database Facility application Programming and
structured Programming macros . The material is for Release 1.1.3 of the TPFDF Program Product. ASDC reserves
the rights to revise the manual and make changes without obligations to notify any person.

TPFDF Application Programming page 3 of 12421


© Aviation Software Development Consultancy India Ltd.
Table ofContents

Structured Programming macros - Contents.............................................................................................5


Introduction to Structured Programming Macros......................................................................................7
Coding Conditional Expressions.................................................................................................................8
The IF-ELSE Construct...............................................................................................................................10
IF-ELSEIF Construct...................................................................................................................................11
Multi-Way Decisions : The CASE statement...........................................................................................12
Loop Control, The DO-WHILE Construct.................................................................................................14
The DO-UNTIL construct............................................................................................................................15
The DO-TIMES Construct..........................................................................................................................16
Exiting Loops , The DOEX,EXIF,OREL,ELOP Statements..................................................................17
The DO-INFINITE Construct......................................................................................................................19
The DO-ONCE Construct...........................................................................................................................20
Boolean Connections of Conditional Expressions.................................................................................21
The GOTO Statement , #LOCA & #GOTO..............................................................................................22
Subroutine Linkage using SPM'S ,#PERF,#SUBR & #ESUB..............................................................23
Data Incrementation Macros......................................................................................................................25
Condensed Form of SPM'S........................................................................................................................26
Other SPM statements................................................................................................................................27
SPM Assembler Directives.........................................................................................................................28
Introduction to TPFDF - Contents.............................................................................................................30
Introduction to TPFDF.................................................................................................................................31
TPFDF Interface with TPF and TPF Applications...................................................................................32
TPFDF Components...................................................................................................................................33
TPFDF Terminology....................................................................................................................................34
Defining TPFDF Files and LREC's............................................................................................................41
Defining TPFDF Files and LREC's............................................................................................................45
TPFDF Interface Block : The SW00SR....................................................................................................46
TPFDF Level Usage & Register Conventions.........................................................................................47
Advantages and Disadvantages of TPFDF.............................................................................................48
TPFDF File Commands and Command Sequence................................................................................50
TPFDF General Macros - Contents..........................................................................................................54
Coding a TPFDF Command macro..........................................................................................................55
Common Parameters used in TPFDF Command Macros....................................................................56
TPFDF Macros : OPEN a Subfile -- DBOPN......................................................................................65
TPFDF Macros : Read an LREC -- DBRED........................................................................................67
TPFDF Macros : Close a Subfile(s) – DBCLS........................................................................................70
Checking Return conditions of TPFDF Command macros...................................................................72
TPFDF Macros : ADD an LREC --- DBADD............................................................................................74
TPFDF Macros : Delete an LREC -- DBDEL...........................................................................................77
TPFDF Macros : Modify an LREC -- DBMOD........................................................................................79
TPFDF Macros : Miscellaneous General Macros..................................................................................81
TPFDF Advanced Macros - Contents.......................................................................................................90
TPFDF Subfile Macro : Checkpoint a Subfile - DBCKP.......................................................................91
TPFDF Subfile Macro :Copy a Subfile - DBCPY....................................................................................92
TPFDF Subfile Macro : Restore a Subfile - DBRST.............................................................................93
TPFDF Advanced Macro : SORT a File - DBSRT..................................................................................95
TPFDF Advanced Macro : MERGE 2 Files – DBMRG..........................................................................97
TPFDF Tape Macro : Write File to tape - DBTLG..................................................................................99
TPFDF TAPE Macro : Read File from tape – DBTRD.........................................................................100

TPFDF Application Programming page 4 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF TAPE Macro : Write File to DISK - DBTLD..............................................................................101
TPFDF Indexing Support..........................................................................................................................102
TPFDF Index Support Macro: Create Index LREC - DBIDX..............................................................107
TPFDF Index Support Macro : Delete Index LREC – DBDIX.............................................................108
TPFDF Partitioning and Interleaving.......................................................................................................109
TPFDF Nuggets - Contents......................................................................................................................112
Sample DSEC TS for coding TPFDF DSECTS....................................................................................113
OA Entries for Online Maintenance of TPFDF Files............................................................................114
TPFDF System Dumps.............................................................................................................................118

TPFDF Application Programming page 5 of 12421


© Aviation Software Development Consultancy India Ltd.
Chapter 1
Structured Programming Macros

TPFDF Application Programming page 6 of 12421


© Aviation Software Development Consultancy India Ltd.
Structured Programming macros - Contents

 Introduction to Structured Programming Macros


 Coding Conditional expressions
 The IF-ELSE Construct
 IF-ELSEIF Construct
 Multi-Way Decisions : The CASE statement
 Loop Control , The DO-WHILE Construct
 The DO-UNTIL Construct
 The DO-TIMES Construct
 Exiting Loops , The DOEX,EXIF,OREL,ELOP Statements
 The DO-INFINITE Construct
 The DO-ONCE Construct
 Boolean Connections of Conditional Expressions
 The GOTO Statement , #LOCA & #GOTO
 Subroutine Linkage using SPM'S ,#PERF,#SUBR & #ESUB

TPFDF Application Programming page 7 of 12421


© Aviation Software Development Consultancy India Ltd.
Structured Programming macros - Contents

 Data Conversion Macros


 Data Incrementation macros
 Condensed Form of SPM'S
 Other SPM statements
 SPM Assembler Directives

TPFDF Application Programming page 8 of 12421


© Aviation Software Development Consultancy India Ltd.
Introduction to Structured Programming Macros

 SPM'S Originated from IBM , Enhanced by other installations


 Comes as part of the TPFDF Program Product
 Helps Develop Structured Programs in Assembly Language & TPF

 Advantages of Using SPM'S


 Faster Development of Assembler & TPF Programs
 Easier Readability (Can indent) and Maintenance
 Smaller Programs (as they look !)
 Increased Productivity , More Focus on design less on coding efforts
 Makes Debugging easy, Can quickly localise problems , Gives clear understanding of programming
logic
 Don’t need to remember complex assembler instructions to control loops

 Disadvantage of SPM'S
 Code Generated may be less efficient
 Program Sizes could be much larger than equivalent code generated by traditional assembler programs

TPFDF Application Programming page 9 of 12421


© Aviation Software Development Consultancy India Ltd.
Coding Conditional Expressions

 Conditional Expressions needs to be coded in SPM Constructs to test conditions for


 Selection as in the IF - ELSE constructs
 Iteration as in DO-WHILE or DO-UNTIL Constructs

 Conditional Expressions are coded like assembler instructions but in a more verbal and readable form
Example:
In Assembly Language : CLI EBW000,X'FF'
Using SPM : (CLI,EBW000,EQ,X'FF')

 Conditional Expressions should specify the Destination, source / value and the condition to be tested for.

 Compare Family of Instructions in the S/390 Instruction Set CLC,CLI,C,CR,CH,CP etc and other instructions that
test for a condition and set a condition code like LTR,TM,OC,ICM etc .. can form a conditional expression

 The Test Condition for testing the return condition code can be specified using the symbolic equivalents as
EQ,NE,L,LE,G,GE,Z,NZ,O,M,NO,NM,NL,NG etc..

TPFDF Application Programming page 10 of 12421


© Aviation Software Development Consultancy India Ltd.
Coding Conditional Expressions

 The Source field can be specified as coded in the assembler instruction in case of Literals and Immediate values
Example: (CLC,4(4,R1),EQ,=F'0')

 For the compare type of instructions the test condition should be specified between the Source and the
Destination

 For Other instructions the test condition should be the last parameter
Example: (LTR RAC,RAC,Z)

 Either register conventions can be used in SPM'S

 Conditional Expressions generate equivalent assembler instructions as specified in the Instruction field of the
Conditional Expression

TPFDF Application Programming page 11 of 12421


© Aviation Software Development Consultancy India Ltd.
The IF-ELSE Construct

 The IF-ELSE Constructs help perform some process based upon a certain condition

 SPM'S Provide the following statements


 #IF (Conditional Expression) THEN
This helps in selection based on the satisfaction of the condition
 #ELSE
All cases where the #IF condition was not satisfied is executed
 #EIF
End of the IF-ELSE Construct

 SPM's Generate labels automatically to branch to on conditions being satisfied / not satisfied

 Example :
#IF (CLI,MI0ACC+8,EQ,C'B') THEN
BAS R7,BOOK_PASSENGER
#ELSE
WTOPC TEXT = 'INVALID PAC'
EXITC
#EIF

 Example of Nested IF Statement :

#IF (CLI,MI0ACC+8,EQ,C'B') THEN


BAS R7,IS_SEAT_AVAILABLE
#IF (TM,EBX090,X'FF',O) THEN
BAS R7,BOOK_PASSENGER
#EIF
#ELSE
WTOPC TEXT = 'INVALID PAC'
EXITC
#EIF

TPFDF Application Programming page 12 of 12421


© Aviation Software Development Consultancy India Ltd.
IF-ELSEIF Construct

 The ELSEIF Condition facilitates more than one selection cases using the IF-ELSE Structure

 SPM Provides #ELIF Statement for alternate selection


 #ELIF (Conditional Expression) THEN
This helps in selection based on the satisfaction of the conditional expression

 Follows the first #IF statement and before the #ELSE#EIF Statements

 Conditions are tested one after another in the physical code sequence , The first condition satisfied only is
executed

 Example :

#IF (CLI,MI0ACC+8,EQ,C'B') THEN


BAS R7,IS_SEAT_AVAILABLE
#IF (TM,EBX090,X'FF',O) THEN
BAS R7,BOOK_PASSENGER
#EIF
#ELIF (CLI,MI0ACC+8,EQ,C'X') THEN
BAS R7,IS_PASS_BOOKED
#IF (TM,EBX091,X'FF',O) THEN
BAS R7,CANCEL PASSENGER
#EIF
#ELSE
WTOPC TEXT = 'INVALID PAC'
EXITC
#EIF

TPFDF Application Programming page 13 of 12421


© Aviation Software Development Consultancy India Ltd.
Multi-Way Decisions: The CASE Statement

 The CASE Statement handles multiple selections based upon a numeric value contained in a GPR

 The numeric value of the first case should be a power of 2 , and the other numeric values in the case set should
be a multiple of the number in the first case

 SPM'S Provide the following statements for case selection

 #CAST GPR|POWER=x|MAX=n

Indicates start of the selection , The case number in a register (Not R0) is used to index into the branch table (cases) ,
POWER parameter indicates case numbers are multiples of 2 e , e defaults to 0 , MAX = n specifies the maximum case
number possible, If specified should also code a #CASE ERROR

 #CASE n1|,n2|…,|nx|,ERROR

Start of selected case(s) , Cannot be Zero . Error case is given control when a case greater than MAX possible case is
specified
 #ECAS

Indicates the end of the case selection structure , Generates branch table for all case numbers specified

TPFDF Application Programming page 14 of 12421


© Aviation Software Development Consultancy India Ltd.
Multi-Way Decisions : The CASE statement

Example :

L R2,EBX080 LOAD CASE SWITCH VALUE


#CAST R2,POWER=1,MAX=8
#CASE 2 REC RETRIEVAL ERROR
SERRC E,101666
#CASE 4 FACE ERROR
SERRC E,102666
#CASE 6,8 INVALID PAC
WTOPC TEXT='INVALID PAC'
EXITC
#CASE ERROR
SERRC E,666666
#ECAS

TPFDF Application Programming page 15 of 12421


© Aviation Software Development Consultancy India Ltd.
Loop Control, The DO-WHILE Construct

 The DO-WHILE Constructs help repeatedly perform some process based upon a certain condition , Generates
BCT,BXLE,BXH,BCTR type instructions

 DO-WHILE tests the condition at the top of the loop and hence the loop is executed atleast once if and only if the

 condition is satisfied on first entry to the loop

 SPM'S Provide the following statements for DO-WHILE

 #DO WHILE=(Conditional Expression)


Repeat Process if and only if condition is satisfied

 #EDO
Indicates end of #DO Construct

 SPM's Generate labels automatically to branch to on conditions being satisfied / not satisfied

 Example of DO-WHILE Construct :

#DO WHILE=(CLI,EBW000,EQ,X'FF')
BAS R7,SEND_MESSAGE
#IF (TM,ALLDONE,X'00',Z) THEN
MVI EBW000,X'FF'
#EIF
#EDO

TPFDF Application Programming page 16 of 12421


© Aviation Software Development Consultancy India Ltd.
The DO-UNTIL construct

 The DO-UNTIL Construct help repeatedly perform some process based upon a certain condition , Generates
BCT,BXLE,BXH,BCTR type instructions

 DO-UNTIL tests the condition at the bottom of the loop and hence the loop is executed atleast once irrespective of
the condition being satisfied

 SPM'S Provide the following statements for DO-UNTIL

 #DO UNTIL=(Conditional Expression)

Execute Process atleast once , repeat Process if and only if condition is satisfied

 #EDO

Indicates end of #DO Construct

 Example of DO-UNTIL Construct :

#DO UNTIL=(R3,GE,R5)
#IF (CLC,LOCAN1(L'LOCPFX+L'LOCAWB),EQ,LOCAN2
MVC 0(L'LOCITM,R6),LOCCAR
LA R6,L'O287ITM(R6) NEXT CAR ITEM SLOT
LA R5,1(R5) INCREMENT CAR CTR
#EIF
#EDO

TPFDF Application Programming page 17 of 12421


© Aviation Software Development Consultancy India Ltd.
The DO-TIMES Construct

 The DO-TIMES Construct help repeatedly perform some process for a particular number of times

 DO-TIMES Generates a BCT instruction at the bottom of the loop tests the condition at the bottom of the loop

 SPM'S Provide the following statements for DO-TIMES

 #DO TIMES=(REG1|,VAL1|,REG2)

Execute Process a set number of times,REG1 has the value for the number of times the loop has to execute ,
VAL1 is an optional parameter that has the immediate value to be loaded in REG1 Before executing the loop ,
REG2 is the branch register used to generate a BCTR

 #EDO
Indicates end of #DO Construct

 Examples of DO-TIMES Construct :

LA R3,100
#DO TIMES=(R3)
MVC 0(L'LOCITM,R6),LOCCAR
LA R6,L'O287ITM(R6) NEXT CAR ITEM SLOT
LA R5,1(R5) INCREMENT CAR CTR
#EDO

#DO TIMES=(R3,X/EBW000)
MVC 0(L'LOCITM,R6),LOCCAR
LA R6,L'O287ITM(R6) NEXT CAR ITEM SLOT
LA R5,1(R5) INCREMENT CAR CTR
#EDO

LA R4,ENDLOOP
#DO TIMES=(R3,100,R4)
MVC 0(L'LOCITM,R6),LOCCAR
LA R6,L'O287ITM(R6) NEXT CAR ITEM SLOT
LA R5,1(R5) INCREMENT CAR CTR
#EDO

TPFDF Application Programming page 18 of 12421


© Aviation Software Development Consultancy India Ltd.
Exiting Loops , The DOEX,EXIF,OREL,ELOP Statements

 SPM'S Provide statements to exit the processing of a loop when some exceptions occur

 Two such SPM'S are provided for exiting on exception

1) #DOEX (Conditional expression)

If the condition is satisfied then it marks an exception wherein the instructions between the #ELOP statement
and the #EDO statements are executed and the loop terminates

#ELOP

Marks the beginning of code that is executed if the #DOEX condition is satisfied , Precedes #EDO

2)#EXIF (Conditional Expression)

If the condition is satisfied then it marks an exception wherein the instructions between the #EXIF statement
and the #OREL statements are executed on completion a branch is taken to #EDO , Without executing
codes between #ELOP and #EDO

#OREL

Marks the end of instructions that needs to be executed when #EXIF Condition is satisfied , Branches to
#EDO .

TPFDF Application Programming page 19 of 12421


© Aviation Software Development Consultancy India Ltd.
Exiting Loops , The DOEX,EXIF,OREL,ELOP Statements

 These Exit SPM'S can be used with any form of the #DO loops

 Example of #DOEX,#ELOP

#DO TIMES=(R0) MAX # TO LOOP


#DOEX (CLI,EBX090,EQ,C' ') CLASS FIELD IS BLANK, NUMBER OF
CLASSES REACHED
LA R4,1(R4) NEXT CLASS
LA R1,1(R1) ADD ONE TO CLASS COUNT
#ELOP
L R4,EBW000 RESET RECORD BASE
ST R1,TEMPST SAVE CLASS COUNT
#EDO

 Example of #EXIF,#OREL

#DO TIMES=R2 DO UNTIL END OF NAME TABLE


#EXIF (CL,R0,EQ,TABNAME) IS THIS THE NAME SLOT SLOT ?
SR R14,R4 FIND INDEX FROM TABLE BASE
LR R4,R14 SAVE TABLE INDEX IN R4
#OREL
LA R14,PATLEN(R14) NEXT PAT SLOT
#ELOP
SR R4,R4 TABLE SLOT NOT FOUND
#EDO

TPFDF Application Programming page 20 of 12421


© Aviation Software Development Consultancy India Ltd.
The DO-INFINITE Construct

 The DO-INFINITE Construct helps construct an infinite loop , However exit conditions inside the loop have to be
defined using the #DOEX,#EXIF Statements

 DO-INFINITE should be avoided unless you are sure that you will take the exit condition out of the loop one way
or the other

 SPM'S Provide the following statements for DO-INFINITE

 #DO INF

Start of Infinite loop

 #EDO

Indicates end of #DO Construct

 Example of DO-INF Construct :

#DO INF
#DOEX CLI,0(RGE),L,C'A',OR, CHARACTER NOT
# CLI,0(RGE),H,C'Z' BETWEEN A AND Z
LA RGE,1(RGE) POINT TO NEXT CHARACTER
#EDO
LR RGF,RGE SAVE END OF MESSAGE
SR RGE,RGC CALCULATE LENGTH IN REGISTER RGE

TPFDF Application Programming page 21 of 12421


© Aviation Software Development Consultancy India Ltd.
The DO-ONCE Construct

 The DO-ONCE Construct a non-loop or a sequence of instructions executed Only Once

 However it allows you to use structured programming constructs such as #EXIF,#DOEX etc..

 SPM'S Provide the following statements for DO-ONCE

 #DO ONCE

Start of Non-loop

 #EDO

Indicates end of #DO Construct

 Example of DO-ONCE Construct :

#DO ONCE

#PERF R14,'CREATE FILE'


#DOEX (TM,ERROR,X'FF'O)
#PERF R14,'READ FIRST ITEM'
#DOEX (CLI,EBW000,EQ,X'FF')

ENTRC ABCD

#EDO

 There exists also a #DO FROM =,BY=,TO= Which generates BXLE,BXH Instruction based loops , It is seldom
used however would be a nice SPM to know

TPFDF Application Programming page 22 of 12421


© Aviation Software Development Consultancy India Ltd.
Boolean Connections of Conditional Expressions

 Boolean connections can be made to conditional expressions to form complex conditional expressions
 The Four Boolean connectors available are

 AND
 OR
 ANDIF
 ORIF

 AND and OR connect conditional expressions within a group and ANDIF and ORIF Connect conditional
expression groups itself

 Conditional expressions groups are processed top to bottom and conditional expressions within a group is
processed sequential and from top to bottom

 Example :

#IF (CLI,MI0ACC+12,EQ,C'C',AND,CLI,MI0ACC+13,EQ,C'M'),
# ORIF,(CLI,MI0ACC+12,GE,C'0',AND,CLI,MI0ACC+12,LE,C'9',
# AND,CLI,MI0ACC+13,GE,C'0',AND,CLI,MI0ACC+13,LE,C'9') THEN
VALID INPUT FORMAT PROCESSING
#ELSE
INVALID INPUT FORMAT PROCESSING
#EIF

TPFDF Application Programming page 23 of 12421


© Aviation Software Development Consultancy India Ltd.
The GOTO Statement , #LOCA & #GOTO

 The GOTO statement can be used to process abnormal exit conditions to force branch out of a loop

 Use of GOTO Should be avoided as it violates rules of structured programming , However can be used wisely

 SPM Statements supported for the GOTO SPM

 #GOTO Label|,IF,(Conditional Expression)

Label should be a location in the program defined using a #LOCA SPM , Can code optionally a conditional
expression with the #IF SPM to test before taking the GOTO Path

 #LOCA Label

Start of the code that would get control on a #GOTO Label SPM

Example :
#GOTO ERROR_ROUTINE,IF,(LTR,R0,R0,Z)
Fall through Code
:
:
#LOCA ERROR_ROUTINE
Error routine code goes in here

TPFDF Application Programming page 24 of 12421


© Aviation Software Development Consultancy India Ltd.
Subroutine Linkage using SPM'S ,#PERF,#SUBR & #ESUB

 SPM Statements are provided to call subroutines from and return from subroutine back to the mainline code ,
Generates BAL instructions , Optionally one can save and restore linkage register

 SPM'S Provided for Subroutine Linkage

 #PERF REG|SUBNAME|SAVEAREA1

#PERF generates a call to the specified subroutine , REG is the linkage register you want to use for the
subroutine call ,SUBNAME is the name of the called subroutine , Optionally can specify a SAVEAREA1 whose
first full word will be used to save the linkage register across the subroutine call

 #SUBR SUBNAME|REG|SAVEAREA2

#SUBR defines the start of the subroutine instructions , SUBNAME is the name of the subroutine,REG should
be specified if subroutine is physically before the call to the subroutine, Conflict in register specifications
between #PERF and #SUBR results in an MNOTE , #SUBR Register is ignored,SAVEAREA2 can be specified
where the linkage register will be saved and reloaded in the subroutine.

 #ESUB
Denotes end of Subroutine , Mandatory for each #SUBR

 Example :

#PERF R7,VALIDATE_PRIMARY_ACTION_CODE,EBW060
:
:
:
#SUBR VALIDATE_PRIMARY_ACTION_CODE,R7,EBW080
:
:
:
#ESUB

TPFDF Application Programming page 25 of 12421


© Aviation Software Development Consultancy India Ltd.
Data Conversion Macros

 SPM'S Provide macros to convert data from One form to another , A very useful feature that relieves the
programmer from repeating the same piece of conversion code over and over again

 The Conversion macro's Provided are

 #CONB : Convert Decimal to Binary

 #COND : Convert Binary to Decimal

 #CONH : Convert 2 character EBCDIC to 1 Byte HEX

 #CONP : Convert Hex to Printable characters

 #CONT : Convert Binary to Printable Characters

 #CONX : Convert hex to hex Printable characters

 These macros typically take as input , The input data , output area or register , length , workarea ,Fill characters
and converts data to the required form and in some cases returns error indicators

TPFDF Application Programming page 26 of 12421


© Aviation Software Development Consultancy India Ltd.
Data Incrementation Macros

 SPM'S Provide macros to Increment a value specified in a register or a storage area by a specified value

 The Incrementation macro's Provided are

 #STPC : Step Character , Increments the 1 byte value in a storage area by the specified value using a
specified work register , Generates LA instruction , If R0 Specified then generates AH

 #STPH : Step Halfword , Increments the 2 byte value in a storage area by the specified value using a
specified work register, generates AH instruction

 #STPF : Step Fullword , Increments the 4 byte value in a storage area by the specified value using a
specified work register, generates A instruction

 #STPR : Step Registers, Steps one or more registers by a specified increment value , Up to 10 registers
can be incremented using a single #STPR

 Examples :

#STPC R6,6,EBW080
#STPH R3,H/EBW004,EBW016
#STPF R2,2000,INCAREA
#STPR R1,R3,R4,1

TPFDF Application Programming page 27 of 12421


© Aviation Software Development Consultancy India Ltd.
Condensed Form of SPM'S

 To make coding conditional expressions easy , The condensed form of SPM'S are supported

 In condensed form , When it is obvious what instruction is required , One does not have to code the instruction
opcode in the conditional expression

 Example:

#IF R3,EQ,R5 Generates CR instruction

Note that we do not require the brackets too

#IF R5,GE,H/3(R7) Generates a CH instruction

#IF EBW000,NE,TESTFLD Generates a CLC instruction

#IF EBW000,GT,C'D' Generates a CLI instruction

#IF EBW000,BIT3,OFF Generates TM instruction

#IF EBW000,BITS3-7,MIXED Generates TM Instruction

#IF EBW000,BITS1/2/5/7,ON Generates TM Instruction

#IF R3,ZERO Generates LTR Instruction

#IF R3,NONZERO Generates LTR Instruction

#IF TEST1(4),NONZERO Generates an OC instruction

 Also , One does not need to repeat field names when they are Obvious ,

Example :

#IF EBW000,GT,0,AND,LT,9 Generates CLI Instructions

#IF R3,GE,R5,AND,LE,EBW000,AND,NE,=F'0'

Generated instructions which are tested against value in R3

TPFDF Application Programming page 28 of 12421


© Aviation Software Development Consultancy India Ltd.
Other SPM statements

 The Following are the Miscellaneous SPM Statements

 #EXEC : Generates an EX Instruction

Example : #EXEC,R3,CLC,EBW000,EQ,EBW080

 SPM'S support certain TPF Macro's , uses the OK,NOK, INUSE statements

Example :
#IF (FINWC,D3,OK) THEN (CAN ALSO USE FIWHC,FILNC etc)
#IF WAITC,NOK THEN
#IF LEVTA,D2,NOTUSED THEN

 The Continuation macro SPM '#" , When conditional expressions exceed one line , Instead of using a continuation
marker in column 72 of the current line , a # Macro can be used as the operation code in the next line , But the
last operand of current line should be a ','

 #EIFM Statement , Terminates multiple #IF Statements , Instead of coding a series of #EIF to terminate a number
of Nested IF statements , Use #EIFM n Where n is the number of #EIF to be generated

 The #TEXTA Macro is a very powerful SPM Macro that can be used to selecting data , converting data from one
form to another and to format data like inserting blanks , periods etc .., It is a good self study Exercise

TPFDF Application Programming page 29 of 12421


© Aviation Software Development Consultancy India Ltd.
SPM Assembler Directives

 #SPM LEVEL=NO|YES|POP , To control printing of the nesting levels and link labels that are generated by
SPM'S

 #SPM PRINT=GEN|NOGEN , To control the printing of the instructions generated by the SPM Macros

Always ensure #SPM PRINT=GEN while generating code to test under CMSTPF Source view trace

TPFDF Application Programming page 30 of 12421


© Aviation Software Development Consultancy India Ltd.
Chapter 2

Introduction to TPFDF

TPFDF Application Programming page 31 of 12421


© Aviation Software Development Consultancy India Ltd.
Introduction to TPFDF - Contents

 Introduction to TPFDF

 TPFDF Interface with TPF and TPF Applications

 TPFDF Components

 TPFDF Terminology

 Defining TPFDF Files and LREC's

 TPFDF Interface Block : The SW00SR

 TPFDF Level Usage & Register Conventions

 Advantages and Disadvantages of TPFDF

 TPFDF File Commands and Command Sequence

TPFDF Application Programming page 32 of 12421


© Aviation Software Development Consultancy India Ltd.
Introduction to TPFDF

 TPFDF , Transaction Processing Facility Database Facility is a Middle Ware Program Product

 TPFDF Developed initially by Swissair in the Late 70's

 TPFDF is the database Manager that runs in a TPF or ALCS environment

 Adopted By IBM in 1989 , Since then supported by IBM

 TPFDF is a Data Base Management System for Real Time TPF Files , Tapes and General data sets , Forms
Interface between Application Programs and TPF

 The Latest Release of the TPFDF Program Product is TPFDF Release 1.1.3 Put Level 11

 Provides Facilities for Recoup , Capture / Restore , Database Validation , Data Collection apart from Online
Database Utilities and API Macros

 Programs Written in Assembler , or ISOC for TPF can use the TPFDF Database manager

TPFDF Application Programming page 33 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Interface with TPF and TPF Applications

 TPFDF Provides command macros as Interface for Application Programs

 Command Macros translate the commands to TPF Macros which in turn perform the Physical actions on the
database

TPFDF Application Programming page 34 of 12421


© Aviation Software Development Consultancy India Ltd.
TPF Applications

TPFDF Command Macros

TPFDF Programs

Generates TPF Macros

TPF

I/O

ONLINE TPF DATABASE

TPFDF Application Programming page 35 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Components

 The TPFDF Program Product has 4 Distinct Components as Follows

 Command Macros for data Processing

 Online Database Maintenance Utilities

 Database Validation , Capture/Restore Function

 TPFDF File Recoup

 Database definitions (DBDEF's) have to be made for each TPFDF File , These Definitions are used while TPFDF
Services Command macros , During Online Database utilities , Validation,Capture,Restore,Recoup

 Online Database Utilities assist to display TPFDF Files , Modify , delete logical records and perform other Online
utilities

 Command Macros form the API to TPF

 Validation , Capture and Restore are utilities to Validate a TPFDF File , Capture and Restore TPFDF Files

 SAPR : Swissair Parametric Recoup is for Chain Chasing TPFDF Files

 The Database definitions of all TPFDF Files are held in a Central Database Definition table that is referred to by
all the TPFDF Components

TPFDF Application Programming page 36 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Terminology

 The Terminology as used in TPFDF might differ from what their TPF/Other Systems Counterparts mean .

 The Terms that are most commonly used in TPFDF are defined below

 File : A TPFDF Database is made up of Files with the same Record ID , A TPFDF File consists is made
up of Subfiles

 Subfile : A Subfile Consists of a Prime Block (Fixed or Pool) and its Overflow Blocks if present

 TPFDF Operations are performed at the Subfile Level , thereby isolating operations to a single Prime
and its overflows

 Logical Records (LRECS) : Each Block is made up of Logical records that hold data

 Each Subfile has one Prime block and as records are added to it TPFDF Automatically obtains an Overflow Block,
It manages the Chaining of blocks

 Blocks (Prime and Overflow) in TPFDF are of 3 Sizes , L1 : 381 Bytes , L2 : 1055 Bytes and L4 : 4095 Bytes

 Each TPFDF Block contains a TPFDF Standard Header and an Optional TPFDF Standard Trailer

 The TPFDF Header is of Size 26 Bytes (Applications can add fields to the standard header) and the TPFDF
Trailer is of Size 36 bytes

TPFDF Application Programming page 37 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Terminology

 The TPFDF Standard Record Header has the Following fields

 2 Byte Record ID
 1 Byte RCC
 1 Byte Control Byte
 4 Byte Program Stamp
 4 Byte Forward Chain
 4 Byte Backward Chain

These Form the TPF Part of the Record Header

 2 - Byte Next Available Byte (Maintained by TPFDF)


 2 - Byte Sequence Number for updates on Files
 6 - Byte of Work area

 The TPFDF Standard Record Trailer has the Following fields

 2 - Byte Program Base Index


 2 - Byte Database Index
 2 - Byte ID of the owning Subsystem
 10 Spare Bytes
 8 - Byte Time of Day Clock
 2 - Byte Original File ID
 2 - Byte Original Block check character
 1 - Byte Last issued Command
 4 - Byte File address of the prime block

TPFDF Application Programming page 38 of 12421


© Aviation Software Development Consultancy India Ltd.
 4 - Byte file address of this Block

TPFDF Terminology

FILE

Header
FORWARD CHAIN Header
RECORD ID Header
Header

Header Header

LRECS
Trailer
Trailer
Trailer
Trailer

OVERFLOW BLOCKS
OVERFLOW BLOCKS
Trailer
Trailer

PRIME BLOCK PRIME BLOCK

SUBFILE SUBFILE

TPFDF Application Programming page 39 of 12421


© Aviation Software Development Consultancy India Ltd.
FIGURE DEPICTING A TYPICAL TPFDF DATABASE STRUCTURE , EXPLAINING FILE ,
SUBFILE , HEADER,TRAILER AND LRECS

TPFDF Terminology

 Logical Records are the smallest unit of accessible data that can be read , updated or deleted by a TPFDF
Application program

 LRECS Can be defined as Fixed-length or Variable length in the DSECT Describing the file

 Each LREC is identified by a Primary Key which is a 1 Byte field in the LREC

 Variable length LRECS have in them a 2-Byte Size of the LREC Preceding the Key

 After the Primary Key and the LREC SIZE comes the User data

 One file can contain LRECS with different Primary Keys (Each Primary key might mean a different Kind of data)

 LREC Primary Keys can take values from X'10' to X'EF'

 A Variable Length LREC can contain Only one variable length field and it should be the last of the fields contained
in an LREC

 The Size Field in the LREC is the size of user data plus the size of primary key plus the size of the size field

TPFDF Application Programming page 40 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Terminology

 To access a TPFDF Subfile , One should know the File address of the Prime block of the Subfile

 If the Prime Block of the Subfile is a Fixed File , TPFDF Provides you with a mechanism to retrieve the correct
Ordinal number depending upon an input data string known as the ALGORITHM

 The File type of the FILE is specified in the File DSECT against the SW00RCT Field

 TPFDF Provides you with several algorithms , One of which should be chosen at the design stage and coded in
the DSECT in the SW00RBV Field

 An Algorithm argument can be provided to the TPFDF Command macro which will then determine which Subfile
to Operate upon based on the Algorithm being used and the Algorithm String

 Example :

 A File of Passenger names is designed , such that Ordinals 0..25 will


contain passenger names beginning A..Z Respectively , So we would have 26
Subfiles . And the first character of the name will be the Algorithm
String . The Algorithm is provided by TPFDF

 The Algorithms Supported by TPFDF is tabulated in the following page

 Algorithms are of two flavours namely Direct Translation Algorithms and Hashing Algorithms

TPFDF Application Programming page 41 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Terminology

ALGORITHM NAME ALGORITHM STRING NO.OF ADDRESSABLE ORDINALS

1 CHARACTER
#TPFDB01 26 ORDINALS
A-Z
(0-25)

676 ORDINALS
2 CHARACTERS
#TPFDB02 (0-675)
AA-ZZ

17576 ORDINALS
#TPFDB03
3 CHARACTERS (0-17575)

ONLY ONE ORDINAL


#TPFDB04
N.A NUMBER USED

USER SUPPLIED ORDINAL AS DEFINED IN THE FACE TABLE


#TPFDB05
NUMBER IN 4 BYTE FIELD FOR THIS RECORD TYPE

1 BYTE ALPHA-NUMERIC VALUE


#TPFDB06 36 ORDINALS
(0-9,A-Z)
(0-35)

2 BYTE ALPHA-NUMERIC VALUE


#TPFDB07 (AA-AZ…A0..A9..ZA..ZZ.. 1296 ORDINALS
Z0..Z9..00.09..0A..0Z..9A.9Z) (0-1295)

3 BYTE ALPHA-NUMERIC VALUE


#TPFDB08 46656 ORDINALS
(AAA..AAZ..AA0..AA9..A00..A09..Z
(0-46655)
90…999..ZZZ)

AS DEFINED IN THE FACE TABLE


#TPFDB09
8 BYTE VALUE (HASHED) FOR THIS FACE TYPE

TPFDF Application Programming page 42 of 12421


© Aviation Software Development Consultancy India Ltd.
ALGORITHM NAME ALGORITHM STRING NO.OF ADDRESSABLE ORDINALS
1 BYTE ALPHA-NUMERIC OR
#TPFDB0A SPECIAL CHARACTER ( . , $ ,* , - , 43 ORDINALS
/,#,@) (0-42)

#TPFDB0B 2 BYTE ALPHA-NUMERIC OR 1849 ORDINALS


SPECIAL CHARACTERS (0-1848)

USER SUPPLIED ORDINAL AS DEFINED IN THE FACE TABLE


#TPFDB0C NUMBER IN 2 BYTE FIELD FOR THIS RECORD TYPE

#TPFDB0D AS DEFINED IN THE FACE TABLE


DEPENDS UPON THE LREC
(FOR USE WITH FIXED LENGTH FOR THIS RECORD TYPE
NUMBER IN THE FILE
LRECS)

#TPFDB0F
FOR PARTITIONED FILES AS DEFINED IN THE FACE TABLE
10 BYTE STRING FOR THIS RECORD TYPE

AS DEFINED IN THE FACE TABLE


#TPFDBFF FOR INDEXED DETAIL FILES FOR THE INDEX RECORD OF THIS
RECORD

 Older names of the algorithms beginning with #ACPDBxx is also supported

TPFDF Application Programming page 43 of 12421


© Aviation Software Development Consultancy India Ltd.
Defining TPFDF Files and LREC's

 A TPFDF File is defined at two places

 The File DSECT Definition


 The Database Definition or the DBDEF

 The DSECT apart from describing the Lay out of the logical records in the file also specifies the following
information

 The File name


 The Size of the Blocks (For Prime and Overflow)
 The File record type ( If Prime Fixed)
 Algorithm to be used
 TPFDF Option Byte settings

 Sample DSECT Definitions

&SW00WID SETC 'AB' FILE ID


&SW00ILV SETC '0' MAXIMUM INTERLEAVING FACTOR IF APPLIC
&SW00PTN SETC '0' NUMBER OF PARTITIONS
&SW00BOR SETC '0' BASE ORDINAL NUMBER
&SW00EOR SETC '-1' END ORDINAL NBR
&SW00WRS SETC 'L1' BLOCK SIZE
&SW00ARS SETC 'L1' ALTERNATE BLOCK SIZE
&SW01EO# SETC '&SW00EOR' RECOUP END ORDINAL
&SW00RCT SETC '#ASDCTRN' FACE FILE TYPE
&SW00RBV SETC '#TPFDB01' FILE ALGORITHM
&SW02FIL SETC 'TRABSQ' FILE DSECT NAME
&SW00OP1 SETC '00000000' OPT BYTE1 (SEE SRGA-09-SAMP DOCUMENT)
&SW00OP2 SETC '00000110' OPT BYTE2 (SEE SRGA-09-SAMP DOCUMENT)
&SW00OP3 SETC '00000000' OPT BYTE3 (SEE SRGA-06-SAMP DOCUMENT)
&SW00TQK SETC '15' HIGHEST TLREC

TPFDF Application Programming page 44 of 12421


© Aviation Software Development Consultancy India Ltd.
Defining TPFDF Files and LREC's

 File DSECT Naming Conventions

TPFDF File DSECT Names are of 6 Characters Length

A A N N C C
APPLICATION TYPE FILE IDENTIFIER COMPANY CODE
The First Character of the Application Type identifies the Type of application the DSECT Belongs to . Example
A Accounting

APPLICATION TYPE FILE IDENTIFIER COMPANY CODE

The First Character of the Application Type identifies the Type of application the DSECT Belongs to .

Example
A Accounting
C Cargo
F Fare quote/ticketing
G General functions
L Host to Host
M Message switching
R Passenger reservation
S System software
W Departure control system

The Second Character of the Application Type , identifies the type


of File
G General Data Set
P Traditional (Non-TPFDF File)
R Real time Files (Prime Fixed or Pool)
W Work File , Exists Only for Life of an ECB
T Temporary Lrec stored in W-type File

TPFDF Application Programming page 45 of 12421


© Aviation Software Development Consultancy India Ltd.
Defining TPFDF Files and LREC's

The 3rd and 4th Character of a DSECT Name is a unique identifier that makes the FILE Unique across an Application

The 5th and 6th Characters forms a 2- Character Company code from where the DSECT Originated From

Example :

WR20SQ , Is a TPFDF Real time file (Fixed or Pool) used by DCS

RWT2SQ Is a TPFDF Work file used by Reservations

 The Database definition or the DBDEF is a macro coded in a System real time program by the Database
administrator for each TPFDF File

 The DBDEF Programs are assembled and loaded to the TPF System and forms a Central DBDEF Table that
resides in core

 The Central DBDEF Table is looked up by the TPFDF Programs when applications perform operations on TPFDF
Files

 The DBDEF Table is also used by other TPFDF Components such as the Online utilities , Validation , Capture ,
Restore , Data collection and Recoup

 The DBDEF picks up File related data such as record ID , Record type , Block sizes etc .. from the File DSECT,

Example
DBDEF FILE=TRABSQ,
(ITK=#TRABK80,ID2=(CHK0),
RID=TR2CSQ,ADR=TRABCAR-TRABBID)

TPFDF Application Programming page 46 of 12421


© Aviation Software Development Consultancy India Ltd.
Defining TPFDF Files and LREC's
SAMPLE DSECT :
.**********************************************************************
.* DEFINITIONS FOR TPFDB *
.**********************************************************************
&SW00WID SETC 'AB' FILE ID
&SW00ILV SETC '0' MAXIMUM INTERLEAVING FACTOR IF APPLIC
&SW00PTN SETC '0' NUMBER OF PARTITIONS
&SW00BOR SETC '0' BASE ORDINAL NUMBER
&SW00EOR SETC '-1' END ORDINAL NBR
&SW00WRS SETC 'L1' BLOCK SIZE
&SW00ARS SETC 'L1' ALTERNATE BLOCK SIZE
&SW01EO# SETC '&SW00EOR' RECOUP END ORDINAL
&SW00RCT SETC '#TRABSQ' FACE FILE TYPE
&SW00RBV SETC '#TPFDB01' FILE ALGORITHM
&SW02FIL SETC 'TRABSQ' FILE DSECT NAME
&SW00OP1 SETC '00000000' OPT BYTE1 (SEE SRGA-09-SAMP DOCUMENT)
&SW00OP2 SETC '00000110' OPT BYTE2 (SEE SRGA-09-SAMP DOCUMENT)
&SW00OP3 SETC '00000000' OPT BYTE3 (SEE SRGA-06-SAMP DOCUMENT)
&SW00TQK SETC '15' HIGHEST TLREC
.**********************************************************************

* STANDARD ACPDB HEADER *


***********************************************************************
TRABHDR&CG1 DS CL16 STANDARD FILE HEADER
DS CL10 STANDARD ACPDB HEADER
TRABVAR&CG1 EQU * START OF VARIABLE USER-AREA
TRABHDL&CG1 EQU TRABVAR&CG1-TRABHDR&CG1 HEADER-LENGTH UP TO CR8IVAR
ORG TRABHDR&CG1
TRABREC&CG1 DS 0CL1 1ST RECORD START (1=VARIABLE,ELSE SIZE)
TRABSIZ&CG1 DS H SIZE OF LOGICAL RECORD
TRABKEY&CG1 DS X LOGICAL RECORD IDENTIFIER
***********************************************************************
* EQUATE OF LOGICAL RECORD KEYS (KEY AND LENGTH) *
***********************************************************************
#TRABK10 EQU X'10' LOGICAL RECORD KEY X'10'
#TRABK80 EQU X'80' LOGICAL RECORD KEY X'80'
#TRABL10 EQU TRABE10&CG1-TRABREC&CG1 LENGTH OF LOGICAL RECORD X'10'
#TRABL80 EQU TRABE80&CG1-TRABREC&CG1 LENGTH OF LOGICAL RECORD X'80'
TRABORG&CG1 EQU * START OF LOGICAL RECORD DESCRIPTION
.*
***********************************************************************
* HEADER ITEM KEY = X'10' *
***********************************************************************
TRABPAR&CG1 DS CL2 DATE OF LAST UPDATE (PARS DATE)
TRABLNI&CG1 DS CL2 LAST UPDATE LNIATA
TRABE10&CG1 EQU * END OF LOGICAL RECORD WITH KEY = X'10'
ORG TRABORG&CG1
***********************************************************************
* KEY = X'80' *
***********************************************************************

TPFDF Application Programming page 47 of 12421


© Aviation Software Development Consultancy India Ltd.
TRABAWB&CG1 DS CL11 AWB NUMBER
TRABSTA&CG1 DS X STATUS OF AWB
TRABPCS&CG1 DS CL3 NUMBER OF PIECES
TRABIWT&CG1 DS CL2 CONSIGNMENT WEIGHT
TRABORN&CG1 DS CL3 ORIGIN CITY
TRABDES&CG1 DS CL3 DESTINATION CITY
TRABCAR&CG1 DS XL4 CAR DETAIL RECORD FILE ADDRESS
TRABE80&CG1 EQU * END OF LOGICAL RECORD WITH KEY=X'80'
ORG TRABORG&CG1
.**********************************************************************

TPFDF Application Programming page 48 of 12421


© Aviation Software Development Consultancy India Ltd.
Defining TPFDF Files and LREC's

 LRECS Can be organized within a file in a Particular order ascending or descending or without any order at all

 These LRECS can be organised UP or DOWN on a KEY , Where the KEY can be a Combination of upto 6 fields
in an LREC

 If Organisation is UP , LRECS are stored in ascending order of Key fields , If DOWN Organised LRECS are stored
n Descending order of Key fields , On NOORG Organisation no particular order is are maintained when LRECS
are stored

 The Organisation can be coded in the DBDEF or can be specified on TPFDF Command macros , The DBDEF
Key Organisation (Default Keys) precedes over command macro key Organisation if both are specified when
adding LRECS

 KEY Organisations once set will be in effect till an application issues a command macro with a different
Organisation or a NOKEY Option

TPFDF Application Programming page 49 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Interface Block : The SW00SR

 Whenever any Subfile is opened by an application program , TPFDF retrieves the file information of the file from
the central database definition table and copies information into an internal workarea called as the Database
Interface Block (DBIFB)
 The DBIFB has several slots in it , One for each opened Subfile , The SWOOSR Slot hence functions as the
working copy of the DBDEF table and maintains information relevant to the current status of operations on the
Subfile
 The Base of the SWOOSR Slot is always Register R3 , Hence all programs using TPFDF need to code SW00SR
REG=R3 , at the beginning of the program , Also "Do Remember that TPFDF hence Reserves register R3 For its
use "
 Important SW00SR DSECT Fields

SW00SR FIELD DISPLACEMENT DESCRIPTION


SW00WID 010 2 Byte Record ID of required File
4 Byte File address of Prime
SW00FAD 044
Record
1 Byte TPFDF Command Return
SW00RTN 081
Indicator
SW00REC 084 4 Byte Address of Located Record
SW00RT2 0DB 1 Byte 2nd Return Indicator
SW00WKA 260 4 Byte Address of Workarea

 Also Available are 2 user fields , SW00USI a 1-Byte user Indicator Field and SW00USA a 4-Byte user address
field

TPFDF Application Programming page 50 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Level Usage & Register Conventions

 TPFDF Reserves Some data levels for use to Process the TPFDF Command macros

 By Default TPFDF uses 4 data levels , D9,DA,DB,DC

 Data levels are used Sequentially and then wrapped around using DETAC's , The default level usage order of
assignment is DA,DB,DC,D9,DA,DB,DC,D9… , At SQ the order is D9,DA,DB,DC,D9,DA,DB,DC … , The first and
the fifth opened TPFDF Files use the same Data level

 Files are held at these datalevels , When Overflow block is processed the Prime is detac'ed

 Level DD is used internally by TPFDF , However TPFDF DETAC's it and ATTAC's only while processing
command macros , Level DD is used to hold the SW00SR and also for Tape operations and File Packing

 SW00SR is carved out of a 4K Block , Each Block can hold 5 SW00SR Slots , The 6 th Slot Onwards is carved out
from an overflow 4K Blocks

 ECB Field CE1DBS has the address of the DBIFB

 Usage of data levels D9,DA,DB,DC and DD is forbidden

 Register R3 is Reserved as the SW00SR Base , R14 & R15 are unpredictable across a TPFDF Command Macro

TPFDF Application Programming page 51 of 12421


© Aviation Software Development Consultancy India Ltd.
Advantages and Disadvantages of TPFDF

 Advantages of using TPFDF

 Relieves Applications from being aware of Physical size , Pool Type and location of data
 Standard Procedures to read,modify,update,add,delete Files
 Logical reference to data
 Programmer doesn't have to worry about chaining of overflows , Space available in a Physical Block
 Increases Productivity , Minimal Application enhancement efforts
 Easy Portability of applications , Good to use features such as Online utilities to modify the database ,
Database validation
 Essential Support packages such as Capture/Restore , Recoup , Data collection
 File Commit Option
 No need to learn and code TPF Macro's (Advantage !!)
 Can Maintain Records in a Preferred Organisation
 Automatic Optimal usage of file storage (Packing)
 Can also Operate on Tapes and General data sets

TPFDF Application Programming page 52 of 12421


© Aviation Software Development Consultancy India Ltd.
Advantages and Disadvantages of TPFDF

 Disadvantages of using TPFDF

 Huge Resource usage , More core blocks and lot of Detacs/Attacs


 Enters a number of TPFDF Programs (Beginning with UF)
 Increase in Number of Instructions executed and Processing time
 Programmers tend to forget basic TPF Macros , Functions and Parameters

TPFDF Application Programming page 53 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF File Commands and Command Sequence

 The Following Commands/Operations can be performed on a TPFDF File , These Commands Work on a Subfile
Level and Optionally on a range of Subfiles or the entire File

 FILE OPEN : This Command is the Basic Command and is a Pre-requisite to most of the TPFDF
Command Macros , Sets up the SW00SR slot for the File

 READ : To Read a LREC From s Opened Subfile

 ADD : To Add an LREC to a Opened Subfile

 DELETE : To Delete an LREC(s) From a Subfile

 MODIFY : To Modify an LREC that has been read previously

 REPLACE : To Replace an LREC which is read previously with a new LREC

 DISPLAY : To Display LRECS From the current Subfile

 CLOSE : To stop processing a Subfile , Removes SW00SR Slot

 CREATE : Get a Pool Prime Record and Create a New TPFDF Subfile

 CLEAR : Non-Committal exit Without CLOSING Opened Subfiles , LREC Modifications not written to
DASD lost

 RETAIN : To save File address , Core address and Displacement in the block of the current LREC

TPFDF Application Programming page 54 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF File Commands and Command Sequence

 SPACE : Allocate Free workarea space in the DBIFB For an opened Subfile

 DBIFB : To Find Base address of any SW00SR Slot which has been opened previously

 DBADR : Calculate Ordinal Number Given an Algorithm argument , Used to select a Range of Subfiles for
TPFDF Operations

 COPY : To Copy a Subfile into Pool blocks

 RESTORE : Restore a Subfile Previously copied using TPFDF COPY Command

 CHECKPOINT : To save Blocks of opened Subfile into DASD , Issues FILNC Macro on all blocks of the
opened Subfile

 SORT : Sort LRECS From an input Subfile onto another Subfile

 MERGE : To Merge LRECS From input Subfile into a Target Subfile

 FREE LEVEL : Free a datalevel from TPFDF For normal TPF Use

 DBKEY : To define a list of keys for use with subsequent TPFDF Command macros with a Subfile

 UNIQUE KEY : To get a Unique 4-bye Key value to use in LRECS

TPFDF Application Programming page 55 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF File Commands and Command Sequence

 READ TAPE : Read Subfile from an input Tape

 LOAD TAPE : To write Subfile onto DASD

 LOG TAPE : To write Subfile onto a Real time tape or general tape

 INDEX : To create an INDEX to the prime block of a Subfile in its index Subfile

 DEINDEX : To remove the INDEX Lrec for the detail Subfile from its top level indices

 OPEN Should be the First Command for any Subfile .

 MODIFY , DELETE , REPLACE Should follow either a READ or an ADD

 All opened Subfiles should be Closed before EXIT

 Invalid Command Sequences can cause TPFDF dumps , And so will EXIT without closing all opened Subfiles
(Unless CLEARED)

TPFDF Application Programming page 56 of 12421


© Aviation Software Development Consultancy India Ltd.
Chapter 3

TPFDF General Macros

TPFDF Application Programming page 57 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF General Macros - Contents

 Coding a TPFDF Command macro

 Common Parameters used in TPFDF Command Macros

 TPFDF Macros : OPEN a Subfile -- DBOPN

 TPFDF Macros : Read an LREC -- DBRED

 TPFDF Macros : Close a Subfile(s) – DBCLS

 Checking Return conditions of TPFDF Command macros

 TPFDF Macros : ADD an LREC -- DBADD

 TPFDF Macros : Delete an LREC -- DBDEL

 TPFDF Macros : Modify an LREC -- DBMOD

 TPFDF Macros : Replace an LREC – DBREP

 TPFDF Macros : Miscellaneous General Macros

TPFDF Application Programming page 58 of 12421


© Aviation Software Development Consultancy India Ltd.
Coding a TPFDF Command macro

 A TPFDF Command macro consists of the Command macro and its Optional and Mandatory Parameters

 Parameters are either Positional or Keyword

 Most of the Parameters are commonly used across many of the TPFDF Command macros

 TPFDF command macros whose parameters exceed one line in the Program should be continued in the next line,
A continuation character should be entered in Column 72

 The continued line's last character should be a comma ,The continued line should begin at column 16

 Command Macros can be coded within SPM Constructs such as DO Loops and IF-THEN-ELSE Loops

 TPFDF Command macros can be coded in one of the 3 Formats

 ACPDB OPEN,REF=TRABSQ,REG=R7,HOLD,DETAC
 TPFDB OPEN,REF=TRABSQ,REG=R7,HOLD,DETAC
 DBOPN REF=TRABSQ,REG=R7,HOLD,DETAC

 Although all 3 Formats primarily perform the same task , The last of the 3 formats is preferred and is advisable to
use these , Since IBM has announced that new features only would be supported for the last two formats from
PUT5 Onwards

TPFDF Application Programming page 59 of 12421


© Aviation Software Development Consultancy India Ltd.
Common Parameters used in TPFDF Command Macros

 "REF =" Parameter :

Code a DSECT name of the TPFDF File or a reference to the DSECT name ,either an 8-byte field containing
the file reference name or a 4 byte field containing the address of the reference name

When coded alongside the TPFDF OPEN Command , Allocates a SW00SR Slot for the opened Subfile and
also loads register R3 With the SW00SR Slot address , The same reference is used to refer to the Subfile for
subsequent commands on the Subfile

The DSECT Name makes up the Subfile reference for the SW00SR Slot in the SW00SR Block

Example :

DBOPN REF=TRABSR
DBOPN REF=EBW000
DBOPN REF=A/EBW000

 "FILE =" Parameter :

If the First 6 Characters of the REF= Parameter is not the name of the DSECT then it is mandatory to code the
FILE= parameter and supply the DSECT Name through it

Using FILE= on command macros means that the application has set up R3 to point to the required SW00SR
slot on its own behest

 "SUFFIX =" Parameter :

Code a character as an argument , Generates using statement for the DSECT With the suffixed character

TPFDF Application Programming page 60 of 12421


© Aviation Software Development Consultancy India Ltd.
Common Parameters used in TPFDF Command Macros

 Parameters to choose one Subfile of the TPFDF File :

One of the following 3 Parameters have to be coded in order to choose the Subfile (All 3 are mutually exclusive)

 The "ALG=" Parameter

Code an Algorithm string value here that pertains to a Subfile , a Label, an A/Label, Register or an Absolute
value can be specified here .

Example :

EXAMPLE :
DBOPN REF=TRABSQ,ALG==C'A'
DBOPN REF=TRABSQ,ALG=A/EBW000
DBOPN REF=TRABSQ,ALG=EBW000
DBRED REF=TRABSQ,REG=R3,ALG=EBX096

 The "ORD=" Parameter

Code a label or a A/label as an argument that contains a 4-byte field containing an Ordinal number of a fixed
file (Prime of a Subfile) in the TPFDF File

EXAMPLE :
DBOPN REF=TRABSQ,ORD=EBX024
DBOPN REF=WR36SQ,REG=R5,ORD=WKAORD

 The "FADDR=" Parameter

Code a parameter which contains the label of a 4-byte location that contains the File address of the Subfile you
want to operate on

EXAMPLE :

DBOPN REF=TR2CSQ,FADDR=TRABCAR

TPFDF Application Programming page 61 of 12421


© Aviation Software Development Consultancy India Ltd.
Common Parameters used in TPFDF Command Macros

 More than One Subfile of the same file DSECT can be referenced by using different REF Names

EXAMPLE :
DBOPN REF=TRABSQ01,ALG==C'A'
DBOPN REF=TRABSQ02,ORD=EBW000

Each opened Subfile hence would have a Different SW00SR slot , While accessing the Subfile the same
SW00SR Ref name has to be specified

 The Following Parameters are Commonly used with TPFDF Command Macros to specify the LREC(s) to operate
on with TPFDF Command macros

LREC(s) are selected for TPFDF Command operations by using one of the three following parameters

 KEYn Parameters , This Parameter in itself has sub-parameters which are either positional or
keyword
 LRECNBR Parameter
 NOKEY Parameter
The "KEYn" Parameter :

Upto 6 Key Parameters KEY1,KEY2..KEY6 Can be set up with a TPFDF Command macro , These must be
specified in ascending order and are connected with Boolean AND Operation

If KEYn Parameters are specified Organisation of the keys also should be specified , Once Keys and
Organisation are setup for a Subfile it remains in effect until another TPFDF macro is issued with another set of
Key parameters or Keys are nullified using the NOKEY Parameter

TPFDF Application Programming page 62 of 12421


© Aviation Software Development Consultancy India Ltd.
Common Parameters used in TPFDF Command Macros

 Object codes for Key Comparison is generated at the end of the program after the Literal Organisations , during
run time this code is transferred to the SW00SR slot's SW00KL1 which is a 108 Byte Key 1 to 6 Instruction
execution area in the SW00SR

 Sub Parameters used with the KEYn Parameter

Each KEYn Parameter has subparameters coded within Parenthesis following the Keyword KEYn=

Available Parameters :

R=, S=, L=, C=, D=, M= , UP|DOWN|NOORG , PKY=

 The "R=" subparameter :

Specifies the Field in the LREC to be compared with the search argument specified with the "S="
Subparameter , The argument must be a valid LREC Field of the REF= DSECT

This argument results in generating the Target part of the Assembler instruction generated in base
displacement format , Displacement can be decided at run time using the D/Label , Where label is either
a Difference of two labels or a decimal displacement within the LREC

EXAMPLE :

DBRED REF=TRABSQ,UP,KEY1=(R=TRABKEY,S=X'80'),
KEY2=(R=TRABAWB,S=MI0ACC+10)
DBRED REF=TRABSQ,UP,KEY1=(R=TRABKEY,S=X'80'),
KEY2=(R=D/TRABAWB-TRABKEY,S=MI0ACC+10)
DBRED REF=TRABSQ,UP,KEY1=(R=TRABKEY,S=X'80'),
KEY2=(R=D/3,S=MI0ACC+10)

TPFDF Application Programming page 63 of 12421


© Aviation Software Development Consultancy India Ltd.
Common Parameters used in TPFDF Command Macros

 The "S=" subparameter :

Specifies the Value to compare with against the field in the LREC specified with the "R=" Subparameter,
Specify a label,A/label,register(That contains address of search argument),equate(CLI Instruction
Generated),I/Value, or a Literal ( CP instruction Generated if Literal =P is coded)

This argument results in generating the Source part of the Assembler instruction generated in base
displacement format

EXAMPLE :

DBRED REF=TRABSQ,UP,KEY1=(R=TRABKEY,S=#TRABK80),
KEY2=(R=TRABAWB,S=MI0ACC+10)
DBRED REF=TRABSQ,UP,KEY1=(R=TRABKEY,S=X'80'),
KEY2=(R=TRABAWB,S==C'AB123456789')

 The "L=" subparameter :

Specifies the length of data to compare between the "R=" and "S=" subparameter Fields , Defaults to
length of the target field specify a label of a 2-byte field which has the length,Length(s) using L'Label(s)
or a halfword literal , can be coded only along side the S= parameter (except with sort and merge
Commands) ,

EXAMPLE :

DBRED REF=WRK0SQ,UP,KEY1=(R=WRK0KEY,S=#WRK0K80),
KEY2=(R=WRK0ALC,S=MI0ALC), * Default Length
KEY3=(R=WRK0CNA,S=MI0CNA,L=EBW000), *Dynamic Length
KEY4=(R=WRK0FLN,S=MI0FLN,L=L'WRK0ALC+L'WRK0FLN),
KEY5=(R=WRK0BPT,S=MI0BPT,L==H'3')

TPFDF Application Programming page 64 of 12421


© Aviation Software Development Consultancy India Ltd.
Common Parameters used in TPFDF Command Macros

 The "M=" and "D=" subparameter :

Specify the "M=" Subparameter to specify a 1-Byte mask as the search argument , M= is mutually
exclusive with the L= Parameter and the D= Parameter , Generates a TM instruction , The mask value
should be specified as an immediate value

EXAMPLE :

DBRED REF=TRABSQ,
KEY1=(R=TRABKEY,S=#TRABK80,UP),
KEY2=(R=TRABAWB,S=MI0ACC+10,UP),
KEY3=(R=TRABSTA,M=X'20',O)

Specify the "D=" Subparameter to specify a 1-Byte Dynamic mask to be decided at run time , Specify a
label or a location (A/Label) of a 1-Byte field where the mask will be set up at run time

EXAMPLE :

DBRED REF=TRABSQ,
KEY1=(R=TRABKEY,S=#TRABK80,UP),
KEY2=(R=TRABAWB,S=MI0ACC+10,UP),
KEY3=(R=TRABSTA,D=EBX033,O)

 The "C=" subparameter :

Specify the condition that has to be satisfied on the Key compare of the R= and S=/D=/M=
subparameter arguments

The compare codes that can be used with the S= Subparameter :

GT, LT, NE, EQ, NH, NL, GE, LE , E , H , L .

The R= Subparameter will be on the left side of the compare and the S= Subparameter on the right ,
Defaults to EQ if C= not specified with S=

TPFDF Application Programming page 65 of 12421


© Aviation Software Development Consultancy India Ltd.
Common Parameters used in TPFDF Command Macros

 The "C=" subparameter (Continued…) :

The compare codes that can be used with the D= or M= Subparameter :

Z, O , M , NZ , NO , NM

The R= Subparameter will be on the left side of the compare and the D= or M= Subparameter on the
right , It is mandatory to code the C= Parameter for D= or M= , If not coded an MNOTE (severity 8 )
and an unconditional branch instruction following the TM are generated

 The UP|DOWN|NOORG subparameter

The DOWN , UP and NOORG subparameters specifies the Organisation of the key

DOWN Specifies that the key fields are in Descending order in the Subfile

UP Specifies that the key fields are in ascending order in the Subfile

NOORG Specifies that the key fields are in no specific order in the Subfile

If the Organisation is same for all the Keys specified in the TPFDF Command macro , The
organisation can be specified as a Parameter to the TPFDF Command macro , and applies to all
subsequent Key definitions

The Default Key Organisation is NOORG

 Do not Define a UP or DOWN Key Organisation after a NOORG on any of the Keys, With TPFDF PUT9 it has
become mandatory to code an Organisation explicitly for each key , Unless you have common ORG For all keys .

TPFDF Application Programming page 66 of 12421


© Aviation Software Development Consultancy India Ltd.
Common Parameters used in TPFDF Command Macros

 The UP|DOWN|NOORG subparameter (Continued..)

EXAMPLE :

DBRED REF=TRABSQ,
KEY1=(R=TRABKEY,S=#TRABK80,UP),
KEY2=(R=TRABAWB,S=MI0ACC+10,UP),
KEY3=(R=TRABSTA,D=X'FF',O,NOORG)

DBRED REF=TRABSQ,
KEY1=(R=TRABKEY,S=#TRABK80,UP),
KEY2=(R=TRABAWB,S=MI0ACC+10,UP),
KEY3=(R=TRABSTA,D=X'FF',O),
KEY4=(R=TRABORG,S==C'MAA',NE)

Key Organisation set up is generated as part of the Assembler listing for all TPFDF Command macros

Default Key Organisation for D=/M= Keys and all Subsequent Keys is NOORG, Always watch for these
statements if you have not followed KEY Organisation rules , MNOTES will be generated to Warn/Inform you

 The "LRECNBR" Parameter :

Specify the Sequence number of the LREC that you want to read or write , Code a register , A 4-byte field ,
A/Label the label which contains the address of the 4-Byte Field or an Immediate value

First LREC Number in Prime block is LREC Number 1, KEYn and LRECNBR can be coded together , On
ADD Command new LREC is added after the LREC Sequence number specified in LRECNBR

 The "NOKEY" Parameter :

Code this to deactivate any previously active keys , Used to Process without any KEYS all LRECS
Processed from current LREC.

TPFDF Application Programming page 67 of 12421


© Aviation Software Development Consultancy India Ltd.
Common Parameters used in TPFDF Command Macros

 The "ERROR=" Parameter

Specify a SPM label defined using #LOCA to branch to on a error when executing a TPFDF
command macro

 The "ERRORA=" Parameter

Specify a Assembler label to branch to on a error when executing a TPFDF command macro

 The "REG=" Parameter

On Successful Completion of a command macro , TPFDF Returns the base address of the LREC
that has been processed , With READ Command it is the address of the LREC that has just been
read , With ADD Command it is the address of the recently added LREC

 The "NODUMP" Parameter

Code this parameter on TPFDF Command macros if you want TPFDF not to dump on a Severe error
. Avoid using this Parameter as far as Possible

TPFDF Application Programming page 68 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Macros : OPEN a Subfile -- DBOPN

 The DBOPN is coded for a Subfile before performing other operations on it , Create SW00SR Slot in the DBIFB ,
Refers to the DBDEF , Also generates USING statement with the specified register also generates SUFFIXED
labels if SUFFIX Parameter is coded

 Mandatory Parameters for DBOPN

REF= | FILE= (or both)

 Optional Parameters for DBOPN

REG= , SUFFIX=

ALG= | ORD = | FADDR =

BEGORD = | ENDORD = (or both)

BEGORD : Beginning Ordinal Number to be used overriding start Ordinal

ENDORD : For choosing a range of Subfiles

WRAPAROUND

WRAPAROUND : Used with FULLFILE option of READ

UP|DOWN|NOORG

KEYn(R=,S=|D=|M=,L=,C=.UP|DOWN|NOORG) (n=1..6)

HOLD|NOHOLD

HOLD : Code HOLD if you intend modifying the Subfile , Similar to coding FIWHC , If SW00OP2 BIT6 is set on
and File is modified without issuing a Hold a DB010C Dump is taken

TPFDF Application Programming page 69 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Macros : OPEN a Subfile -- DBOPN

 Optional Parameters for DBOPN (Continued…)

NOHOLD : Code this when you want to perform read only operations on this Subfile , NOHOLD is the Default

DETAC

If DETAC is specified , Each block of the Subfile read is kept in Main storage , Updates not written to Disk
unless checkpointed or closed , Used for faster access of LRECS , Code for time critical applications , Closing
this Subfile with abort does not commit the changes made to DISK , This is a Unique commit mechanism
provided by TPFDF , Very Expensive Parameter , use prudently

SPACE|SPACEB

Request for Some workspace that can be used as scratch area or to build records to be added , You can
specify the number of bytes (Immediate value) , Register to hold base address of workarea , If not specified the
Application has to LOAD the workarea address from SW00WKA (Note L instruction and not a LA instruction !! )

SPACE parameter initialises storage to X'00' While SPACEB initialises to X'40'

DBOPN REF=TRABSQ,SPACE=(#TRABL80,R4)

DBOPN REF=TRABSQ,SPACEB=(#TRABL80)
L R4,SW00WKA

POOLTYP
Code this to Override the Pooltype of the Subfile , Should be 1 , 2 or 3

TPFDF Application Programming page 70 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Macros : Read an LREC -- DBRED

 The DBRED command reads an LREC From an opened Subfile , The pointer to the LREC is loaded in the
specified register coded using the REG= parameter also known as the current LREC , If LREC is not found till end
of Subfile READ sets a LREC not found indicator in SW00RTN byte , After reading the LREC Fields in the LREC
Can be accessed using DSECT Labels , Subsequent DBRED will start reading from Current LREC.

 Mandatory Parameters for DBRED

REF= | FILE= (or both)

 Optional Parameters for DBRED

REG=

ALG= | ORD = | FADDR =

UP|DOWN|NOORG

KEYn(R=,S=|D=|M=,L=,C=.UP|DOWN|NOORG) (n=1..6)

LRECNBR

NOKEY

ERROR | ERRORA

TPFDF Application Programming page 71 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Macros : Read an LREC --- DBRED

BEGIN|BACKWARD|LAST|PREVIOUS

BEGIN : Reads the first LREC matching the search argument in the Subfile regardless of where the Current
LREC Pointer is now in

Coding this in a Loop will lead to an infinite loop

BACKWARD : Reads the LREC immediately preceding the current LREC

Mutually Exclusive with the KEYn and LRECNBR Parameters

LAST : Reads the last LREC that matches the search argument in the Subfile

PREVIOUS : A previously retained LREC using the DBRET Command can be read later using the DBRED
PREVIOUS Command

STACK|STACKREF

Used in Conjunction with the DBRET Command macro will be discussed later

LIST

Lets you specify a list of LRECS to be read , Specify a register


That contains the address of the list , The list contains the list of LRECS separated by '/' , also range of
LRECS can be specified using the '-' , LAST and ALL are keywords that can be used in the LIST

Example of LIST Structure :

1/7/9/10/13
1/3/5-7/9/12-3
1/2/9/13-LAST

TPFDF Application Programming page 72 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Macros : Read an LREC -- DBRED

ADJUST

Used in conjunction with the LIST Parameter to specify the adjustment factor on the values in the list , If
Adjustment factor is 2 and LIST is 1/5/9 , DBRED reads 3 and 7 also.

FAST

Used to fasten the DBRED Processing , TPFDF generates Inline code in this case , Cannot be used with
KEYn , LRECNBR parameters , Previously active keys are deactivated , Typically used to read all LRECS in
a Subfile.

FULLFILE

Allows you to read from a Range of Subfiles , BEGORD and ENDORD of DBOPN restricts the range of
Subfiles for the fullfile operation

HEADER
To locate the header of the Prime block of a Subfile , Core address of the block is returned . When used with
FULLFILE locates the header of the next Subfile

EXAMPLES:

DBRED REF=TRABSQ,REG=R4
DBRED REF=WRZ2SQ,REG=R5,LAST
DBRED REF=RRPISQ,REG=R5,FULLFILE
DBRED REF=AR32SQ,REG=R5,UP
KEY1=(PKY=#AR32K80)
KEY2=(R=AR32SLJ,S=AR20SLJD)

NOTE : CODING PKY=#AR32K80 is EQUIVALENT TO CODING


KEY1=(R=AR32KEY,S=#AR32K80,EQ)

TPFDF Application Programming page 73 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Macros : Close a Subfile(s) – DBCLS

 The DBCLS command is usually the last command macro issued on a Subfile , Files all updates made to the
Subfile to DASD , Need to code regardless of modification to Subfile to release blocks and SW00SR slot , All
opened Subfiles should be closed before EXITC , Can close more than One Subfile with one call

 Mandatory Parameters for DBCLS

REF= | FILE= (or both),

REF=ALL can be coded to close all open Subfiles

NODUMP

 Optional Parameters for DBCLS

ABORT=

ABORT is coded for closing a Subfile without filing blocks to DASD , Use only when opened in the DETAC
mode

ALG= | ORD = | FADDR = , SUFFIX=

RELEASE|NORELEASE|REUSE

RELEASE , Releases the SW00SR Slot and is the default , if NORELEASE is coded the SW00SR slot is not
released , You may perform a subsequent Command on the Subfile

REUSE

SW00SR Slot , Key parameters are retained , SW00FAD is zeroised , can issue a subsequent DBRED with a
different ALG | ORD | FADDR , Cannot use REUSE and RELEASE together.

TPFDF Application Programming page 74 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Macros : Close a Subfile(s) – DBCLS

RELFC

Release the Subfile , Equivalent to deleting the entire Subfile , The prime file address and all its chains are
released , If Prime is Fixed all chains are released and Prime is initialised
W-type files are automatically released with DBCLS

NEWREF

Specify a New REF name can be used with either NORELEASE or REUSE to rename the SW00SR Slot
reference

PACK|NOPACK

Deleting LRECS leaves empty space in the Blocks , TPFDF Packs the Subfile if the amount of LREC Space
falls below a specified percentage in the block, LRECS are moved between blocks to fill up empty space and
empty overflow resulting from the PACK operation is returned to the system .

PACK , Force packs the file regardless of available free space


NOPACK restricts PACK operation regardless of space used

EXCLUDE|INCLUDE=(LIST=)

Takes as argument list of REF names to specify which files are to be closed , Used with the REF=ALL
parameter , Specify an area where the list of files to be closed are defined

EXAMPLES:

DBCLS REF=ALL,INCLUDE=(TRABSQ,WRX8SQ)
DBCLS REF=ALL,EXCLUDE=(TRABSQ,WRX8SQ)
DBCLS REF=ALL,INCLUDE=(LIST=EBW000)

At EBW000 the first Halfword should contain the number of files


in the list , Followed by 8 character ref names

TPFDF Application Programming page 75 of 12421


© Aviation Software Development Consultancy India Ltd.
Checking Return conditions of TPFDF Command macros

 The Following Return codes can be checked on return from TPFDF Command macros

SW00RTN Conditions returned from TPFDF Commands

SW00RTN Return code Condition encountered


#BIT0 ON I/O Error
#BIT1 ON LREC Not Found
#BIT2 ON FACE return error
#BIT3 ON ALGORITHM error
#BIT4 ON Data in Block is Corrupted
#BIT5 ON EOF
#BIT6 ON Sequence error in data
#BIT7 ON Sort/Merge error

Bits 0,2,4,7 ON on TPFDF Command macros cause system error dumps with return to the application

TPFDF Application Programming page 76 of 12421


© Aviation Software Development Consultancy India Ltd.
Checking Return conditions of TPFDF Command macros

 TPFDF has defined equates to test SW00RTN Values

Return value SW00RTN Condition


#TPFDBEX (X'AB') Any error except index
#TPFDBER (X'BB') Any error
#TPFDBNR (X'44') LREC not found
#TPFDBOK (X'00') No error , Record found

 TPFDF Provides short form of testing SW00RTN using SPM's as follows

DBFOUND(YES|NO) Check if LREC Found


DBERROR(YES|NO) Check if error occurred
DBEOF(YES|NO) Check End of file condition
DBIDX(YES|NO) Check for INDEX errors

 SW00RT1 has the count of total errors while FULLFILE Processing

 SW00RT2 #BIT0 on means error in LIST= specification


#BIT1 FMSG/OMSG error during DBDSP

TPFDF Application Programming page 77 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Application Programming page 78 of 12421
© Aviation Software Development Consultancy India Ltd.
TPFDF Macros : ADD an LREC --- DBADD

 The DBADD command adds a new LREC to a subfile , Facilitates addition of LREC BEFORE or AFTER the
current LREC , At a position in the subfile as defined by keys and organisation , By supplying a LRECNBR or at
the end of the subfile

 Mandatory Parameters for DBADD

REF= | FILE= (or both)

NEWLREC= | NULLREC =

NEWLREC : Specify the address of the new LREC to be added as the argument , can specify a label
(Length > 3) , A/label or a register , For Variable length lrecs size and key should have been set up in the new
LREC

NULLREC : To add an empty LREC to a subfile , specify a location that contains the length of the empty LREC
(register|label|A/label) and the primary key of the empty LREC , Adding a NULLREC to a UP/DOWN organised
subfile might corrupt the organisation . Normally used with W-type and T-type files

EXAMPLE :

DBADD REF=TRABSQ,NEWLREC=EBW000,UP
KEY1=(R=TRABKEY,S=EBW002),
KEY2=(R=TRABAWB,S=EBW003,L=L'TRABAWB)
DBADD FILE=WRXXSQ,UP,PKY=#WRXXK10,REG=R5,
KEY1=(PKY=#WRXXK10),NULLREC==AL2(#WRXXL10),
ERROR=ADDERROR

TPFDF Application Programming page 79 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Macros : ADD an LREC -- DBADD

 Optional parameters for DBADD

ALG= | ORD = | FADDR = , SUFFIX=

REG=

UP|DOWN|NOORG

KEYn(R=,S=|D=|M=,L=,C=.UP|DOWN|NOORG) (n=1..6)

ERROR|ERRORA

LRECNBR

FAST

FAST : Generates Inline code , cannot be used with KEYn Parameters , Active keys get deactivated

AFTER|BEFORE

AFTER : Add LREC after the current LREC located previously using a DBRED

BEFORE : Add LREC Before the current LREC located previously using a DBRED

INDEX

INDEX : Creates the Index slot in the parent record for this subfile (Used with TPFDF Indexed files)

UNIQUE

UNIQUE: Adds the LREC only if there is no matching LREC previously existing in the subfile as per the key
specification , The UNIQUE=YES can be coded in the DBDEF to make it a default option with all DBADDS for
the file

TPFDF Application Programming page 80 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Macros : ADD an LREC -- DBADD

KEYLIST :

KEYLIST : To define a list of keys to be used with DBADD , Setting up the Keylist will be dealt later , Specify
the address of the keylist area in a register , label or A/label

EXAMPLES :

DBADD REF=TRABSQ,NEWLREC=EBW000,AFTER

DBADD REF=TRABSQ,NEWLREC=EBW000,BEFORE

DBADD REF=TRABSQ,NEWLREC=TRABRECA,UP,UNIQUE,
KEY1=(R=TRABKEY,S=#TRABK80),
KEY2=(R=TRABAWB,S=TRABAWBA,L=L'TRABAWB)

Use UNIQUE,BEFORE or AFTER with DBADD's to improve program efficiency

TPFDF Application Programming page 81 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Macros : Delete an LREC -- DBDEL

 The DBDEL command deletes an LREC from a subfile , Can delete the current LREC , LREC(s) with matching
KEYn combinations also can delete by supplying a LRECNBR or a LRECNBR and KEYn combination , By default
deletes current LREC

 Mandatory Parameters for DBDEL

 REF= | FILE= (or both)

 Optional parameters for DBDEL

ALG= | ORD = | FADDR = , SUFFIX=

REG=

UP|DOWN|NOORG

KEYn(R=,S=|D=|M=,L=,C=.UP|DOWN|NOORG) (n=1..6)

ERROR|ERRORA

LRECNBR

BEGIN

BEGIN : Starts from the beginning of the subfile before searching for LRECS to delete

ALL

ALL: All LRECS in the subfile will be deleted if specified , When used with the KEYn parameters deletes all
matching records , If ALL records of subfile is deleted if the prime is a pool record then all the prime and
overflow files will be released back to the system , If prime is fixed , it is filed to DASD and its overflows are
released

TPFDF Application Programming page 82 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Macros : Delete an LREC -- DBDEL

FULLFILE

FULLFILE : If specified alongside ALL deletes every LREC in every Subfile of the file as defined by BEGORD
and ENDORD of DBOPN

KEYLIST:

ALG:

LAST:

LAST : To delete the last LREC in a subfile , can also be used with KEYn parameters in which case the LAST
matching lrec will be deleted

NEXT:

NEXT : Deletes the next LREC after the current LREC

LIST:

LIST: When used with NEXT deletes all LRECS described in the LIST structure seperated by / and -

EXCLUDE|INCLUDE:

INCLUDE : LRECS getting deleted may have references to other files (Embedded address of pool subfiles) ,
These subfiles can also be deleted by coding the INCLUDE= parameter , code within brackets the reference of
the subfile or ALL

EXCLUDE : Embedded subfile can be excluded from getting deleted EXCLUDE= parameter code within
brackets the reference of the subfile or ALL

TPFDF Application Programming page 83 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Macros : Modify an LREC -- DBMOD

 The DBMOD command lets you to modify the fields in the existing LREC , However the modified LREC and the
old copy of the LREC should be of the same size , Should also ensure that Key fields that are used for
organisation are not changed so as not to mess up the organisation

 Modification is applied to the current LREC

 Mandatory Parameters for DBMOD

 REF= | FILE= (or both)

 Optional parameters for DBMOD

REG

EXAMPLES :

DBRED REF=TRABSQ,UP,REG=R4,ERROR=READERROR,
KEY1=(PKY=#TRABK80),
KEY2=(R=TRABAWB,S=MI0AWB)

#IF (DBFOUND,YES) THEN


#IF TRABSTA,NE,X'FF' THEN
MVI TRABSTA,X'FF'
DBMOD REF=TRABSQ
#ELSE
#GOTO ITEM_ALREADY_CANCELLED
#EIF
#ELSE
#GOTO AWB_NOT_BOOKED
#EIF

TPFDF Application Programming page 84 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Macros: Replace an LREC --- DBREP

 The DBREP is used to replace the current LREC with a new LREC that is supplied , Similar to DBMOD the
difference being that the size of the new LREC can be different from the old LREC , The Key fields used for
organisation however should be the same

 If the key fields are to be changed , One should DELETE the old LREC and ADD the new LREC , so that the new
LREC finds its place according to the file organisation

 Mandatory Parameters for DBREP

REF= | FILE= (or both)

NEWLREC=

 Optional parameters for DBREP

ERROR= | ERRORA

REG=

EXAMPLE:

DBRED REF=TRABSQ,UP,REG=R4,ERROR=READERROR,
KEY1=(PKY=#TRABK80),
KEY2=(R=TRABAWB,S=MI0AWB)
#IF (DBFOUND,YES) THEN
#IF TRABSTA,EQ,X'20' THEN
MVC EBW000(#TRABL80),TRABSIZ
MVC EBW000+#TRABL80(L'EXPLOSIVE),EXPLOSIVE
LH R6,EBW000
LA R6,L'EXPLOSIVE(,R6)
STH R6,EBW000
DBREP REF=TRABSQ
#ELSE
#GOTO ITEM_NOT_EXPLOSIVE
#EIF
#ELSE
#GOTO AWB_NOT_BOOKED
#EIF

EXPLOSIVE DC C'ITEM EXPLOSIVE'

TPFDF Application Programming page 85 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Macros : Miscellaneous General Macros

 The TPFDF Command macros that are discussed in this section are

 DBCRE
 DBADR
 DBDSP
 DBKEY
 DBSPA
 DBIFB
 DBFRL
 DBCLR

 The DBCRE Command Macro :

This command creates a subfile whose prime block is a pool file , Performs the GETFC function internally , also
sets up the SW00SR slot for the new subfile , The pool type depends upon the DSECT name (Can be
overridden using the POOLTYP parameter or in the DBDEF) , The size is determined from the DBDEF

 Mandatory Parameters for DBCRE

REF= | FILE= (or both)

 Optional parameters for DBCRE

ALG=

ERROR|ERRORA

POOLTYP

TPFDF Application Programming page 86 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Macros : Miscellaneous General Macros

INDEX=

INDEX: INDEX is coded to also update the Index LREC for this subfile along with creation of the subfile

EXAMPLE:

DBRED REF=TRABSQ,UP,REG=R4,ERROR=READERROR,
KEY1=(PKY=#TRABK80),
KEY2=(R=TRABAWB,S=MI0AWB)
#IF (DBFOUND,YES) THEN
#IF TRABCAR,EQ,=F'0'THEN
DBCRE REF=TR2CSQ,REG=R5
MVI EBW002,#TR2CK40
MVC EBW003(11),MI0AWB
MVC EBW014(L'NAME),NAME
LA R2,L'TR2CSIZ+L'TR2CKEY+L'TR2CAWB+L'NAME
STH R2,EBW000
DBADD REF=TR2CSQ,NEWLREC=EBW000
MVC TRABCAR,SW00FAD
DBCLS REF=TR2CSQ
#ELSE
#GOTO 'CAR_ALREADY_BOOKED'
#EIF
#ELSE
#GOTO AWB_NOT_BOOKED
#EIF

 The DBADR Command Macro :


This command allows you to find a file address given an algorithm or an ordinal number or to associate a REF
to a range of subfiles

 Mandatory Parameters for DBADR

REF= | FILE= (or both)


ALG|ORD|BEGALG|ENDALG (or both BEGALG & ANDALG)

TPFDF Application Programming page 87 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Macros : Miscellaneous General Macros

ALG = When given the Algorithm string returns the file address in SW00WR1 and the ordinal number in
SW00WR2

BEGALG & ENDALG = Use this to calculate the beginning ordinal and the end ordinal for the range of
subfiles , Subsequent DBRED's with the FULLFILE option will read LRECs in the entire range of subfiles ,
BEGALG updates SW00ORD with the ordinal number and ENDALG updates SW00END with the end ordinal
number , Argument is the algorithm supplied using a Label,A/label or a literal

 Optional parameters for DBADR

ERROR|ERRORA

BEGORD|ENDORD=

BEGORD : Specify a label or a A/label to pass an ordinal number to be copied to SW00ORD

ENDORD : Specify a label or a A/label to pass an ordinal number to be copied to SW00END

BEGORD or ENDORD cannot be used with BEGALG or ENDALG

IBM recommends BEGALG|ENDALG in favour of BEGORD|ENDORD

WRAPAROUND

WRAPAROUND : If begin ordinal is greater than end ordinal use this parameter to wraparound when FACE
end ordinal is encountered.

EXAMPLE:

DBADR REF=TRABSQ,BEGALG=='A',ENDALG=='O'
DBRED REF=TRABSQ,FULLFILE .. THIS CAN GO ON IN A LOOP ...

TPFDF Application Programming page 88 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Macros : Miscellaneous General Macros

 The DBDSP Command Macro :

This command allows you send output to a terminal selected LRECS from an opened subfile , LRECS must be
made of valid printable EBCDIC characters

Mandatory Parameters for DBDSP


REF= | FILE= (or both)

Optional Parameters for DBDSP

ALG|FADDR|ORD

KEYn(R=,S=|D=|M=,L=,C=.UP|DOWN|NOORG) (n=1..6)

UP|DOWN|NOORG|SUFFIX

ERROR|ERRORA

FULLFILE

NOCLOSE :

Subfile not closed after the display , Do not use with FULLFILE or specifying that control should be returned to
program

NOFINAL

NOFINAL: To let TPFDF know that this is only part of the display not the Final one

NOUIO

NOUIO : Returns control back to application after Display

TPFDF Application Programming page 89 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Macros : Miscellaneous General Macros

RELFC

RELFC : Closed Subfile (By default) is released

STRIP

STRIP : Data in the LREC(s) that need not be displayed can be specified using this label , Specify a 2-Byte
label or a register(Other than R14/R15) or a literal to specify the part of the LREC that you want to discard ,
The 2-Byte size field in variable length Lrecs is automatically discarded so need not include that in the strip
count

EXAMPLE:

DBDSP REF=WRK2SQ,KEY1=(PKY=#WRK2K20),
STRIP==AL2(WRK2NAM-WRK2KEY)

 The DBKEY Command Macro :

This command macro allows you to define a list of keys for use with a subfile , Upto 6 keys can be specified ,
These keys can then be used with DBRED,DBADD,DBDEL using the KEYLIST parameter

Mandatory Parameters for DBKEY

REF= | FILE= (or both)

TPFDF Application Programming page 90 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Macros : Miscellaneous General Macros

KEYLIST

KEYLIST : Specify a register or a label or a A/label which had the address of the keylist , The keylist should
have been set up previously following the format given below , Described by DSECT SW01SR

SW01NKY DS H NUMBER OF KEY PARAMETERS DEFINED (MAX 6)


SW01KIT DS 0XL12 KEY ITEM LENGTH
SW01DIS DS AL2 DISPLACEMENT (R=.....)
SW01LEN DS AL2 LENGTH (L=.....)
SW01CON DS XL1 COMPLEMENT OF REQUIRED CONDITION CODE IN
* BRANCH INSTRUCTION EG
* EQ=X'70',NE=X'80',GT=X'D0',NH=X'20',
* LT=X'B0',GE=X'40',
* Z =X'70',O =X'E0',M =X'B0',NZ=X'80',
* NM=X'40',NO=X'10'
SW01MSK DS XL1 TM INSTRUCTION IF NE X'00' MASK ELSE CLC
SW01SEA DS AL4 CORE ADDRESS WHERE SEARCH ARGUMENT IS
* NOT USED IF SW01MSK IS SET
SW01ID1 DS XL1 OPTION INDICATORS
* BIT 0 = 1 DOWN ORGANISED
* BIT 1 = 1 UP ORGANISED
* BIT 2 = 1 SPARE
* BIT 3 = 1 2ND BASE
* BIT 4 = 1 CLI WITH MASK IN SW01MSK
* MASK IS RIGHTADJ. IN SW01FDS
* BIT 5 = 1 CP INSTRUCTION
* BIT 6 = 1 TM INSTRUCTION
* MASK IS RIGHTADJ. IN SW01FDS
* BIT 7 = 1 RESERVED (NOT USED HERE)
SW01ID2 DS XL1 SPARE BYTE
ORG SW01NKY

 The DBSPA Command Macro :


This command macro allows you to get work space in the TPFDF interface block , can be used to add space to
an open file (Update SW00WKA)

Mandatory Parameters for DBSPA

REF= | FILE= (or both)

TPFDF Application Programming page 91 of 12421


© Aviation Software Development Consultancy India Ltd.
SPACE|SPACEB

TPFDF Macros : Miscellaneous General Macros

IF SPACE or SPACEB was used with DBOPN and if DPSPA is issued then the original allocated space is
zeroised

EXAMPLE:

DBSPA REF=TRABSQ,SPACEB=(#TRABL80,R5)

 The DBIFB Command Macro :


This command macro is used to check if a subfile is open and if opened returns the SW00SR slot base
address

Mandatory Parameters for DBIFB

REF= (Refname|Label|A/label|FIRST|NEXT)

FIRST : Gets the SW00SR slot address in R3 of the first opened subfile

NEXT : Subfile opened next to the current subfile

Both FIRST and NEXT return with R14 pointing to 8-Byte location of the REF name

Optional Parameters for DBIFB

ERROR|ERRORA

NEWREF

NEWREF : Allows to change Refname if located

REG=

EXAMPLE:
DBIFB REF=WRMBSQ
#IF (R3,NZ)
DBCLS REF=WRMBSQ
#EIF

TPFDF Application Programming page 92 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Macros : Miscellaneous General Macros

 The DBFRL Command Macro :

This command macro is used to Free a data level used by TPFDF for use by the Application

Mandatory Parameters for DBFRL

REF= (Refname|Label|A/label|ALL) |FILE=|LEVEL=|

ALL: Sets R3 to 0 , Detaches all blocks held by all open subfiles at all TPFDF datalevels

LEVEL : Specify a datalevel in Hex X'0' to X'F' or symbolically as A to F or DA to DF , Cannot be used with
REF= parameter

EXAMPLE:

DBFRL REF=CRTJSQ
DBFRL LEVEL=DA

 The DBCLR Command Macro :

DBCLR lets you exit the program without closing any open subfiles and without generating a dump.
Usage not Recommended , For Emergency Exit use DBCLS with the Abort Option.

EXAMPLE:

DBCLR REF=CRTJSQ

TPFDF Application Programming page 93 of 12421


© Aviation Software Development Consultancy India Ltd.
Chapter 4

TPFDF Advanced Macros

TPFDF Application Programming page 94 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Advanced Macros - Contents

 TPFDF Subfile Macro : Checkpoint a Subfile – DBCKP

 TPFDF Subfile Macro : Copy a Subfile – DBCPY

 TPFDF Subfile Macro : Restore a Subfile – DBRST

 TPFDF Advanced Macro : SORT a File – DBSRT

 TPFDF Advanced Macro : MERGE 2 Files – DBMRG

 TPFDF TAPE Macro : Write File to tape – DBTLG

 TPFDF TAPE Macro : Read File from tape – DBTRD

 TPFDF TAPE Macro : Write File to DISK – DBTLD

 TPFDF Indexing Support

 TPFDF Index Support Macro : Create Index LREC – DBIDX

 TPFDF Index Support Macro : Delete Index LREC – DBDIX

 TPFDF Partitioning and Interleaving

TPFDF Application Programming page 95 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Subfile Macro : Checkpoint a Subfile - DBCKP

 The DBCKP Command allows to checkpoint to database updates made to a TPFDF File , TPFDF files all the
blocks of the Subfile to DISK (issues the FILNC Macro) , The current LREC pointer remains.

 Mandatory Parameters for DBCKP

REF= | FILE= (or both),

 Optional Parameters for DBCKP

ERROR|ERRORA

REG=

DETAC|NODET

DETAC : Subfile is put into DETAC mode after checkpointing ,

NODET : Puts Subfile in Normal mode after checkpointing

EXAMPLES:

DBCKP REF=TRABSQ,REG=R4
DBCKP REF=TRABSQ,REG=R4,DETAC,ERROR=DBERROR

TPFDF Application Programming page 96 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Subfile Macro :Copy a Subfile - DBCPY

 The DBCPY command copies the subfile into pool files , close the original subfile and uses the pool copy for all
subsequent TPFDF Commands on the subfile , Uses the default pooltype for the file.

 Mandatory Parameters for DBCPY

REF= | FILE= (or both),

 Optional Parameters for DBCPY

ALG|FADDR|ORD

ERROR|ERRORA

POOLTYP

TOADD=(LABEL,HELD)

TOADD : Specify a 4-byte Label giving the location of the prime block you want the block copied to

HELD : If specified issues a FINWC instead of FIWHC

EXAMPLES:

DBCPY REF=TRABSQ
DBCPY REF=TRABSQ,TOADD=(EBW000,HELD)

TPFDF Application Programming page 97 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Subfile Macro : Restore a Subfile - DBRST

 The DBRST command restores a subfile previously copied using a DBCPY

 Mandatory Parameters for DBRST

REF= | FILE= (or both),

RSTRADD=Label,HELD

RSTRADD : specify a label of a 4-byte field containing the file address to which the currently opened subfile
has to be restored , If this address is zero then TPFDF creates a new subfile

HELD : If coded opens the target subfile with FINWC macro , Use this when you want to restore a subfile which
is held

 Optional Parameters for DBRST

ALG|FADDR|ORD

ERROR|ERRORA

SUFFIX=

REG=

TPFDF Application Programming page 98 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Subfile Macro : Restore a Subfile - DBRST

FLIP

FLIP: Code this if the 2 Subfiles (The previously copied pool subfile and the target subfile )

FROMCHAIN:

FROMCHAIN: Only restore of prime block is done , Only chaining is performed for overflow blocks instead of
getting new pool blocks

EXAMPLES:

DBOPN REF=TR00SQ,ALG=MI0ALG
DBRED REF=TR00SQ,REG=R4
MVC EBW000,SW00FAD
DBCPY REF=TR00SQ
MVC EBW004,SW00FAD
DBRED REF=TR00SQ,REK=R4,KEY1=(PKY=#TR00K80)
DBDEL REF=TR00SQ
DBCLS REF=TR00SQ,REUSE
DBRST REF=TR00SQ,FADDR=EBW004,RSTRADD=EBW000,ERROR=RSTERR

TPFDF Application Programming page 99 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Advanced Macro : SORT a File - DBSRT

 The DBSRT command creates a copy of a file and sorts it according to the KEYn parameters provided

 Mandatory Parameters for DBSRT

REF= | FILE= (or both),

REF = The Ref name of the subfile where the sorted records will be stored

INPUTREF=

INPUTREF : Specify the name of the input subfile , Specify the REF name or an A/label
Both References in REF= and INPUTREF= should have been opened previously.

UP|DOWN:

 Optional Parameters for DBSRT

ERROR|ERRORA

KEYn(R=,S=|D=|M=,L=,C=.UP|DOWN|NOORG) (n=1..6)

KEYLIST

FULLFILE

POOLTYP

TPFDF Application Programming page 100 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Advanced Macro : SORT a File – DBSRT

RELEASE

RELFC

RELEASE and RELFC are to release the SW00SR of the inputref and to release the blocks of the inputref after
the sort

EXAMPLES:

DBOPN REF=CR00SQ,FADDR=CRABCAR
DBRED REF=CR00SQ,REG=R4,BEGIN
DBIFB REF=CR00SQ,NEWREF=CR00SQA
DBOPN REF=CR00SQ,HOLD,DETAC
DBCRE REF=CR00SQ
DBSRT REF=CR00SQ,INPUTREF=CR00SQA,UP,RELEASE,
KEY1=(CR00KEY),
KEY2=(CR00NAM),
KEY3=(CR00CTY)

TPFDF Application Programming page 101 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Advanced Macro : MERGE 2 Files – DBMRG

 The DBMRG allows to merge two TPFDF files or subfiles into one output file

 Mandatory Parameters for DBMRG

REF= | FILE= (or both),

REF= The Ref name of the subfile where the Merged records will be stored

INPUTREF=

INPUTREF : Specify the name of the input subfile to be merged with the subfile in REF=
Both References in REF= and INPUTREF= should have been opened previously

 Optional Parameters for DBMRG

ERROR|ERRORA

KEYn(R=,S=|D=|M=,L=,C=.UP|DOWN|NOORG) (n=1..6)

KEYLIST

FULLFILE

RELEASE

RELFC

TPFDF Application Programming page 102 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Advanced Macro : MERGE 2 Files – DBMRG

UP|DOWN

UP|DOWN : Specify UP or DOWN to indicate the Order in which LRECS have to be read from the input subfile
(High key to Low key OR Low key to high key)

One cannot have the output file opened in the DETAC mode

Should ensure input subfile and target subfile are in the same sorted order

TPFDF Application Programming page 103 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Tape Macro : Write File to tape - DBTLG

 The DBTLG allows to write a file to a Real time or general tape

 Mandatory Parameters for DBTLG

REF= | FILE= (or both),

TAPE=

TAPE : Specify the name of the tape , Directly by 3 character name or by a label or A/label pointing to 3
character tape name

 Optional Parameters for DBTLG

FADDR|ORD|ALG

ERROR|ERRORA

KEYn(R=,S=|D=|M=,L=,C=.UP|DOWN|NOORG) (n=1..6)

KEYLIST

FULLFILE

INCLUDE ( LIST=|ALL)

INITIALISE : Initialises DASD file after writing to tape

DELETE : Deletes all lrecs in subfile after writing to tape

EXAMPLES:

DBTLG REF=CR00SQ,TAPE=ABC,FULLFILE,DELETE,INCLUDE=(ALL)

TPFDF Application Programming page 104 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF TAPE Macro : Read File from tape – DBTRD

 The DBTRD reads a subfile created by DBTLG or by offline programs into main storage

 Mandatory Parameters for DBTRD

REF= | FILE= (or both),


TAPE=

 Optional Parameters for DBTRD

ERROR|ERRORA

REG=

EXAMPLES:

DBOPN REF=CR00SQ,HOLD
DBTRD REF=CR00SQ,TAPE=ABC

TPFDF Application Programming page 105 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF TAPE Macro : Write File to DISK - DBTLD

 The DBTLD writes a subfile from main storage read in by DBTRD to DASD

 Mandatory Parameters for DBTLD

REF= | FILE= (or both),

 Optional Parameters for DBTLD

ERROR|ERRORA

REG=

CREATE = Creates new files when writing to DISK and not use the original addresses

EXAMPLES:

DBOPN REF=CR00SQ,HOLD
DBTRD REF=CR00SQ,TAPE=ABC
DBTLD REF=CR00SQ

TPFDF Application Programming page 106 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Indexing Support

 TPFDF Supports organising the database into an indexed structure hence enabling to construct a Hierarchical
database and to locate Lrecs quicker than to go for a Sequential search

 TPFDF Supports 3 Mechanisms to Implement Indexing

1. Block Indexing
2. B+Tree Indexing
3. TPFDF Indexing
4.
The 1st and the 2nd Indexing mechanisms are used for quick location of lrecs in a subfile
The 3rd Index mechanism helps in organising the database into a Hierarchical structure.

BLOCK INDEXING

 Algorithms and Keys provide the identity for an LREC in a particular subfile , But to locate this LREC TPFDF has
to search all LRECS in the subfile sequentially trying to match the key specifications

 This slows down the search considerably when the subfile has a number of LRECS and hence a number of
overflow blocks and I/O's

 For Files using the Block Indexing support TPFDF Maintains TLRECs (Technical LREC's) in the prime block of
the subfile

TPFDF Application Programming page 107 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Indexing Support

 There exists one TLREC for each overflow block , Each TLREC contains the File address of the overflow block
and the Key field of the first LREC in the overflow block on which the file is Organised

 using block indexing does not affect normal TPFDF command processing except that the LRECs are located
faster than they would be if Block indexing is not used

 TLREC's have a primary key 02 , These LRECS are updated every time the first LREC in a overflow block is
deleted or when the subfile is packed or closed

 Block Indexing requires the Key fields on which the Blocks are indexed to be unique ,UP or DOWN organised and
LRECS should be of variable length , You cannot add null lrecs to a block indexed file

 The SW00TQK Field in the DSECT has to be updated with the key field length in the LRECS on which the Block
indices have to be set up

 The TLRECs are held only in the Prime block and that poses a limit on the number of overflows that can be block
indexed , The remaining LRECS are searched sequentially

TPFDF Application Programming page 108 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Indexing Support

B+TREE Indexing

 Similair to Block indexing support , uses index TLRECs to identify the first data LREC in each block of a subfile

 TLRECs not maintained in Prime block of subfile , are maintained in separate B+tree structure

 TPFDF retrieves the block containing the LREC directly after looking at the B+tree index , The LRECS are
searched sequentially in the block later

 Each subfile using B+tree indexing has a B+tree structure for it

 SW00OP3 bit 5 is set on to indicate Block indexing for a TPFDF File

 Removes restrictions posed by Block indexing on the number of blocks that can be indexed , Poses a host of
other limitations on TPFDF Command macros and Option byte settings

 B+tree indexing support has been included to the TPFDF Program product from PUT level 5 onwards

TPFDF Application Programming page 109 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Indexing Support

TPFDF File Indexing

 TPFDF File indexing allows organising the database into a hierarchical structure , The structure is made up of
parent files called as Index files and child files called as detail files

 LRECS in the index file are called as the Index lrecs and typically each index lrec would have a pointer to a detail
file or to a subsequent index file (2nd Level Index)

 Several Index files can refer to the same detail file , This is called as Multiple indexing

 One Index LREC can be pointing to more than one indexed detail file

 The Top level index files should be fixed files , The subsequent indices and the detail files are usually pool files
with algorithm #TPFDFFF

 Index LRECS apart from containing the file address of the detail file also have Key fields that relate to the detail
file

 The detail files can be directly opened using an algorithm string , The Alg string in this case is made up of atleast
two parts where one part of the Alg string is for deciding the subfile of the top level index and the other part is for
searching the Index file lrecs as the key field

 The Index files are maintained by TPFDF , using indexing allows for easy access of detail files and reduces the
number of TPFDF Command macros in application programs

TPFDF Application Programming page 110 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Indexing Support

 TPFDF Provides 2 command macros to create indices and to remove indices for detail files

 DSECT and the DBDEF has to be defined for an index structure specially , The DBA would be able to assist you
in this regard

TPFDF Application Programming page 111 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Index Support Macro: Create Index LREC - DBIDX

The DBIDX Command macro

 The DBIDX command macro allows you to update index or indices for a indexed detail record

 Mandatory Parameters for DBIDX

REF= | FILE= (or both),

ALG=

ALG: The algorithm string specified here decides on which subfile the index lrec has to be updated to and also
the contents of the index lrec

Optionally using the DBADD with INDEX an LREC to the detail file automatically updates the index for this
detail file

EXAMPLES:

DBOPN REF=WRA2SQ,HOLD,SPACE=#WRA2SQWKA
DBCRE FILE=WRA2SQ,ERROR=DBCRERR
DBIDX REF=WRA2SQ,ALG=MI0NAM

If the Alg name was MICHAELG and if the first character was to decide the subfile (Alg - TPFDB01) , Then
the index LREC would be created in ordinal 12 and if the index lrec key is the first 5 characters of the name
the index lrec would look like

000D 80 A1234567 00 MICHA

TPFDF Application Programming page 112 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Index Support Macro : Delete Index LREC – DBDIX

The DBDIX Command macro

 The DBDIX command macro allows you to delete index or indices for a indexed detail record

 Mandatory Parameters for DBDIX

REF= | FILE= (or both),


ALG=

 There is no INDEX option with DBDEL so on deletion of the detail subfile the application has to delete the indices
using the DBDIX command

EXAMPLES:

DBOPN REF=WRA2SQ,HOLD,ALG=MI0NAM
DBDEL FILE=WRA2SQ,ALL
DBDIX REF=WRA2SQ,ALG=MI0NAM
DBCLS REF=WRA2SQ,RELEASE,RELFC

TPFDF Application Programming page 113 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Partitioning and Interleaving

 The ordinals in a File can be divided into different parts such that each of the group of ordinals (subfiles) belong to
a different partitions or interleaves

 This is a logical mechanism of separating the database for different purposes (Poor man's MDBF)

 The number of partitions or interleaves are specified in the DSECT in the SW00PTN and SW00ILV parameters
respectively , cannot be implemented using Miscellaneous files

 Example :

If there are 100 ordinals for a TPFDF file and if it has 4 partitions ,
then partitions 1 thru 4 each would have 25 ordinals ,
0..24,25..49,50..74,75..99

Ordinal 0 for partition 1 is 0 , while for partition 2 it is 25 , 50 for


partition 3 and 75 for partition 4

If there are 100 ordinals for a TPFDF file and if it has 4 interleaves ,
then interleaves 1 thru 4 each would have 25 ordinals , Interleave 1 would
consist of ordinals 0,4,8,12,16,20… 96 . Interleave 2 would consist of
ordinals 1,5,9,13,17,21… 97 . Interleave 3 would contain ordinals
2,6,10,14,18,22… 98 and interleave 4 3,7,11,15,19,23…99

Ordinal 0 for interleave 1 is 0, While for interleave 2 it is 1 , 3 for


interleave 3 and 4 for the last interleave

TPFDF Application Programming page 114 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Partitioning and Interleaving

 Advantage of partitioning the database is the ease of adding a new partition

 Disadvantage of partitioning comes when one needs to increase the number of ordinals in a partition

 Advantage of Interleaving is that the number of ordinals in an interleave can be increased easily

 Disadvantage is the number of interleaves cannot be increased

 Two parameters are provided with TPFDF that can be used to specify the partition number and the interleave
number , These are allowed with most of the TPFDF Command macros

The INTERLV= Parameter

Specify a Register an absolute value or a label indicating the location of a 2-byte field containing the number of
interleave that you want the command macro to perform operation on , Can be used with
DBOPN,DBRED,DBADD,DBDEL

The PARTITN= Parameter

Specify a Register an absolute value or a label indicating the location of a 2-byte field containing the partition number
that you want the command macro to perform operation on , Can be used with DBOPN,DBRED,DBADD,DBDEL

TPFDF Application Programming page 115 of 12421


© Aviation Software Development Consultancy India Ltd.
Chapter 5

TPFDF Nuggets

TPFDF Application Programming page 116 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Application Programming page 117 of 12421
© Aviation Software Development Consultancy India Ltd.
TPFDF Nuggets - Contents

 Sample DSECTS for coding TPFDF DSECTS

 OA Entries for Online Maintenance of TPFDF Files

 TPFDF Option Byte Settings

 TPFDF System Dumps

TPFDF Application Programming page 118 of 12421


© Aviation Software Development Consultancy India Ltd.
Sample DSEC TS for coding TPFDF DSECTS

 Use the Following Sample DSECTS as the template for coding New application DSECTS .

DSECT Name Description


SAM1SR R-type Fixed file (Prime Fixed)
SAM2SR R-type Pool file (Prime Pool)
SAM3SR W-type file
SAM4SR R-type top level Index file
SAM5SR R-type Detail file or lower level index file
SAMBSR R-type B+tree Index file

TPFDF Application Programming page 119 of 12421


© Aviation Software Development Consultancy India Ltd.
OA Entries for Online Maintenance of TPFDF Files

 Following is a list of OA entries that can be used to Online maintain the TPFDF Database .

OA Entry Description
OAI/DBTAB Display Central DBDEF table
OAI/ Initialise OAI Work File
OA/FADDR Initialise specifying file address
OA* TPFDF File display
OAI/DBTAB/DSECT/REC
OAI/DBTAB/DSECT/DBG
OAI/DBTAB/DSECT/REC
OAI/DBTAB/DSECT/IDX Display DBDEF for dsect
OAI/DBTAB/DSECT/PGN
OAI/DBTAB/DSECT/COM

OAA Add an LREC


OAF Display chains
OAG For General data sets display
OAINIT Initialise TPFDF File (Dangerous entry)
OAR Replace an LREC
OAX Delete an LREC
OAS Use with SST for display of SW00SR and Blocks
OAZ TOD-Clock conversion
OAH TPFDF Online utility help display

TPFDF Application Programming page 120 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Option Byte Settings

SW00OP1 Settings :

Bit Number Implication


Implement Full backward chaining , Needs to be set up
BIT0
for DBRED BACKWARD
Implement Automatic chain correction , Truncates
BIT1 chain if TPFDF finds broken chain , Data may be lost if
set
Implement Current files , Set SW00NOC , wraps
BIT2 around lrecs and keeps only the latest data , can be set
for log files
Implement Push down chaining , always adds new
BIT3
lrecs to the prime block
Issue checkpoint for each DBUKY macro , A
BIT4 mechanism to ensure serialisation of adding related
lrecs
If set SW00WRS is the size of prime block , SW00WRS
size is first taken for overflow block and should it
BIT5
exceed the size converts it into a SW00ARS sized
block
Checks for packing value always regardless of a
BIT6
DBDEL macro
BIT7 Maintains file sequence upd counter

TPFDF Application Programming page 121 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF Option Byte Settings

SW00OP2 Settings :

Bit Number Implication


Validates NAB every time a block is filed , Processing
BIT0
overhead involved
BIT1 New pool blocks used for files after packing
New pool blocks are used for restore and old blocks are
BIT2
released
New pool blocks are used for tape load and old blocks
BIT3
are released
To be able to update a file using a FINWC and without
BIT4
a hold , No DB010C dump issued
BIT5 Same as above but for overflow blocks
Issue a DB010C dump when file is modified without
BIT6
issuing a HOLD
BIT7 Reserved for future use

TPFDF Application Programming page 122 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFD F Option Byte Settings

SW00OP3 Settings :

Bit Number Implication


BIT0 Set up for Extended Lrecs
BIT1 Reserved for Future use
BIT2 Reserved for Future use
BIT3 Fixed file with index files referring to it
BIT4 Checkpoint each time an Index lrec is added or deleted
BIT5 Set this file for B+tree indexing
Default open with DETAC mode on the file (Expensive
BIT6
operation)
BIT7 Set this up if the Unique Key feature is to be used

TPFDF Application Programming page 123 of 12421


© Aviation Software Development Consultancy India Ltd.
TPFDF System Dumps

DUMP NUMBER DESCRIPTION


DB0100 FINWC/FIWHC Error on data level
DB0101 Illegal item size found in item
DB0102 Face error return
DB0104 Illegal NAB found in block
DB0105 Invalid TPFDB request (sequence)
DB0106 R3 not loaded on SW00SR
DB0107 FINWC error on level D
DB0108 FILNC I/O error on data level
DB0109 Too many files opened concurrently
DB010A File ID not found in DBTAB
DB010B FMSG error
DB010C File update without hold option in open
DB010D FILNC on SW00LVL with bad nab
DB010E No block found after attac
DB010F BAD block – NAB disagrees
DB0110 Create not first command
DB0111 TAPE = Parameter missing in Tapelog
DB0112 File open at exit time
DB0115 REF = was not found serrc exit
DB0116 Invalid algorithm value defined
DB0117 Add with default keys can not be resolved
DB0118 File id not found in DBTAB (taperead)
DB0119 Bad block size found on tape (taperead)
DB011A Level D not allowed
DB011B Find error level D for rel.file(RELFC)
DB011C Invalid addr in FADDR=
DB011E Space=/spaceb= exceeds one phys.blk
DB011F Measurement not active
DB0120 Illegal chain loop
DB0121 Key specification incorrect
DB0123 Index/deindex on read-only path
DB0124 Cmd/param. Not allowed for p-type file
DB0125 P-type add block but no fch defined
DB0126 TPFDB UKEY unique key value exceeded
DB0127 Index lrec size too big, exceeds SPACE=
DB0128 Replace command with TAPE= is invalid
DB012D New style retain – GW06SR in error
DB0130 No space in CTIN for DBTAB table
DB0131 Duplicate ID in DBDEF table
DB0132 Tape write SYNCC error
DB0133 Error in size for DBCPY P-Type file
DB0134 MDBF information mismatch
DB0135 Invalid ssu count
DB0136 Invalid exclude item count
DB0137 Excluded ssu attempting file access
DB0138 Accessing already released pool address

TPFDF Application Programming page 124 of 12421


© Aviation Software Development Consultancy India Ltd.

You might also like