Philip Howells' code

Philip Howells' code

Run FTP Script Command (AUTOFTP)

 
Type choices, press Enter. 

Input Script File  . . . . . . . > $FTP_INPUT 	10 Chars 
  Library  . . . . . . . . . . . > $ADMIN 	10 Chars 
  Member . . . . . . . . . . . . > OVERNIGHT 	10 Chars 
Remote System Name . . . . . . . > CH1SRV08 
Remote USERNAME  . . . . . . . . > PHOWELLS 
Remote PASSWORD  . . . . . . . . > 
Domain (NT only) . . . . . . . . > SICPA 

Batch Mode (Y/N)?  . . . . . . . > Y 		Y, N 
Job Name . . . . . . . . . . . . > SICPAXFR 	Character value 
JOBD . . . . . . . . . . . . . . > IS_ADMIN 	Default *USRPRF 
  Library  . . . . . . . . . . . > $ADMIN 	Character value 
JOBQ . . . . . . . . . . . . . . > A064LBCH2 	Default *JOBD 
  Library  . . . . . . . . . . . > A0GPL 	Character value 

Log (Y/N)? . . . . . . . . . . . > Y 		Y, N 

Date      (ddmmyy) . . . . . . . > 060801 	Blank=Today 
Time 24hr (hhmmss) . . . . . . . > 2030 	Blank=Now 

Recurring (Y/N)? . . . . . . . . > Y 		Y, N 
MONDAY    Run (Y/N)? . . . . . . . N 		Y, N 
TUESDAY   Run (Y/N)? . . . . . . > Y 		Y, N 
WEDNESDAY Run (Y/N)? . . . . . . . N 		Y, N 
THURSDAY  Run (Y/N)? . . . . . . . N 		Y, N 
FRIDAY    Run (Y/N)? . . . . . . > Y 		Y, N 
SATURDAY  Run (Y/N)? . . . . . . > Y 		Y, N 
SUNDAY    Run (Y/N)? . . . . . . . N 		Y, N 

F3=Exit F4=Prompt F5=Refresh F12=Cancel F13=How to use this display 
F24=More keys 

Input File Consideration

The command expects to find a script that uses the format QCLSRC with the default field labels SRCSEQ + SRCDAT + SRCDTA, though SRCDAT is ignored in this command). Example... 

SRCSEQ  SRCDAT  SRCDTA 
0001.00 010,423 
0002.00 010,423 cd 039 
0003.00 010,423 namefmt 1 
0004.00 010,423 mput /SICPA/DATAWHS/039* 
0005.00 010,423 mput /SICPA/DATAWHS/h* 
0006.00 010,423 quit 
 
		
		Code: AUTOFTP (CMD)
*************** Beginning of data ***************************************************************************************
0001.00 CMD PROMPT('Run FTP Script Command') 
0002.00 
0003.00 INPUTF: PARM KWD(INPUTF) TYPE(*CHAR) LEN(10) MIN(1) ALWUNPRT(*NO) ALWVAR(*YES) CHOICE('10 Chars') + 
0004.00 PROMPT('Input Script File') 
0005.00 
0006.00 INPUTLIB: PARM KWD(INPUTLIB) TYPE(*CHAR) LEN(10) MIN(1) ALWUNPRT(*NO) ALWVAR(*YES) CHOICE('10 Chars') + 
0007.00 PROMPT(' Library') 
0008.00 
0009.00 INPUTMBR: PARM KWD(INPUTMBR) TYPE(*CHAR) LEN(10) MIN(1) ALWUNPRT(*NO) ALWVAR(*YES) CHOICE('10 Chars') + 
0010.00 PROMPT(' Member') 
0011.00 
0012.00 RMTSYS: PARM KWD(RMTSYS) TYPE(*CHAR) LEN(15) MIN(1) ALWUNPRT(*NO) ALWVAR(*YES) + 
0013.00 CHOICE('AS/400 Max 10)') PROMPT('Remote System Name') 
0014.00 
0015.00 USERNAME: PARM KWD(USERNAME) TYPE(*CHAR) LEN(15) MIN(1) ALWUNPRT(*NO) ALWVAR(*YES) CASE(*MIXED) + 
0016.00 CHOICE('AS/400 Max 10)') PROMPT('Remote USERNAME') 
0017.00 
0018.00 PASSWORD: PARM KWD(PASSWORD) TYPE(*CHAR) LEN(15) MIN(1) ALWUNPRT(*NO) ALWVAR(*YES) CASE(*MIXED) + 
0019.00 DSPINPUT(*NO) CHOICE('AS/400 Max 10)') PROMPT('Remote PASSWORD') 
0020.00 
0021.00 DOMAIN: PARM KWD(DOMAIN) TYPE(*CHAR) LEN(15) MIN(0) ALWUNPRT(*NO) ALWVAR(*YES) + 
0022.00 CHOICE('15 Chars') PROMPT('Domain (NT only)') 
0023.00 
0024.00 BATCH: PARM KWD(BATCH) TYPE(*CHAR) LEN(1) RSTD(*YES) DFT(N) VALUES(Y N) MIN(0) ALWUNPRT(*NO) + 
0025.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('Batch Mode (Y/N)?') 
0026.00 
0027.00 BATCHVAL: PMTCTL CTL(BATCH) COND((*EQ Y)) 
0028.00 
0029.00 JOBNAME: PARM KWD(JOBNAME) TYPE(*CHAR) LEN(10) DFT(AUTOFTPBCH) MIN(0) ALWUNPRT(*NO) ALWVAR(*YES) + 
0030.00 DSPINPUT(*YES) PMTCTL(BATCHVAL) PROMPT('Job Name') 
0031.00 
0032.00 JOBD: PARM KWD(JOBD) TYPE(*CHAR) LEN(10) MIN(0) ALWUNPRT(*YES) + 
0033.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('JOBD') CHOICE('Default *USRPRF') PMTCTL(BATCHVAL) 
0034.00 
0035.00 JOBDLIB: PARM KWD(JOBDLIB) TYPE(*CHAR) LEN(10) MIN(0) ALWUNPRT(*NO) + 
0036.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT(' Library') PMTCTL(BATCHVAL) 
0037.00 
0038.00 JOBQ: PARM KWD(JOBQ) TYPE(*CHAR) LEN(10) MIN(0) ALWUNPRT(*YES) + 
0039.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('JOBQ') CHOICE('Default *JOBD') PMTCTL(BATCHVAL) 
0040.00 
0041.00 JOBQLIB: PARM KWD(JOBQLIB) TYPE(*CHAR) LEN(10) MIN(0) ALWUNPRT(*NO) + 
0042.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT(' Library') PMTCTL(BATCHVAL) 
0043.00 
0044.00 LOG: PARM KWD(LOG) TYPE(*CHAR) LEN(1) RSTD(*YES) MIN(0) ALWUNPRT(*NO) VALUES(Y N) DFT(N) + 
0045.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('Log (Y/N)?') PMTCTL(BATCHVAL) 
0046.00 
0047.00 DATE: PARM KWD(DATE) TYPE(*DATE) RSTD(*NO) MIN(0) ALWUNPRT(*YES) + 
0048.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('Date (ddmmyy)') PMTCTL(BATCHVAL) CHOICE('Blank=Today') 
0049.00 
0050.00 TIME: PARM KWD(TIME) TYPE(*TIME) RSTD(*NO) MIN(0) ALWUNPRT(*YES) + 
0051.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('Time 24hr (hhmmss)') PMTCTL(BATCHVAL) CHOICE('Blank=Now') 
0052.00 
0053.00 TIMEVAL: PMTCTL CTL(TIME) COND((*SPCFD)) 
0054.00 
0055.00 RECUR: PARM KWD(RECUR) TYPE(*CHAR) LEN(1) RSTD(*YES) MIN(0) ALWUNPRT(*NO) VALUES(Y N) DFT(N) + 
0056.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('Recurring (Y/N)?') PMTCTL(TIMEVAL) 
0057.00 
0058.00 RECURVAL: PMTCTL CTL(RECUR) COND((*EQ Y)) 
0059.00 
0060.00 MON: PARM KWD(MON) TYPE(*CHAR) LEN(1) RSTD(*YES) MIN(0) ALWUNPRT(*NO) VALUES(Y N) DFT(N) + 
0061.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('MONDAY Run (Y/N)?') PMTCTL(RECURVAL) 
0062.00 
0063.00 TUE: PARM KWD(TUE) TYPE(*CHAR) LEN(1) RSTD(*YES) MIN(0) ALWUNPRT(*NO) VALUES(Y N) DFT(N) + 
0064.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('TUESDAY Run (Y/N)?') PMTCTL(RECURVAL) 
0065.00 
0066.00 WED: PARM KWD(WED) TYPE(*CHAR) LEN(1) RSTD(*YES) MIN(0) ALWUNPRT(*NO) VALUES(Y N) DFT(N) + 
0067.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('WEDNESDAY Run (Y/N)?') PMTCTL(RECURVAL) 
0068.00 
0069.00 THU: PARM KWD(THU) TYPE(*CHAR) LEN(1) RSTD(*YES) MIN(0) ALWUNPRT(*NO) VALUES(Y N) DFT(N) + 
0070.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('THURSDAY Run (Y/N)?') PMTCTL(RECURVAL) 
0071.00 
0072.00 FRI: PARM KWD(FRI) TYPE(*CHAR) LEN(1) RSTD(*YES) MIN(0) ALWUNPRT(*NO) VALUES(Y N) DFT(N) + 
0073.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('FRIDAY Run (Y/N)?') PMTCTL(RECURVAL) 
0074.00 
0075.00 SAT: PARM KWD(SAT) TYPE(*CHAR) LEN(1) RSTD(*YES) MIN(0) ALWUNPRT(*NO) VALUES(Y N) DFT(N) + 
0076.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('SATURDAY Run (Y/N)?') PMTCTL(RECURVAL) 
0077.00 
0078.00 SUN: PARM KWD(SUN) TYPE(*CHAR) LEN(1) RSTD(*YES) MIN(0) ALWUNPRT(*NO) VALUES(Y N) DFT(N) + 
0079.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('SUNDAY Run (Y/N)?') PMTCTL(RECURVAL) 
0080.00 
****************** End of data ****************************************************************************************** 

