Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP unknown file name from PC to Mainframe

Status
Not open for further replies.

JazzyLee

Programmer
Jan 24, 2002
47
0
0
US
I am not sure this question belong in this forum but will be happy to re-post if pointed to the right forum. I am trying to FTP a file from a specific folder on my PC with the following code:

corpftp.corp.life.net (exit=255
resources\corpftpuser
Password
cd corpftp\cdf\vouchers
get GL__*.* 'cxt.input.vouchers' (replace
quit

My problem is that the folder has files added to it each day by the bank and are unique by having the month and day added:
GL__0201.001
GL__0201.002
GL__0202.001
GL__0203.001
etc....
I want to automate the transfer process but only want to select the file that matches today's month and day (with the code above, I am getting all the files and then have to edit the Mainframe file).

Does anyone have a code (if it's possible) that can be added to my code above that will replace the '*.*' with today's date 'mmdd.*' that will allow me to pick only the current file from the list in the folder?
 

Yes this is defiantly a coding question. And yes this can be done really simply. what OS's are available to host this code?

Can use C or vb. Let me know what OS will be used to execute application. Incidentally I am a windows man; especially when it comes to this type of thing. [pipe]

Listening ...

Amiel Summers
 
Amiel,
OS on the PC would be Windows XP, Servers are running Windows 2000 and 2003 (depending on which one we use) and the Mainframe is Zos Version 1.6 and running FTP CS Vir6 from the Mainframe. I currently have FTP jobs that are set up to pull a specific file in from the PC and write it to a specific dataset name on the Mainframe. I am stumped with trying to get only the file that was added to the folder each day, especially since the bank is using numbering extensions. I am sure I will probably need to execute a set of VB codes to convert the daily files into a specific filename and then execute it in the FTP process right before the command line that will perform the "GET" ... just don't know how or where to start. Any help would be greatly appreciated.

Thanks!
 
Pardon for untimely response. I debated including code in detail here; decided against it. Wrong forum and although not too terribly complex; can become complex using this means to communicate the specifics.

The solution should be written as a complete executable and not a script or batch file kind of thing. Your example shows a manual process that is executed while user observes actions and results. This is fine provided you are willing to observe actions and results and can interpret and respond correctly to unexpected results that may occur. Anyway;

Program running on Widows machine uses ftp libraries (inet control) to establish connection to ftp server and transfer file(s). VB or VBA code parces source directory listing using vb functions. As in:
'
' starts with
' Function that reads in directory listing
' created by redirecting 'dir' function output to file.
' Then opens the file reading line by line until reaching
' line beginning with "GL__"'.
' Program then loops processing each line beginning
' with "GL__ until done.

firstpart = Mid(gl_match_string,5,8) extracts the four numbers preceding the dot.

secondpart = Mid (gl_match_string,10,13) extract three numbers after the dot


Note: directory listing (dos 'dir' command) can order files by name or by date but either may prove to be unreliable (the point to explicitly naming each file) approach to getting correct data file.


all that remains is to compare values against todays date, ie.:

str_year = datepart("yyyy", date) ' gets year
str_month = datepart("m", date) ' gets the month.
str_day = datepart("w", date) ' gets day of week


Once done, string comparisons using a case or if statements will allow the program to find the file name that corresponds to the current (or requested) date.

Among the advantage of packaging the process this way is that it can be scheduled to run automatically and error checking will provide you with verification that the process successfully ran.

...and see, I told you this would get too complicated...[purpleface]. This will automate the transfer process.

Amiel Summers
 
You are right ... I am even more confused than before. However, after reading your suggestion, I will attempt to write a VB Function that will search the directory for any file with a create date of today, copy that file into a designated file name (append all subsequent files sent in the same day to this designated output file) and then perform a simple GET from my Mainframe FTP process to get the new file I created and move it over to the the Mainframe dataset. Being a newbie, I can't say if I'll succeed but I am willing to try. Thanks for the suggestion, even though some codes would have set me in the right direction. This is all NEW to me. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top