IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

To pull the file with Date and Time using FTP


IBM Mainframe Forums -> TSO/ISPF
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vinu007

New User


Joined: 16 Jul 2021
Posts: 4
Location: India

PostPosted: Fri Jul 16, 2021 11:36 am
Reply with quote

Hi Team,

I would like to read the .txt file named as FILEA_20210715_091012.txt to a Mainframe dataset ZIL1.TEST.FILE using FTP
The Date and Time part of this .txt file keeps on changing daily.
So can anyone please help to read this .txt file using wild card character
in FTP

Something like
GET 'FILEA_YYYYMMDD_HHMMSS' +
' ZIL1.TEST.FILE'

Not sure whether the above FTP script is correct. Please help.

Thanks
Vinu
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 607
Location: Bamberg, Germany

PostPosted: Fri Jul 16, 2021 11:41 am
Reply with quote

Try system symbols for the dataset name, but it looks fishy to me.
Code:
Format                                                             
======                                                             
                                                                   
>>-Get--foreign_file--+------------+--+------------+----------->< 
                      '-local_file-'  '-(--REPLACE-'               
Back to top
View user's profile Send private message
vinu007

New User


Joined: 16 Jul 2021
Posts: 4
Location: India

PostPosted: Fri Jul 16, 2021 11:48 am
Reply with quote

Hi Joerg,

In the .txt file FILEA_20210715_091012,
the bolded part will always change

So whether YYYYMMDD will pick this changing part daily


GET 'FILEA_YYYYMMDD_HHMMSS' +
' ZIL1.TEST.FILE'

Whether we need to use REPLACE

Thanks
Vinu
Back to top
View user's profile Send private message
prino
Warnings : 1

Senior Member


Joined: 07 Feb 2009
Posts: 1263
Location: Vilnius, Lithuania

PostPosted: Fri Jul 16, 2021 5:03 pm
Reply with quote

And where did you find out that you should use YYYYMMDD_HHMMSS?

In the manual supplied by your PHB?

Read about wildcards, YMDHS definitely aren't!
Back to top
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1188

PostPosted: Fri Jul 16, 2021 5:18 pm
Reply with quote

vinu007 wrote:
Hi Joerg,

In the .txt file FILEA_20210715_091012,
the bolded part will always change

So whether YYYYMMDD will pick this changing part daily


GET 'FILEA_YYYYMMDD_HHMMSS' +
' ZIL1.TEST.FILE'

Whether we need to use REPLACE

Thanks
Vinu

Assuming your code should not work outside of 2000-2099 window, you can code:
Code:
// EXPORT SYMLIST=*
. . . . . . .
//SYSIN DD *,SYMBOLS=EXECSYS
GET ‘FILEA_20&YYMMDD._&HHMMSS..txt’ ‘ZIL.TEST.FILE’
. . . . . . .

I guess the suffix .txt is required for you remote filename?
Or use &YR4.&MON.&DAY. - for your date part in the range 0001-9999 years icon_lol.gif
Anyway, the new time &HHMMSS will not correspond to that part of the remote file; you need to get the correct value from somewhere, or use wildcards… icon_exclaim.gif

