View previous topic :: View next topic
|
Author |
Message |
vinu007
New User
Joined: 16 Jul 2021 Posts: 4 Location: India
|
|
|
|
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 |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1334 Location: Bamberg, Germany
|
|
|
|
Try system symbols for the dataset name, but it looks fishy to me.
Code: |
Format
======
>>-Get--foreign_file--+------------+--+------------+-----------><
'-local_file-' '-(--REPLACE-' |
|
|
Back to top |
|
|
vinu007
New User
Joined: 16 Jul 2021 Posts: 4 Location: India
|
|
|
|
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 |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1314 Location: Vilnius, Lithuania
|
|
|
|
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2140 Location: USA
|
|
|
|
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
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…
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 |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2593 Location: Silicon Valley
|
|
|
|
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 |
|
|
vinu007
New User
Joined: 16 Jul 2021 Posts: 4 Location: India
|
|
|
|
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 |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1334 Location: Bamberg, Germany
|
|
|
|
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2140 Location: USA
|
|
|
|
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 |
|
|
vinu007
New User
Joined: 16 Jul 2021 Posts: 4 Location: India
|
|
|
|
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 |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1334 Location: Bamberg, Germany
|
|
|
|
First, provide output of jobclass setup
Code: |
$D JOBCLASS(<the_one_u_use>),SYSSYM
$HASP837 JOBCLASS(<the_one_u_use>) SYSSYM=? |
|
|
Back to top |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
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 |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2140 Location: USA
|
|
|
|
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 |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2593 Location: Silicon Valley
|
|
|
|
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 |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1334 Location: Bamberg, Germany
|
|
|
|
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 |
|
|
jgiltner62
New User
Joined: 29 Jul 2021 Posts: 1 Location: USA
|
|
|
|
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 |
|
|
|