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

Need to write the date at the end of the File Name


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
Poha Eater

New User


Joined: 31 Aug 2016
Posts: 74
Location: India

PostPosted: Tue Jul 23, 2019 2:33 pm
Reply with quote

Hi,

I need the help regarding the requirement in which I need to write the date at the end of the file Name in the Output File. For ex, I have 2 Input files - One is having file names and the second one is having date. Below is the structure of the Input File :
Code:
TEST.DUMMY.FILE1
TEST.DUMMY.ABC.FILE2
TEST.DUMMY.FGHIJK.FILE3


The length of file names can vary.

The 2nd Input File which is Date file has structure like this :
Code:
06302019


The Output file should have records like this after appending the date at the end of the file name :
Code:
TEST.DUMMY.FILE1.06302019
TEST.DUMMY.ABC.FILE2.06302019
TEST.DUMMY.FGHIJK.FILE3.06302019


Is there any way to achieve this by using SORT ? Please let me know if someone is aware about this or written sort for something similar to my requirement. This would be a great help for me.

Thanks for the reading.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Tue Jul 23, 2019 4:48 pm
Reply with quote

Since you are posting on the Expert Forum, I assume that you realize your output file contains illegal and unusable data set names:
Code:
TEST.DUMMY.FILE1.06302019
TEST.DUMMY.ABC.FILE2.06302019
TEST.DUMMY.FGHIJK.FILE3.06302019
If you don't know why, I recommend that you review the rules for data set names (in the MVS JCL Reference manual, for example). If these are Unix System Services file names, then you'll be okay but not if they are supposed to be data set names.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Tue Jul 23, 2019 5:08 pm
Reply with quote

1.Simple way is to use SYMNAMES to at the end ( or add at certain position if each record is variable length) using BUILD then add SQZ=(SHIFT=LEFT) to remove spaces in between the records.
2. Use JOINKEYS and REFORTMAT accordingly.

Robert has a point , You must use something like this ‘D063019’.
Back to top
View user's profile Send private message
Poha Eater

New User


Joined: 31 Aug 2016
Posts: 74
Location: India

PostPosted: Thu Jul 25, 2019 5:07 pm
Reply with quote

Hi Robert,

Thanks for reading the post. I understand your point regarding datasets naming convention and i am aware about that. But you got it right, there are Unix System File names.

Hi Rohit,

Thanks for your suggestion. I will try this and let you know the result.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Thu Jul 25, 2019 8:24 pm
Reply with quote

Code:
//*==============================================================
//* APPEND SYSTEM DATE TO THE END OF DSN (OR ANY OTHER STRING)   
//*==============================================================
//APPENDDT EXEC PGM=SORT                                         
//*                                                             
//SYSOUT   DD  SYSOUT=*                                         
//*                                                             
//SORTIN   DD  *                                                 
unix.a001.b001.c001.d001     
unix.a001.b001.d002           
unix.a001.d003               
unix.a001.b001.c002.d001     
unix.a001.b001.d002           
unix.a001.d003               
unix.a001.b002.c001.d001     
unix.a001.b002.d002           
unix.a001.d003               
unix.a001.b002.c001.d001     
unix.a001.b002.d002           
unix.a001.d003               
//*                                                             
//SORTOUT  DD  SYSOUT=*                                         
//*                                                             
//SYSIN    DD  *                                                 
 INREC BUILD=(1,50,C'.',&DATE1)                                 
*                                                               
 SORT FIELDS=COPY                                               
*                                                               
 OUTREC BUILD=(1,59,SQZ=(SHIFT=LEFT))                           
*                                                               
 END                                                             
//*                                                             
//*=============================================

Code:
********************************* TOP OF DATA ****
unix.a001.b001.c001.d001.20190725                 
unix.a001.b001.d002.20190725                     
unix.a001.d003.20190725                           
unix.a001.b001.c002.d001.20190725                 
unix.a001.b001.d002.20190725                     
unix.a001.d003.20190725                           
unix.a001.b002.c001.d001.20190725                 
unix.a001.b002.d002.20190725                     
unix.a001.d003.20190725                           
unix.a001.b002.c001.d001.20190725                 
unix.a001.b002.d002.20190725                     
unix.a001.d003.20190725                           
******************************** BOTTOM OF DATA **

Back to top
View user's profile Send private message
Poha Eater

New User


Joined: 31 Aug 2016
Posts: 74
Location: India

PostPosted: Thu Jul 25, 2019 10:42 pm
Reply with quote

Hi Sergeyken,

Thank you very much for the code. This is really helpful. I have a question here as well. Here you are using the system date and in my case i am trying to append the date which is present in the 2nd Input File.

