RECID (Record Identification) Keyword for Intersystem Communications Function Files --Example

Figure 415 through Figure 418 show how to specify the RECID keyword.

Figure 415. Specifying the RECID Keyword (Default Record Format)

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A          R DFTFMT
00020A            ID             3A
00030A            FLD1          20A
00040A            FLD2           5B 0
     A
00050A          R RCD1                      RECID(1 'ABC')
00060A            ID             3A
00070A            FLD1          10S 0
00080A            FLD2           5B 0
     A
00090A          R RCD2                      RECID(1 'DEF')
00100A            ID             3A
00110A            FLD1          10S 0
00120A            FLD2           5A
00130A            FLD3           2B 0
     A

Record format DFTFMT will be the RECID default record format.

Figure 416. Specifying the RECID Keyword (Default Record Format)

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A          R RCD1                      RECID(1 'H')
00020A            ID             1A
00030A            FLD1          10A
00040A            FLD2          10A
00050A            FLD3           6S 2
     A
00060A          R RCD2                      RECID(1 'D')
00070A            ID             1A
00080A            FLD1           8S 2
00090A            FLD2          10A
00100A            FLD3           5B 0
     A
00110A          R RCD3                      RECID(1 'L')
00120A            ID             1A
00130A            FLD1          50A
     A

Record format RCD1 will be the RECID default record format. If no match is found, an escape message will be issued to your program because the RECID default record format has the RECID keyword specified for it. If no data is received, record format RCD1 will be used.

An application program reads header and detail records from an ICF file. The program issues input operations to the file name (not to individual record names) and receives the records (headers and details) in the order the sending application sends them. In this example, the sending and receiving applications provide for an explicit code (an H for header records and a D for detail records) to identify which type of record is being sent and received. The RECID keyword identifies where in the input buffer (disregarding indicators) the H or D appears and specifies the value (starting in the position specified) that identifies the type of record.

In Figure 417, three record formats are defined in ICF file. The application program issues input operations using the file name, for instance, RPTFILE.

Figure 417. Specifying the RECID Keyword (Purpose of the RECID Keyword)

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A          R HEADER                    RECID(1 'H')
00020A                                      RCVTRNRND(10 'Host stopped sending')
00030A            CODE           1
00040A            TITLE         30
00050A            ACTNBR         6  0
00060A          R DETAIL                    RECID(1 'D')
00070A            CODE           1
00080A            ITMNBR         8  0
00090A            DESCRP        20
00100A          R CATCH
00110A            FIELD         37
     A

Assume that the records received on nine successive input operations are one header, then three details, then one header, then four details. The sending application must identify the headers by placing an H in field CODE and the details by placing a D in field CODE. For each input operation, the OS/400 program compares the value in position 1 in the buffer with the value specified on the RECID keyword. (Position 1 is the location of field CODE in the buffer.) If the value in a record is H, the OS/400 program selects record format name HEADER; if the value in a record is D, the OS/400 program selects record format name DETAIL.

Record format CATCH (the RECID default record format) is the record format name selected if a record is received that does not contain either H or D in the first position of the data portion of the buffer.

Following is the buffer for record format HEADER:


Response indicator 10 (1 byte)
CODE (1 byte)
TITLE (30 bytes)
ACTNBR (6 bytes)

Figure 418. Specifying the RECID Keyword (Relation between the RECID Keywords when the Value Parameters Have Similar Values)

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
A          R RCD1                      RECID(1 'ABC')
A            FLD1          10
A          R RCD2                      RECID(1 'AB')
A            FLD1          10
A          R RCD3                      RECID(1 'A')
A            FLD1          10
A          R CATCH
A            FIELD         10
A

Three record formats need to be distinguished from one another; the first character in the value parameter is the same. Specifying the most specific (longest) value parameter first in the DDS enables the OS/400 program to distinguish the first record format from the others. The reason is that if the first 10 positions of the buffer contain ABCDEFGHIJ, and RCD3 were specified first, RCD3 would be identified even though RCD1 is desired. RCD1 and RCD2 could not be identified because the OS/400 program does not test after one successful match.