You are on page 1of 3

Logical File

Difference between Regular Logical file and Join Logical file

Regular Logical file or Multi format Logical File

1. One or more than one record format


2. Record format name is same as physical file name

Join Logical file

1. Only one record format


2. Record format name is different from physical file
3. We can view of selected fields in different physical files.

Join Logical File

1. Only one record format with the JFILE keyword specified for it
2. At least two physical file names specified on the JFILE
3. At least one join specification (J in 17th position with the JFLD keyword specified)
4. A maximum 31 secondary files
5. At least one filed name

JDFTVAL

This file-level keyword in a join logical file so the system provides default values for fields
when a join to a secondary file does not produce any records. JDFTVAL is valid only for join
logical files.

If you specify JDFTVAL, your program retrieves records for which a secondary file does not
have a corresponding record. If you do not specify JDFTVAL, a record in the primary file for
which there is no corresponding record in a secondary file is skipped.

00010A JDFTVAL
00020A R RECORD1 JFILE (PF1 PF2)
00030A J JOIN (PF1 PF2)
00040A JFLD (NAME NAME)
00050A NAME JREF (1)
00060A ADDR
00070A BAL

JDUPSEQ

This join-level keyword has to specify the order in which records with duplicate join fields
are presented when your program reads a join logical file.

JDUPSEQ (sequencing-field-name [*DESCEND])

This keyword has no effect on the ordering of unique records. If you do not specify the
keyword, the system does not guarantee the order in which records with duplicate join
fields are presented.

00010A R JREC JFILE (PF1 PF2)


00020A J JOIN (PF1 PF2)
00030A JFLD (NAME1 NAME2)
00040A JDUPSEQ (PHONE)
00050A NAME1
00060A ADDR
00070A PHONE

JFILE

The JFILE keyword is required at the record level in a join logical file. The JFILE keyword
requires a minimum of two physical file names. You can specify the same file name more
than once.

The first file is called the primary file, which is the file from which the join begins. All other
files are called secondary files. Up to 255 secondary files can be specified (256 total files on
the JFILE keyword).

JOIN

You can use file names or relative file numbers to indicate which files are to be joined. You
must specify a relative file number if the same file is specified more than once on the JFILE
keyword.

JFLD

The join fields must correspond to fields in the physical files identified on the JOIN keyword
for this join specification. The name you specify on the JFLD keyword must be the same as
the name specified in the physical file unless it was renamed in the join logical file. If you do
not specify a JOIN keyword, then the JFILE keyword is used.

JREF

You can specify either the physical file name or its relative file number. If a physical file is
named twice on the JFILE keyword, then you must specify the relative file number. The
relative file number corresponds to the physical file name specified on the JFILE keyword.
For example, specifying JREF(1) associate a field with the first physical file specified on the
JFILE keyword. Specifying JREF(2) associates a field with the second physical file specified
on the JFILE keyword.

RECORD EXISTENCE CHECK

DCL VAR (&eprfc) TYPE (*CHAR) LEN (8) value ('GEN0001')


DCLF FILE (IMRFCHL1)
OVRDBF FILE (IMRFCHL1) POSITION (*KEY 1 IMRFCHF &EPRFC)
RCVF RCDFMT (imrfchf)
MONMSG MSGID (CPF4137) EXEC (do)
SNDPGMMSG MSG ('rec not found')
goto end
enddo
sndpgmmsg msg ('rec found')
end: endpgm

Logical File Vs Open Query File

The physical file you are working with very large, creating and using a logical file will allow
an application faster than using an open query file.
Since access paths created by open query file is temporary, applications that use an access
path frequently will be more efficient using a logical file, since access path will not have to
be rebuilt every time the file is open.

You might also like