Tutorial Advanced Use 06 December 2020 Nick Jones
Tutorial – Advanced Use 06 December 2020 Nick Jones Jim Evans Compute (Bridgend) Ltd 8 Merthyr Mawr Road BRIDGEND CF 31 3 NH +44 (0)1656 652222 http: //www. cbl. com 1
Advanced SELCOPY Ø Dynamic Allocation Ø @pointers Ø VSAM Processing Ø DB 2 Processing Ø IMS/DL 1 Processing Ø The SLC program Compute (Bridgend) Ltd 2
Dynamic Allocation Ø Allocates a DSN to the specified fname. o Ø Ø Ø DEFAULTF used if fname is not specified. Any PS, PO, VSAM, GDG DSN or library DSN + member. DISP=SHR default for input/output dataset allocation. DISP=MOD for output dataset with APPEND parameter. DSN="dsname" allocate and open at statement analysis. DSN=field is supported (e. g. DSN=44 at 1) o o o Variable dataset name which may change during SELCOPY processing. Defers allocation and open until I/O operation executed at selection time. Once allocated, changes to field value ignored until CLOSE/OPEN executed. Compute (Bridgend) Ltd 3
Dynamic Allocation Sample 1 Print first 10 records of datasets whose DSNs are supplied as input. EQU INDSN_L 1 54 EQU INREC_L INDSN+INDSN_L 1024 OPTION WORKLEN=INREC+INREC_L READ CARD INTO INDSN @DSNL = LRECL PRINT FROM INDSN ==LOOP== READ DDIN DSN=@DSNL AT INDSN * Input DSN(+member) area. * Input DSN(+member) max length. * Input data record area. * Input data record max length. DATAWIDTH=80 NORDW * Input DSN read from SYSIN. * Length of DSN. * Print the input dataset name. INTO INREC * Dynamic alloc. IF EOF DDIN * If end-of-file. OR INCOUNT DDIN >= 10 * or record count exceeds 10. THEN CLOSE DDIN * Close the current data set. * Dynamic Alloc and Open will occur next time READ is executed. THEN GOTO LOOP_END * Exit the loop. POS INREC+LRECL, INREC+INREC_L-1 = " " PRINT FROM INREC LENGTH=80 GOTO LOOP ==LOOP_END== SPACE 2 * Clear residue. * Print first 80 bytes. * Get the next data record. * Skip to SYSPRINT lines. END ** Input dataset names follow ** NBJ. DATASET. BASIC 01. KSDS NBJ. FSU. TEST. GDG(0) APE. TXT(ZOPCODES) Compute (Bridgend) Ltd 4
@Pointers Ø Ø Ø Numeric value variables. May used in position and length specification. POS UXATPTR contains the 4 -byte, binary storage address pointed to by the default pointer “@”. IF POS AND POS THEN 1, 1000 <> ‘ ’ @+1, 1000 = ‘ ‘ ptr=@end = @end-1 PRINT FROM POS @, @end @len = @end-@+1 MOVE @len AT @ TO 1001 Compute (Bridgend) Ltd * * * Default pointer (@) --> first non-blank. Pointer @end --> next blank. @end --> non-blank character before. Print variable length word data. @len = length of word data. Copy word text to position 1001. 5
@Pointer Sample 1 Use @pointers to build and scan an array of field values. EQU IN 1 EQU IN 2 'CBL. SSC. CTL' 'CBL. SSC. CTL. F 80' EQU MARRE EQU MARRL 1 10 20800 * 1 st Input PDS. * 2 nd Input PDS. * Array of member names built from pds 1 * Array element length (member name = 8 bytes). * Max length of array (1080 array elements) EQU PDSIN MARR+MARRL * PDS input. EQU PDSINL 256 * PDS input maximum lrecl. OPTION WORKLEN=PDSIN+PDSINL DO ARRAY_RTN STOPAFT=1 READ PDS 2 DSN=IN 2 DIR INTO PDSIN IF POS MARR, @ARR+MARRE-1 = 8 AT PDSIN THEN DUMMY ELSE PRINT FROM PDSIN LENGTH 8 GOTO GET * Dir records only. STEP=MARRE * Member name found in array. * Log mismatching member name. * Get next record. ==ARRAY_RTN== @ARR = MARR =ARRAY_LOOP== * Loop to build array of member names. READ PDS 1 DSN=IN 1 DIR INTO @ARR * Directory records only. POS @ARR+8, @ARR+LRECL-1 = ' ' * Blank rest of record following member. IF EOF PDS 1 THEN GOTO ARRAY_LOOP_END @ARR = @ARR+MARRE GOTO ARRAY_LOOP =ARRAY_LOOP_END= * Next input position. =RETURN= Compute (Bridgend) Ltd 6
@Pointer Sample 2 Use UXATPTR field to navigate MVS control blocks. //SQ 11793 JOB , 'TEST DATA', CLASS=A, MSGCLASS=X, MSGLEVEL=(1, 1), // NOTIFY=&SYSUID //* Obtain Programmer's name from JOBCARD. (i. e. "TEST DATA". ) //* //STEP 1 EXEC PGM=SELCOPY //SYSPRINT DD DISP=SHR, DSN=NBJ. SYSPRINT(SSPTR 01) //SYSIN DD * OPT WORKLEN=100 DO GETJOBPGMNAME PRINT FROM @ LENGTH 20 GOTO GET ==GETJOBPGMNAME== ** Sub-routine ** * On return @ --> Programmer Name from JOB card. POS POS UXATPTR = = X'0000, 0010' 4 AT @+4 IF POS @+256 <> 'TCB' THEN PRINT FROM @ LENGTH 512 THEN CANCEL * * @ @ --> --> A(CVT) CVT (Communications Vector Table) TCB pointers Current TCB (Task Control Block) * Verify @ --> TCB TYPE=D POS UXATPTR = 4 AT @+180 POS UXATPTR = 4 AT @+260 POS UXATPTR = X'00' * @ --> JSCB (Job Step) * @ --> JCT-x'10‘ (Job Control Table) * High order byte must be zero. POS UXATPTR = 4 AT @+55 POS UXATPTR = X'00' * @ --> 1 st ACT (Account Control Table) * High order byte must be zero. @ =return= /* = @+24 Compute (Bridgend) Ltd * @ --> JOB Card Programmer Name. 7
VSAM (1/2) Ø KSDS, ESDS, RRDS (VRRDS) parameters on READ. o o Sequential Direct by key, record number or relative byte. (KEY=, KGE=, REC=, RBA=) Variable value supported by KEY=, KGE=, REC=, RBA= as field. Direct then sequential. (STARTKEY=, STARTKGE=, STARTREC=, STARTRBA=) READ Ø KSDS STARTKEY=‘DDDX’ Input Record Sequence o o First to last - FWD (default) Last to first - BWD Combine with direct then sequential input. KSDS multiple changes in direction. (e. g. FWD BWD FWD) READ Ø INKSDS STARTKGE=‘DDDX’ BWD READ PATH for KSDS input via alternate index key. o Supports KEY=, KGE=, STARTKEY=, STARTKGE= Compute (Bridgend) Ltd 8
VSAM (2/2) Ø READ UPDATE to input then update, delete, insert records. o o o Ø INSERT for KSDS record inserts in any sequence. o Ø Prior READ is not required. WRITE to load KSDS records in key sequence. o Ø UPDATE and DELETE operations affect last input record read. INSERT operation for KSDS will insert by key. Input position lost following KSDS insert – would require a direct read. More efficient than INSERT. SELCOPY positions - VSAM areas (last VSAM call). o o POS RPL POS RETVSAM+1 Compute (Bridgend) Ltd (VSAM Request Parameter List) (VSAM Return, Component and Error Codes) 9
VSAM Sample 1 Read and print RRDS records starting at record 381. 1 SELCOPY REL 3. 30 AT CBL - Bridgend UK (Internal Only) --------------------------- 2016/06/30 18: 28 -------- PAGE 1 ---- OPTION DATAWIDTH=50 1. READ 2. PRINT INPUT RECNO ----1 2 3 4 5 6 7 8 9 SUMMARY. . SEL-ID -----1 2 INRRDS DSN="NBJ. SSDEMO. RRDS" RRDS STARTREC=381 * Read the RRDS from record 381. LENGTH 50 * Print the input record. SEL TOT ID. 1 2 3 4 5 ---. . . . , . . . . 0. . , . . 0 1 2 381 WINWSYSI 020 20060803 1056 000 BCB 08 2 2 382 WINWVOLS 016 20041125 1229 000 BD 208 3 2 383 WINWWINL 012 20050412 0959 000 BE 008 4 2 384 WINYLGON 007 20040407 1320 000 BE 708 5 2 385 WINYOPEN 031 20041103 1049 000 BEB 08 6 2 386 WINYSAVE 002 20040407 1321 000 BF 808 7 2 387 PWRLMAIN 015 20050629 1044 000 BF 908 8 2 388 PWRFOBJ 0 100 20041215 1622 000 BFC 08 9 2 389 PWRWLIST 045 20051213 1403 000 C 1 A 08. . , . . 1. . , . . 2. . , . . 3. . , . . 4. . , . . 5 SELTOT FILE ----9 READ INRRDS 9 BLKSIZE ------100 LRECL ----100 U FSIZE ----389 RECORD LENGTH -----100 100 100 CI DSN ---4096 NBJ. SSDEMO. RRDS ** SELCOPY IS LICENSED BY COMPUTE (BRIDGEND) LTD +44 (1656) 652222 & 656466 ** ** EXPIRY DATE -- 2017/07/13 ** Compute (Bridgend) Ltd 10
VSAM Sample 2 Read KSDS directly using variable key value and update-in-place. EQU INKEY_L 1 7 EQU INREC_L INKEY+INKEY_L 4096 OPTION * Input KSDS key position. * Input KSDS key length. WORKLEN=INREC+INREC_L * Input data record area. * Input data record max length. READ CARD READ INKSDS DATAWIDTH=80 INTO INKEY * Get the key value. DSN="NBJ. DATASET. BASIC 01. KSDS" KEY=INKEY_L AT INKEY KSDS UPD INTO INREC * Keyed input with update. IF POS INREC = "--- KEY/REC NOT FOUND ---" THEN SPACE THEN PRINT FROM INKEY LENGTH=INKEY_L THEN PRINT FROM INREC THEN SPACE IF POS THEN END 0000030 0000010 000000 A 0000022 0000045 0000031 ANY = 'CBLxxx' PRINT FROM POS INREC LENGTH=80 POS @ = 'CBLM 05' UPDATE INKSDS FROM INREC Compute (Bridgend) Ltd * * * * * No matching record. Skip a line. Print the key. Print "not found". Skip a line Scan for "CBLxxx". Print 1 st 80 characters. Update with "CBLM 05". Update the input record. 11
VSAM Sample 3 Read KSDS backwards for highest key value, then load new records. EQU KSREC 1 EQU KEYO 0 !EQU KEYL 7 EQU DATO 8 EQU KSREC_L 322 * KSDS Input/Output record. * KSDS key offset+length (char). * KSDS data (excl. key) * KSDS Input/Output record max len. EQU * Next VSAM key (as packed numeric) * Next VSAM key packed length 4. PDKEY_L KSREC+KSREC_L 4 OPTION WORKLEN=PDKEY+PDKEY_L DO LASTKEY_RTN STOPAFT=1 * Work area. READ CARD INTO KSREC+DATO * Input card to KSDS. ADD 5 TO PDKEY_L AT PDKEY TYPE=P * Increment key value by 5. CVPC PDKEY_L AT PDKEY TO KEYL AT KSREC+KEYO * Unpack the key value. LRECL = LRECL+KEYL * Output rec length (key+data). WRITE OUTKSDS DSN="NBJ. DATASET. BASIC 01. KSDS" FROM KSREC DEFER * Load KSDS the record. GOTO GET ==LASTKEY_RTN== ** Get the highest key value. READ INKSDS DSN="NBJ. DATASET. BASIC 01. KSDS" INTO KSREC KSDS BWD * Read backwards. * Convert the character numeric key to packed decimal. CVCP KEYL AT KSREC+KEYO TO PDKEY_L AT PDKEY CLOSE INKSDS * Close input. =RETURN= END NBJ. SSDEMO. OUT PS VB 100 59 CBLM 14 2016/06/20 NBJ. SSDEMO. RRDS 0 0 NBJ. SSDEMO. RRDS. DATA VS U 0 59 CBLM 05 2016/06/30 NBJ. SSDEMO 03. OUT PS VB 100 882 CBLM 06 2016/06/21 NBJ. SSDEMO 07. KSDS 0 0 NBJ. SSDEMO 07. KSDS. DATA VS U 0 59 CBLM 09 2016/06/21 Compute (Bridgend) Ltd 12
DB 2 (1/2) Ø Ø SELCOPY DB 2 PLAN BIND to DB 2 sub-systems. Dynamic SQL prepared during SELCOPY execution. o o o Ø Ø (SQL SELECT query with FETCH) (Prepared INSERT) (Current input row) (General SQL statement execution) DB 2 load module libraries in search path. (CAF modules) Operations subject to usual DB 2 authorisation. o Ø READ WRITE/INSERT UPDATE DELETE DB 2 SQL= SQLID associated with the SELCOPY execution (usually ACF user id). SELCOPY positions - DB 2 areas (last SQL statement). o o POS POS RPL SQLCA SQLDA SQLMA Compute (Bridgend) Ltd (SELCOPQL Request Parameter List) (SQL Communications Area) (SQL Descriptor Area with SQLVA chain) (SQL Message Area) 13
DB 2 (2/2) Ø SELCOPY SELCOPQL Request Parameter List, POS RPL Offset Description Length Type RPL+00 SQL Verb 8 Char RPL+08 SQL Function 8 Char RPL+16 Return Code 4 Bin RPL+20 SQL Return Code 4 Bin RPL+24 CAF Return Code 4 Bin RPL+28 CAF Reason Code 4 Bin RPL+32 Current Row Data Length 4 Bin RPL+36 Maximum Row Data Length 4 Bin RPL+40 SQLCODE from PREPARE 4 Bin Compute (Bridgend) Ltd 14
DB 2 Sample 1 Read as printable character. 1 SELCOPY REL 3. 30 AT CBL - Bridgend UK (Internal Only) --------------------------- 2016/06/28 15: 42 -------- PAGE 1 ---- OPTION DATAWIDTH=50 PAGEWIDTH=80 OPTION SSN=CBLA * Override default DB 2 sub-system. READ INDB 2 SQL=" SELECT TRACK_NUM, NAME WHERE ORDER BY " 1. 2. INPUT RECNO ----1 2 3 4 5 PRINT LENGTH=50 FROM NBJ. SELCTRN_TRACK ALBUM_ID=10 TRACK_NUM CHAR SEP * As Character with separators. STOPAFT=5 SEL TOT ID. 1 2 3 4 5 ---. . . . , . . . . 0. . , . . 0 1 2 1|Rolling In the Deep 2 2 2|Rumour Has It 3 2 3|Turning Tables 4 2 4|Don't You Remember 5 2 5|Set Fire to the Rain. . , . . 1. . , . . 2. . , . . 3. . , . . 4. . , . . 5 SUMMARY. . SEL-ID -----1 SELTOT FILE ----5 READ INDB 2 2 ***WARNING*** BLKSIZE ------- LRECL ----572 U *EOF*NOT*REACHED* FSIZE ----5 CI -- RECORD LENGTH -----572 572 572 DSN --- 5 4 = RETURN CODE FROM SELCOPY ** SELCOPY IS LICENSED BY COMPUTE (BRIDGEND) LTD +44 (1656) 652222 & 656466 ** ** EXPIRY DATE -- 2017/07/13 ** Compute (Bridgend) Ltd 15
DB 2 Sample 2 Read, update then commit changes. 1 SELCOPY REL 3. 30 AT CBL - Bridgend UK (Internal Only) --------------------------- 2016/06/29 10: 49 -------- PAGE 1 ---- OPTION DATAWIDTH=50 PAGEWIDTH=90 OPTION SSN=CBLA * Override default DB 2 sub-system. READ INDB 2 SELECT NAME SQL=" WHERE FOR UPDATE OF " 1. FROM NBJ. SELCTRN_TRACK ALBUM_ID=10 NAME VLEN * Read rows from this result table. 2. IF EOF THEN DB 2 3. 4. 5. 6. IF POS ANY = "Deep" PTR=@HIT THEN PRINT LENGTH=50 THEN POS @HIT = "Sand" THEN PRINT LENGTH=50 THEN UPD INDB 2 INPUT RECNO ----1 1 SUMMARY. . SEL-ID -----1 2 3 ----5 6 INDB 2 "COMMIT" * If no more rows. * Commit changes. * * * Scan for "Deep" in track name. Print before update. Replace "Deep" with "Sand" Print after update. Update the DB 2 table row. SEL TOT ID. 1 2 3 4 5 ---. . . . , . . . . 0. . , . . 0 1 3 Rolling In the Deep 1 5 Rolling In the Sand. . , . . 1. . , . . 2. . , . . 3. . , . . 4. . , . . 5 SELTOT FILE ----13 READ INDB 2 1 1 UPD INDB 2 Compute (Bridgend) Ltd BLKSIZE ------- LRECL ----39 U FSIZE ----13 39 U 13 CI -- RECORD LENGTH -----21 21 DSN --- 16
DB 2 Sample 2 – Log Output 1 *** CBL Dynamic SQL Interface Version 3. 30 AT *** --------------------CBLS 010 I 10: 49: 05 CBL Dynamic SQL Interface is started. Date: 2016 -06 -29 CBLS 000 I 10: 49: 05 (Sel 1) Connected to DB 2 Version 9. 1. 0 Subsystem: CBLA Plan: ZZI 34000 User: NBJ Current SQLID: NBJ CBLS 004 I 10: 49: 05 (Sel 1) OPEN SELECT cursor INDB 2 SELECT NAME FROM NBJ. SELCTRN_TRACK WHERE ALBUM_ID=10 FOR UPDATE OF NAME CBLS 013 I 10: 49: 05 (Sel 6) UPDATE statement generated: UPDATE NBJ. SELCTRN_TRACK SET NAME=? WHERE CURRENT OF C 1 CBLS 005 I 10: 49: 05 (Sel 1) End Of File on SELECT cursor INDB 2 CBLS 006 I 10: 49: 05 (Sel 1) CLOSE SELECT cursor INDB 2 Prepare and OPEN DB 2 CPU= Rows Fetched=13 DB 2 CPU= Rows Updated=1 DB 2 CPU= Update Prepares=1 DB 2 CPU= Total DB 2 CPU= CBLS 007 I 10: 49: 05 (Sel 2) EXECUTE COMMIT 000000. 001044 000000. 008299 000000. 000893 000000. 009470 000000. 019706 seconds. SQL Code=0 DB 2 CPU= 000000. 001570 seconds. CBLS 001 I 10: 49: 05 (Sel 1) Disconnected from DB 2 Subsystem CBLA Total connection DB 2 CPU= 000000. 022399 seconds. CBLS 009 I 10: 49: 05 CBL Dynamic SQL Interface is stopped GETMAINs issued=11 Storage=13824 HWM=13792 FREEMAINs issued=11 Storage=13824 Total Interface CPU= 000000. 055653 seconds. --- End --- Compute (Bridgend) Ltd 17
DB 2 Sample 3 Copy table rows to an identical, test version of the table. 1 SELCOPY REL 3. 30 AT CBL - Bridgend UK (Internal Only) --------------------------- 2016/06/29 11: 14 -------- PAGE 1 ---- OPTION DATAWIDTH=50 PAGEWIDTH=133 OPTION SSN=CBLA * Override default DB 2 sub-system. 1. 2. 3. READ INTAB WRITE OUTTAB PRINT TYPE=D INPUT SEL RECNO TOT ID. ------- --1 1 3 0000 000 A 0001 0013 D 996 0020 40404040 0040 40404040 0060 40404040 0080 C 3 C 2 F 1 F 2 C 4 C 4 F 7 F 1 00 A 0 0000 01000000 00 C 0 85404040 00 E 0 40404040 0100 40404040 0120 F 04 BF 0 F 0 0140 F 0 F 0 0000 F 2 F 0 SUMMARY. . SEL-ID -----1 2 3 TAB="NBJ. SELCTRN_TRACK" TAB="NBJ. SELCTRN_TRACK_COPY" STOPAFT=1 352 93938995 40404040 F 4 C 4 F 5 F 1 44100 C 00 40404040 0000 F 2 F 0 F 1 F 160 F 0 SELTOT FILE ----1, 070 READ INTAB 1, 070 INS OUTTAB 1 8740 C 995 40404040 F 8 F 2 F 8 C 3 0007 DB 00 40404040 0000 F 2 F 0 F 1 F 260 F 0 F 860 F 1 F 9 BLKSIZE ------- 40 A 38885 40404040 00000003 0005151 C 40404040 F 1 F 160 F 0 F 860 F 0 F 2 60 F 1 F 24 B LRECL ----352 U 0 U PFX 40 C 48585 40404040 7 AFD 00000001 40404040 F 160 F 2 F 1 60 F 1 F 14 B F 2 F 94 BF 1 FSIZE ----1, 070 0 9740404040 4040 00000005 40404040 60 F 0 F 84 B F 3 F 04 BF 3 F 74 BF 0 F 0 CI -- 40404040 40400823 007 AD 876 C 1848593 40404040 F 0 F 04 BF 0 F 64 BF 0 F 0 *. . . Rolling In the Deep * * *. . * *CB 12 DD 714 D 51828 C. . : . . . . : Q. * *. . . . Adel* *e * *. . 2011 -01 -21 -08. 00. 0* *0. 000000. . 2012 -08 -02 -11. 30. 36. 00* *0000. . 2011 -08 -19 -12. 29. 17. 000000* DSN --- ** ** SELCOPY IS LICENSED BY COMPUTE (BRIDGEND) LTD +44 (1656) 652222 & 656466 ** ** ** EXPIRY DATE -- 2017/07/13 ** Compute (Bridgend) Ltd 18
DB 2 Sample 3 – Log Output 1 *** CBL Dynamic SQL Interface Version 3. 30 AT *** --------------------CBLS 010 I 11: 14: 10 CBL Dynamic SQL Interface is started. Date: 2016 -06 -29 CBLS 000 I 11: 14: 10 (Sel 1) Connected to DB 2 Version 9. 1. 0 Subsystem: CBLA Plan: ZZI 34000 User: NBJ Current SQLID: NBJ CBLS 004 I 11: 14: 10 (Sel 1) OPEN SELECT cursor INTAB SELECT * FROM NBJ. SELCTRN_TRACK CBLS 004 I 11: 14: 10 (Sel 2) OPEN INSERT cursor OUTTAB INSERT INTO NBJ. SELCTRN_TRACK_COPY (ALBUM_ID, TRACK_NUM, NAME, TRACK_ID, PERSISTENT_ID, TOTAL_TIME, FILE_SIZE, BIT_RATE, SAMPLE_RATE, YEAR, NORMALIZATION, DISC_NUMBER, ALBUM_ARTIST, RELEASE_DATE, DATE_ADDED, DATE_MODIFIED) VALUES(? , ? , ? , ? , ? ) CBLS 005 I 11: 14: 11 (Sel 1) End Of File on SELECT cursor INTAB CBLS 006 I 11: 14: 11 (Sel 1) CLOSE SELECT cursor INTAB Prepare and OPEN DB 2 CPU= Rows Fetched=1070 DB 2 CPU= Total DB 2 CPU= 000000. 001476 seconds. 000000. 213096 seconds. 000000. 214572 seconds. CBLS 006 I 11: 14: 11 (Sel 2) CLOSE INSERT cursor OUTTAB Rows Inserted=1070 DB 2 CPU= Insert Prepares=1 DB 2 CPU= Total DB 2 CPU= 000000. 691061 seconds. 000000. 010436 seconds. 000000. 701497 seconds. CBLS 001 I 11: 14: 11 (Sel 1) Disconnected from DB 2 Subsystem CBLA Total connection DB 2 CPU= 000000. 917084 seconds. CBLS 009 I 11: 14: 11 CBL Dynamic SQL Interface is stopped GETMAINs issued=14 Storage=16696 HWM=16280 FREEMAINs issued=14 Storage=16696 Total Interface CPU= 000000. 991470 seconds. --- End --- Compute (Bridgend) Ltd 19
IMS/DL 1 (1/2) Ø Ø SELCOPY called by region controller (DFSRRC 00). PSB with PCB required to process database segments. o o Ø SELCOPY I/O operations (GN, GHU, ISRT, REPL, etc. ) o o Ø PROCOPT SENSEG PCB identified by #n (i. e. nth non-I/O PCB in the PSB) PCB identified by dbdname #n (i. e. nth PCB to reference dbdname ) I/O operations support SSA via the SSA= parameter. STOKSTAT(STOCKEY GT 00255000000) CYCCOUNT(CYCLKEY GT 62*CYCLKEY LT 93) BACKORDR*C(02250236 -001 0025900326 Ø 30 PR 265943) SSA= references RSA for GSAM on GN, GU, ISRT. Compute (Bridgend) Ltd 20
IMS/DL 1 (2/2) Ø SELCOPY references last PCB processed as POS PCB Offset Description Length Type PCB+00 DBD name 8 Char PCB+08 Segment Level 2 Zoned PCB+10 (STATUS) Status Code 2 Char PCB+12 Processing Options 4 Char PCB+20 (SEG) Segment Name 8 Char PCB+28 Key Feedback Area Length 4 Bin PCB+32 #Sensitive Segments 4 Bin PCB+34 Key Feedback Area Var Char Compute (Bridgend) Ltd 21
IMS/DL 1 Sample 1 Input named segments sequentially. //NBJJOB , , CLASS=A, MSGCLASS=X, MSGLEVEL=(1, 1), NOTIFY=&SYSUID // JCLLIB ORDER=IMS 1210. PROCLIB //STEP 001 EXEC DLIBATCH, PSB=DFHSAM 04, DBRC=N, IRLM=N, MBR=SELCOPY //G. IEFRDER DD DUMMY, UNIT=SYSDA //G. DFSVSAMP DD DISP=SHR, DSN=NBJ. SELCOPY. IMS. DFSVSAMP(DEFAULT) //SYSPRINT DD DISP=SHR, DSN=NBJ. SYSPRINT(SSIMS 05) //SYSIN DD * OPTION PAGEDEPTH=99999 PAGEWIDTH=90 DATAWIDTH=80 OPTION WORKLEN=2100 *. . , . . 1. . , . . 2. . , . . 3. . , . . 4. . , . . 5. . , . POS 2001 = " SSIMS 05: Error. . Get segment failed with status code: " STOPAFT=1 GN DI 21 PART IF THEN THEN PRINT /* #1 IMS SEG='PARTROOT' * 1 st PCB to ref DI 21 PART. * PARTROOT segments only. POS STATUS <> ' ' POS 2056 = POS STATUS LENGTH=2 PLOG ' *#*' TYPE=S PLOG FROM 2001, 2060 TYPE=S PLOG ' *#*' TYPE=S RC = 1024 EOJ Compute (Bridgend) Ltd 22
IMS/DL 1 Sample 2 Write concatenated key value for each segment to sequential data set: . . . JCL as for IMS/DL 1 Sample 1 //OUTSSA DD DISP=SHR, DSN=NBJ. SELCOPY. IMS. KEYS(DI 21 PART) //SYSIN DD * EQU INSEG 1 * Input segment. EQU INSEG_L 5000 * Maximum expected segment size. EQU SSAKY INSEG+INSEG_L EQU SEGN 0 !EQU CMDC SEGN+SEGN_L !EQU QUAL CMDC+CMDC_L !EQU CKEY QUAL+QUAL_L !EQU SSAKY_L 11+2048 OPTION GN * SSA string for GU on restart. SEGN_L 8 * Segment Name Off/Len. CMDC_L 2 * Command Code Off/Len. '*C' QUAL_L 1 * Qualifier Off/Len. '(' CKEY_L 2048 * Concat Key Off/Len. '. . )' * SSA string max length. * (keylen max=2048) WORKLEN=SSAKY+SSAKY_L DI 21 PART #1 IMS INTO INSEG IF POS STATUS = ' ' !OR POS STATUS = 'G' THEN DO BUILD_SSA ELSE CANCEL * If acceptable status. * Build an SSA. * Unexpected status. GOTO GET * Get the next segment. ==BUILD_SSA== ** Build a concatenated key SSA. ** MOVE SEGN_L AT POS PCB+20 TO SSAKY+SEGN * Segment name. (POS SEG) POS SSAKY+CMDC = '*C(' * Cat Key cmd code. @KEYL = 4 AT POS PCB+28 TYPE=B * Length of key. MOVE @KEYL AT POS PCB+36 TO SSAKY+CKEY, SSAKY+CKEY_L-1 @SSAL = @KEYL+CKEY+1 * Fixed portion + key length + bracket. POS SSAKY+@SSAL-1 = ')' * Closing bracket. WRITE OUTSSA FROM SSAKY, SSAKY+@SSAL-1 * Output the SSA. =RETURN= /* Compute (Bridgend) Ltd 23
IMS/DL 1 Sample 3 Print 80 chars of segment selected by concatenated key, and all its children: . . . JCL as for IMS/DL 1 Sample 1 OPTION PAGEDEPTH=99999 PAGEWIDTH=90 OPTION WORKLEN=2100 DATAWIDTH=80 READ CARD INTO 1001 SPACE 2 !PRINT "### New Root Segment ###" * Input SSA. * Print eye-catcher. GU DI 21 PART #1 IMS INTO 11 SSA=1001 * Get parent seg by key. IF POS STATUS='GE' * "Not found" status? THEN PRINT "## Segment not found for the following concatenated key: " THEN PRINT FROM 1001 LENGTH=80 * Print failing key value. THEN GOTO GET * Get the next key. DO PRINT_SEG * Print the input segment. ==LOOP== GNP DI 21 PART #1 IMS INTO 11 * Get next sequential seg in parent. IF POS STATUS=' ' !OR POS STATUS='GA' !OR POS STATUS='GK' THEN DO PRINT_SEG * Print the input segment. THEN GOTO LOOP * Get the next segment. IF POS STATUS <> 'G' THEN CANCEL ELSE GOTO GET ==PRINT_SEG== MOVE 8 FROM MOD PRINT FROM =RETURN= POS SEG * A status other than no more segs in parent? * Cancel all further operation. 1 POS 1 * SEGNAME POS 9 = ': ' * : POS 11+LRECL, 1000 = ' ' * Blank residue. LENGTH=80 * 1 st 80 bytes. END PARTROOT*C(02 RC 07 GF 273 J PARTROOT*C(02 CK 05 CW 181 XXX PARTROOT*C(02 CK 05 CW 181 K /* Compute (Bridgend) Ltd TO ) ) ) 24
IMS/DL 1 Checkpoint (1/2) Ø Basic CHKP supported using SELCOPY CHKP operation. o Ø Checkpoint ID identified as 8 characters at POS 1 Extended CHKP/XRST possible via CALL ASMTDLI. o Save/restore the work area buffer. Ø CHKP requires PSB generated with CMPAT=Y. Ø XRST DL 1 call required once only at start of program. Ø Extended (symbolic) CHKP calls can occur after XRST. o o o CHKP calls loses current position in all data bases (except GSAM). Re-position using GU/GHU with SSA= and a saved concatenated key. IEFRDER required for CHKP checkpoint log records. Compute (Bridgend) Ltd 25
IMS/DL 1 Checkpoint (2/2) Ø XRST DL 1 call. . . o Establishes environment for extended CHKP calls. o CKPTID value specified as parameter DFSRRC 00. . . o o o Ø Normal program start if no CKPTID specified. Restart program if CKPTID specified and checkpoint log record exists. Restart repositions pointers within data bases as recorded by the nominated checkpoint log record id. o On restart, input QSAM/VSAM data sets require re-positioning logic. o IMSLOGR containing checkpoint records required for XRST restart. BMC AR/CTL check point pacing. o o Returns status code “SK” for suppressed check point. May be forced using CALL ASMTARC instead of CALL ASMTDLI. Note: ASMTARC has a slightly different parameter list to ASMTDLI. Compute (Bridgend) Ltd 26
IMS/DL 1 Sample 4 Update (REPL) specific named segments with program restart possibility: //NBJJOB , , CLASS=A, MSGCLASS=X, MSGLEVEL=(1, 1), NOTIFY=&SYSUID // JCLLIB ORDER=IMS 1210. PROCLIB //STEP 001 EXEC PGM=SELCOPY //IEFRDER DD DISP=SHR, DSN=NBJ. SELCOPY. IMS. LOG //IMSLOGR DD DISP=SHR, DSN=NBJ. SELCOPY. IMS. LOG. RESTART //SYSPRINT DD SYSOUT=* //SYSIN DD * READ IEFRDER !WRITE IMSLOGR /* //STEP 002 EXEC DLIBATCH, PSB=DFSSAM 09, MBR=SELCOPY, CKPTID=SELC 0001 // DBRC=N, IRLM=N //G. IEFRDER DD DISP=SHR, DSN=*. STEP 001. IEFRDER //G. IMSLOGR DD DISP=SHR, DSN=*. STEP 001. IMSLOGR //G. DFSVSAMP DD DISP=SHR, DSN=NBJ. SELCOPY. IMS. DFSVSAMP(DEFAULT) //SYSPRINT DD DISP=SHR, DSN=NBJ. SYSPRINT(SSIMS 09) //SYSIN DD * * ### SELCOPY control statements follow. ### continued. . . Compute (Bridgend) Ltd 27
IMS/DL 1 Sample 4. . . continued EQU INSEG EQU PKEY EQU PNAM EQU INSEG_L 1 5000 EQU SSAKY INSEG+INSEG_L EQU SEGN 0 !EQU CMDC SEGN+SEGN_L !EQU QUAL CMDC+CMDC_L !EQU CKEY QUAL+QUAL_L !EQU SSAKY_L 11+2048 EQU EQU NPARM_L ICALL_L CHKID_L CHKNO_L * Input segment. * Part Key Offset. * Part Name Offset. * Maximum expected segment size. 0 26 * SSA string for GU on restart. SEGN_L 8 * Segment Name Off/Len. CMDC_L 2 * Command Code Off/Len. '*C' QUAL_L 1 * Qualifier Off/Len. '(' CKEY_L 2048 * Concat Key Off/Len. '. . )' * SSA string max length. SSAKY+SSAKY_L 4 NPARM+NPARM_L 4 ICALL+ICALL_L 14 CHKID+CHKID_L 4 OPT WORKLEN=CHKNO+CHKNO_L DO XRST_RTN STOPAFT=1 * * * * GHN IF AND THEN THEN DI 21 PART #1 IMS POS INSEG+PNAM POS INSEG+PKEY+3 POS INSEG+PNAM DO BUILD_SSA REPL DI 21 PART #1 DO CHKP_RTN GHU DI 21 PART #1 GOTO GET DL 1 function call #parms. (BIN) DL 1 function call #parms. (4 -bytes) DL 1 function name. (CHKP or XRST) DL 1 function name length. Checkpoint id area length. Checkpoint number. (BIN) Checkpoint number length. (4 -bytes) PAGEDEPTH=9999 * Execute XRST (once only). INTO INSEG SSA="PARTROOT " = "RESISTOR " = "5" = "RESISTOR (5 -OHM)" * SSA for current segment. IMS FROM INSEG * Update current segment. * Checkpoint. IMS INTO INSEG SSA=SSAKY * Reposition. * Get the next segment. *** Sub-routines follow *** continued. . . 28
IMS/DL 1 Sample 4. . . continued ==BUILD_SSA== ** Build a concatenated key SSA. ** MOVE SEGN_L AT POS PCB+20 TO SSAKY+SEGN POS SSAKY+CMDC = '*C(' @KEYL = 4 MOVE @KEYL AT POS PCB+28 AT POS PCB+36 @SSAL = @KEYL+CKEY+1 POS SSAKY+@SSAL-1 =RETURN= ==XRST_RTN== POS ICALL POS NPARM * Segment name. * Cat Key cmd code. TYPE=B * Length of key. TO SSAKY+CKEY, SSAKY+CKEY_L-1 * Fixed portion + key length + bracket. * Closing bracket. = ')' ** Extended restart - (Normal start if chkpid is blank). = 'XRST' * DL 1 function. = X'0000, 0006' * #parms. CALL ASMTDLI NPARM ICALL PARM-2 CHKID_L CHKID IF POS CHKID, CHKID+CHKID_L-1 = ' ' FILL=' ' THEN POS CHKID = 'SELC ' THEN POS CHKNO = X'0000, 0000' =RETURN= UXLRECL-8 1 * If not restart. * Init CHKP id. * Init CHKP count. ==CHKP_RTN== ** Extended check point. POS ICALL = 'CHKP' * DL 1 function. ADD 1 TO CHKNO_L AT CHKNO TYPE=B * CHKP id + 1 CVBC CHKNO_L AT CHKNO TO CHKID+4 FMT=9999 * Char format. CALL ASMTDLI =RETURN= /* Compute (Bridgend) Ltd NPARM ICALL PARM-2 CHKID_L CHKID UXLRECL-8 1 29
IMS/DL 1 Sample 5 Insert (ISRT) specific named segments with program restart possibility: . . . JCL similar to IMS/DL 1 Sample 4 EQU INREC 1 * Input key GSAM record area. EQU PSEG 0 * Insert segment name Offset. EQU PDAT 8 * Insert data Offset. EQU INREC_L 256 * Input key GSAM record max length. EQU XXSSA_L INREC+INREC_L 256 * Build SSA area. * Build SSA max length. EQU EQU XXSSA+XXSSA_L 4 NPARM+NPARM_L 4 ICALL+ICALL_L 14 CHKID+CHKID_L 4 * * * * OPT NPARM_L ICALL_L CHKID_L CHKNO_L WORKLEN CHKNO+CHKNO_L DO XRST_RTN POS XXSSA = " GN DL 1 function call #parms. (BIN) DL 1 function call #parms. (4 -bytes) DL 1 function name. (CHKP or XRST) DL 1 function name length. Checkpoint id area length. Checkpoint number. (BIN) Checkpoint number length. (4 -bytes) *L " CBLGSAMD #1 IMS PAGEDEPTH=9999 STOPAFT=1 * Execute XRST (once only). STOPAFT=1 * Initialise SSA for ISRT. INTO INREC * GSAM input (SEGNAME + data). MOVE 8 AT INREC+PSEG TO XXSSA POS INREC+LRECL, INREC+INREC_L-1 = " " ISRT DI 21 PART #1 IMS IF POS STATUS <> THEN CANCEL DO CHKP_RTN GOTO GET " FROM INREC+PDAT " * Insert segment name. * Clear residue. SSA=XXSSA * If unexpected status code. * Cancel further operations. * Checkpoint. * Get the next input value. ** Sub-Routines follow ** continued. . . 30
IMS/DL 1 Sample 5. . . continued ==XRST_RTN== POS ICALL POS NPARM ** Extended restart - (Normal start if chkpid is blank). = 'XRST' * DL 1 function. = X'0000, 0006' * #parms. CALL ASMTDLI NPARM ICALL PARM-2 CHKID_L CHKID IF POS CHKID, CHKID+CHKID_L-1 = ' ' FILL=' ' THEN POS CHKID = 'SELC ' THEN POS CHKNO = X'0000, 0000' =RETURN= ==CHKP_RTN== POS ICALL = 'CHKP' Compute (Bridgend) Ltd NPARM ICALL 1 * If not restart. * Init CHKP id. * Init CHKP count. * DL 1 function. ADD 1 TO CHKNO_L AT CHKNO TYPE=B CVBC CHKNO_L AT CHKNO TO CHKID+4 FMT=9999 CALL ASMTDLI =RETURN= /* UXLRECL-8 PARM-2 CHKID_L CHKID * CHKP id + 1 * Char format. UXLRECL-8 1 31
SLC Program Ø Ø Ø Included in SELCOPY Product Suite Alternative SELCOPY program written in C++ SELCOPY for Windows, Linux and UNIX source code Same control statement syntax as SELCOPY program Features available only in SLC include: o o o Regular Expressions Declared Variables IF/AND/OR range tests reverse scan CHANGE, LEFT, RIGHT, CENTRE and CHOP Date conversion and arithmetic Input SELCOPYi generated lists Compute (Bridgend) Ltd 32
z/OS SLC Sample Report uncataloged VTOC entries for a specified volume: //JGESI JOB , , CLASS=A, MSGCLASS=X, MSGLEVEL=(1, 1), NOTIFY=&SYSUID //* // SET VOL=CBLM 06 Tailor volume name to run against. //* //SLCUNCAT EXEC PGM=SLC, PARM='&VOL' //SYSPRINT DD DISP=SHR, DSN=CBL. SYSPRINT(UC&VOL) //SYSIN DD * NOPRINT * Suppress print of control statements and summary. * SELCOPY (SLC) to identify uncataloged datasets on a specified volume. option REPORT HEAD='Uncataloged datasets on VOL=%1' option WORKLEN=44444 PAGEDEPTH=9999 do Get. VTOCEntry do Check. If. Cataloged goto get * Return to the start of the implied loop. ==Check. If. Cataloged== close MYCAT pos 101 = 'cat' ** Internal Sub-routines ** * Close current catalog entry list. !pos 101+4 = 44 at 1 * "CAT <entryname>" if pos 101+4, 101+4+44 -1 = ' ' then pos @ = '. ' * Extra dot prevents wildcards being auto-added. read MYCAT list=44+4 at 101 select='ENTRY' if eof MYCAT or pos 201 <> pos 1 length=44 then print '**Uncat**: ' from @L at 1 then @uncat = 0 stopaft=1 then @uncat = @uncat+1 =return= into 201 ==Get. VTOCEntry== read MYVTOC list='vtoc %1' header select='DSN, SMi, ORG, RECFM, LRECL, BLKSZ' @L = lrecl * Save length of VTOC record if eof then MYVTOC space 2 print 'Number of uncat datasets on %1: ' @uncat fmt='zz, zz 9' space 4 !then EOJ if incount MYVTOC <= 2 * If it's a header/scale record. then print ' ' from @L at 1 then goto Get. VTOCEntry =return= 33
SELCOPY for Windows Ø Ø Ø Included in SELCOPY Product Suite mainframe licences STDIN/STDOUT for piping I/O for different file line data (record) formats: o o o Ø Ø Ø RECFM U - crlf, lf or other end-of-line characters RECFM F - Fixed length lines RECFM V/VB – Variable length with RDW/BDW Non-native data types (Packed Decimal/Hex Float) Micro Focus file I/O (VSAM emulation) Database/Spreadsheet I/O via ODBC Compute (Bridgend) Ltd 34
- Slides: 34