MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Write CObol program to perform FTP

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
mrar_160
Beginner


Joined: 07 Mar 2006
Posts: 4
Topics: 1

PostPosted: Tue Mar 07, 2006 9:22 pm    Post subject: Write CObol program to perform FTP Reply with quote

Hi all.. Very Happy
I have 2 questions..

1 ) Can i write a cobol program to do FTP from my OS390 to my server?
I got a problem how/what can i use to do the FTP..
It is any parameter or variable in COBOL to invoke FTP command?
Any body have any experience in how to perform FTP using COBOL program?


2) I need to know, why when i do a FTP using JCL, if i use GET command, i must put "(replace" command. If not, the file will not replace the existing dataset in host. The problem is, if there is no filename in remote directory, the GET command will replace the existing dataset with empty..

Thank you..
Back to top
View user's profile Send private message
Ravi
Beginner


Joined: 27 Jun 2005
Posts: 88
Topics: 2

PostPosted: Wed Mar 08, 2006 12:46 am    Post subject: Reply with quote

mrar_160,

1. Its possible. I never tried thru COBOL as FTP thru JCL really works fine for me and its approiate.
For COBOL its like another CALL statement.

2.
Code:

----------------- V=IBM P=Z/OS FTP SUB-CMDS R=V1R4 I=GET D=M -----------------
 (REPLACE                                                                     
     Causes a data set on your local host to be overwritten, if it already     
     exists. If the data set already exists, and you do not use the replace   
     parameter, the existing data set is not overwritten. A message           
     informing you of this is displayed.                                       
                                                                               
     If the data set already exists and you specify REPLACE, the data in       
     the file is overwritten, but not reallocated. This means the local       
     data set retains its existing characteristics.                           
...
...
         Attention: A Get subcommand issued for an empty or nonexisting       
         foreign file erases the contents of the existing local data set.     
My solution would be in two phase.
FTP the file into a Temporary PS file. Check for empty file condition and then only COPY to original PS.
Back to top
View user's profile Send private message
mrar_160
Beginner


Joined: 07 Mar 2006
Posts: 4
Topics: 1

PostPosted: Wed Mar 08, 2006 5:10 am    Post subject: Reply with quote

Thank RAVI..

Quote:
1. Its possible. I never tried thru COBOL as FTP thru JCL really works fine for me and its approiate.
For COBOL its like another CALL statement.


My OS390 is old version, cannot produce system date using JCL..I need to get current date when i perform FTP..So, i decide to use COBOL to perform FTP and use current date..
I will try to find the solution to perform FTP using COBOL..If you can give me any tips for searching, pls do.



Quote:
My solution would be in two phase.
FTP the file into a Temporary PS file. Check for empty file condition and then only COPY to original PS.

That good idea..i will try your suggestion..
Thank you..
Back to top
View user's profile Send private message
Ravi
Beginner


Joined: 27 Jun 2005
Posts: 88
Topics: 2

PostPosted: Wed Mar 08, 2006 5:54 am    Post subject: Reply with quote

Quote:

My OS390 is old version, cannot produce system date using JCL..I need to get current date when i perform FTP .So, i decide to use COBOL to perform FTP and use current date..

Solution 1:
Try building the FTP control card thru COBOL. Where you can get the date and other required dataset or file naming conventions.
In the next step use PGM=FTP with the generated control card.

Solution 2:
Use REXX and FTP together. (do a Search)

Hope you are aware that thru SORT you can get the date. Search this forums to get the current date thru SORT jcl.
Back to top
View user's profile Send private message
mrar_160
Beginner


Joined: 07 Mar 2006
Posts: 4
Topics: 1

PostPosted: Wed Mar 08, 2006 9:21 pm    Post subject: Reply with quote

Ok..I interested with the second solution..
i Attached my cobol programming to perform FTP.
PGM Name : FTPCOB
Code:

**************************************************************** 
 DATA DIVISION.                                                   
 WORKING-STORAGE SECTION.                                         
*YYMMDD                                                           
 01 CURRENTDATE.                                                 
       02  CURRENTYEAR     PIC 9(4).                             
       02  CURRENTMONTH    PIC 99.                               
       02  CURRENTDAY      PIC 99.                               
*YYDDD                                                           
 01 DAYOFYEAR.                                                   
          02  FILLER          PIC 9(4).                           
          02  YEARDAY         PIC 9(3).                           
 PROCEDURE DIVISION.                                             
 BEGIN.                                                           
      ACCEPT  CURRENTDATE FROM DATE YYYYMMDD.                     
      DISPLAY "GET FILEABC"                                           
              CURRENTMONTH CURRENTDAY "A.TXT 'SYS001.DATASET'" 
              " (REPLACE".                       
STOP RUN.


Than, my JCL will call this cobol program..
See my JCL below.
Code:

//STEP0001 EXEC PGM=FTPCOB                                           
//STEPLIB  DD   DISP=SHR,DSN=&SYSUID..LOAD                             
//SYSOUT   DD DSN=&SYSUID..TEMP.FTP,DISP=(OLD,CATLG,DELETE),           
//          SPACE=(TRK,(2,2)),                                         
//          DCB=(RECFM=FB,LRECL=80,BLKSIZE=800)                         
//*                                                                     
//STEP0002 EXEC PGM=FTP                                                 
//FTPOUT   DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
// DD DSN=SYSUID.FTP(FTPINFO),DISP=SHR                                 
// DD DSN=&SYSUID..TEMP.FTP,DISP=SHR                                   
/*                                                                     


The problem now, When the file is not exist in the server, than the FTP will replace the dataset with empty..My intent, if no file in the server, than FTP will not replace the dataset with empty,just remain with the previus data..
So, i think i want to try to write COBOL prgram to perform FTP.
If there is no way to write the cobol program, i will try your suggestion, to check whether the dataset is empty..

RAVI,
Do you have any simple COBOL FTP program? I have a problem how to CALL a FTP in COBOL..
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group