The option (REPLACE defines either you allow to replace the old dataset ZIL.TEST.FILE, or not? It’s up to you.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2258
Location: Silicon Valley

PostPosted: Fri Jul 16, 2021 10:21 pm
Reply with quote

I think FTP supports a DIR command. Issue DIR, then parse out the names that it gives you and then issue the GET command.
Back to top
View user's profile Send private message
vinu007

New User


Joined: 16 Jul 2021
Posts: 4
Location: India

PostPosted: Fri Jul 23, 2021 2:16 pm
Reply with quote

Hi Prino,

One of my team mate mentioned to try this way but it didn't work.

Hi All
I have tried the below script but didn't work.

The file name is FILEA.20210510142109.txt

Code:
get 'FILEA.20&YYMMDD.&HHMMSS.txt +
        'ZIL1.TEST.FILE'


However got error message as
FILEA.20&YYMMDD.&HHMMSS.txt is not a valid file path

Appreciate any help in this.

Thanks
Vinu
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 607
Location: Bamberg, Germany

PostPosted: Fri Jul 23, 2021 2:30 pm
Reply with quote

It looks like system symbols are not allowed for the jobclass you have used or you have not followed using SYMBOLS=EXECSYS. Whatever comes first.
Back to top
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1188

PostPosted: Fri Jul 23, 2021 5:02 pm
Reply with quote

vinu007 wrote:
I have tried the below script but didn't work.

The file name is FILEA.20210510142109.txt

Code:
get 'FILEA.20&YYMMDD.&HHMMSS.txt +
        'ZIL1.TEST.FILE'


However got error message as
FILEA.20&YYMMDD.&HHMMSS.txt is not a valid file path

This means that the system variables are not substituted into your code; there might be multiple reasons for it.
Present your FULL code sample, plus ALL messages around it.
Otherwise there is nothing to discuss.
Back to top
View user's profile Send private message
vinu007

New User


Joined: 16 Jul 2021
Posts: 4
Location: India

PostPosted: Fri Jul 23, 2021 5:50 pm
Reply with quote

Yes, I have used SYSMBOLS=EXECSYS however getting the same error "FILEA.20&YYMMDD.&HHMMSS.txt is not a valid file path"

So I think my jobclass is not taking SYMBOLS.
I was told to use SFTP scrpt instead of FTP script.
So using

sget 'FILEA.20&YYMMDD.&HHMMSS.txt +
'ZIL1.TEST.FILE'

Is there any other way as SYMBOLS is not working for me. Sorry

Appreciate your help.

Thanks
Vinu
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 607
Location: Bamberg, Germany

PostPosted: Fri Jul 23, 2021 6:20 pm
Reply with quote

First, provide output of jobclass setup
Code:
$D JOBCLASS(<the_one_u_use>),SYSSYM         
$HASP837 JOBCLASS(<the_one_u_use>)         SYSSYM=?
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 768
Location: Pennsylvania

PostPosted: Fri Jul 23, 2021 7:22 pm
Reply with quote

Even if you get the symbolic substitution to work, you are not going to accomplish your goal.

The process will put the current date and time in your ftp/sftp 'get' command. The chances of the file on the server having that name is slim to none.

You need to re-evaluate your entire approach. Think about what Pedro recommended above:

Quote:
I think FTP supports a DIR command. Issue DIR, then parse out the names that it gives you and then issue the GET command.
_________________
Pedro Vera


Additionally, I am not sure who told you to use SFTP, but that creates another huge wrinkle.

You can not SFTP directly from z/os operating system. You need another product as a bridge to OMVS (USS).
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2772
Location: NYC,USA

PostPosted: Fri Jul 23, 2021 8:26 pm
Reply with quote

Besides-
Whoever producing the .txt file ask them not to suffix date and time , if they can .
Also check with scheduling team if they have any mechanism in place already to deal with this scenario's.
Last , if they can remove the time then you can generate the SFTP card by adding date and pull the file.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8584
Location: Dubuque, Iowa, USA

PostPosted: Fri Jul 23, 2021 9:03 pm
Reply with quote

How many files are on the server at one time? If you're only getting one file per day, using a wildcard would work:
Code:
get FILEA.20*.*.TXT 'ZIL1.TEST.FILE'
although not tested is similar to FTP get commands I've used in the past. The other option would be to use an FTP to retrieve the list of files in the directory and parse that list using a program in the language of your choice (I've used SAS in the past) to extract the file name(s) to pass to a second FTP step to get the data.
Back to top
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1188

PostPosted: Fri Jul 23, 2021 11:49 pm
Reply with quote

BTW, using the variable &HHMMSS is absolutely senseless, even if it would work fine: the time the remote file has been created in 100% of times is DIFFERENT from the time you are going to FTP it…
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2258
Location: Silicon Valley

PostPosted: Sat Jul 24, 2021 2:14 am
Reply with quote

Quote:
I would like to read the .txt file named as FILEA_20210715_091012.txt to a Mainframe dataset

I noticed that some of the solutions given use an MVS naming convention, but the original post referred to a long name.
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 607
Location: Bamberg, Germany

PostPosted: Sat Jul 24, 2021 12:22 pm
Reply with quote

The main problem will remain, it is very unlikely to get the remote dsn by the timestamp with full name whether or not the symbols are properly resolved.
Back to top
View user's profile Send private message
jgiltner62

New User


Joined: 29 Jul 2021
Posts: 1
Location: USA

PostPosted: Thu Jul 29, 2021 8:14 pm
Reply with quote

Without knowing what date and what time to use, system symbols will not help. They will resolve the the current date/time when the job runs on the mainframe. If you knew what date and time you needed to pull, then you could just change the job to specify the full file name.

You need to know the file name before the job is run. It might be possible to write a REXX EXEC that runs FTP and can collect the output of the DIR command to parse the file names and then issue the appropriate get command. However, you would need to know which file you want to upload. I am assuming that there could be multiple files in the source directory.

It might be easier to have the remote site setup a process to push the file to you instead of you pulling it.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> TSO/ISPF

 


Similar Topics
Topic Forum Replies
This topic is locked: you cannot edit posts or make replies. Sort to include records of file 2 int... Java & MQSeries 1
No new posts How to modify file content using REXX CLIST & REXX 3
No new posts VB file copy COBOL program gives erro... COBOL Programming 3
No new posts SORT for dynamic trailer record + CSV... DFSORT/ICETOOL 14
No new posts Copy a DS Member to multiple users at... TSO/ISPF 8
Search our Forums:

Back to Top