So is there any syntax available for reading the date from a file and then append at the end of the dataset name.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Thu Jul 25, 2019 11:19 pm
Reply with quote

Code:
//*====================================================================
//* APPEND SINGLE SUFFIX FROM JCL SET VARIABLE VIA PARM FIELD         
// SET JCLSUFF='JCL.suffix'                                           
//*====================================================================
//APPENDPA EXEC PGM=SORT,                                             
//             PARM='JP0"&JCLSUFF"'                                   
//*                                                                   
//SYSOUT   DD  SYSOUT=*                                               
//*                                                                   
//SORTIN   DD  *                                                       
unix.a001.b001.c001.d001                                               
unix.a001.b001.d002                                                   
unix.a001.d003                                                         
unix.a001.b001.c002.d001                                               
unix.a001.b001.d002                                                   
unix.a001.d003                                                         
unix.a001.b002.c001.d001                                               
unix.a001.b002.d002                                                   
unix.a001.d003                                                         
unix.a001.b002.c001.d001                                               
unix.a001.b002.d002                                                   
unix.a001.d003                                                         
//*                                                                   
//SORTOUT  DD  SYSOUT=*                                               
//*                                                                   
//SYSIN    DD  *                                                       
 INREC BUILD=(1,50,C'.',JP0,20X) extend with blanks to at least 71 char
*                                                                     
 SORT FIELDS=COPY                                                     
*                                                                     
 OUTREC BUILD=(1,71,SQZ=(SHIFT=LEFT))                                 
*                                                                     
 END                                                                   
//*                                                                   
//*====================================================================
Code:
********************************* TOP OF DATA ****
unix.a001.b001.c001.d001.JCL.suffix               
unix.a001.b001.d002.JCL.suffix                   
unix.a001.d003.JCL.suffix                         
unix.a001.b001.c002.d001.JCL.suffix               
unix.a001.b001.d002.JCL.suffix                   
unix.a001.d003.JCL.suffix                         
unix.a001.b002.c001.d001.JCL.suffix               
unix.a001.b002.d002.JCL.suffix                   
unix.a001.d003.JCL.suffix                         
unix.a001.b002.c001.d001.JCL.suffix               
unix.a001.b002.d002.JCL.suffix                   
unix.a001.d003.JCL.suffix                         
******************************** BOTTOM OF DATA **



Code:
//*===========================================================
//* APPEND SUFFIX FROM SEPARATE FILE, BY SUFFIX TYPE         
//*===========================================================
//APPENDST EXEC PGM=SORT                                     
//*                                                           
//SYSOUT   DD  SYSOUT=*                                       
//*                                                           
//SUFFIX   DD  *                                             
3  this_is_suffix_3                                           
2  this_is_suffix_2                                           
1  this_is_suffix_1                                           
//*                                                           
//NAMES    DD  *                                             
1  unix.a001.b001.c001.d001                                   
2  unix.a001.b001.d002                                       
3  unix.a001.d003                                             
2  unix.a001.b001.c002.d001                                   
3  unix.a001.b001.d002                                       
1  unix.a001.d003                                             
3  unix.a001.b002.c001.d001                                   
1  unix.a001.b002.d002                                       
2  unix.a001.d003                                             
2  unix.a001.b002.c001.d001                                   
1  unix.a001.b002.d002                                       
3  unix.a001.d003                                             
//*                                                           
//SORTOUT  DD  SYSOUT=*                                       
//*                                                           
//SYSIN    DD  *                                             
 JOINKEYS F1=SUFFIX,                                         
          FIELDS=(1,2,A)                                     
*                                                             
 JOINKEYS F2=NAMES,                                           
          FIELDS=(1,2,A)                                     
*                                                             
 REFORMAT FIELDS=(F2:4,50,                                   
                  F1:4,20)                                   
*                                                             
 INREC BUILD=(1,50,C'.',51,20)                               
*                                           
 SORT FIELDS=COPY                           
*                                           
 OUTREC BUILD=(1,71,SQZ=(SHIFT=LEFT))       
*                                           
 END                                         
//*                                         
//*==========================================
Code:
********************************* TOP OF DATA *****
unix.a001.b001.c001.d001.this_is_suffix_1         
unix.a001.d003.this_is_suffix_1                   
unix.a001.b002.d002.this_is_suffix_1               
unix.a001.b002.d002.this_is_suffix_1               
unix.a001.b001.d002.this_is_suffix_2               
unix.a001.b001.c002.d001.this_is_suffix_2         
unix.a001.d003.this_is_suffix_2                   
unix.a001.b002.c001.d001.this_is_suffix_2         
unix.a001.d003.this_is_suffix_3                   
unix.a001.b001.d002.this_is_suffix_3               
unix.a001.b002.c001.d001.this_is_suffix_3         
unix.a001.d003.this_is_suffix_3                   
******************************** BOTTOM OF DATA ***
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Fri Jul 26, 2019 12:37 am
Reply with quote

