SPM TPFDF1
SPM TPFDF1
SPM TPFDF1
&
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
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.
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.
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.
Disadvantage of SPM'S
Code Generated may be less efficient
Program Sizes could be much larger than equivalent code generated by traditional assembler programs
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..
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)
Conditional Expressions generate equivalent assembler instructions as specified in the Instruction field of the
Conditional Expression
The IF-ELSE Constructs help perform some process based upon a certain condition
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
The ELSEIF Condition facilitates more than one selection cases using the IF-ELSE Structure
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 :
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
#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
Example :
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
#EDO
Indicates end of #DO Construct
SPM's Generate labels automatically to branch to on conditions being satisfied / not satisfied
#DO WHILE=(CLI,EBW000,EQ,X'FF')
BAS R7,SEND_MESSAGE
#IF (TM,ALLDONE,X'00',Z) THEN
MVI EBW000,X'FF'
#EIF
#EDO
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
Execute Process atleast once , repeat Process if and only if condition is satisfied
#EDO
#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
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
#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
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
SPM'S Provide statements to exit the processing of a loop when some exceptions occur
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
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 .
These Exit SPM'S can be used with any form of the #DO loops
Example of #DOEX,#ELOP
Example of #EXIF,#OREL
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
#DO INF
#EDO
#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
However it allows you to use structured programming constructs such as #EXIF,#DOEX etc..
#DO ONCE
Start of Non-loop
#EDO
#DO ONCE
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
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
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
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
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
#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
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
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
SPM'S Provide macros to Increment a value specified in a register or a storage area by a specified value
#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
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:
Also , One does not need to repeat field names when they are Obvious ,
Example :
#IF R3,GE,R5,AND,LE,EBW000,AND,NE,=F'0'
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
#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
Introduction to TPFDF
Introduction to TPFDF
TPFDF Components
TPFDF Terminology
TPFDF , Transaction Processing Facility Database Facility is a Middle Ware Program Product
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
Command Macros translate the commands to TPF Macros which in turn perform the Physical actions on the
database
TPFDF Programs
TPF
I/O
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
Validation , Capture and Restore are utilities to Validate a TPFDF File , Capture and Restore 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
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
2 Byte Record ID
1 Byte RCC
1 Byte Control Byte
4 Byte Program Stamp
4 Byte Forward Chain
4 Byte Backward Chain
TPFDF Terminology
FILE
Header
FORWARD CHAIN Header
RECORD ID Header
Header
Header Header
LRECS
Trailer
Trailer
Trailer
Trailer
OVERFLOW BLOCKS
OVERFLOW BLOCKS
Trailer
Trailer
SUBFILE SUBFILE
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)
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
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 :
Algorithms are of two flavours namely Direct Translation Algorithms and Hashing Algorithms
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)
#TPFDB0F
FOR PARTITIONED FILES AS DEFINED IN THE FACE TABLE
10 BYTE STRING FOR THIS RECORD TYPE
The DSECT apart from describing the Lay out of the logical records in the file also specifies the following
information
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
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 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 :
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)
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
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
Also Available are 2 user fields , SW00USI a 1-Byte user Indicator Field and SW00USA a 4-Byte user address
field
TPFDF Reserves Some data levels for use to Process the TPFDF Command macros
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
Register R3 is Reserved as the SW00SR Base , R14 & R15 are unpredictable across a TPFDF Command Macro
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
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
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
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
CHECKPOINT : To save Blocks of opened Subfile into DASD , Issues FILNC Macro on all blocks of the
opened 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
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
Invalid Command Sequences can cause TPFDF dumps , And so will EXIT without closing all opened Subfiles
(Unless CLEARED)
A TPFDF Command macro consists of the Command macro and its Optional and Mandatory Parameters
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
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
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
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
Code a character as an argument , Generates using statement for the DSECT With the suffixed character
One of the following 3 Parameters have to be coded in order to choose the Subfile (All 3 are mutually exclusive)
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
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
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
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
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
Each KEYn Parameter has subparameters coded within Parenthesis following the Keyword KEYn=
Available Parameters :
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)
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')
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')
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)
Specify the condition that has to be satisfied on the Key compare of the R= and S=/D=/M=
subparameter arguments
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=
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 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
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 .
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
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
Code this to deactivate any previously active keys , Used to Process without any KEYS all LRECS
Processed from current LREC.
Specify a SPM label defined using #LOCA to branch to on a error when executing a TPFDF
command macro
Specify a Assembler label to branch to on a error when executing a TPFDF command macro
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
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
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
REG= , SUFFIX=
WRAPAROUND
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
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 !! )
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
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.
REG=
UP|DOWN|NOORG
KEYn(R=,S=|D=|M=,L=,C=.UP|DOWN|NOORG) (n=1..6)
LRECNBR
NOKEY
ERROR | ERRORA
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
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
1/7/9/10/13
1/3/5-7/9/12-3
1/2/9/13-LAST
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)
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
NODUMP
ABORT=
ABORT is coded for closing a Subfile without filing blocks to DASD , Use only when opened in the DETAC
mode
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.
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 .
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)
The Following Return codes can be checked on return from TPFDF Command macros
Bits 0,2,4,7 ON on TPFDF Command macros cause system error dumps with return to the application
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
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
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
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)
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
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
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:
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
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
REG
EXAMPLES :
DBRED REF=TRABSQ,UP,REG=R4,ERROR=READERROR,
KEY1=(PKY=#TRABK80),
KEY2=(R=TRABAWB,S=MI0AWB)
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
NEWLREC=
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
The TPFDF Command macros that are discussed in this section are
DBCRE
DBADR
DBDSP
DBKEY
DBSPA
DBIFB
DBFRL
DBCLR
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
ALG=
ERROR|ERRORA
POOLTYP
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
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
ERROR|ERRORA
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 ...
This command allows you send output to a terminal selected LRECS from an opened subfile , LRECS must be
made of valid printable EBCDIC characters
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
RELFC
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)
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
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
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)
REF= (Refname|Label|A/label|FIRST|NEXT)
FIRST : Gets the SW00SR slot address in R3 of the first opened subfile
Both FIRST and NEXT return with R14 pointing to 8-Byte location of the REF name
ERROR|ERRORA
NEWREF
REG=
EXAMPLE:
DBIFB REF=WRMBSQ
#IF (R3,NZ)
DBCLS REF=WRMBSQ
#EIF
This command macro is used to Free a data level used by TPFDF for use by the Application
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
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
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.
ERROR|ERRORA
REG=
DETAC|NODET
EXAMPLES:
DBCKP REF=TRABSQ,REG=R4
DBCKP REF=TRABSQ,REG=R4,DETAC,ERROR=DBERROR
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.
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
EXAMPLES:
DBCPY REF=TRABSQ
DBCPY REF=TRABSQ,TOADD=(EBW000,HELD)
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
ALG|FADDR|ORD
ERROR|ERRORA
SUFFIX=
REG=
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
The DBSRT command creates a copy of a file and sorts it according to the KEYn parameters provided
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:
ERROR|ERRORA
KEYn(R=,S=|D=|M=,L=,C=.UP|DOWN|NOORG) (n=1..6)
KEYLIST
FULLFILE
POOLTYP
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)
The DBMRG allows to merge two TPFDF files or subfiles into one output file
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
ERROR|ERRORA
KEYn(R=,S=|D=|M=,L=,C=.UP|DOWN|NOORG) (n=1..6)
KEYLIST
FULLFILE
RELEASE
RELFC
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
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
FADDR|ORD|ALG
ERROR|ERRORA
KEYn(R=,S=|D=|M=,L=,C=.UP|DOWN|NOORG) (n=1..6)
KEYLIST
FULLFILE
INCLUDE ( LIST=|ALL)
EXAMPLES:
DBTLG REF=CR00SQ,TAPE=ABC,FULLFILE,DELETE,INCLUDE=(ALL)
The DBTRD reads a subfile created by DBTLG or by offline programs into main storage
ERROR|ERRORA
REG=
EXAMPLES:
DBOPN REF=CR00SQ,HOLD
DBTRD REF=CR00SQ,TAPE=ABC
The DBTLD writes a subfile from main storage read in by DBTRD to DASD
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 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
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
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
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
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 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 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
The DBIDX command macro allows you to update index or indices for a indexed detail record
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
The DBDIX command macro allows you to delete index or indices for a indexed detail record
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
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
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
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
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
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
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 Nuggets
Use the Following Sample DSECTS as the template for coding New application DSECTS .
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
SW00OP1 Settings :
SW00OP2 Settings :
SW00OP3 Settings :