Linking logically related data
The following scenario addresses linking logically related data.
Problem
A file contains different LREC types. The contents of an LREC depend on the LREC ID, as follows:
- LREC ID
- Contents of LREC
- X'80'
- Surname and first name
- X'90'
- Address
- X'A0'
- Salary details
- X'B0'
- Telephone number, and so on.
Generally, information is requested by type rather than specifically (for example, by name, address, or telephone information). However, there must be a unique link connecting the address, salary, and telephone information to the name. To make this link, you could use a unique value based on the person’s name. However, this would waste space because you would have to repeat the value for all LREC types (90, A0, B0) related to a particular name.
Solution
The TPFDF product supports a unique key generator that returns a unique value for a file. You can store this value in LRECs that are related to each other. The unique key can define relationships in a file, between files, between subsystems, between systems, and between companies.
The unique key is a 4-byte hexadecimal value.
DSECT set symbols
&SW00OP3 SETC '.......1'
To hold the unique key, you must define a 4-byte field in each LREC.
DBDEF statements
No changes are necessary if the changes are made in the DSECT macro.
Application coding
In this example, a subfile is created. Name, address, and salary records are then added:
DBOPN REF=zzzzzz,HOLD
DBUKY REF=zzzzzz
TPFDF puts the unique value in field SW00UKY
To set up the LREC (including size and primary key fields):
MVC zzzzUKY,SW00UKY
Insert the unique key value into the LREC
DBADD REF=zzzzzz,KEY1=(PKY=#zzzzK80,UP)