Module 6: CICS File Handling
STARTBR
The STARTBR command starts a browse operation. It positions CICS at a starting record in the file but does not retrieve any record. After STARTBR, you use READNEXT and READPREV to fetch records one at a time, and ENDBR to finish.
Syntax of the STARTBR command
- FILE - the file name from the File Control Table.
- RIDFLD - the field containing the key, RRN or RBA where the browse will start.
- RRN - the RIDFLD value is a relative record number for an RRDS.
- RBA - the RIDFLD value is a relative byte address for an ESDS or KSDS.
- GTEQ - start at the first record whose key is greater than or equal to the RIDFLD value.
- EQUAL - start at the record whose key is exactly equal to the RIDFLD value.
- GENERIC - match only part of the key (KSDS only). Pair it with KEYLENGTH, a binary halfword or literal giving the key length to use.
How STARTBR positions the browse
- STARTBR is required before any browse, even if you want to start at the first record in the file.
- The GTEQ/EQUAL option decides whether the browse must land on an exact key match or may start at the next higher key.
- If no record satisfies the condition, the NOTFND condition is raised.
- To start at the beginning of a KSDS, move LOW-VALUE to an alphanumeric RIDFLD field (or zero for a numeric key). For an ESDS move zero; for an RRDS move 1.
- To start at the end of a file (for a backward browse), move HIGH-VALUE to the RIDFLD field. For a KSDS with a numeric key, redefine the field as alphanumeric first, then move HIGH-VALUE.
- Examples:-
* Start a browse at the beginning of the file 1000-START-INVOICE-BROWSE. MOVE LOW-VALUE TO STARTBR-KEY. EXEC CICS STARTBR FILE('INVOICE') RIDFLD(STARTBR-KEY) RESP(RESPONSE-CODE) END-EXEC. IF RESPONSE-CODE = DFHRESP(NOTFND) MOVE 'Y' TO INVOICE-EOF-SW ELSE IF RESPONSE-CODE NOT = DFHRESP(NORMAL) PERFORM 9999-TERMINATE-PROGRAM END-IF. * Start a browse at a specific record 2100-START-CUSTOMER-BROWSE. EXEC CICS STARTBR FILE('CUSTMAS') RIDFLD(CM-CUSTOMER-NUMBER) EQUAL RESP(RESPONSE-CODE) END-EXEC.
