Q: If you send more than one file of the same name with the Send Network File (SNDNETF) command and receive the files with the Receive Network File (RCVNETF) command, the group of files with the same name are received in a last in, first out (LIFO) order. I need to run a job that will receive the first file sent so I can process the network files in first in, first out (FIFO) order. The options for the File number (NBR) parameter are *LAST, *ONLY, or number.
Network files are sent from an AS/400 in the distribution center to the division AS/400 every 15 minutes. The network files stack up on the division AS/400 until the processing job begins receiving them. Can I modify the job to process the network files in FIFO order?
- Jo Ellen Belton
A: For some reason, IBM did not build this capability into the RCVNETF command. To solve this problem, I wrote the Receive First Network File (RCVFSTNETF) command shown in 1. This command functions the same as the RCVNETF command, except it receives the first network file of a specified name that arrived on the system.
A: For some reason, IBM did not build this capability into the RCVNETF command. To solve this problem, I wrote the Receive First Network File (RCVFSTNETF) command shown in Figure 1. This command functions the same as the RCVNETF command, except it receives the first network file of a specified name that arrived on the system.
The RCVFSTNETF command executes the FST001CL program (shown in 2), which executes the Work with Network Files (WRKNETF) command to create an output file in QTEMP. The program reads the first record from the file and uses that information to receive the associated network file with the RCVNETF command.
The RCVFSTNETF command executes the FST001CL program (shown in Figure 2), which executes the Work with Network Files (WRKNETF) command to create an output file in QTEMP. The program reads the first record from the file and uses that information to receive the associated network file with the RCVNETF command.
- Robin Klima
Receiving the First Network File
Figure 1: The RCVFSTNETF Command
/*===============================================================*/ /* To compile: */ /* */ /* CRTCMD CMD(XXX/RCVFSTNETF) PGM(XXX/FST001CL) + */ /* SRCFILE(XXX/QCMDSRC) */ /* */ /*===============================================================*/ RCVFSTNETF: CMD PROMPT('Receive First Network File') PARM KWD(FROMFILE) TYPE(*CHAR) LEN(10) MIN(1) + PROMPT('From file') PARM KWD(TOFILE) TYPE(TOFILE) PROMPT('To file') TOFILE: QUAL TYPE(*NAME) DFT(*FROMFILE) SPCVAL((*FROMFILE)) QUAL TYPE(*NAME) DFT(*LIBL) SPCVAL((*LIBL) + (*CURLIB)) PROMPT('Library') PARM KWD(FROMMBR) TYPE(*CHAR) LEN(10) DFT(*ONLY) + SPCVAL((*ONLY)) PROMPT('Member to be + received') PARM KWD(TOMBR) TYPE(*NAME) DFT(*FROMMBR) + SPCVAL((*FROMMBR) (*FIRST)) PROMPT('To + member') PARM KWD(MBROPT) TYPE(*CHAR) LEN(8) RSTD(*YES) + DFT(*REPLACE) VALUES(*REPLACE *ADD) + PMTCTL(*PMTRQS) PROMPT('Replace or add + records') PARM KWD(USER) TYPE(*NAME) DFT(*CURRENT) + SPCVAL((*CURRENT)) PMTCTL(*PMTRQS) + PROMPT('User') PARM KWD(FROMTYPE) TYPE(*CHAR) LEN(8) RSTD(*YES) + DFT(*NETFILE) VALUES(*NETFILE *SRC) + PMTCTL(*PMTRQS) PROMPT('From file type')
Receiving the First Network File
Figure 2: CL Program FST001CL
/*===============================================================*/ /* To compile: */ /* */ /* CRTCLPGM PGM(XXX/FST001CL) SRCFILE(XXX/QCLSRC) */ /* */ /*===============================================================*/ PGM PARM(&FROMFILE &TOFILE &FROMMBR &TOMBR + &MBROPT &USER &FROMTYPE) DCL VAR(&FROMFILE) TYPE(*CHAR) LEN(10) DCL VAR(&TOFILE) TYPE(*CHAR) LEN(20) DCL VAR(&FROMMBR) TYPE(*CHAR) LEN(10) DCL VAR(&TOMBR) TYPE(*CHAR) LEN(10) DCL VAR(&MBROPT) TYPE(*CHAR) LEN(8) DCL VAR(&USER) TYPE(*CHAR) LEN(10) DCL VAR(&FROMTYPE) TYPE(*CHAR) LEN(8) DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(80) DCLF FILE(QANFDNTF) /* Send all errors to error handling routine */ MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR)) /* Load file in QTEMP with network files */ WRKNETF USER(&USER) OUTPUT(*OUTFILE) + OUTFILE(QTEMP/QANFDNTF) /* Override model file to temporary file */ OVRDBF FILE(QANFDNTF) TOFILE(QTEMP/QANFDNTF) RMVMSG CLEAR(*ALL) /* Read the first record */ RCVF MONMSG MSGID(CPF0864) EXEC(SNDPGMMSG MSGID(CPF8060) + MSGF(QCPFMSG) MSGDTA(&MSGDTA) + MSGTYPE(*ESCAPE)) /* Receive the first network file */ RCVNETF FROMFILE(&FROMFILE) TOFILE(%SST(&TOFILE 11 + 10)/%SST(&TOFILE 1 10)) FROMMBR(&FROMMBR) + TOMBR(&TOMBR) MBROPT(&MBROPT) + NBR(&NFDNBR) USER(&USER) FROMTYPE(&FROMTYPE) /* Send message back to user */ RCVMSG MSGDTA(&MSGDTA) MSGID(&MSGID) IF COND(&MSGID *NE ' ') THEN(SNDPGMMSG + MSGID(&MSGID) MSGF(QCPFMSG) + MSGDTA(&MSGDTA) MSGTYPE(*INFO)) /* Branch around error handling routine */ GOTO CMDLBL(ENDPGM) /* Error handling routine */ ERROR: RCVMSG MSGTYPE(*EXCP) MSGDTA(&MSGDTA) MSGID(&MSGID) SNDPGMMSG MSGID(&MSGID) MSGF(QCPFMSG) MSGDTA(&MSGDTA) + MSGTYPE(*ESCAPE) ENDPGM: ENDPGM
LATEST COMMENTS
MC Press Online