-
Notifications
You must be signed in to change notification settings - Fork 20
/
QSHCPYSRCC.CLLE
146 lines (129 loc) · 7.76 KB
/
QSHCPYSRCC.CLLE
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
PGM PARM(&SRCFILEALL &SRCMBR &SRCTYPE &TOIFSFILE +
&IFSOPT)
/*----------------------------------------------------------------------------*/
/* Variables */
/*----------------------------------------------------------------------------*/
DCL VAR(&IFSOPT) TYPE(*CHAR) LEN(10)
DCL VAR(&TOIFSFILE) TYPE(*CHAR) LEN(255)
DCL VAR(&TMPSCRIPT) TYPE(*CHAR) LEN(255)
DCL VAR(&SRCTYPE) TYPE(*CHAR) LEN(10)
DCL VAR(&SRCTYPTMP) TYPE(*CHAR) LEN(10)
DCL VAR(&SRCMBR) TYPE(*CHAR) LEN(10)
DCL VAR(&SRCLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&SRCFILE) TYPE(*CHAR) LEN(10)
DCL VAR(&SRCFILEALL) TYPE(*CHAR) LEN(20)
DCL VAR(&MBROPT) TYPE(*CHAR) LEN(10)
DCL VAR(&OUTFILE) TYPE(*CHAR) LEN(20)
DCL VAR(&OUTFILPATH) TYPE(*CHAR) LEN(255)
DCL VAR(&OFILE) TYPE(*CHAR) LEN(10)
DCL VAR(&OLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&QSHRTN) TYPE(*DEC) LEN(5 0)
DCL VAR(&QSHRTNC) TYPE(*CHAR) LEN(5)
DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(200)
DCL VAR(&MSGDTA4) TYPE(*CHAR) LEN(4)
DCL VAR(&CPFID) TYPE(*CHAR) LEN(7)
DCL VAR(&CMD) TYPE(*CHAR) LEN(9999)
DCL VAR(&STDOUTIFS) TYPE(*CHAR) LEN(255)
DCL VAR(&STDOUTFILE) TYPE(*CHAR) LEN(255)
DCL VAR(&JOB) TYPE(*CHAR) LEN(10)
DCL VAR(&JOBNBR) TYPE(*CHAR) LEN(6)
DCL VAR(&USER) TYPE(*CHAR) LEN(10)
DCL VAR(&TEMPDIR) TYPE(*CHAR) LEN(255) +
VALUE('/tmp')
DCL VAR(&QSHTEMP) TYPE(*CHAR) LEN(255) +
VALUE('/tmp/qsh')
DCL VAR(&DSPSTDOUT) TYPE(*CHAR) LEN(4)
DCL VAR(&LOGSTDOUT) TYPE(*CHAR) LEN(4)
DCL VAR(&DLTSTDOUT) TYPE(*CHAR) LEN(4)
DCL VAR(&PRTSTDOUT) TYPE(*CHAR) LEN(4)
DCL VAR(&IFSSTDOUT) TYPE(*CHAR) LEN(4)
DCL VAR(&IFSOPT) TYPE(*CHAR) LEN(10)
DCL VAR(&IFSFILE) TYPE(*CHAR) LEN(255)
DCL VAR(&RTNVAL) TYPE(*CHAR) LEN(6)
DCL VAR(&CURJOB) TYPE(*CHAR) LEN(10)
DCL VAR(&CURUSER) TYPE(*CHAR) LEN(10)
DCL VAR(&CURNBR) TYPE(*CHAR) LEN(6)
DCL VAR(&QDATE) TYPE(*CHAR) LEN(6)
DCL VAR(&QTIME) TYPE(*CHAR) LEN(9)
DCL VAR(&PRTTXT) TYPE(*CHAR) LEN(30)
DCL VAR(&CCSID) TYPE(*CHAR) LEN(10)
/*----------------------------------------------------------------------------*/
/* MONITOR FOR GLOBAL ERROR. ANY ERROR IS A CAUSE TO BLOW OUT OF HERE */
/* AND WE WANT A GRACEFUL EXIT. */
/*----------------------------------------------------------------------------*/
MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERRORS))
/*----------------------------------------------------------------------------*/
/* MAIN */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* RETRIEVE JOB DATE/TIME INFO */
/*----------------------------------------------------------------------------*/
RTVSYSVAL SYSVAL(QDATE) RTNVAR(&QDATE)
RTVSYSVAL SYSVAL(QTIME) RTNVAR(&QTIME)
RTVJOBA JOB(&CURJOB) USER(&CURUSER) NBR(&CURNBR)
/*----------------------------------------------------------------------------*/
/* Extract source member info */
/*----------------------------------------------------------------------------*/
CHGVAR VAR(&SRCFILE) VALUE(%SST(&SRCFILEALL 1 10))
CHGVAR VAR(&SRCLIB) VALUE(%SST(&SRCFILEALL 11 10))
/*----------------------------------------------------------------------------*/
/* Create temporary IFS source name data area */
/*----------------------------------------------------------------------------*/
CRTDTAARA DTAARA(QTEMP/TMPSRCFILE) TYPE(*CHAR) +
LEN(255) TEXT('Temp Source IFS Member')
MONMSG MSGID(CPF0000)
CHGDTAARA DTAARA(QTEMP/TMPSRCFILE *ALL) VALUE(' ')
/*----------------------------------------------------------------------------*/
/* Does source member exist */
/*----------------------------------------------------------------------------*/
CHKOBJ OBJ(&SRCLIB/&SRCFILE) OBJTYPE(*FILE) +
MBR(&SRCMBR)
MONMSG MSGID(CPF0000) EXEC(DO)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Error +
checking for source member' |> &SRCLIB |< +
'/' |< &SRCFILE |< '(' |< &SRCMBR |< ')') +
MSGTYPE(*ESCAPE)
ENDDO
/* Get source type if *MEMBER for source type */
IF COND(&SRCTYPE *EQ *MEMBER) THEN(DO)
RTVMBRD FILE(&SRCLIB/&SRCFILE) MBR(&SRCMBR) +
SRCTYPE(&SRCTYPTMP)
ENDDO
IF COND(&SRCTYPE *NE *MEMBER) THEN(DO)
CHGVAR VAR(&SRCTYPTMP) VALUE(&SRCTYPE)
ENDDO
/*----------------------------------------------------------------------------*/
/* Build temp script file name */
/*----------------------------------------------------------------------------*/
IF COND(&TOIFSFILE *EQ *GENERATE) THEN(DO)
CHGVAR VAR(&TMPSCRIPT) VALUE(&QSHTEMP |< '/' |< +
&SRCMBR |< '_' |< &QDATE |< &QTIME |< +
&CURUSER |< '.' |< &SRCTYPTMP)
ENDDO
IF COND(&TOIFSFILE *NE *GENERATE) THEN(DO)
CHGVAR VAR(&TMPSCRIPT) VALUE(&TOIFSFILE)
ENDDO
/*----------------------------------------------------------------------------*/
/* Copy source member script to IFS */
/*----------------------------------------------------------------------------*/
/* Set temp script output file name */
CHGDTAARA DTAARA(QTEMP/TMPSRCFILE *ALL) +
VALUE(&TMPSCRIPT)
CPYTOSTMF FROMMBR('/QSYS.LIB/' |< &SRCLIB |< '.LIB/' +
|< &SRCFILE |< '.FILE/' |< &SRCMBR |< +
'.MBR') TOSTMF(&TMPSCRIPT) +
STMFOPT(&IFSOPT) CVTDTA(*AUTO) +
STMFCCSID(*PCASCII) ENDLINFMT(*LF) +
AUT(*INDIR) STMFCODPAG(*STMF)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Source +
member' |> &SRCLIB |< '/' |< &SRCFILE |< +
'(' |< &SRCMBR |< ') was copied to IFS +
file' |> &TMPSCRIPT) MSGTYPE(*COMP)
RETURN
ERRORS:
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Source +
member' |> &SRCLIB |< '/' |< &SRCFILE |< +
'(' |< &SRCMBR |< ') copy to IFS file +
failed. Check the job log') MSGTYPE(*ESCAPE)
ENDPGM:
ENDPGM