Problem solve Get help with specific problems with your technologies, process and projects.

Automatically check FTP process for errors

Forget about having to manually check for FTP errors. This program checks for them automatically.

Forget about having to manually check for FTP errors. This program checks for them automatically.

This program would be called from another program, usually a CL program that is using FTP to retrieve files from a remote server. The override is to file OUTPUT, which holds the FTP process messages. The command RCVF reads the file one record at a time. If there is a message code of 4xx or 5xx, then an error occurred and the CL program would be coded to handle the error.

We have programs that retrieve files automatically on a daily basis. If the remote FTP server is down or the file does not exist, then an error message is generated and dealt with by the calling program. This negates having to manually check sever status or existence of files. If you don't check the FTP messages, the FTP process will run and end without any error messages to inform of the problem.


   PGM        PARM(&RFILE)                 
   DCL        VAR(&FTPERR)  TYPE(*CHAR) LEN(1)                  
   DCL        VAR(&FTPDAT)  TYPE(*CHAR) LEN(60)

                                                                
   OVRDBF     FILE(INPUT)   TOFILE(QGPL/QFTPSRC) MBR(INPUT017)  
   OVRDBF     FILE(OUTPUT)  TOFILE(QGPL/QFTPSRC) +              
                MBR(OUTPUT017)                             
   CLRPFM     FILE(QGPL/QFTPSRC) MBR(OUTPUT017)
                                                
   FTP        RMTSYS('210.211.100.10')              
                                                
   OVRDBF     FILE(OUTPUT) TOFILE(USRLIB/OUTPUT) 




 /* Check FTP messages for errors */



              CALL       PGM(QGPL/FTPCHKCL) PARM(&FTPERR &FTPDAT)



              IF         COND(&FTPERR = 'Y') THEN(DO)

              SNDNETMSG  MSG('EVERCOM RPT NOT TRANSFERRED! PROBLEM +

                           WITH FTP. ERROR CODE: ' *CAT &FTPDAT *CAT +

                           '. SEE QGPL/QFTPSRC/OUTPUT12 FOR +

                           DETAILS') TOUSRID(GCRGGUSR S9999999))
              GOTO       CMDLBL(END)        
              ENDDO                         
              DLTOVR     FILE(*ALL)         
                                            
 END:         ENDPGM



 PGM        PARM(&FTPERR &FTPDAT)



              DCLF       FILE(OPRLIB/OUTFILE) RCDFMT(*ALL)



              DCL        VAR(&FTPERR) TYPE(*CHAR) LEN(1)

              DCL        VAR(&FTPDAT) TYPE(*CHAR) LEN(60)



              CHGVAR     VAR(&FTPDAT) VALUE(*BLANKS)

              CHGVAR     VAR(&FTPERR) VALUE('N')

 RCVF:

              RCVF

              MONMSG     MSGID(CPF0864) EXEC(RETURN)

              IF         COND(%SST(&DATA 1 1) *EQ '4') THEN(DO)

                CHGVAR   VAR(&FTPERR) VALUE('Y')

                CHGVAR   VAR(&FTPDAT) VALUE(&DATA)

                ENDDO

              IF         COND(%SST(&DATA 1 2) *EQ '53' *OR %SST(&DATA +

                           1 2) *EQ '55') THEN(DO)

                CHGVAR   VAR(&FTPERR) VALUE('Y')  

                CHGVAR   VAR(&FTPERR) VALUE('Y')

                CHGVAR   VAR(&FTPDAT) VALUE(&DATA)

                ENDDO

                GOTO     CMDLBL(RCVF)



              RETURN

 ENDPGM


==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: tips, tutorials and more.

Ask your programming questions--or help out your peers by answering them--in our live discussion forums.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

This was last published in April 2004

Dig Deeper on RPG iSeries programming

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close