Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 10: CICS Transaction Processing


STARTBR

EXEC CICS STARTBR begins a browse: sequential reading of a VSAM file starting at a chosen key.

It positions the file at a record, then READNEXT and READPREV walk through the records one by one in key sequence.

What STARTBR does

  • Sets a browse starting position on a file, using RIDFLD as the key.
  • GTEQ starts at the first key greater than or equal to RIDFLD; EQUAL needs an exact key match; GENERIC matches a partial key.
  • After STARTBR, each READNEXT returns the next record in key sequence.
  • ENDBR ends the browse and releases the file position.

The browse loop

  • Issue STARTBR once, then loop on READNEXT until the ENDFILE condition is raised.
  • Check RESP after every READNEXT. ENDFILE means the last record has been passed.
  • Always issue ENDBR, even when the loop ends early, to free the browse.
  • RESETBR repositions an active browse without ending it.

STARTBR for update

  • READNEXT with the UPDATE option locks the record so it can be changed with REWRITE or DELETE.
  • The lock is held until the next READNEXT, ENDBR, or SYNCPOINT.
  • Never hold an update browse across a terminal interaction in a pseudo-conversational program.
  • A browse without UPDATE is read-only and safe for reports and lists.

Example of a browse loop

  • STARTBR positions at the first key at or above WS-CUST-NO; the loop reads forward until ENDFILE.
  • EXEC CICS STARTBR FILE('CUSTMAS') RIDFLD(WS-CUST-NO) GTEQ RESP(WS-RESP) END-EXEC. PERFORM UNTIL WS-RESP = DFHRESP(ENDFILE) EXEC CICS READNEXT FILE('CUSTMAS') INTO(CUST-REC) RIDFLD(WS-CUST-NO) RESP(WS-RESP) END-EXEC IF WS-RESP = DFHRESP(NORMAL) PERFORM 2000-PRINT-LINE END-IF END-PERFORM. EXEC CICS ENDBR FILE('CUSTMAS') END-EXEC.
  • ENDBR is issued after the loop so the browse position is always released.





© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant