Monitoring IFS Directory in real time

195 pts.
Tags:
AS/400
FTP
IFS Directory
We have a requirement that people will FTP a file to IFS directory and we should monitor for arrival of the file and pick up the file and process in the application. Is there any way we can monitor IFS directory in real time for arrival of a new file. The file will be placed in IFS directory using FTP PUT command.

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 7  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • CharlieBrowne
    If you write code to do it yourself, generally you have the system that is writing the file to write 2 files, and you monitor for the 2nd file.Else you have the potential of reading in the file before it is completely written to the IFS.
    I recommend purchasing a product. It is much easier to to get it running and running correctly.
    I have had excellent success with GO ANYWHERE from Linoma Software.
    41,430 pointsBadges:
    report
  • azohawk

    I am not disagreeing with Charlie Browne, but would like to give another option.

    Create a dataq and have a program monitor the dataque to process the data when it arrives.  Have the other system that uploads the data put it in the dataque.

    675 pointsBadges:
    report
  • Babs312

    Hi All,

    Thanks for your response. I am not sure whether data queue option will work or not as the file will be transferred by other system into a folder. I agree with Charlie, it will be easy with 3rd party system but it requires investment and I need to justify to the management.

    195 pointsBadges:
    report
  • barrygiles64
    You can use QSHELL to list the contents of an IFS directory to a PF and then read the physical file and pull out your file name. I use LSOUTPUT in QTEMP as this is the standard file used for FTP. If you want I can supply you with CLP source code that does this. 
    50 pointsBadges:
    report
  • barrygiles64
                 PGM        PARM(&FILENM &IFSPATH &RETN)                     
                                                                             
                 DCL        VAR(&FILENM) TYPE(*CHAR) LEN(128)                
                 DCL        VAR(&IFSPATH) TYPE(*CHAR) LEN(128)               
                 DCL        VAR(&CMD) TYPE(*CHAR) LEN(512)                   
                 DCL        VAR(&RETN) TYPE(*CHAR) LEN(7)                    
                 DCL        VAR(&MSGID) TYPE(*CHAR) LEN(7)                   
                 DCL        VAR(&MSGDTA) TYPE(*CHAR) LEN(256)                
                 DCL        VAR(&RESULT) TYPE(*CHAR) LEN(4)                  
                 DCL        VAR(&STATUS) TYPE(*DEC) LEN(10 0)                
                 DCL        VAR(&SIGNAL) TYPE(*DEC) LEN(10 0)                
                 DCL        VAR(&CHARSTAT) TYPE(*CHAR) LEN(10)               
                 DCL        VAR(&CHARSIG) TYPE(*CHAR) LEN(10)                
                                                                             
    /* Delete file in QTEMP ready for next run                               
                 DLTF       FILE(QTEMP/LSOUTPUT)                             
                 MONMSG     MSGID(CPF2105)                                   
                                                                             
    /* Create file in QTEMP                                                  
                 CRTPF      FILE(QTEMP/LSOUTPUT) RCDLEN(256)                 
                                                                             
    /* Set the command output to QTEMP/LSOUTPUT                                           ADDENVVAR  ENVVAR(QIBM_QSH_CMD_OUTPUT) VALUE(STDOUT) +     
                              LEVEL(*JOB)                                   
                 MONMSG     MSGID(CPFA980) EXEC(DO)                         
                 RCVMSG     MSGTYPE(*EXCP) RMV(*YES)                        
                 ENDDO                                                      
                                                                            
    /* Override File Standard Output to use QTEMP as unix QSHELL commands   
    /* run under a it's own job stream.                                     
                 OVRDBF     FILE(STDOUT) TOFILE(QTEMP/LSOUTPUT) +           
                              SECURE(*YES) OVRSCOPE(*JOB)                   
                                                                            
    /* -  Build QShell Command to Run                                       
                 CHGVAR     VAR(&CMD) VALUE('cd ')                          
                 CHGVAR     VAR(&CMD) VALUE(&CMD *BCAT &IFSPATH)            
                                                                            
    /* -  Needed to Append next command                                     
                 CHGVAR     VAR(&CMD) VALUE(&CMD *BCAT '&&')                
                                                                            
    /* -  Build QShell Command to Run                                       
                 CHGVAR     VAR(&CMD) VALUE(&CMD *BCAT 'ls')                
                 CHGVAR     VAR(&CMD) VALUE(&CMD *BCAT &IFSPATH)            
                 CHGVAR     VAR(&CMD) VALUE(&CMD *TCAT &FILENM)             
                                                                            
    /* Set the QSH command to issue escape messages for erros               
                 ADDENVVAR  ENVVAR(QIBM_QSH_CMD_ESCAPE_MSG) VALUE(Y) +      
                              REPLACE(*YES)                                 
                 MONMSG     MSGID(CPFA980) EXEC(DO)                         
                 RCVMSG     MSGTYPE(*EXCP) RMV(*YES)                        
                 ENDDO                                                      
                                                                            
    /* -  Run QShell Commands                                               
                 QSH        CMD(&CMD)                                       
                 MONMSG     MSGID(QSH0005 QSH0006 QSH0007) EXEC(DO)         
                 RCVMSG     MSGTYPE(*LAST) RMV(*YES) MSGDTA(&MSGDTA) +      
                              MSGID(&MSGID)                                 
                                                                            
    /* -  CPF0005 - QSHELL COMMAND ENDED "NORMALLY."                        
                 IF         COND(&MSGID *EQ 'QSH0005') THEN(DO)             
                 CHGVAR     VAR(&RESULT) VALUE(%SST(&MSGDTA 1 4))           
                 CHGVAR     VAR(&STATUS) VALUE(%BIN(&RESULT))               
                 CHGVAR     VAR(&SIGNAL) VALUE(0)                           
                 ENDDO                                                      
    /* -  QSH0006 - QSHELL COMMAND ENDED WHEN IT RECEIVED A  SIGNAL      
                 IF         COND(&MSGID *EQ 'QSH0006') THEN(DO)          
                 CHGVAR     VAR(&RESULT) VALUE(%SST(&MSGDTA 1 4))        
                 CHGVAR     VAR(&SIGNAL) VALUE(%BIN(&RESULT))            
                 CHGVAR     VAR(&STATUS) VALUE(-1)                       
                 ENDDO                                                   
    /* -  QSH0007 - QSHELL COMMAND ENDED DUE TO AN EXCEPTION             
                 IF         COND(&MSGID *EQ 'QSH0007') THEN(DO)          
                 CHGVAR     VAR(&STATUS) VALUE(-1)                       
                 CHGVAR     VAR(&SIGNAL) VALUE(-1)                       
                 ENDDO                                                   
                 ENDDO                                                   
                                                                         
    /* -  IF QSHELL COMMAND ENDED IN ERROR                                     
                 IF         COND(&STATUS *NE 0) THEN(DO)                       
                 CHGVAR     VAR(&CHARSTAT) VALUE(&STATUS)                      
                 CHGVAR     VAR(&CHARSIG) VALUE(&SIGNAL)                       
                 SNDPGMMSG  MSGID(CPF9897) MSGF(QCPFMSG) MSGDTA('QShell +      
                              command failed with status ' *CAT +              
                              &CHARSTAT *CAT ' and signal ' *CAT &CHARSIG)     
                 CHGVAR     VAR(&RETN) VALUE(CPF9897)                          
                 ENDDO                                                         
                                                                               
    50 pointsBadges:
    report
  • barrygiles64
    Read a file LSOUTPUT in CL. The path name will exist in the LSOUTPUT also 

    DCLF       FILE(LSOUTPUT) OPNID(LSFILE2)
    DCL        VAR(&FILENM) TYPE(*CHAR) LEN(128)

    /* Retrieve the file name from the LSOUTPUT File.                    
     RCVF2:      RCVF       OPNID(LSFILE2)                               
                 MONMSG     MSGID(CPF0864) EXEC(GOTO EOF2) /* EOF */     
                                                                         
    /* Unzip the File                                                    
                 CHGVAR     VAR(&FILENM) VALUE(&LSFILE2_LSOUTPUT)        
    50 pointsBadges:
    report
  • Babs312

    Hi Barry,

    Thank you very much for the code.  It is useful.  I will try at my side.

    195 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following