-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathPDSTEST.rexx
91 lines (75 loc) · 2.39 KB
/
PDSTEST.rexx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* This REXX script takes a dataset/member and iterates over every */
/* PDS in the file, attempting to open the PDS in write mode */
/* If successful it will create a member named after the second */
/* argument. The member will contain the second argument and the date */
/* For example: EX 'SOME.PDS(PDSTEST)' 'IN.PDS(LIST) PWNED' */
parse arg indsn text .
ADDRESS TSO
verbose = 1 /* set to zero to supress access error messages */
today = DATE('S')
if indsn = '' then do
say '*** Error you must pass a dataset with PDS to check'
say "*** Usage: ex 'some.pds(PDSTEST)' 'some.dataset(member) testing' "
exit -1
end
if text = '' then do
say '*** Error you must pass text which will be placed in the apf lib'
say "*** Usage: ex 'some.pds(PDSTEST)' 'some.dataset(member) testing' "
exit -1
end
/* Read the TESTING.DATASETS file */
"ALLOC F(INFILE) DA('"indsn"') SHR REUSE"
"EXECIO * DISKR INFILE (STEM dsn. FINIS"
"FREE F(INFILE)"
outtext.0 = 1
outtext.1 = text today
member = text
say "*** Total PDSes to check:" dsn.0
say "*** Attempting to create:" member
say "*** Member contents:" outtext.1
CALL prompt_user
IF RESULT = 'N' THEN EXIT 0
/* Process each dataset */
DO i = 1 TO dsn.0
dataset = STRIP(dsn.i)
SAY "*** Trying:" dataset
/* Allocate the dataset */
x = OUTTRAP('textacs.')
"ALLOC F(OUTFILE) DA('"dataset"') SHR REUSE"
y = OUTTRAP('OFF')
IF RC <> 0 THEN DO
SAY "*** Error allocating" dataset". RC =" RC
DO x = 1 to testacs.0
if verbose then say " " testacs.x
END
CALL prompt_user
IF RESULT = 'N' THEN LEAVE
ELSE ITERATE
END
/* "EXECIO 1 DISKW OUTFILE (FINIS" */
"EXECIO 1 DISKW OUTFILE (STEM outtext. FINIS"
write_rc = RC
/* Free the dataset */
"FREE F(OUTFILE)"
/* Check if write was successful */
IF write_rc = 0 THEN
SAY "*** Successfully updated" dataset
ELSE
SAY "*** Error writing to" dataset". RC =" write_rc
/* Prompt user to continue */
CALL prompt_user
IF RESULT = 'N' THEN LEAVE
END
SAY "Processing complete."
EXIT 0
/* Subroutine to prompt user */
prompt_user:
DO FOREVER
SAY "Continue to next dataset? (Y/N)"
PULL answer
answer = TRANSLATE(LEFT(answer, 1))
IF answer = 'Y' | answer = 'N' THEN LEAVE
SAY "Please enter Y or N."
END
RESULT = answer
RETURN