Is it possible to browse a VSAM file in descending order?
Posted: Mon Apr 04, 2016 6:43 am
Is there an easy way of finding out the highest key currently in use in a KSDS? I'm trying to implement a simple "Add new record" function in <advertising removed>. In my test data Custf is a VSAM file keyed on Custf.Account, and I'm trying to work out the COBOL that I want for a NewKey function in
Code' d
If Custf were SQL I'd be able to use SELECT MAX(Account) FROM ..., and if STARTBR offered an DESC order option I could browse to the last record, but it doesn't. Setting Account = 999999 and then EXEC CICS STARTBR (which would immediately ENDFILE) wouldn't return the last record (would it?). So what's my best approach?
Thank you,
Robert Barnes
Advertising removed
WHEN (Add);
* CustF.Account = NewKey; [???
GET custf KEY(CustF.Account) UPDATE;
#243 E GET ... UPDATE with neither CHECKCOPY nor CHECKSUM MUST create a new record
ACCEPT (IWSPG2.custf.*) EXCEPT(IWSPG2.Account) TO custf MESSAGE OWSPG2.ERROR;
#447 I Numeric Data will already be converted to numbers
END GET custf UPDATE RESPOND OWSPG2;
* CustF.Account = NewKey; [???
GET custf KEY(CustF.Account) UPDATE;
#243 E GET ... UPDATE with neither CHECKCOPY nor CHECKSUM MUST create a new record
ACCEPT (IWSPG2.custf.*) EXCEPT(IWSPG2.Account) TO custf MESSAGE OWSPG2.ERROR;
#447 I Numeric Data will already be converted to numbers
END GET custf UPDATE RESPOND OWSPG2;
Code' d
If Custf were SQL I'd be able to use SELECT MAX(Account) FROM ..., and if STARTBR offered an DESC order option I could browse to the last record, but it doesn't. Setting Account = 999999 and then EXEC CICS STARTBR (which would immediately ENDFILE) wouldn't return the last record (would it?). So what's my best approach?
Thank you,
Robert Barnes
Advertising removed