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

Change date (DD/MM/YY) in 2nd record of a file using DFSORT


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
uday kiran

New User


Joined: 09 May 2005
Posts: 4
Location: India

PostPosted: Wed Sep 07, 2016 10:57 pm
Reply with quote

Hi All,

I have 20 report files (133 LRECL, RECFM=FBA).

As an example they all have header as shown below,
Code:

------------------MEDICARE REPORT----------------------------------
PART A      ------------------------------   EXECUTION DATE: 07/09/16
-------------------------------------------------------------------------


My requirement is, I will have to update EXECUTION DATE in all files with a day minus. i.e it should now become 06/09/16. Its just one time request.

I wanted to achieve this using DFSORT not through COBOL program. Can some one help me on how the sort card should be like?

Since I have 20 files to be changed (at later point of time it can be more), Can I execute SORT on all 20 files in one step instead of executing same sort for 20 times?

Please let me know if you require more details.
Code'd for you.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Wed Sep 07, 2016 11:05 pm
Reply with quote

What have you tried so far ? I am sure you did not do research and just looking for readymade solution. look here is the latest topic for your interest and think how you can modify to fit what you want.
Please make a use of code tags when required.
ibmmainframes.com/viewtopic.php?t=65374&highlight=
Back to top
View user's profile Send private message
uday kiran

New User


Joined: 09 May 2005
Posts: 4
Location: India

PostPosted: Wed Sep 07, 2016 11:25 pm
Reply with quote

Hey Rohit,

I know that I can use DATE1-1 and replace the execution date.

However I wanted to know if I can convert the execution date (DD/MM/YY. Please note that my format is not DD/MM/CCYY) to Julian date (using TOJUL) and perform -1 on that and convert that back to DD/MM/YY.

I didn't find any clue in the link you provided.

Unless you know, never comment. We are here asking for help. If you can, please do. If not, Thank You.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Thu Sep 08, 2016 12:14 am
Reply with quote

1. People here may answer and ask questions and advise as they want as your are the one who has a problem and seeking help not us. So don't
ever teach me/anyone here to how and what they ask and comment.
2. look at your initial post what have you asked and then you change your mind and asking how the date conversion works or possible for what you want so you got to learn how to post the question in right manner by telling what has been tried and what you can't do by yourself than correcting later.
3.If you don't know how to identify the second record and reformat the Date of what you have to what DFSORT accepts and then perform the basic math and then reformat back to what you want in the final output then do some research on INREC,PARSE,OUTREC, OVERLAY BUILD functions of DFSORT.
4. As per me one step solution is not achievable but then you need to change the input dataset dynamically hence the expectation was you get that hint from the link that is shared but you did not get it.
5.Date conversion , see if you can find what you need here
Back to top
View user's profile Send private message
uday kiran

New User


Joined: 09 May 2005
Posts: 4
Location: India

PostPosted: Thu Sep 08, 2016 12:34 am
Reply with quote

Sorry Rohit for misquoting you. I don't mean to.

Can I execute SORT on all 20 files in a step?
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Thu Sep 08, 2016 1:25 am
Reply with quote

First thing first, Is it the same date in all the files?

Can the previous date go back to previous month/year?

Do you need to take weekend/holidays in account?

Last but not the least, TRY something.

.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Sep 08, 2016 2:39 am
Reply with quote

You state that the formats are the same and it is a once-off, so very simple:

Code:
 COPY COPY
 INREC IFTHEN=(WHEN=(identify uniquely the lines you want to change),
             OVERLAY=(columnnumberofsevenindate:C'6')


You can concatenate all the inputs, but remember you will just get one output unless you include code to identify the different outputs and have one OUTFIL for each report.

If you don't mind the output all being in one file, go with concatenation. From what you have said, it will work.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Thu Sep 08, 2016 3:01 am
Reply with quote

Quote:
Sorry Rohit for misquoting you. I don't mean to
Please,never do that to someone who is helping you.
tested sample and modify per what you need because you poorly stated the requirement( Missing the offsets which is most important if you wanted handy solution),
Code:
SORT FIELDS=COPY                                             
INREC IFTHEN=(WHEN=INIT,OVERLAY=(20:C'20',16,2,13,2,10,2)),   
      IFTHEN=(WHEN=(1,6,CH,EQ,C'PART A'),OVERLAY=(30:20,8,Y4T,
                            SUBDAYS,+1,TOGREG=Y4T))           
OUTREC IFTHEN=(WHEN=(1,6,CH,EQ,C'PART A'),OVERLAY=(10:36,2,   
                                        C'/',34,2,C'/',32,2)),
IFOUTLEN=17   

Bill, feel free to modify or advise on this approach.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Thu Sep 08, 2016 12:07 pm
Reply with quote

Can't we take help of ICETOOL here ?
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Thu Sep 08, 2016 8:15 pm
Reply with quote

You can make use of the Y2W(mmddyy) or Y2T(yymdd) formats which takes care of the CC part during a date arithmetic with 6 byte date fields.
Here is the results from a sample test.
Code:
//STEP01   EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                         
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
07/09/16                                                               
01/03/16                                                               
01/01/00                                                               
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  OPTION COPY                                                           
  INREC OVERLAY=(81:4,2,1,2,7,2,81:81,6,Y2W,SUBDAYS,+1,TOGREG=Y2W,     
                 15:83,2,C'/',81,2,C'/',85,2)
SORTOUT
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
07/09/16      06/09/16                                                 
01/03/16      29/02/16                                                 
01/01/00      31/12/99                                                 


Like Bill suggested, you can simply hard-code the date if this is a one-time activity and forget about the calculation. Also I'd use ICETOOL as Pandora suggested to put it in one step if you have 20 or more input AND output files.
Back to top
View user's profile Send private message
uday kiran

New User


Joined: 09 May 2005
Posts: 4
Location: India

PostPosted: Thu Sep 08, 2016 9:03 pm
Reply with quote

Rohit,

Thank You. I coded based on your hints.


Input file: 80 bytes
1st record 10th byte - MEDICARE REPORT
2nd record 1st byte - PART A
2nd record 30th byte 08/09/16


SORT FIELDS=COPY
INREC IFTHEN=(WHEN=1,6,CH,EQ,C'PART A', OVERLAY=(40:DATE1(.)-1))
OUTREC IFTHEN=(WHEN=1,6,CH,EQ,C'PART A'),OVERLAY=(30:48,2,C'/',45,3,42,2,20X))
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Thu Sep 08, 2016 11:10 pm
Reply with quote

Uday,

Did your requirement just change from - subtracting a day from a date value in the input file TO just finding "current system date - 1"?
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Fri Sep 09, 2016 1:49 am
Reply with quote

I guess, it was a coincidence that TS posted the current date as an example
Quote:
As an example they all have header as shown below,

Uday, please make a use of code tags going forward and try this for what you want
Code:
//SORTIN   DD *                                                     
PART A   12/12/16                                                   
//SORTOUT   DD SYSOUT=*                                             
//SYSIN DD *                                                       
    SORT FIELDS=COPY                                               
    INREC IFTHEN=(WHEN=(1,6,CH,EQ,C'PART A'),OVERLAY=(40:DATE1(.)-1,
                                      10:48,2,C'/',45,2,C'/',42,2)),
    IFOUTLEN=17                                                     
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
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 Access to non cataloged VSAM file JCL & VSAM 18
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
Search our Forums:

Back to Top