Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

FTP return Codes

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
IndianBlues

New User


Joined: 23 May 2006
Posts: 6
Location: Cincinnati

PostPosted: Tue May 19, 2009 6:53 am    Post subject: FTP return Codes
Reply with quote

I'm getting or pulling different files from a remote server through FTP process. Before pulling these files I need to check for any duplicate files. If I find any duplicate files I should stop further processing and resolve duplicate files issue. So, if RC on the duplicate files is zero, i'm executing IDCAMS to set MAXCC to 16 which further stops job execution. So, when duplicate files are not found then job execution continues. In this case I cannot use COND on subsequent steps. I can only check for previous step condition code only. My tech lead wants this to be done in a different way. He wants me to check for FTP return code. I did some research and FTP return codes are in XXyyy format where XX depends on subcommand and yyy are reply codes. I can also use an EXIT=nn parameter but any error returns nn value. Is there any way of checking for FTP return codes in JCL?
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue May 19, 2009 7:01 am    Post subject:
Reply with quote

Hello and welcome to the forum,

No. All jcl can do is execute programs.

Quote:
Before pulling these files I need to check for any duplicate files. If I find any duplicate files I should stop further processing
I don't believe you would use ftp to do this.

If you have a list of files, you could determine if they exist, but htis has nothing to do with ftp. . .
Back to top
View user's profile Send private message
IndianBlues

New User


Joined: 23 May 2006
Posts: 6
Location: Cincinnati

PostPosted: Tue May 19, 2009 7:19 am    Post subject:
Reply with quote

Well main issue here is checking for return codes on subsequent job steps. I could use LS to check for duplicate files but if the files are not there then step return code is a non zero value. So, I cannot use site specific standards of COND=(0,LT) on further steps. So, tech lead wants me to check for FTP return code than step return code. Any idea on how to check for FTP return codes in a job.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue May 19, 2009 8:25 am    Post subject:
Reply with quote

Hello,

You need to take some time and more clearly present what you want to do.

It is unclear where you need to check the existence of the files. On the mainframe or some other system? If you know the file names you intend to "pull" from some remote to the mainframe and your concern is if they have already been transmitted, i see no need for ftp to check anything. This can all be done on the mainframe with utilities.

You mention "checking for return codes on subsequent job steps". What would you check?

If i understand what you want to do, you could check for duplicates before ever running any ftp - but i may completely misunderstand
icon_confused.gif

As i mentioned before, ftp codes are not available to COND= processing.
Back to top
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 401
Location: Mumbai

PostPosted: Tue May 19, 2009 9:18 am    Post subject: Reply to: FTP return Codes
Reply with quote

It seems like you are already dropping into Unix (omvs) to use the ls command so why not just do everything from within Unix. Assuming the file names are the same on both the remote server and your unix directory, you can use a simple shell script. Of course, in production you may want to add a few bells and whistles (like not having the password in the script, saving the FTP output somewhere, etc), but basically this type of thing shoud do:
Code:
#!/bin/sh                                   
             
# protect command file in case it is left behind by an error

[ ! -f ftpcmds ] || rm ftpcmds
umask 177                                                     

# login code for the ftp server
                                           
echo yourid      >  ftpcmds                 
echo yourpasswd  >> ftpcmds                 
                                             
# set up for downloads (directory, transfer mode, etc)
                                             
echo bin         >> ftpcmds                 
echo cd /srcdir  >> ftpcmds                 
                                             
# add nonexistent files as 'get' commands
                                             
[ -f file1   ] || echo get file1 >> ftpcmds 
[ -f file2   ] || echo get file2 >> ftpcmds 
                                             
# termination, ftp invocation and cleanup                   
                                             
echo quit        >> ftpcmds                 
ftp remote.server.name < ftpcmds             
rm ftpcmds                                   
Back to top
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 401
Location: Mumbai

PostPosted: Tue May 19, 2009 9:38 am    Post subject:
Reply with quote

I don't know why I used a file in that last example. I wasn't thinking straight and the edit timeout expired before I could change it. This simplified version should work without the command file (removed comments for brevity):
Code:
#!/bin/sh                         
                                 
LOCALDIR=/your/download/directory       
(                                 
  echo yourid                     
  echo yourpswd                   
  echo bin                       
  echo cd /somedir 
  echo lcd $LOCALDIR             
  [ -f $LOCALDIR/file1 ]   || echo get file1
  [ -f $LOCALDIR/file2 ]   || echo get file2
  echo quit                       
) | ftp remote.server.name
Back to top
View user's profile Send private message
IndianBlues

New User


Joined: 23 May 2006
Posts: 6
Location: Cincinnati

PostPosted: Tue May 19, 2009 7:02 pm    Post subject: FTP Return Codes
Reply with quote

Thanks to all your help. I should have presented my case in a better way. Anyway, this is what we're doing
Get files from a remote server to clients mainframe on a daily basis. Once we pull these files we process them and then connect back to remote server to delete files that we processed. It is our responsibility to delete files that are processed. If in any case files are not deleted on the remote server, vendor will NOT delete them but instead place files with .001 extension. With this there will be duplicate files on the remote server. So, we need to first checking for presence of duplicate file. I used LS to check for existence of duplicate file. If file is present (RC=0) then job execution is stopped by executing IDCAMS and setting MAXCC=16. If file is not present (RC=70) then we should continue with our processing. Since RC is 70 is there a way in JCL to reset this to RC to zero. I tried using IDCAMS to reset it but this didn't work. I want to reset this RC to zero so that I can use COND=(0,LT) on further steps. Otherwise, I can only test for condition code from previous step.

One other important issue, When I check for duplicate files and if files are found then IDCAMS is executed to set MAXCC=16 otherwise it executes further steps. Well, it should continue only when files are not found (RC=70) and any other cases like transmission failure, etc. should make the job abend as usual.

So, please let me know if there is a way to check for FTP return codes (not step RC) or is there a way to reset job step RC to zero or any better way of doing the above process.
Back to top
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 401
Location: Mumbai

PostPosted: Wed May 20, 2009 7:25 am    Post subject: Reply to: FTP return Codes
Reply with quote

This sounds like a much more complicated process than simple JCL can or should handle. I'd suggest writing a Rexx program to do this. Then you have full control of everything. You can check return codes, redirect FTP output to files you can read to get the return codes from individual FTP commands (and to get file lists), invoke FTP multiple times, clean up, and do whatever else you need to do. You might need to learn a little about Unix and invoking unix commands from Rexx running under TSO or running Rexx in Unix, but its a useful set of skills.

This is a case of using the right tool for the job. JCL can only start programs and skip other programs. Trying to get it to perform business logic is way outside its purpose.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts QUESTION: RETURN CHANNEL pahiker CA Products 21 Thu Apr 20, 2017 12:31 am
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts MAX-RC 88 and Return code 606 in DFH0... lind sh CICS 2 Tue Jan 24, 2017 1:23 pm
No new posts How to Capture the Max return code of... anilkumar922 All Other Mainframe Topics 2 Thu Jan 12, 2017 12:02 pm
No new posts DFHWS2LS return value divated CICS 4 Mon Nov 07, 2016 5:44 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us