Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Change date (DD/MM/YY) in 2nd record of a file using DFSORT
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Wed Sep 07, 2016 11:05 pm    Post subject:
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.
http://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    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Thu Sep 08, 2016 12:14 am    Post subject:
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    Post subject:
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: 331
Location: USA

PostPosted: Thu Sep 08, 2016 1:25 am    Post subject: Reply to: Change date (DD/MM/YY) in 2nd record of a file using DFSORT
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Thu Sep 08, 2016 2:39 am    Post subject: Reply to: Change date (DD/MM/YY) in 2nd record of a file using DFSORT
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Thu Sep 08, 2016 3:01 am    Post subject:
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

Moderator


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

PostPosted: Thu Sep 08, 2016 12:07 pm    Post subject:
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: 2163
Location: @my desk

PostPosted: Thu Sep 08, 2016 8:15 pm    Post subject:
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    Post subject:
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: 2163
Location: @my desk

PostPosted: Thu Sep 08, 2016 11:10 pm    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Fri Sep 09, 2016 1:49 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us