Home > AS/400 Tips > iSeries programmer tips > Automatically check FTP process for errors
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES PROGRAMMER TIPS

Automatically check FTP process for errors


Robert Gray
04.23.2004
Rating: -4.45- (out of 5) Hall of fame tip of the month winner


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


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.



Code


   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.


Rate this Tip
To rate tips, you must be a member of Search400.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
RPG iSeries programming
Enhancing RPG with external SQL stored procedures
Introduction to SQLRPGLE on IBM i: Making a report
Making the most of RPG data handling on IBM i
IBM i shop boosts online sales with RPG-based Web platform
Migrating from RPG to EGL on IBM i
Allow access to data from a stored procedure result set using COBOL or RPG
EGL Rich UI on IBM i: Do you Dojo?
Programming for the Web on the IBM i, what is possible
A taste of COMMON: ILE, IBM releases, Web applications and new products
Documenting nested program structures on the AS/400

FTP
How to view source files in the library
Simplify the process of converting a spool file from iSeries into an Excel spreadsheet
Generically send a text file from the IFS via FTP
Automate Client Access to find files on Windows scheduler
SAVF by FTP on AS/400 -- error "source file not found"
Use a virtual directory to move a .bmp file from the IFS to a remote server
Transferring binary files to IFS from a PC via FTP
FTP from AS/400 to PC folder
How to FTP without knowing the file name
IFS folder error

iSeries CL programming
Taking advantage of CL advancements, starting with V5R3
Checking in on your IBM i authorization lists
Running PHP open source applications: NOBODY needs authority
Simplify the process of converting a spool file from iSeries into an Excel spreadsheet
CL program for daily backups
An automated CL method of moving a query from AS/400 to Excel
Changing user password expiration
Eight steps for creating program documentation using AS/400 utilities
DAYSPAST CLLE program for AS/400: Compares object creation date with today's date
Advanced Job Scheduler help

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
Report Program Generator  (Search400.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



iSeries Security - Security Tools, Physical Security and System Security
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts