JDUPSEQ (Join Duplicate Sequence) keyword—join logical files only

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

The format of the keyword is:
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.

If more than one JDUPSEQ keyword is specified in one join specification, the order in which you specify the JDUPSEQ keywords determines the order of presentation of duplicate records. This is similar to specifying an additional key field, in that it determines the order in which records with duplicate keys are presented.

This keyword is valid only for join logical files.

In a single join specification, the total length of fields specified as to fields on the JFLD keyword and fields specified on the JDUPSEQ keyword cannot exceed 120 bytes.

The sequencing field name must be a field that (1) exists in the to file for this join specification and (2) has not been specified as a to field on the JFLD keyword for this join specification. The sequencing field name can be a concatenated field or a SST field. The sequencing field name need not be specified in the record format for the join logical file.

Optionally, you can specify *DESCEND to change the order in which duplicate records are presented. Without *DESCEND, duplicate records are presented in the following default sequences:
  • Ascending signed order for a numeric sequencing field
  • Ascending order for a character sequencing field

Examples

The following example shows how to specify the JDUPSEQ keyword.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A          R JREC                      JFILE(PF1 PF2)
00020A          J                           JOIN(PF1 PF2)
00030A                                      JFLD(NAME1 NAME2)
00040A                                      JDUPSEQ(PHONE)
00050A            NAME1
00060A            ADDR
00070A            PHONE

This example assumes that PF1 and PF2 have the following records:

PF1 NAME1 ADDR PF2 NAME2 TELEPHONE
Anne 120 1st St. Anne 555-1111
Doug 40 Pillsbury Anne 555-6666
Mark 2 Lakeside Dr. Anne 555-2222
    Doug 555-5555

There are three records for Anne in PF2, showing three telephone numbers. With JDUPSEQ specified as shown, the records are returned as follows:

NAME ADDR TELEPHONE
Anne 120 1st St. 555-1111
Anne 120 1st St. 555-2222
Anne 120 1st St. 555-6666
Doug 40 Pillsbury 555-5555

The JDUPSEQ keyword only affects the order of records when duplicates exist.

The following example assumes that the logical file is based on the same physical files as example 1. There are three records for Anne in PF2, showing three telephone numbers.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A          R JREC                      JFILE(PF1 PF2)
00020A          J                           JOIN(PF1 PF2)
00030A                                      JFLD(NAME1 NAME2)
00040A                                      JDUPSEQ(PHONE *DESCEND)
00050A            NAME1
00060A            ADDR
00070A            PHONE
     A

When you specify JDUPSEQ with *DESCEND, the records are returned as follows:

NAME1 ADDR TELEPHONE
Anne 120 1st St. 555-6666
Anne 120 1st St. 555-2222
Anne 120 1st St. 555-1111
Doug 40 Pillsbury 555-5555

The list shows Anne's telephone numbers in descending order.