Find and Replace string with current Date
Moderators: Frank Yaeger, Moderator Group
Find and Replace string with current Date
My requirement is to replace the '########' string with current date in a SFTP control member.
Input
PWD
ls -l
get 'ETOLDAG_000003_########.csv' 'UGLXCD.EBAXMD.NETWORK.TEST'
rename 'ETOLDAG_000003_########.csv' 'ETOLDAG_000003_########.csv.taken'
quit
Output
PWD
ls -l
get 'ETOLDAG_000003_20100722.csv' 'UGLXCD.EBAXMD.NETWORK.TEST'
rename 'ETOLDAG_000003_20100722.csv' 'ETOLDAG_000003_20100722.csv.taken'
quit
I have coded the jcl given below to satisfy my current requirement. The same SFTP control card will be used in future to handle additional files. The current solution depends on the position of the string '########' and won't work if the filename character is increased
Can this be handled using FINDREP or any alternative solution to search the string at any position and replace with current date.?
/FTPCRE EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD PATH='/u/TST169/sftpinpa',PATHOPTS=ORDONLY,
// LRECL=80,RECFM=FB,FILEDATA=TEXT
//SYSIN DD *
OPTION COPY
OUTREC IFTHEN=(WHEN=(22,8,CH,EQ,C'########'),OVERLAY=(22:DATE1)),
IFTHEN=(WHEN=(25,8,CH,EQ,C'########'),OVERLAY=(25:DATE1)),
IFTHEN=(WHEN=(31,8,CH,EQ,C'########'),OVERLAY=(31:DATE1))
//*
//SORTOUT DD PATH='/u/TST169/sftpinpa',PATHOPTS=OWRONLY,
// LRECL=80,RECFM=FB,FILEDATA=TEXT
Input
PWD
ls -l
get 'ETOLDAG_000003_########.csv' 'UGLXCD.EBAXMD.NETWORK.TEST'
rename 'ETOLDAG_000003_########.csv' 'ETOLDAG_000003_########.csv.taken'
quit
Output
PWD
ls -l
get 'ETOLDAG_000003_20100722.csv' 'UGLXCD.EBAXMD.NETWORK.TEST'
rename 'ETOLDAG_000003_20100722.csv' 'ETOLDAG_000003_20100722.csv.taken'
quit
I have coded the jcl given below to satisfy my current requirement. The same SFTP control card will be used in future to handle additional files. The current solution depends on the position of the string '########' and won't work if the filename character is increased
Can this be handled using FINDREP or any alternative solution to search the string at any position and replace with current date.?
/FTPCRE EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD PATH='/u/TST169/sftpinpa',PATHOPTS=ORDONLY,
// LRECL=80,RECFM=FB,FILEDATA=TEXT
//SYSIN DD *
OPTION COPY
OUTREC IFTHEN=(WHEN=(22,8,CH,EQ,C'########'),OVERLAY=(22:DATE1)),
IFTHEN=(WHEN=(25,8,CH,EQ,C'########'),OVERLAY=(25:DATE1)),
IFTHEN=(WHEN=(31,8,CH,EQ,C'########'),OVERLAY=(31:DATE1))
//*
//SORTOUT DD PATH='/u/TST169/sftpinpa',PATHOPTS=OWRONLY,
// LRECL=80,RECFM=FB,FILEDATA=TEXT
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
A DFSORT job like this should do it:
Code: Select all
/FTPCRE EXEC PGM=SORT
//SYMNAMES DD *
Mydate,S'&YR4.&MON.&DAY'
//SYSOUT DD SYSOUT=*
//SORTIN DD PATH='/u/TST169/sftpinpa',PATHOPTS=ORDONLY,
// LRECL=80,RECFM=FB,FILEDATA=TEXT
//SYSIN DD *
OPTION COPY
OUTREC FINDREP=(IN=C'########',OUT=Mydate)
//*
//SORTOUT DD PATH='/u/TST169/sftpinpa',PATHOPTS=OWRONLY,
// LRECL=80,RECFM=FB,FILEDATA=TEXT
Last edited by Frank Yaeger on Mon Jul 26, 2010 8:30 pm, edited 1 time in total.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
Hi Frank,
This example looks pretty different than what I've seen with SORT applications, what doesin SORTIN tell the sort-program? May be I'm overlooking the obvious, however, please assist me to understand it.
Thanks for your time.
This example looks pretty different than what I've seen with SORT applications, what does
Code: Select all
//SORTIN DD PATH='/u/TST169/sftpinpa',PATHOPTS=ORDONLY,
// LRECL=80,RECFM=FB,FILEDATA=TEXT
//SYSIN DD *
Thanks for your time.
Regards,
Anuj
Anuj
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
It's a z/OS UNIX file. Here's an example in the DFSORT APG:
http://publibz.boulder.ibm.com/cgi-bin/ ... 0527161936
and here are some references:
http://publibz.boulder.ibm.com/cgi-bin/ ... 0527161936
http://publibz.boulder.ibm.com/cgi-bin/ ... 0527161936
and here are some references:
http://publibz.boulder.ibm.com/cgi-bin/ ... 0527161936
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
Welcome to the forum!
Fist of all, the name is Yaeger - it is important to use the correct name ahen a name is used.
Second - please do NOT address a question to a particular individual. In this case, Frank is no longer on the forum. He retired a year ago.
And last - it is best to start a new topic for your new question rather than posting a reply to a topic that has been dormant 3+ years. A link to the original topic may be included in ypour post if you want to refer to some other topic.
Good luck and enjoy the forum
Fist of all, the name is Yaeger - it is important to use the correct name ahen a name is used.
Second - please do NOT address a question to a particular individual. In this case, Frank is no longer on the forum. He retired a year ago.
And last - it is best to start a new topic for your new question rather than posting a reply to a topic that has been dormant 3+ years. A link to the original topic may be included in ypour post if you want to refer to some other topic.
Good luck and enjoy the forum
Have a good one
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page