Code:
//*=================================================
//* APPEND SINGLE SUFFIX FROM SEPARATE FILE         
//*=================================================
//APPENDSL EXEC PGM=SORT                           
//*                                                 
//SYSOUT   DD  SYSOUT=*                             
//*                                                 
//SORTIN   DD  *                                   
DATE this_is_suffix                                 
//         DD  *                                   
unix.a001.b001.c001.d001                           
unix.a001.b001.d002                                 
unix.a001.d003                                     
unix.a001.b001.c002.d001                           
unix.a001.b001.d002                                 
unix.a001.d003                                     
unix.a001.b002.c001.d001                           
unix.a001.b002.d002                                 
unix.a001.d003                                     
unix.a001.b002.c001.d001                           
unix.a001.b002.d002                                 
unix.a001.d003                                     
//*                                                 
//SORTOUT  DD  SYSOUT=*                             
//*                                                 
//SYSIN    DD  *                                   
 INREC IFTHEN=(WHEN=INIT,                           
               OVERLAY=(50:C'.')),                 
       IFTHEN=(WHEN=GROUP,                         
               BEGIN=(1,5,CH,EQ,C'DATE'),           
               PUSH=(51:5,20))                     
*                                                   
 SORT FIELDS=COPY                                   
*                                         
 OUTREC BUILD=(1,71,SQZ=(SHIFT=LEFT))     
*                                         
 OUTFIL INCLUDE=(1,4,CH,NE,C'DATE')       
*                                         
 END                                               
//*                                                 
//*=============================================
Code:
********************************* TOP OF DATA ****
unix.a001.b001.c001.d001.this_is_suffix           
unix.a001.b001.d002.this_is_suffix               
unix.a001.d003.this_is_suffix                     
unix.a001.b001.c002.d001.this_is_suffix           
unix.a001.b001.d002.this_is_suffix               
unix.a001.d003.this_is_suffix                     
unix.a001.b002.c001.d001.this_is_suffix           
unix.a001.b002.d002.this_is_suffix               
unix.a001.d003.this_is_suffix                     
unix.a001.b002.c001.d001.this_is_suffix           
unix.a001.b002.d002.this_is_suffix               
unix.a001.d003.this_is_suffix                     
******************************** BOTTOM OF DATA **
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Fri Jul 26, 2019 4:25 pm
Reply with quote

Quote:
Thank you very much for the code. This is really helpful. I have a question here as well. Here you are using the system date and in my case i am trying to append the date which is present in the 2nd Input File.
So is there any syntax available for reading the date from a file and then append at the end of the dataset name.

ibmmainframes.com/about63954.html
ibmmainframes.com/about59524.html
ibmmainframes.com/about45659.html
There are several such topics already discussed in past on this and here are few , Please Google, try it first and that way we learn.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Fri Jul 26, 2019 4:46 pm
Reply with quote

Rohit Umarjikar wrote:
Quote:
Thank you very much for the code. This is really helpful. I have a question here as well. Here you are using the system date and in my case i am trying to append the date which is present in the 2nd Input File.
So is there any syntax available for reading the date from a file and then append at the end of the dataset name.

ibmmainframes.com/about63954.html
ibmmainframes.com/about59524.html
ibmmainframes.com/about45659.html
There are several such topics already discussed in past on this and here are few , Please Google, try it first and that way we learn.

I would not recommend using those three mentioned samples.

The last two of them are supposed to do a different task, not what the TS asked about.

All three of them do lack of simple straightforward logical approach; they are using unneeded operations, and even up to 3 JCL steps - instead of only one single step really needed.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Fri Jul 26, 2019 6:56 pm
Reply with quote

SYMNAMES is a simple Straightforward logical approach.
Quote:
The last two of them are supposed to do a different task, not what the TS asked about.

You did not get the point. The point is do a little research before posting, get an idea how it can be done by little twist than waiting for the code. If you spend more time than me doing research then you might as well get the exact one. The first and last one doing exactly what is asked for.
Back to top
View user's profile Send private message
Poha Eater

New User


Joined: 31 Aug 2016
Posts: 74
Location: India

PostPosted: Fri Jul 26, 2019 7:52 pm
Reply with quote

Hi sergeyken,

I tried the JOIN key version of the solution you provided and it worked. But after seeing your latest suggestion i believe i should use the solution with "DATE" identifier because in this case i have to put the identifier in only one file.

