//IDCAMS JOB (ACCT),'CREATE LINEAR VSAM',// MSGCLASS=A,CLASS=A,TIME=30,
// NOTIFY=&SYSUID,MSGLEVEL=(1,1)
/*JOBPARM LINES=999999
// EXEC PGM=IDCAMS
//SYSIN DD *
DELETE S6B.XX.LINEAR SET LASTCC=0
DEFINE CLUSTER (NAME(S6B.XX.LINEAR) -
TRACKS(5) -
CISZ(8192) -
SHAREOPTIONS(1,3) -
LINEAR)
//SYSPRINT DD SYSOUT=*
You can use the following three rules to create control intervals in the sample LDS. Each full word in the LDS contains its relative byte offset from the start of the data set.
Rule LINEAR is key to this process. It obtains the CISIZE of the sample VSAM LDS and the address of the buffer storage in the VSAM LDS interface. It then populates this buffer with the desired data before inserting the contents of the buffer into the physical LDS.
LINCREATE(FIRST, LAST);_ LOCAL A, CISIZE;
_ --------------------------------------------------------------------
_ ------------------------------------------------------------+-------
_ A = FIRST; ¦ 1
_ UNTIL EQ : ¦ 2
_ CALL LINEAR(A); ¦
_ A = A + CISIZE; ¦
_ CALL @EQ(A, LAST); ¦
_ END; ¦
_ --------------------------------------------------------------------
LINEAR(RBA);_ LOCAL OFFSET, ADDRESS;
_ --------------------------------------------------------------------
_ ---------------------------------------------------------------+----
_ GET LINEAR WHERE RBA = - 1; ¦ 1
_ CISIZE = LINEAR.CISIZE; ¦ 2
_ LINEAR.RBA = RBA; ¦ 3
_ OFFSET = 0; ¦ 4
_ ADDRESS = LINEAR.ADDRESS; ¦ 5
_ UNTIL EQ : ¦ 6
_ CALL @EQ(OFFSET, CISIZE); ¦
_ LINEARMAP.DATA = RBA + OFFSET; ¦
_ LINEARMAP.KEY = 1; ¦
_ CALL LINEARREP; ¦
_ OFFSET = OFFSET + 4; ¦
_ END; ¦
_ INSERT LINEAR; ¦ 7
_ -----------------------------------------------------------------------
LINEARREP;_
_ -------------------------------------------------------------------
_ ------------------------------------------------------------+------
_ REPLACE LINEARMAP(LINEAR.ADDRESS + OFFSET); ¦ 1
_ -------------------------------------------------------------------
_ ON COMMITLIMIT :
_ COMMIT;
_ REPLACE LINEARMAP(LINEAR.ADDRESS + OFFSET);
PRINT INDATASET(S6B.XX.LINEAR)IDCAMS SYSTEM SERVICES TIME: 04:44:44
LISTING OF DATA SET -S6B.XX.LINEAR
RBA OF RECORD - 0
00000 00000000 00000004 00000008 0000000C 00000010 00000014 00000018 0000001C
00020 00000020 00000024 00000028 0000002C 00000030 00000034 00000038 0000003C
00040 00000040 00000044 00000048 0000004C 00000050 00000054 00000058 0000005C
00060 00000060 00000064 00000068 0000006C 00000070 00000074 00000078 0000007C
00080 00000080 00000084 00000088 0000008C 00000090 00000094 00000098 0000009C
000A0 000000A0 000000A4 000000A8 000000AC 000000B0 000000B4 000000B8 000000BC
000C0 000000C0 000000C4 000000C8 000000CC 000000D0 000000D4 000000D8 000000DC
000E0 000000E0 000000E4 000000E8 000000EC 000000F0 000000F4 000000F8 000000FC
etc., etc. until
01F80 00001F80 00001F84 00001F88 00001F8C 00001F90 00001F94 00001F98 00001F9C
01FA0 00001FA0 00001FA4 00001FA8 00001FAC 00001FB0 00001FB4 00001FB8 00001FBC
01FC0 00001FC0 00001FC4 00001FC8 00001FCC 00001FD0 00001FD4 00001FD8 00001FDC
01FE0 00001FE0 00001FE4 00001FE8 00001FEC 00001FF0 00001FF4 00001FF8 00001FFC
You can use the following rule to read a word of data at a given RBA in the sample VSAM LDS and display the results as a decimal number. It calculates the control interval to be read, reads the LDS VSAM table to read this control interval into the VSAM LDS interface buffer. It then uses the VSAM MAP table to read the actual data from the correct word in this buffer.
LINGET(RBA);_ LOCAL RECORD, OFFSET;
_ -----------------------------------------------------------------------------
_ REMAINDER(RBA, 4) = 0; ¦ Y N
_ --------------------------------------------------------------------+--------
_ GET LINEAR WHERE RBA = - 1; ¦ 1
_ RECORD = RBA / LINEAR.CISIZE * LINEAR.CISIZE; ¦ 2
_ OFFSET = RBA - RECORD; ¦ 3
_ GET LINEAR WHERE RBA = RECORD; ¦ 4
_ GET LINEARMAP(LINEAR.ADDRESS + OFFSET); ¦ 5
_ RETURN(LINEARMAP.DATA); ¦ 6
_ RETURN('RBA MUST BE A MULTIPLE OF 4'); ¦ 1
_ ------------------------------------------------------------------------------
_ ON GETFAIL :
_ RETURN('GETFAIL RBA ' || RBA);
You can use the following rule to read a word of data at a given RBA, increment it by 1, and replace the data in the sample VSAM LDS. It calculates the control interval to be read and reads the LDS VSAM table to read this control interval into the VSAM LDS interface buffer. It then uses the VSAM MAP table to read the actual data from the correct word in this buffer. It increments it by 1 and replaces the data in the VSAM LDS interface buffer using the VSAM MAP table and then replaces the contents of the VSAM LDS control interval using the VSAM LDS table.
LINREP(RBA)_ LOCAL RECORD, OFFSET;
_ --------------------------------------------------------------
_ REMAINDER(RBA, 4) = 0; ¦ Y N
_ -------------------------------------------------------+------
_ GET LINEAR WHERE RBA = - 1; ¦ 1
_ RECORD = RBA / LINEAR.CISIZE * LINEAR.CISIZE; ¦ 2
_ OFFSET = RBA - RECORD; ¦ 3
_ GET LINEAR WHERE RBA = RECORD; ¦ 4
_ GET LINEARMAP(LINEAR.ADDRESS + OFFSET); ¦ 5
_ LINEARMAP.DATA = LINEARMAP.DATA + 1; ¦ 6
_ REPLACE LINEARMAP(LINEAR.ADDRESS + OFFSET); ¦ 7
_ REPLACE LINEAR; ¦ 8
_ RETURN('RBA ' || RBA || ' HAS BEEN INCREMENTED BY 1'); ¦ 9
_ RETURN('RBA MUST BE A MULTIPLE OF 4'); ¦ 1
_ ---------------------------------------------------------------
_ ON GETFAIL :
_ RETURN('GETFAIL RBA ' || RBA);