AUTOFTP (CL)
*************** Beginning of data ***************************************************************************************
0001.00 PGM PARM(&INPUTF &INPUTLIB &INPUTMBR &RMTSYS &USERNAME &PASSWORD &DOMAIN &BATCH &JOBNAME + 
0002.00 &JOBD &JOBDLIB &JOBQ &JOBQLIB &LOG &DATE &TIME &RECUR &MON &TUE &WED &THU &FRI &SAT &SUN) 
0003.00 
0004.00 DCL VAR(&INPUTF) TYPE(*CHAR) LEN(10) 
0005.00 DCL VAR(&INPUTLIB) TYPE(*CHAR) LEN(10) 
0006.00 DCL VAR(&INPUTMBR) TYPE(*CHAR) LEN(10) 
0007.00 DCL VAR(&RMTSYS) TYPE(*CHAR) LEN(15) 
0008.00 DCL VAR(&USERNAME) TYPE(*CHAR) LEN(15) 
0009.00 DCL VAR(&PASSWORD) TYPE(*CHAR) LEN(15) 
0010.00 DCL VAR(&DOMAIN) TYPE(*CHAR) LEN(15) 
0011.00 DCL VAR(&BATCH) TYPE(*CHAR) LEN(1) 
0012.00 DCL VAR(&JOBNAME) TYPE(*CHAR) LEN(10) 
0013.00 DCL VAR(&JOBD) TYPE(*CHAR) LEN(10) 
0014.00 DCL VAR(&JOBDLIB) TYPE(*CHAR) LEN(10) 
0015.00 DCL VAR(&JOBQ) TYPE(*CHAR) LEN(10) 
0016.00 DCL VAR(&JOBQLIB) TYPE(*CHAR) LEN(10) 
0017.00 DCL VAR(&LOG) TYPE(*CHAR) LEN(1) 
0018.00 DCL VAR(&DATE) TYPE(*CHAR) LEN(7) 
0019.00 DCL VAR(&TIME) TYPE(*CHAR) LEN(6) 
0020.00 DCL VAR(&RECUR) TYPE(*CHAR) LEN(1) 
0021.00 DCL VAR(&MON) TYPE(*CHAR) LEN(1) 
0022.00 DCL VAR(&TUE) TYPE(*CHAR) LEN(1) 
0023.00 DCL VAR(&WED) TYPE(*CHAR) LEN(1) 
0024.00 DCL VAR(&THU) TYPE(*CHAR) LEN(1) 
0025.00 DCL VAR(&FRI) TYPE(*CHAR) LEN(1) 
0026.00 DCL VAR(&SAT) TYPE(*CHAR) LEN(1) 
0027.00 DCL VAR(&SUN) TYPE(*CHAR) LEN(1) 
0028.00 
0029.00 DCL VAR(&BLANK) TYPE(*CHAR) LEN(40) 
0030.00 DCL VAR(&C) TYPE(*CHAR) LEN(1) VALUE('''') 
0031.00 DCL VAR(&SQL) TYPE(*CHAR) LEN(100) 
0032.00 DCL VAR(&LOGUSED) TYPE(*CHAR) LEN(11) 
0033.00 DCL VAR(&LOGCLPGM) TYPE(*CHAR) LEN(5) 
0034.00 DCL VAR(&TODAY) TYPE(*CHAR) LEN(4) 
0035.00 DCL VAR(&DATENOW) TYPE(*CHAR) LEN(6) 
0036.00 DCL VAR(&TIMENOW) TYPE(*CHAR) LEN(6) 
0037.00 DCL VAR(&TEXT) TYPE(*CHAR) LEN(80) 
0038.00 
0039.00 MONMSG MSGID(CPF0000) 
0040.00 
0041.00 IF COND(&BATCH *EQ 'N') THEN(GOTO CMDLBL(INTERACT)) 
0042.00 
0043.00 RTVSYSVAL SYSVAL(QDATE) RTNVAR(&DATENOW) 
0044.00 
0045.00 IF COND(&DATE *EQ '0000000') + 
0046.00 THEN(CHGVAR VAR(&DATE) VALUE(&DATENOW)) 
0047.00 ELSE CHGVAR VAR(&DATE) VALUE(%SST(&DATE 6 2) *TCAT %SST(&DATE 4 2) *TCAT %SST(&DATE 2 2)) 
0048.00 
0049.00 SBMJOB CMD(*LIBL/AUTOFTPSCH INPUTF(&INPUTF) INPUTLIB(&INPUTLIB) + 
0050.00 INPUTMBR(&INPUTMBR) RMTSYS(&RMTSYS) USERNAME(&USERNAME) PASSWORD(&PASSWORD) DOMAIN(&DOMAIN) + 
0051.00 BATCH(&BATCH) JOBNAME(&JOBNAME) JOBD(&JOBD) JOBDLIB(&JOBDLIB) JOBQ(&JOBQ) + 
0052.00 JOBQLIB(&JOBQLIB) LOG(&LOG) DATE(&DATE) TIME(&TIME) RECUR(&RECUR) MON(&MON) + 
0053.00 TUE(&TUE) WED(&WED) THU(&THU) FRI(&FRI) SAT(&SAT) SUN(&SUN)) JOB(AUTOFTPSCH) + 
0054.00 JOBQ($ADMIN/IS_ADMIN)
0055.00 
0056.00 GOTO CMDLBL(EXIT) 
0057.00 
0058.00 INTERACT: 
0059.00 
0060.00 OVRDBF FILE(&INPUTF) TOFILE(&INPUTLIB/&INPUTF) MBR(&INPUTMBR) 
0061.00 
0062.00 /**********************************************/ 
0063.00 /* BUILD & RUN SQL STATEMENT - SET PASSWORD */ 
0064.00 
0065.00 IF COND(&DOMAIN *NE ' ') + 
0066.00 THEN(CHGVAR VAR(&SQL) VALUE('UPDATE ' *CAT &INPUTLIB *TCAT '/' *TCAT &INPUTF *TCAT ' SET SRCDTA = ' + 
0067.00 *CAT &C *TCAT &DOMAIN *TCAT '' *TCAT &USERNAME *TCAT ' ' *CAT &PASSWORD *TCAT &C *TCAT ' WHERE SRCSEQ = 1')) 
0068.00 ELSE CHGVAR VAR(&SQL) VALUE('UPDATE ' *CAT &INPUTLIB *TCAT '/' *TCAT &INPUTF *TCAT ' SET SRCDTA = ' + 
0069.00 *CAT &C *TCAT &USERNAME *TCAT ' ' *CAT &PASSWORD *TCAT &C *TCAT ' WHERE SRCSEQ = 1') 
0070.00 
0071.00 RUNSQL REQUEST(&SQL) 
0072.00 /**********************************************/ 
0073.00 
0074.00 OVRDBF FILE(INPUT) TOFILE(&INPUTLIB/&INPUTF) MBR(&INPUTMBR) 
0075.00 
0076.00 FTP RMTSYS(&RMTSYS) 
0077.00 OVRDBF FILE(INPUT) 
0078.00 
0079.00 /**********************************************/ 
0080.00 /* BUILD & RUN SQL STATEMENT - CLEAR PASSWORD */ 
0081.00 
0082.00 CHGVAR VAR(&SQL) VALUE('UPDATE ' *CAT &INPUTLIB *TCAT '/' *TCAT &INPUTF *TCAT ' SET SRCDTA = ' + 
0083.00 *CAT &C *TCAT &BLANK *TCAT &C *TCAT ' WHERE SRCSEQ = 1') 
0084.00 
0085.00 RUNSQL REQUEST(&SQL) 
0086.00 /**********************************************/ 
0087.00 
0088.00 EXIT: 
0089.00 
0090.00 ENDPGM 
****************** End of data ****************************************************************************************** 

AUTOFTPSCH (CMD)
*************** Beginning of data ***************************************************************************************
0001.00 CMD PROMPT('Run FTP Script Command') 
0002.00 
0003.00 INPUTF: PARM KWD(INPUTF) TYPE(*CHAR) LEN(10) MIN(1) ALWUNPRT(*NO) ALWVAR(*YES) CHOICE('10 Chars') + 
0004.00 PROMPT('Input Script File') 
0005.00 
0006.00 INPUTLIB: PARM KWD(INPUTLIB) TYPE(*CHAR) LEN(10) MIN(1) ALWUNPRT(*NO) ALWVAR(*YES) CHOICE('10 Chars') + 
0007.00 PROMPT(' Library') 
0008.00 
0009.00 INPUTMBR: PARM KWD(INPUTMBR) TYPE(*CHAR) LEN(10) MIN(1) ALWUNPRT(*NO) ALWVAR(*YES) CHOICE('10 Chars') + 
0010.00 PROMPT(' Member') 
0011.00 
0012.00 RMTSYS: PARM KWD(RMTSYS) TYPE(*CHAR) LEN(15) MIN(1) ALWUNPRT(*NO) ALWVAR(*YES) + 
0013.00 CHOICE('AS/400 Max 10)') PROMPT('Remote System Name') 
0014.00 
0015.00 USERNAME: PARM KWD(USERNAME) TYPE(*CHAR) LEN(15) MIN(1) ALWUNPRT(*NO) ALWVAR(*YES) CASE(*MIXED) + 
0016.00 CHOICE('AS/400 Max 10)') PROMPT('Remote USERNAME') 
0017.00 
0018.00 PASSWORD: PARM KWD(PASSWORD) TYPE(*CHAR) LEN(15) MIN(1) ALWUNPRT(*NO) ALWVAR(*YES) CASE(*MIXED) + 
0019.00 DSPINPUT(*NO) CHOICE('AS/400 Max 10)') PROMPT('Remote PASSWORD') 
0020.00 
0021.00 DOMAIN: PARM KWD(DOMAIN) TYPE(*CHAR) LEN(15) MIN(0) ALWUNPRT(*NO) ALWVAR(*YES) + 
0022.00 CHOICE('15 Chars') PROMPT('Domain (NT only)') 
0023.00 
0024.00 BATCH: PARM KWD(BATCH) TYPE(*CHAR) LEN(1) RSTD(*YES) DFT(N) VALUES(Y N) MIN(0) ALWUNPRT(*NO) + 
0025.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('Batch Mode (Y/N)?') 
0026.00 
0027.00 BATCHVAL: PMTCTL CTL(BATCH) COND((*EQ Y)) 
0028.00 
0029.00 JOBNAME: PARM KWD(JOBNAME) TYPE(*CHAR) LEN(10) DFT(AUTOFTPBCH) MIN(0) ALWUNPRT(*NO) ALWVAR(*YES) + 
0030.00 DSPINPUT(*YES) PMTCTL(BATCHVAL) PROMPT('Job Name') 
0031.00 
0032.00 JOBD: PARM KWD(JOBD) TYPE(*CHAR) LEN(10) MIN(0) ALWUNPRT(*YES) + 
0033.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('JOBD') CHOICE('Default *USRPRF') PMTCTL(BATCHVAL) 
0034.00 
0035.00 JOBDLIB: PARM KWD(JOBDLIB) TYPE(*CHAR) LEN(10) MIN(0) ALWUNPRT(*NO) + 
0036.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT(' Library') PMTCTL(BATCHVAL) 
0037.00 
0038.00 JOBQ: PARM KWD(JOBQ) TYPE(*CHAR) LEN(10) MIN(0) ALWUNPRT(*YES) + 
0039.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('JOBQ') CHOICE('Default *JOBD') PMTCTL(BATCHVAL) 
0040.00 
0041.00 JOBQLIB: PARM KWD(JOBQLIB) TYPE(*CHAR) LEN(10) MIN(0) ALWUNPRT(*NO) + 
0042.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT(' Library') PMTCTL(BATCHVAL) 
0043.00 
0044.00 LOG: PARM KWD(LOG) TYPE(*CHAR) LEN(1) RSTD(*YES) MIN(0) ALWUNPRT(*NO) VALUES(Y N) DFT(N) + 
0045.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('Log (Y/N)?') PMTCTL(BATCHVAL) 
0046.00 
0047.00 DATE: PARM KWD(DATE) TYPE(*DATE) RSTD(*NO) MIN(0) ALWUNPRT(*YES) + 
0048.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('Date (ddmmyy)') PMTCTL(BATCHVAL) CHOICE('Blank=Today') 
0049.00 
0050.00 TIME: PARM KWD(TIME) TYPE(*TIME) RSTD(*NO) MIN(0) ALWUNPRT(*YES) + 
0051.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('Time 24hr (hhmmss)') PMTCTL(BATCHVAL) CHOICE('Blank=Now') 
0052.00 
0053.00 TIMEVAL: PMTCTL CTL(TIME) COND((*SPCFD)) 
0054.00 
0055.00 RECUR: PARM KWD(RECUR) TYPE(*CHAR) LEN(1) RSTD(*YES) MIN(0) ALWUNPRT(*NO) VALUES(Y N) DFT(N) + 
0056.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('Recurring (Y/N)?') PMTCTL(TIMEVAL) 
0057.00 
0058.00 RECURVAL: PMTCTL CTL(RECUR) COND((*EQ Y)) 
0059.00 
0060.00 MON: PARM KWD(MON) TYPE(*CHAR) LEN(1) RSTD(*YES) MIN(0) ALWUNPRT(*NO) VALUES(Y N) DFT(N) + 
0061.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('MONDAY Run (Y/N)?') PMTCTL(RECURVAL) 
0062.00 
0063.00 TUE: PARM KWD(TUE) TYPE(*CHAR) LEN(1) RSTD(*YES) MIN(0) ALWUNPRT(*NO) VALUES(Y N) DFT(N) + 
0064.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('TUESDAY Run (Y/N)?') PMTCTL(RECURVAL) 
0065.00 
0066.00 WED: PARM KWD(WED) TYPE(*CHAR) LEN(1) RSTD(*YES) MIN(0) ALWUNPRT(*NO) VALUES(Y N) DFT(N) + 
0067.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('WEDNESDAY Run (Y/N)?') PMTCTL(RECURVAL) 
0068.00 
0069.00 THU: PARM KWD(THU) TYPE(*CHAR) LEN(1) RSTD(*YES) MIN(0) ALWUNPRT(*NO) VALUES(Y N) DFT(N) + 
0070.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('THURSDAY Run (Y/N)?') PMTCTL(RECURVAL) 
0071.00 
0072.00 FRI: PARM KWD(FRI) TYPE(*CHAR) LEN(1) RSTD(*YES) MIN(0) ALWUNPRT(*NO) VALUES(Y N) DFT(N) + 
0073.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('FRIDAY Run (Y/N)?') PMTCTL(RECURVAL) 
0074.00 
0075.00 SAT: PARM KWD(SAT) TYPE(*CHAR) LEN(1) RSTD(*YES) MIN(0) ALWUNPRT(*NO) VALUES(Y N) DFT(N) + 
0076.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('SATURDAY Run (Y/N)?') PMTCTL(RECURVAL) 
0077.00 
0078.00 SUN: PARM KWD(SUN) TYPE(*CHAR) LEN(1) RSTD(*YES) MIN(0) ALWUNPRT(*NO) VALUES(Y N) DFT(N) + 
0079.00 ALWVAR(*YES) DSPINPUT(*YES) PROMPT('SUNDAY Run (Y/N)?') PMTCTL(RECURVAL) 
0080.00 
****************** End of data ****************************************************************************************** 

AUTOFTPSCH (CL)
*************** Beginning of data ***************************************************************************************
0001.00 PGM PARM(&INPUTF &INPUTLIB &INPUTMBR &RMTSYS &USERNAME &PASSWORD &DOMAIN &BATCH &JOBNAME + 
0002.00 &JOBD &JOBDLIB &JOBQ &JOBQLIB &LOG &DATE &TIME &RECUR &MON &TUE &WED &THU &FRI &SAT &SUN) 
0003.00 
0004.00 DCL VAR(&INPUTF) TYPE(*CHAR) LEN(10) 
0005.00 DCL VAR(&INPUTLIB) TYPE(*CHAR) LEN(10) 
0006.00 DCL VAR(&INPUTMBR) TYPE(*CHAR) LEN(10) 
0007.00 DCL VAR(&RMTSYS) TYPE(*CHAR) LEN(15) 
0008.00 DCL VAR(&USERNAME) TYPE(*CHAR) LEN(15) 
0009.00 DCL VAR(&PASSWORD) TYPE(*CHAR) LEN(15) 
0010.00 DCL VAR(&DOMAIN) TYPE(*CHAR) LEN(15) 
0011.00 DCL VAR(&BATCH) TYPE(*CHAR) LEN(1) 
0012.00 DCL VAR(&JOBNAME) TYPE(*CHAR) LEN(10) 
0013.00 DCL VAR(&JOBD) TYPE(*CHAR) LEN(10) 
0014.00 DCL VAR(&JOBDLIB) TYPE(*CHAR) LEN(10) 
0015.00 DCL VAR(&JOBQ) TYPE(*CHAR) LEN(10) 
0016.00 DCL VAR(&JOBQLIB) TYPE(*CHAR) LEN(10) 
0017.00 DCL VAR(&LOG) TYPE(*CHAR) LEN(1) 
0018.00 DCL VAR(&DATE) TYPE(*CHAR) LEN(7) 
0019.00 DCL VAR(&TIME) TYPE(*CHAR) LEN(6) 
0020.00 DCL VAR(&RECUR) TYPE(*CHAR) LEN(1) 
0021.00 DCL VAR(&MON) TYPE(*CHAR) LEN(1) 
0022.00 DCL VAR(&TUE) TYPE(*CHAR) LEN(1) 
0023.00 DCL VAR(&WED) TYPE(*CHAR) LEN(1) 
0024.00 DCL VAR(&THU) TYPE(*CHAR) LEN(1) 
0025.00 DCL VAR(&FRI) TYPE(*CHAR) LEN(1) 
0026.00 DCL VAR(&SAT) TYPE(*CHAR) LEN(1) 
0027.00 DCL VAR(&SUN) TYPE(*CHAR) LEN(1) 
0028.00 
0029.00 DCL VAR(&LOGUSED) TYPE(*CHAR) LEN(11) 
0030.00 DCL VAR(&LOGCLPGM) TYPE(*CHAR) LEN(5) 
0031.00 DCL VAR(&TODAY) TYPE(*CHAR) LEN(4) 
0032.00 DCL VAR(&DATENOW) TYPE(*CHAR) LEN(6) 
0033.00 DCL VAR(&TIMENOW) TYPE(*CHAR) LEN(6) 
0034.00 DCL VAR(&RUNYET) TYPE(*CHAR) LEN(1) VALUE(N) 
0035.00 DCL VAR(&C) TYPE(*CHAR) LEN(1) VALUE('''') 
0036.00 DCL VAR(&SQL) TYPE(*CHAR) LEN(100) 
0037.00 
0038.00 MONMSG MSGID(CPF0000) 
0039.00 
0040.00 OVRDBF FILE(&INPUTF) TOFILE(&INPUTLIB/&INPUTF) MBR(&INPUTMBR) 
0041.00 
0042.00 IF COND(&LOG *EQ 'Y') THEN(DO) 
0043.00 CHGVAR VAR(&LOGUSED) VALUE(*SECLVL) 
0044.00 CHGVAR VAR(&LOGCLPGM) VALUE(*YES) 
0045.00 ENDDO 
0046.00 
0047.00 IF COND(&LOG *EQ 'N') THEN(DO) 
0048.00 CHGVAR VAR(&LOGUSED) VALUE(*NOLIST) 
0049.00 CHGVAR VAR(&LOGCLPGM) VALUE(*NO) 
0050.00 ENDDO 
0051.00 
0052.00 CHGVAR VAR(&DATE) VALUE(%SST(&DATE 6 2) *TCAT %SST(&DATE 4 2) *TCAT %SST(&DATE 2 2)) 
0053.00 CHGVAR VAR(&TIME) VALUE(%SST(&TIME 1 4)) 
0054.00 
0055.00 CHKDTTIM: 
0056.00 
0057.00 RTVSYSVAL SYSVAL(QDAYOFWEEK) RTNVAR(&TODAY) 
0058.00 RTVSYSVAL SYSVAL(QDATE) RTNVAR(&DATENOW) 
0059.00 RTVSYSVAL SYSVAL(QTIME) RTNVAR(&TIMENOW) 
0060.00 
0061.00 CHGVAR VAR(&TIMENOW) VALUE(%SST(&TIMENOW 1 4)) 
0062.00 
0063.00 IF COND(&DATE *EQ '000000' *AND &TIME *EQ '0000' ) THEN(GOTO CMDLBL(SUBMIT)) 
0064.00 IF COND(&DATE *EQ '000000' *AND &TIME *EQ &TIMENOW) THEN(GOTO CMDLBL(SUBMIT)) 
0065.00 IF COND(&DATE *EQ &DATENOW *AND &TIME *EQ '0000' ) THEN(GOTO CMDLBL(SUBMIT)) 
0066.00 IF COND(&DATE *EQ &DATENOW *AND &TIME *EQ &TIMENOW) THEN(GOTO CMDLBL(SUBMIT)) 
0067.00 
0068.00 IF COND(&RUNYET *EQ 'Y' *AND &RECUR *EQ 'Y') THEN(DO) 
0069.00 IF COND(&TODAY *EQ '*MON' *AND &MON *EQ 'Y' *AND &TIME *EQ &TIMENOW) THEN(GOTO CMDLBL(SUBMIT)) 
0070.00 IF COND(&TODAY *EQ '*TUE' *AND &TUE *EQ 'Y' *AND &TIME *EQ &TIMENOW) THEN(GOTO CMDLBL(SUBMIT)) 
0071.00 IF COND(&TODAY *EQ '*WED' *AND &WED *EQ 'Y' *AND &TIME *EQ &TIMENOW) THEN(GOTO CMDLBL(SUBMIT)) 
0072.00 IF COND(&TODAY *EQ '*THU' *AND &THU *EQ 'Y' *AND &TIME *EQ &TIMENOW) THEN(GOTO CMDLBL(SUBMIT)) 
0073.00 IF COND(&TODAY *EQ '*FRI' *AND &FRI *EQ 'Y' *AND &TIME *EQ &TIMENOW) THEN(GOTO CMDLBL(SUBMIT)) 
0074.00 IF COND(&TODAY *EQ '*SAT' *AND &SAT *EQ 'Y' *AND &TIME *EQ &TIMENOW) THEN(GOTO CMDLBL(SUBMIT)) 
0075.00 IF COND(&TODAY *EQ '*SUN' *AND &SUN *EQ 'Y' *AND &TIME *EQ &TIMENOW) THEN(GOTO CMDLBL(SUBMIT)) 
0076.00 ENDDO 
0077.00 
0078.00 DLYJOB DLY(60) 
0079.00 GOTO CMDLBL(CHKDTTIM) 
0080.00 
0081.00 SUBMIT: 
0082.00 
0083.00 OVRDBF FILE(&INPUTF) TOFILE(&INPUTLIB/&INPUTF) MBR(&INPUTMBR) 
0084.00 
0085.00 /**********************************************/ 
0086.00 /* BUILD & RUN SQL STATEMENT - SET PASSWORD */ 
0087.00 
0088.00 IF COND(&DOMAIN *NE ' ') + 
0089.00 THEN(CHGVAR VAR(&SQL) VALUE('UPDATE ' *CAT &INPUTLIB *TCAT '/' *TCAT &INPUTF *TCAT ' SET SRCDTA = ' + 
0090.00 *CAT &C *TCAT &DOMAIN *TCAT '' *TCAT &USERNAME *TCAT ' ' *CAT &PASSWORD *TCAT &C *TCAT ' WHERE SRCSEQ = 1')) 
0091.00 ELSE CHGVAR VAR(&SQL) VALUE('UPDATE ' *CAT &INPUTLIB *TCAT '/' *TCAT &INPUTF *TCAT ' SET SRCDTA = ' + 
0092.00 *CAT &C *TCAT &USERNAME *TCAT ' ' *CAT &PASSWORD *TCAT &C *TCAT ' WHERE SRCSEQ = 1') 
0093.00 
0094.00 RUNSQL REQUEST(&SQL) 
0095.00 /**********************************************/ 
0096.00 
0097.00 IF COND(&JOBD *EQ ' ' *AND &JOBQ *EQ ' ') THEN(+ 
0098.00 SBMJOB CMD(*LIBL/AUTOFTPBCH INPUTF(&INPUTF) INPUTLIB(&INPUTLIB) INPUTMBR(&INPUTMBR) RMTSYS(&RMTSYS)) + 
0099.00 JOB(&JOBNAME) LOG(4 00 &LOGUSED) LOGCLPGM(&LOGCLPGM)) 
0100.00 
0101.00 IF COND(&JOBD *EQ ' ' *AND &JOBQ *NE ' ') THEN(+ 
0102.00 SBMJOB CMD(*LIBL/AUTOFTPBCH INPUTF(&INPUTF) INPUTLIB(&INPUTLIB) INPUTMBR(&INPUTMBR) RMTSYS(&RMTSYS)) + 
0103.00 JOB(&JOBNAME) JOBQ(&JOBQLIB/&JOBQ) LOG(4 00 &LOGUSED) LOGCLPGM(&LOGCLPGM)) 
0104.00 
0105.00 IF COND(&JOBD *NE ' ' *AND &JOBQ *EQ ' ') THEN(+ 
0106.00 SBMJOB CMD(*LIBL/AUTOFTPBCH INPUTF(&INPUTF) INPUTLIB(&INPUTLIB) INPUTMBR(&INPUTMBR) RMTSYS(&RMTSYS)) + 
0107.00 JOB(&JOBNAME) JOBD(&JOBDLIB/&JOBD) LOG(4 00 &LOGUSED) LOGCLPGM(&LOGCLPGM)) 
0108.00 
0109.00 IF COND(&RECUR *EQ 'N') THEN(GOTO CMDLBL(EXIT)) 
0110.00 
0111.00 CHGVAR VAR(&RUNYET) VALUE(Y) 
0112.00 DLYJOB DLY(60) 
0113.00 GOTO CMDLBL(CHKDTTIM) 
0114.00 
0115.00 EXIT: 
0116.00 
0117.00 ENDPGM 
****************** End of data ****************************************************************************************** 

AUTOFTPBCH (CMD)
*************** Beginning of data ***************************************************************************************
0001.00 CMD PROMPT('AS/400 Batch FTP - Needs PARM') 
0002.00 
0003.00 INPUTF: PARM KWD(INPUTF) TYPE(*CHAR) LEN(10) MIN(1) ALWUNPRT(*NO) ALWVAR(*YES) CHOICE('10 Chars') + 
0004.00 PROMPT('Input Script File') 
0005.00 
0006.00 INPUTLIB: PARM KWD(INPUTLIB) TYPE(*CHAR) LEN(10) MIN(1) ALWUNPRT(*NO) ALWVAR(*YES) CHOICE('10 Chars') + 
0007.00 PROMPT(' Library') 
0008.00 
0009.00 INPUTMBR: PARM KWD(INPUTMBR) TYPE(*CHAR) LEN(10) MIN(1) ALWUNPRT(*NO) ALWVAR(*YES) CHOICE('10 Chars') + 
0010.00 PROMPT(' Member') 
0011.00 
0012.00 RMTSYS: PARM KWD(RMTSYS) TYPE(*CHAR) LEN(15) MIN(1) ALWUNPRT(*NO) ALWVAR(*YES) + 
0013.00 CHOICE('AS/400 Max 10)') PROMPT('Remote System Name') 
0014.00 
****************** End of data ******************************************************************************************

AUTOFTPBCH (CL)
*************** Beginning of data ***************************************************************************************
0001.00 PGM PARM(&INPUTF &INPUTLIB &INPUTMBR &RMTSYS) 
0002.00 
0003.00 DCL VAR(&INPUTF) TYPE(*CHAR) LEN(10) 
0004.00 DCL VAR(&INPUTLIB) TYPE(*CHAR) LEN(10) 
0005.00 DCL VAR(&INPUTMBR) TYPE(*CHAR) LEN(10) 
0006.00 DCL VAR(&RMTSYS) TYPE(*CHAR) LEN(15) 
0007.00 DCL VAR(&BLANK) TYPE(*CHAR) LEN(40) 
0008.00 DCL VAR(&C) TYPE(*CHAR) LEN(1) VALUE('''') 
0009.00 DCL VAR(&SQL) TYPE(*CHAR) LEN(100) 
0010.00 
0011.00 MONMSG MSGID(CPF0000) 
0012.00 
0013.00 OVRDBF FILE(&INPUTF) TOFILE(&INPUTLIB/&INPUTF) MBR(&INPUTMBR) 
0014.00 
0015.00 OVRDBF FILE(INPUT) TOFILE(&INPUTLIB/&INPUTF) MBR(&INPUTMBR) 
0016.00 
0017.00 FTP RMTSYS(&RMTSYS) 
0018.00 OVRDBF FILE(INPUT) 
0019.00 
0020.00 /**********************************************/ 
0021.00 /* BUILD & RUN SQL STATEMENT - CLEAR PASSWORD */ 
0022.00 
0023.00 CHGVAR VAR(&SQL) VALUE('UPDATE ' *CAT &INPUTLIB *TCAT '/' *TCAT &INPUTF *TCAT ' SET SRCDTA = ' + 
0024.00 *CAT &C *TCAT &BLANK *TCAT &C *TCAT ' WHERE SRCSEQ = 1') 
0025.00 
0026.00 RUNSQL REQUEST(&SQL) 
0027.00 /**********************************************/ 
0028.00 
0029.00 ENDPGM 
****************** End of data ******************************************************************************************


In order to use the AUTOFTP command...the following code for RUNSQL must be compiled.

RUNSQL (CMD)
*************** Beginning of data ***************************************************************************************
0001.00 /*********************************************************************/ 
0002.00 /* Command definition for RUNSQL command */ 
0003.00 /* Command processing program is ZUCXSQL. */ 
0004.00 /* From "Power Tools for the AS/400, Volume II," Duke Press. */ 
0005.00 /* Copyright (c) 1995 Duke Press, All rights reserved. */ 
0006.00 /* Author : Dan Riehl */ 
0007.00 /*********************************************************************/ 
0008.00 CMD PROMPT('Process SQL commands') 
0009.00 PARM KWD(REQUEST) TYPE(*CHAR) LEN(550) MIN(1) + 
0010.00 PROMPT('SQL request') 
0011.00 PARM KWD(OUTPUT) TYPE(*CHAR) LEN(10) RSTD(*YES) + 
0012.00 DFT(*) VALUES(* *PRINT *OUTFILE) MIN(0) + 
0013.00 PROMPT('Output') 
0014.00 PARM KWD(OUTFILE) TYPE(T1) MIN(0) PMTCTL(P1) + 
0015.00 PROMPT('File to receive output') 
0016.00 PARM KWD(MEMBER) TYPE(T2) MIN(0) PMTCTL(P1) + 
0017.00 PROMPT('Output member options') 
0018.00 PARM KWD(PRTFILE) TYPE(T3) MIN(0) PMTCTL(P2) + 
0019.00 PROMPT('Printer file to use') 
0020.00 T1: QUAL TYPE(*NAME) LEN(10) 
0021.00 QUAL TYPE(*NAME) LEN(10) DFT(*LIBL) + 
0022.00 SPCVAL((*LIBL) (*CURLIB)) PROMPT('Library') 
0023.00 T2: QUAL TYPE(*NAME) LEN(10) DFT(*FIRST) + 
0024.00 SPCVAL((*FIRST)) 
0025.00 QUAL TYPE(*NAME) LEN(10) RSTD(*YES) DFT(*REPLACE) + 
0026.00 SPCVAL((*REPLACE) (*ADD)) PROMPT('Replace + 
0027.00 or add records') 
0028.00 T3: QUAL TYPE(*NAME) LEN(10) DFT(QPQXPRTF) 
0029.00 QUAL TYPE(*NAME) LEN(10) DFT(*LIBL) + 
0030.00 SPCVAL((*LIBL) (*CURLIB)) PROMPT('Library') 
0031.00 P1: PMTCTL CTL(OUTPUT) COND((*EQ *OUTFILE)) 
0032.00 P2: PMTCTL CTL(OUTPUT) COND((*EQ *PRINT)) 
****************** End of data ******************************************************************************************

ZUCXSQL (CL in support of RUNSQL)
*************** Beginning of data ***************************************************************************************
0001.00 /*********************************************************************/ 
0002.00 /* Program: ZUCXSQL */ 
0003.00 /* From "Power Tools for the AS/400, Volume II," Duke Press. */ 
0004.00 /* Copyright (c) 1995 Duke Press, All rights reserved. */ 
0005.00 /* Author : Dan Riehl */ 
0006.00 /* This is the command processing program for command RUNSQL. */ 
0007.00 /*********************************************************************/ 
0008.00 SQL: PGM PARM(&LINES &TYPE &OUTFILE &OUTMBR &PRTFILE) 
0009.00 
0010.00 DCL VAR(&TYPE) TYPE(*CHAR) LEN(10) 
0011.00 DCL VAR(&LINES) TYPE(*CHAR) LEN(550) 
0012.00 DCL VAR(&LINE01) TYPE(*CHAR) LEN(55) 
0013.00 DCL VAR(&LINE02) TYPE(*CHAR) LEN(55) 
0014.00 DCL VAR(&LINE03) TYPE(*CHAR) LEN(55) 
0015.00 DCL VAR(&LINE04) TYPE(*CHAR) LEN(55) 
0016.00 DCL VAR(&LINE05) TYPE(*CHAR) LEN(55) 
0017.00 DCL VAR(&LINE06) TYPE(*CHAR) LEN(55) 
0018.00 DCL VAR(&LINE07) TYPE(*CHAR) LEN(55) 
0019.00 DCL VAR(&LINE08) TYPE(*CHAR) LEN(55) 
0020.00 DCL VAR(&LINE09) TYPE(*CHAR) LEN(55) 
0021.00 DCL VAR(&LINE10) TYPE(*CHAR) LEN(55) 
0022.00 DCL VAR(&OUTFILE) TYPE(*CHAR) LEN(20) 
0023.00 DCL VAR(&OFIL) TYPE(*CHAR) LEN(10) 
0024.00 DCL VAR(&OLIB) TYPE(*CHAR) LEN(10) 
0025.00 DCL VAR(&OUTMBR) TYPE(*CHAR) LEN(20) 
0026.00 DCL VAR(&OMBR) TYPE(*CHAR) LEN(10) 
0027.00 DCL VAR(&ORPL) TYPE(*CHAR) LEN(10) 
0028.00 DCL VAR(&PRTFILE) TYPE(*CHAR) LEN(20) 
0029.00 DCL VAR(&PFIL) TYPE(*CHAR) LEN(10) 
0030.00 DCL VAR(&PLIB) TYPE(*CHAR) LEN(10) 
0031.00 
0032.00 /* TRAILING BLANK TRIMMING FIELDS */ 
0033.00 
0034.00 DCL VAR(&LINEX) TYPE(*CHAR) LEN(550) 
0035.00 DCL VAR(&IS) TYPE(*DEC) LEN(3 0) VALUE(0) /* + 
0036.00 Index for field &LINES */ 
0037.00 DCL VAR(&IX) TYPE(*DEC) LEN(3 0) VALUE(0) /* + 
0038.00 Index for field &LINEX */ 
0039.00 DCL VAR(&H1) TYPE(*DEC) LEN(3 0) /* Work field */ 
0040.00 DCL VAR(&H2) TYPE(*DEC) LEN(3 0) /* Work field */ 
0041.00 DCL VAR(&H3) TYPE(*DEC) LEN(3 0) /* Work field */ 
0042.00 
0043.00 /* STANDARD ERROR HANDLER FIELDS */ 
0044.00 
0045.00 DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) 
0046.00 DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(100) 
0047.00 DCL VAR(&MSGF) TYPE(*CHAR) LEN(10) 
0048.00 DCL VAR(&MSGFLIB) TYPE(*CHAR) LEN(10) 
0049.00 DCL VAR(&ERRORSW) TYPE(*LGL) 
0050.00 MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR)) 
0051.00 
0052.00 /* PARSE &LINES FOR BLANKS ON 55-BYTE BOUNDARIES */ 
0053.00 
0054.00 CHECK: IF COND(&IS < 550 *AND &IX < 550) THEN(DO) /* + 
0055.00 At end of string? */ 
0056.00 CHGVAR VAR(&IX) VALUE(&IX + 1) /* Increment index */ 
0057.00 CHGVAR VAR(&IS) VALUE(&IS + 1) /* Increment index */ 
0058.00 CHGVAR VAR(%SST(&LINEX &IX 1)) VALUE(%SST(&LINES + 
0059.00 &IS 1)) /* Move a byte... */ 
0060.00 CHGVAR VAR(&H1) VALUE(&IX / 55) /* Multiple of 55 */ 
0061.00 CHGVAR VAR(&H2) VALUE(&H1 * 55) /* Extend multiple */ 
0062.00 CHGVAR VAR(&H3) VALUE(&IX - &H2) /* Zero if 55 byte + 
0063.00 boundary */ 
0064.00 IF COND(&H3 = 0) THEN(DO) /* 55 byte boundary */ 
0065.00 IF COND(%SST(&LINEX &IX 1) = ' ') THEN(DO) /* + 
0066.00 55 byte boundary is a blank */ 
0067.00 CHGVAR VAR(&IX) VALUE(&IX + 1) /* Add extra blank */ 
0068.00 ENDDO 
0069.00 ENDDO 
0070.00 GOTO CMDLBL(CHECK) /* Loop back... */ 
0071.00 ENDDO 
0072.00 
0073.00 /* DIVIDE &LINEX INTO 55-BYTE SUBSTITUTION VARIABLES */ 
0074.00 
0075.00 CHGVAR VAR(&LINE01) VALUE(%SST(&LINEX 1 55)) 
0076.00 CHGVAR VAR(&LINE02) VALUE(%SST(&LINEX 56 55)) 
0077.00 CHGVAR VAR(&LINE03) VALUE(%SST(&LINEX 111 55)) 
0078.00 CHGVAR VAR(&LINE04) VALUE(%SST(&LINEX 166 55)) 
0079.00 CHGVAR VAR(&LINE05) VALUE(%SST(&LINEX 221 55)) 
0080.00 CHGVAR VAR(&LINE06) VALUE(%SST(&LINEX 276 55)) 
0081.00 CHGVAR VAR(&LINE07) VALUE(%SST(&LINEX 331 55)) 
0082.00 CHGVAR VAR(&LINE08) VALUE(%SST(&LINEX 386 55)) 
0083.00 CHGVAR VAR(&LINE09) VALUE(%SST(&LINEX 441 55)) 
0084.00 CHGVAR VAR(&LINE10) VALUE(%SST(&LINEX 496 55)) 
0085.00 
0086.00 CHGVAR VAR(&OFIL) VALUE(%SST(&OUTFILE 1 10)) 
0087.00 CHGVAR VAR(&OLIB) VALUE(%SST(&OUTFILE 11 10)) 
0088.00 CHGVAR VAR(&OMBR) VALUE(%SST(&OUTMBR 1 10)) 
0089.00 CHGVAR VAR(&ORPL) VALUE(%SST(&OUTMBR 11 10)) 
0090.00 
0091.00 CHGVAR VAR(&PFIL) VALUE(%SST(&PRTFILE 1 10)) 
0092.00 CHGVAR VAR(&PLIB) VALUE(%SST(&PRTFILE 11 10)) 
0093.00 
0094.00 IF (&TYPE = '*OUTFILE') + 
0095.00 THEN(DO) 
0096.00 STRQMQRY QMQRY(ZUQXSQL) OUTPUT(&TYPE) + 
0097.00 OUTFILE(&OLIB/&OFIL) OUTMBR(&OMBR + 
0098.00 &ORPL) ALWQRYDFN(*YES) SETVAR((LINE01 + 
0099.00 &LINE01) (LINE02 &LINE02) (LINE03 + 
0100.00 &LINE03) (LINE04 &LINE04) (LINE05 + 
0101.00 &LINE05) (LINE06 &LINE06) (LINE07 + 
0102.00 &LINE07) (LINE08 &LINE08) (LINE09 + 
0103.00 &LINE09) (LINE10 &LINE10)) 
0104.00 MONMSG MSGID(QWM0000) EXEC(DO) 
0105.00 SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('+ 
0106.00 Syntax error in SQL statement. See previous + 
0107.00 messages for details') MSGTYPE(*DIAG) 
0108.00 ENDDO 
0109.00 ENDDO 
0110.00 ELSE (DO) 
0111.00 OVRPRTF FILE(QPQXPRTF) TOFILE(&PLIB/&PFIL) 
0112.00 STRQMQRY QMQRY(ZUQXSQL) OUTPUT(&TYPE) + 
0113.00 ALWQRYDFN(*YES) SETVAR((LINE01 + 
0114.00 &LINE01) (LINE02 &LINE02) (LINE03 + 
0115.00 &LINE03) (LINE04 &LINE04) (LINE05 + 
0116.00 &LINE05) (LINE06 &LINE06) (LINE07 + 
0117.00 &LINE07) (LINE08 &LINE08) (LINE09 + 
0118.00 &LINE09) (LINE10 &LINE10)) 
0119.00 MONMSG MSGID(QWM0000) EXEC(DO) 
0120.00 SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('+ 
0121.00 Syntax error in SQL statement. See previous + 
0122.00 messages for details') MSGTYPE(*DIAG) 
0123.00 ENDDO 
0124.00 DLTOVR FILE(QPQXPRTF) 
0125.00 ENDDO 
0126.00 
0127.00 RETURN /* Normal end of program */ 
0128.00 
0129.00 ERROR: /* STANDARD ERROR HANDLER */ 
0130.00 IF COND(&ERRORSW) THEN(SNDPGMMSG MSGID(CPF9999) + 
0131.00 MSGF(QCPFMSG) MSGTYPE(*ESCAPE)) /* Function + 
0132.00 check message */ 
0133.00 CHGVAR VAR(&ERRORSW) VALUE('1') 
0134.00 ERROR2: RCVMSG MSGTYPE(*DIAG) MSGDTA(&MSGDTA) MSGID(&MSGID) + 
0135.00 MSGF(&MSGF) MSGFLIB(&MSGFLIB) 
0136.00 IF COND(&MSGID = ' ') THEN(GOTO + 
0137.00 CMDLBL(ERROR3)) 
0138.00 SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) + 
0139.00 MSGDTA(&MSGDTA) MSGTYPE(*DIAG) 
0140.00 GOTO CMDLBL(ERROR2) 
0141.00 ERROR3: RCVMSG MSGTYPE(*EXCP) MSGDTA(&MSGDTA) MSGID(&MSGID) + 
0142.00 MSGF(&MSGF) MSGFLIB(&MSGFLIB) 
0143.00 SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) + 
0144.00 MSGDTA(&MSGDTA) MSGTYPE(*ESCAPE) 
0145.00 ENDPGM 
****************** End of data ******************************************************************************************

ZUQXSQL (QMQRY in support of RUNSQL)
*************** Beginning of data *******************************************
0001.00 &LINE01&LINE02&LINE03&LINE04&LINE05&LINE06&LINE07&LINE08&LINE09&LINE10 
****************** End of data ********************************************* 

Dig deeper on iSeries programming commands

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchEnterpriseLinux

SearchDataCenter

Close