Also have one question from the latest solution you provided that what is the below statement does here.

Code:
OUTFIL INCLUDE=(1,4,CH,NE,C'DATE')
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Jul 26, 2019 10:31 pm
Reply with quote

The purpose of the INCLUDE is pretty much self explanatory, if you could try running it without that line, you'd be able to see it yourself what is different in the output data.
Good luck!
Back to top
View user's profile Send private message
Poha Eater

New User


Joined: 31 Aug 2016
Posts: 74
Location: India

PostPosted: Sat Jul 27, 2019 12:36 am
Reply with quote

Now i get it. This OUTFIL condition is for second file.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Mon Jul 29, 2019 9:49 pm
Reply with quote

Rohit Umarjikar wrote:
SYMNAMES is a simple Straightforward logical approach.
Quote:
The last two of them are supposed to do a different task, not what the TS asked about.

You did not get the point. The point is do a little research before posting, get an idea how it can be done by little twist than waiting for the code. If you spend more time than me doing research then you might as well get the exact one. The first and last one doing exactly what is asked for.

Just: NO, it's not
Back to top
View user's profile Send private message
Poha Eater

New User


Joined: 31 Aug 2016
Posts: 74
Location: India

PostPosted: Fri Aug 16, 2019 1:58 pm
Reply with quote

Hi Sergeyken,

[quote="sergeyken"]
Code:
//*====================================================================
//* APPEND SINGLE SUFFIX FROM JCL SET VARIABLE VIA PARM FIELD         
// SET JCLSUFF='JCL.suffix'                                           
//*====================================================================
//APPENDPA EXEC PGM=SORT,                                             
//             PARM='JP0"&JCLSUFF"'                                   
//*                                                                   
//SYSOUT   DD  SYSOUT=*                                               
//*                                                                   
//SORTIN   DD  *                                                       
unix.a001.b001.c001.d001                                               
unix.a001.b001.d002                                                   
unix.a001.d003                                                         
unix.a001.b001.c002.d001                                               
unix.a001.b001.d002                                                   
unix.a001.d003                                                         
unix.a001.b002.c001.d001                                               
unix.a001.b002.d002                                                   
unix.a001.d003                                                         
unix.a001.b002.c001.d001                                               
unix.a001.b002.d002                                                   
unix.a001.d003                                                         
//*                                                                   
//SORTOUT  DD  SYSOUT=*                                               
//*                                                                   
//SYSIN    DD  *                                                       
 INREC BUILD=(1,50,C'.',JP0,20X) extend with blanks to at least 71 char
*                                                                     
 SORT FIELDS=COPY                                                     
*                                                                     
 OUTREC BUILD=(1,71,SQZ=(SHIFT=LEFT))                                 
*                                                                     
 END                                                                   
//*                                                                   
//*====================================================================
Code:
********************************* TOP OF DATA ****
unix.a001.b001.c001.d001.JCL.suffix               
unix.a001.b001.d002.JCL.suffix                   
unix.a001.d003.JCL.suffix                         
unix.a001.b001.c002.d001.JCL.suffix               
unix.a001.b001.d002.JCL.suffix                   
unix.a001.d003.JCL.suffix                         
unix.a001.b002.c001.d001.JCL.suffix               
unix.a001.b002.d002.JCL.suffix                   
unix.a001.d003.JCL.suffix                         
unix.a001.b002.c001.d001.JCL.suffix               
unix.a001.b002.d002.JCL.suffix                   
unix.a001.d003.JCL.suffix                         
******************************** BOTTOM OF DATA **


In one of the requirement, i have to append the date at the end of the File Name where i am passing the file name through PARM and date is in the Input File.

Here in this solution, whatever we are passing in PARM is getting appended at the end of the file (SUFFIX) whereas in my current requirement the File Name i am passing through PARM have to append at the beginning (PREFIX) of the date which i am passing through File.

Suppose in PARM i am passing,
Code:
PARM=unix.a001.b001.c001.d001


and the Input File has date like
Code:
08162019


So the Output File will have data like
Code:
unix.a001.b001.c001.d001.08162019


Can we write SORT card for copying the data which we are passing through PARM as Suffix ?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Aug 16, 2019 2:51 pm
Reply with quote

This is a different requirement and so a new topic. Only start a new topic if you cannot adapt the solution for this topic to the new requirement. It should be easy if you try and understand the logic of the control statements used here. If you don't then you should post in the beginners forum. This forum is for people who try. Neither forum is for doing your work for you.

This topic locked and any new one will be deleted if it does not show what you have tried.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Write line by line from two files DFSORT/ICETOOL 7
Search our Forums:

Back to Top