VSAM文件纪录的浏览: 对VSAM文件可以从头开始,依次查询各条纪录,这要用到4条CICS命令:STARTBR, READNEXT, READPREV, ENDBR, 依次为开始浏览,读下 条纪录,读前条纪录和结束浏览命令。 这些命令使用的选项含义与READ命令大致相同,但增加了一条REQID,这个选项用来使程序能对一个文件同时发动多个查询,各个查询可 以有不同的当前位置。在STARTBR时,返回打开的浏览的REQID,在后面的命令中使用REQID指明进行那个浏览的操作。程序通过检查命令 的返回码来判断文件结束等情况。 STARTBR FILE('SBVSAM2') RIDFLD(&KEY) STATUS: ABOUT TO EXECUTE COMMAND NAME= EXEC CICS STARTBR FILE( 'SBVSAM2 ' ) < SYSID() > RIDFLD( 'CITI' ) < KEYLENGTH() < GENERIC > > < REQID( +00000 ) > < RBA | RRN | DEBREC | DEBKEY > < GTEQ | EQUAL > PF 1 HELP 2 HEX 3 END 4 EIB 5 VAR 6 USER 7 SBH 8 SFH 9 MSG 10 SB 11 SF READNEXT FILE('SBVSAM2') RIDFLD(&KEY) STATUS: ABOUT TO EXECUTE COMMAND NAME= EXEC CICS READNEXT FILE( 'SBVSAM2 ' ) < SYSID() > ( SET() | INTO() ) < LENGTH() > RIDFLD( 'CITI' ) < KEYLENGTH() > < REQID( +00000 ) > < RBA | RRN > < UNCOMMITTED | CONSISTENT | REPEATABLE | UPDATE TOKEN() > < NOSUSPEND > PF 1 HELP 2 HEX 3 END 4 EIB 5 VAR 6 USER 7 SBH 8 SFH 9 MSG 10 SB 11 SF READNEXT FILE('SBVSAM2') RIDFLD(&KEY) STATUS: COMMAND EXECUTION COMPLETE NAME= EXEC CICS READNEXT FILE( 'SBVSAM2 ' ) < SYSID() > ( SET() | INTO( 'ISSC BALAACCMF39778173' ) ) < LENGTH( +00023 ) > RIDFLD( 'ISSC' ) < KEYLENGTH() > < REQID( +00000 ) > < RBA | RRN > < UNCOMMITTED | CONSISTENT | REPEATABLE | UPDATE TOKEN() > < NOSUSPEND > RESPONSE: NORMAL EIBRESP=+0000000000 EIBRESP2=+0000000000 READNEXT FILE('SBVSAM2') RIDFLD(&KEY) STATUS: COMMAND EXECUTION COMPLETE NAME= EXEC CICS READNEXT FILE( 'SBVSAM2 ' ) < SYSID() > ( SET() | INTO( '' ) ) < LENGTH( +00000 ) > RIDFLD( 'ISSC' ) < KEYLENGTH() > < REQID( +00000 ) > < RBA | RRN > < UNCOMMITTED | CONSISTENT | REPEATABLE | UPDATE TOKEN() > < NOSUSPEND > RESPONSE: ENDFILE EIBRESP=+0000000020 EIBRESP2=+0000000090 PF 1 HELP 2 HEX 3 END 4 EIB 5 VAR 6 USER 7 SBH 8 SFH 9 MSG 10 SB 11 SF READPREV FILE('SBVSAM2') RIDFLD(&KEY) STATUS: ABOUT TO EXECUTE COMMAND NAME= EXEC CICS READPREV FILE( 'SBVSAM2 ' ) < SYSID() > ( SET() | INTO() ) < LENGTH() > RIDFLD( 'ISSC' ) < KEYLENGTH() > < REQID( +00000 ) > < RBA | RRN > < UNCOMMITTED | CONSISTENT | REPEATABLE | UPDATE TOKEN() > < NOSUSPEND > PF 1 HELP 2 HEX 3 END 4 EIB 5 VAR 6 USER 7 SBH 8 SFH 9 MSG 10 SB 11 SF READPREV FILE('SBVSAM2') RIDFLD(&KEY) STATUS: COMMAND EXECUTION COMPLETE NAME= EXEC CICS READPREV FILE( 'SBVSAM2 ' ) < SYSID() > ( SET() | INTO( 'ISSC BALAACCMF39778173' ) ) < LENGTH( +00023 ) > RIDFLD( 'ISSC' ) < KEYLENGTH() > < REQID( +00000 ) > < RBA | RRN > < UNCOMMITTED | CONSISTENT | REPEATABLE | UPDATE TOKEN() > < NOSUSPEND > RESPONSE: NORMAL EIBRESP=+0000000000 EIBRESP2=+0000000000 PF 1 HELP 2 HEX 3 END 4 EIB 5 VAR 6 USER 7 SBH 8 SFH 9 MSG 10 SB 11 SF VSAM文件纪录更新: CICS使用REWRITE命令来更改数据,REWRITE命令一定要跟在一个READ UPDATE命令之后,而且KSDS的KEY是不能改变的。REWRITE命令 的选项前面都介绍过了,它的异常情况也与READ大致相同,但多了以下几项: LENGERR:写入纪录的长度没有指定或太长 NOSPACE: 文件空间不足,可能的原因是文件中变长纪录长度增加了 INVREQ: 多由以下原因造成:在REWITE一个记录前,没有运行过READ UPDATE命令 ILLOGIC: 其他VSAM文件操作错误。这种情况下可以通过检测EIBRCODE字段来判断错误种类:在EIBRCODE中,第二个字节为VSAM 错误码。具体代码可以到VSAM代码手册中查询。 READ FILE('SBVSAM2') RIDFLD('ISSC') UPDATE STATUS: ABOUT TO EXECUTE COMMAND NAME= EXEC CICS READ FILE( 'SBVSAM2 ' ) < SYSID() > ( SET() | INTO() ) < LENGTH() > RIDFLD( 'ISSC' ) < KEYLENGTH() < GENERIC > > < RBA | RRN | DEBREC | DEBKEY > < GTEQ | EQUAL > < UNCOMMITTED | CONSISTENT | REPEATABLE | UPDATE < TOKEN() > > < NOSUSPEND > PF 1 HELP 2 HEX 3 END 4 EIB 5 VAR 6 USER 7 SBH 8 SFH 9 MSG 10 SB 11 SF REWRITE FILE('SBVSAM2') FROM('ISSC BALAACCMF39778173') STATUS: ABOUT TO EXECUTE COMMAND NAME= EXEC CICS REWRITE FILE( 'SBVSAM2 ' ) < SYSID() > FROM( 'ISSC BALAACCMF39778173' ) < LENGTH( +00023 ) > < TOKEN() > < NOSUSPEND > PF 1 HELP 2 HEX 3 END 4 EIB 5 VAR 6 USER 7 SBH 8 SFH 9 MSG 10 SB 11 SF REWRITE FILE('SBVSAM2') FROM('ISSC BALAACCMF39778173') STATUS: COMMAND EXECUTION COMPLETE NAME= EXEC CICS REWRITE FILE( 'SBVSAM2 ' ) < SYSID() > FROM( 'ISSC BALAACCMF39778173' ) < LENGTH( +00023 ) > < TOKEN() > < NOSUSPEND > RESPONSE: NORMAL EIBRESP=+0000000000 EIBRESP2=+0000000000 PF 1 HELP 2 HEX 3 END 4 EIB 5 VAR 6 USER 7 SBH 8 SFH 9 MSG 10 SB 11 SF ENDBR FILE('SBVSAM2') STATUS: COMMAND EXECUTION COMPLETE NAME= EXEC CICS ENDBR FILE( 'SBVSAM2 ' ) < SYSID() > < REQID( +00000 ) > RESPONSE: NORMAL EIBRESP=+0000000000 EIBRESP2=+0000000000 PF 1 HELP 2 HEX 3 END 4 EIB 5 VAR 6 USER 7 SBH 8 SFH 9 MSG 10 SB 11 SF 添加VSAM文件纪录: CICS使用WRITE命令来向VSAM文件写入纪录。命令选项含义与前面的介绍相同。当我们需要按键值的升序排列插入多个纪录时,须使用 MASSINSERT选项,每个WRITE命令都要包含这个选项,要终止MASSINSERT,可通过UNLOCK命令来实现。 WRITE FILE('SBVSAM2') FROM( 'ISSC BALADBDMF39778173' ) RIDFLD('ISSC') STATUS: ABOUT TO EXECUTE COMMAND NAME= EXEC CICS WRITE FILE( 'SBVSAM2 ' ) < SYSID() > FROM( 'ISSC BALADBDMF39778173' ) < LENGTH( +00023 ) > RIDFLD( 'ISSC' ) < KEYLENGTH() > < RBA | RRN > < MASSINSERT > < NOSUSPEND > PF 1 HELP 2 HEX 3 END 4 EIB 5 VAR 6 USER 7 SBH 8 SFH 9 MSG 10 SB 11 SF WRITE FILE('SBVSAM2') FROM( 'ISSC BALADBDMF39778173' ) RIDFLD('ISSC') STATUS: COMMAND EXECUTION COMPLETE NAME= EXEC CICS WRITE FILE( 'SBVSAM2 ' ) < SYSID() > FROM( 'ISSC BALADBDMF39778173' ) < LENGTH( +00023 ) > RIDFLD( 'ISSC' ) < KEYLENGTH() > < RBA | RRN > < MASSINSERT > < NOSUSPEND > RESPONSE: NORMAL EIBRESP=+0000000000 EIBRESP2=+0000000000 PF 1 HELP 2 HEX 3 END 4 EIB 5 VAR 6 USER 7 SBH 8 SFH 9 MSG 10 SB 11 SF 删除VSAM文件纪录: CICS使用DELETE命令来删除VSAM文件的纪录。只有KSDS和RRDS结构的VSAM文件中的纪录能被删除,这与数据的存放格式有关。ESDS文件 的纪录按进入的顺序排放,只能在文件尾增加纪录,不能删除,而且更新时不能改变长度。如果该记录在请求删除前正在被更新,那么 参数RIDFLD可以不指定,默认为当前记录。如果使用GENERIC参数,必须给定KELENGTH参数,指出KEY长度,同时NUMREC指出要删除的记 录长度,这样就可以一次删除若干条记录。 DELETE FILE('SBVSAM2') RIDFLD('ISSC') STATUS: ABOUT TO EXECUTE COMMAND NAME= EXEC CICS DELETE FILE( 'SBVSAM2 ' ) < SYSID() > < TOKEN() | RIDFLD( 'ISSC' ) < KEYLENGTH() < GENERIC < NUMREC() > > > > < RBA | RRN > < NOSUSPEND > PF 1 HELP 2 HEX 3 END 4 EIB 5 VAR 6 USER 7 SBH 8 SFH 9 MSG 10 SB 11 SF DELETE FILE('SBVSAM2') RIDFLD('ISSC') STATUS: COMMAND EXECUTION COMPLETE NAME= EXEC CICS DELETE FILE( 'SBVSAM2 ' ) < SYSID() > < TOKEN() | RIDFLD( 'ISSC' ) < KEYLENGTH() < GENERIC < NUMREC() > > > > < RBA | RRN > < NOSUSPEND > RESPONSE: NORMAL EIBRESP=+0000000000 EIBRESP2=+0000000000 PF 1 HELP 2 HEX 3 END 4 EIB 5 VAR 6 USER 7 SBH 8 SFH 9 MSG 10 SB 11 SF