I need to create a job to delete PFs based on create date or a variable w/in the name
15 pts.
0
Q:
I need to create a job to delete PFs based on create date or a variable w/in the name
There are several files (they are claim files) created on a daily basis; they have MMDD appended to the name, e.g. ECPAU1118, ECPAH1118. They would like to keep these files out there for a year! but want a 'month-end' job that will delete all files from the previous year for the upcoming month. Can anyone offer a 'simple' solution for this? Thank you so much for your time and assistance!
ASKED: Nov 18 2008  2:57 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
1115 pts.
0
A:
 RATE THIS ANSWER
+1
Click to Vote:
  •   1
  •  0
  • AddThis Social Bookmark Button
I'd create a CL program that does a dspobjd to an outfile of all pf's in the library. Then read the outfile and select the create date that is less than or equal to the date that I pass in as a parm to the program. If the object meets the date criteria, delete it.

Mars808
I had a couple of minutes so I threw the following CL together, I know you said month end job, but I believe the following program would work if you ran it on the first day of the month. Anyway it gives you a starting point. No warranties here !

PGM

DCLF FILE(QSYS/QAFDBASI) RCDFMT(QWHFDBAS)

DCL VAR(&ATFCMO) TYPE(*CHAR) LEN(2)
DCL VAR(&ATFCYR) TYPE(*CHAR) LEN(2)
DCL VAR(&DATE) TYPE(*CHAR) LEN(6)
DCL VAR(&MONTH) TYPE(*CHAR) LEN(2)
DCL VAR(&MSG) TYPE(*CHAR) LEN(100)
DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(100)
DCL VAR(&MSGF) TYPE(*CHAR) LEN(10)
DCL VAR(&MSGFLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&MSGID) TYPE(*CHAR) LEN(7)
DCL VAR(&TYPE) TYPE(*CHAR) LEN(1)
DCL VAR(&YEAR) TYPE(*CHAR) LEN(2)

MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR))

RTVJOBA DATE(&DATE) TYPE(&TYPE)

IF COND(&TYPE *EQ '1') THEN(DO)
SBMJOB CMD(CALL PGM(DLTFD)) JOB(DLTFD)
GOTO CMDLBL(END)
ENDDO

CHGVAR VAR(&MONTH) VALUE(%SST(&DATE 1 2))
CHGVAR VAR(&YEAR) VALUE(%SST(&DATE 5 2))

DSPFD FILE(YOURLIB/*ALL) TYPE(*BASATR) +
OUTPUT(*OUTFILE) OUTFILE(QTEMP/YOURFILE)
OVRDBF FILE(QAFDBASI) TOFILE(QTEMP/YOURFILE)

READ: RCVF RCDFMT(QWHFDBAS)
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(END)) +
/* End of file detected */

CHGVAR VAR(&ATFCMO) VALUE(%SST(&ATFCDT 3 2))
CHGVAR VAR(&ATFCYR) VALUE(%SST(&ATFCDT 1 2))

IF COND(&ATFCMO *EQ &MONTH *AND &ATFCYR *NE +
&YEAR) THEN(DO)
DLTF FILE(YOURLIB/&ATFILE)
MONMSG MSGID(CPF3142) /* File not found */
ENDDO

GOTO CMDLBL(READ)

ERROR:
RCVMSG MSGTYPE(*EXCP) MSGDTA(&MSGDTA) MSGID(&MSGID) +
MSGF(&MSGF) MSGFLIB(&MSGFLIB)
RTVMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +
MSGDTA(&MSGDTA) MSG(&MSG)
SNDMSG MSG(&MSG) TOUSR(YOURPROFIL)

END: RETURN
ENDPGM

Hope this helps,
Bill Poulin
Last Answered: Nov 20 2008  1:30 PM GMT by Wpoulin   1115 pts.
Latest Contributors: Sofar   95 pts., Philpl1jb   24610 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Mars808   15 pts.  |   Nov 21 2008  6:03PM GMT

Aloha- Thank you so much for your time, I really appreciate it.
I actually came up w/ something really simple (maybe too much so!)
Here’s mine, maybe if anyone sees anything glaringly ‘wrong’ you could be so kind as to let me know-
PGM
DCL VAR(&MO) TYPE(*CHAR) LEN(2)
DCL VAR(&DLTUB) TYPE(*CHAR) LEN(9)
DCL VAR(&DLTHF) TYPE(*CHAR) LEN(9)

RTVSYSVAL SYSVAL(QMONTH) RTNVAR(&MO)

CHGVAR VAR(&DLTUB) VALUE(’ECPAU4′ *CAT &MO *CAT ‘*’)
CHGVAR VAR(&DLTHF) VALUE(’ECPAH4′ *CAT &MO *CAT ‘*’)

DLTF FILE(HS#FTST/&DLTUB)
MONMSG MSGID(CPF2125)
DLTF FILE(HS#FTST/&DLTHF)
MONMSG MSGID(CPF2125)
ENDPGM

 
0