Problem : Files, logicals and members
I have a 2 files that are compiled with *nomax as the number of members. They are a part of a CL and many RPG programs. They have two logicals that are both used in many RPG programs as well. I do not think they are clearing properly using the CLRPFM. Here is what I need:
The base file and members (in my opinion) should be used in the downstream RPG pgms. I am using the OVRDBF command but I think I am using it incorrectly or I am missing something.. Here is my process:
All logicals of file “B” and base file “B” should be cleared before the CPYF takes place, member specific.
File “A” in the CL gets copied to file “B”. This must be member specific and I have the proper CL code to get the user name. Base file”B” and all of the logicals that relate to “B” need to get cleared and then repopulated, from “A”, member specific.
File “A” then needs to be cleared by the member name and all of the logicals that are used as well. The logicals for both “A” and “B” are member specific as well. I did this because I found that the RPG programs returned no data and when I added members to the logicals, the data appeared. I do not know if this is the best (or only) way to do this and need “best practices” solutions.
Please give me the best and correct code to do all of these things in the CL portion of the job.
Solution : Files, logicals and members
Hi
programs to copy Maxmbr attributes
Cmd CPYMAXMBR
CMD PROMPT(‘Copy maxmbr attributes to LF’)
PARM KWD(TOFILE) TYPE(Q0001) MIN(1) PROMPT(‘File’)
Q0001: QUAL TYPE(*NAME)
QUAL TYPE(*NAME) DFT(*LIBL) SPCVAL((*LIBL *LIBL) +
(*CURLIB *CURLIB)) PROMPT(‘Library’)
————————–
Cl program CpyMaxMbr
pgm (&DbFileLib)
DCLF QAFDMBR
dcl &DbFileLib *char 20
dcl &dbfile *char 10
dcl &dbLib *char 10
dcl &Txt *CHAR 80
dcl &TMP *CHAR 80 VALUE(‘ZXCPYCXZ’)
/* ALL ERRORS ARE PORCESSED AT THENEND OF THE PROGRAM */
MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR))
chgvar &dbfile %sst(&dbfilelib 1 10)
chgvar &dblib %sst(&dbfilelib 11 10)
CHKOBJ OBJ(&DBLIB/&DBFILE) OBJTYPE(*FILE) +
MBR(*NONE) AUT(*OBJEXIST)
DLTF QTEMP/DSPFFD
MONMSG CPF0000
DSPFD FILE(&DBLIB/&DBFILE) TYPE(*BASATR) +
OUTPUT(*OUTFILE) FILEATR(*PF) +
OUTFILE(QTEMP/DSPFD)
OVRDBF FILE(QAFDMBR) TOFILE(QTEMP/DSPFD)
RCVF
MONMSG CPF0000 /* trap invalid data */
DLTOVR FILE(QAFDMBR)
DLTF QTEMP/DSPDBR
MONMSG CPF0000
DSPDBR FILE(&DBLIB/&DBFILE) OUTPUT(*OUTFILE) +
OUTFILE(QTEMP/DSPDBR)
CALL PGM(CPYMAXMBRA) PARM(&MBMAXM)
RETURN
/*************************
/* Error processing */
ERROR:
RCVMSG MSGTYPE(*LAST) MSG(&TXT)
/* issue any other error as an escape message */
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&TXT) +
MSGTYPE(*ESCAPE)
endpgm
————————–
Cl program CpyMaxMbrA
pgm (&MBMAXM)
DCLF QADSPDBR
dcl &MBMAXM *DEC (5 0)
DCL &MAX *CHAR 10
DCL &TXT *CHAR 80
/* ALL ERRORS ARE PORCESSED AT THENEND OF THE PROGRAM */
MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR))
IF COND(&MBMAXM = 0) THEN(CHGVAR VAR(&MAX) +
VALUE(*NOMAX))
ELSE CMD(CHGVAR VAR(&MAX) VALUE(&MBMAXM))
OVRDBF FILE(QADSPDBR) TOFILE(QTEMP/DSPDBR)
RCVF:
RCVF
MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(EOF))
CHGLF FILE(&WHRELI/&WHREFI) MAXMBRS(&MAX)
GOTO RCVF
EOF:
DLTOVR FILE(QADSPDBR)
RETURN
/*************************
/* Error processing */
ERROR:
RCVMSG MSGTYPE(*LAST) MSG(&TXT)
/* issue any other error as an escape message */
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&TXT) +
MSGTYPE(*ESCAPE)
endpgm
————————–
CLRPFM will not be affected by an empty file.
as mentioned previously the only thing that would cause a CLRPFM to fail are.
CPF3130 Member &2 already in use.
CPF3133 File &1 in library &3 contains no members.
CPF3134 Referential constraint error processing member &2.
CPF3136 File &1 in &3 not allowed on command.
CPF3137 No authority to clear, initialize, or copy member &2.
CPF3141 Member &2 not found.
CPF3142 File &1 in library &3 not found.
CPF3144 Member &2 not cleared or initialized.
CPF3156 File &1 in library &3 in use.
CPF3157 Triggers prevent requested operation.
CPF3159 Member &2 saved with STG(*FREE).
CPF3160 Operation on member &2 ended. Entry cannot be journaled.
CPF3179 Cannot clear or initialize DDM file &1 in &3.
CPF32B8 Distributed file error, reason code &3.
CPF32CF Distributed file error, reason code &3.
CPF32C3 Distributed file error, level ID mismatch
CPF320B Operation was not valid for database file &1.
CPF3203 Cannot allocate object for file &1 in &2.
There is nothing to say can not clear empty file. If the problem persists we can try to debug it.