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
 

 

Replacing date with another date

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
mohitsaini
Warnings : 1

New User


Joined: 15 May 2006
Posts: 87

PostPosted: Fri Jul 08, 2011 8:09 pm    Post subject: Replacing date with another date
Reply with quote

Hi there,

I have a following requirement:

Records in an input file are as follows:
1AAAAAAAA2010030BBBBBBBBBBB2010031CCCCCCCCCC2010032
2AAAAAAAA2010030BBBBBBBBBBB2010031CCCCCCCCCC2010032
3AAAAAAAA2010030BBBBBBBBBBB2010031CCCCCCCCCC2010032
4AAAAAAAA2010030BBBBBBBBBBB2010031CCCCCCCCCC2010032
5AAAAAAAA2010030BBBBBBBBBBB2010031CCCCCCCCCC2010032

Where 2010030, 2010031 and 2010032 are dates (YYYYDDD date format) in S9(7) Comp-3 format. If 2010031 is today's date then 2010030 is yesterday's date and 2010032 is tomorrow's date.

Now I would like to replace these dates with another set of dates in all records. For example, I would like to have my records as shown below:

Output file will look like this:
1AAAAAAAA2011120BBBBBBBBBBB2011121CCCCCCCCCC2011122
2AAAAAAAA2011120BBBBBBBBBBB2011121CCCCCCCCCC2011122
3AAAAAAAA2011120BBBBBBBBBBB2011121CCCCCCCCCC2011122
4AAAAAAAA2011120BBBBBBBBBBB2011121CCCCCCCCCC2011122
5AAAAAAAA2011120BBBBBBBBBBB2011121CCCCCCCCCC2011122

Thus 2010030, 2010031 and 2010032 have been replaced by 2011120, 2011121 and 2011122.

Now main challenge that I am facing is that I want user to enter (via a JCL) only one date. In the above case the user will enter 2011121 and I want my sort card to do the rest. Rest as in that the sort will calculate 2011120 (Minus 1 day) and 2011122 (Plus 1 day) and will do the required replacements


My attempt:I have written a COBOL program that converts user entered date to COMP-3 and writes it like the below to a file:

Date1,'%^&*' --> %^* is COMP-3 equivalent of the date entered

Then I use this file as SYMNAMES and try to replace one column with that.

The problem with my approach is that I am just able to replace only one column and not the rest. Also since I am dealing with dates then I really don't know how to get (in this scenario) Minus 1 and Plus 1 dates from the sort itself.

Also I am thinking on the lines to get rid of the COBOL program and make it working via sort only. Is that possible?

Right now I am open to all options. Please assist.
Back to top
View user's profile Send private message

Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Jul 08, 2011 8:44 pm    Post subject:
Reply with quote

Code:

1AAAAAAAAyestdateBBBBBBBBBBBtodaysdateCCCCCCCCCCtomorrowsdate

Will this be case always?
Back to top
View user's profile Send private message
mohitsaini
Warnings : 1

New User


Joined: 15 May 2006
Posts: 87

PostPosted: Fri Jul 08, 2011 9:06 pm    Post subject:
Reply with quote

Hi Sambhaji,

It looks I didn't make myself clear on that.

It could be anydate but it will always have Minus 1 day and Plus 1 day before and after.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Jul 08, 2011 9:09 pm    Post subject:
Reply with quote

mohitsaini wrote:
Hi Sambhaji,

It looks I didn't make myself clear on that.

It could be anydate but it will always have Minus 1 day and Plus 1 day before and after.

OK.. So what I understand from this is whatever date is passed you want to put it at center one and (passed date -1) on left side and (passed date+1) on right .. Is that correct?
Back to top
View user's profile Send private message
mohitsaini
Warnings : 1

New User


Joined: 15 May 2006
Posts: 87

PostPosted: Fri Jul 08, 2011 9:12 pm    Post subject:
Reply with quote

Yes Sambhaji ... that's correct.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Fri Jul 08, 2011 9:35 pm    Post subject:
Reply with quote

mohitsaini,
See if below works...I am assuming 80 byte,FB input file and your date fields starts at 10,23 and 36th position respectively.
Code:
//STEP0001  EXEC PGM=SORT                                             
//SYSOUT    DD SYSOUT=*                                               
//SYSPRINT  DD SYSOUT=*                                               
//SORTIN    DD *                                                     
2011121      --> USER ENTERED INPUT DATE                             
/*                                                                   
//OUT      DD DSN=&&DATE,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)         
//SYSIN    DD *                                                       
 OPTION COPY                                                         
 OUTFIL FNAMES=OUT,REMOVECC,NODETAIL,                                 
        TRAILER1=(C'USER-DATE,C''',01,07,C'''')                       
/                                                                     
//STEP0002  EXEC PGM=SORT                                             
//SYSOUT    DD SYSOUT=*                                               
//SYSPRINT  DD SYSOUT=*                                               
//SYMNAMES  DD DSN=&&DATE,DISP=SHR                                   
//SORTIN    DD DSN=YOUR INPUT FILE FB/80                             
//SORTOUT   DD DSN=YOUR OUTPUT FILE FB/80                             
//             DISP=(,CATLG,DELETE),                                 
//             UNIT=SYSDA                                             
//SYSIN    DD *                                                       
 INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:USER-DATE,                       
                                  23:81,07,Y4T,TOJUL=Y4U,             
                                  10:81,07,Y4T,ADDDAYS,+1,TOJUL=Y4U, 
                                  36:81,07,Y4T,ADDDAYS,+2,TOJUL=Y4U))
 OPTION COPY                                                         
 OUTFIL BUILD=(1,80)                                                 
/*                                                                   

Thanks,
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Jul 08, 2011 9:39 pm    Post subject:
Reply with quote

OK,
This is the input I have used..
Code:

RECNO  SOMETHING YESTDATE SOMETHING2  TODAYDATE SOMETHING3 TOMODATE
C 1   C 8        PS 4     C 11        PS 4      C 10       PS 4   
1---- 2--------- 10------ 14--------- 25------- 29-------- 39------
****************************** Top of Data ************************
1     AAAAAAAA   2010030  BBBBBBBBBBB 2010031   CCCCCCCCCC 2010032
2     AAAAAAAA   2010030  BBBBBBBBBBB 2010031   CCCCCCCCCC 2010032
3     AAAAAAAA   2010030  BBBBBBBBBBB 2010031   CCCCCCCCCC 2010032
4     AAAAAAAA   2010030  BBBBBBBBBBB 2010031   CCCCCCCCCC 2010032
5     AAAAAAAA   2010030  BBBBBBBBBBB 2010031   CCCCCCCCCC 2010032



This is the symname dataset user need to configure..

Code:

VNAME COMMA1 QUOTE1  VNAME   QUOTE2
C 5   C 1    C 1    PS 4     C 1   
1---- 6----- 7----- 8------- 12----
****************************** Top
TDATE ,      '      2011121  '     


This is the code..
Code:

//S2    EXEC  PGM=SORT                               
//SYSOUT    DD  SYSOUT=*                             
//SYMNAMES  DD DSN=symnamedateaset,DISP=SHR 
//SORTIN    DD DSN=Inputfile,DISP=SHR   
//SORTOUT DD DSN=Outputfile,DISP=SHR   
//SYSIN    DD    *                                   
 SORT FIELDS=COPY                                   
 INREC OVERLAY=(25:TDATE,                           
                10:25,4,Y4U,SUBDAYS,+1,TOJUL=Y4U,   
                39:25,4,Y4U,ADDDAYS,+1,TOJUL=Y4U)   
/*                                                   

Output will look like this


Code:

RECNO  SOMETHING YESTDATE SOMETHING2  TODAYDATE SOMETHING3 TOMODATE
C 1   C 8        PS 4     C 11        PS 4      C 10       PS 4   
1---- 2--------- 10------ 14--------- 25------- 29-------- 39------
****************************** Top of Data ************************
1     AAAAAAAA   2011120  BBBBBBBBBBB 2011121   CCCCCCCCCC 2011122
2     AAAAAAAA   2011120  BBBBBBBBBBB 2011121   CCCCCCCCCC 2011122
3     AAAAAAAA   2011120  BBBBBBBBBBB 2011121   CCCCCCCCCC 2011122
4     AAAAAAAA   2011120  BBBBBBBBBBB 2011121   CCCCCCCCCC 2011122
5     AAAAAAAA   2011120  BBBBBBBBBBB 2011121   CCCCCCCCCC 2011122
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Jul 08, 2011 9:41 pm    Post subject:
Reply with quote

sqlcode1 wrote:

//SYSIN DD *
INREC IFTHEN=(WHEN=
/* [/code]
Thanks,

Sqlcode1, Not sure why you have used IFTHEN... icon_question.gif
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jul 08, 2011 9:41 pm    Post subject:
Reply with quote

mohitsaini,

You don't have to use a cobol program to convert the date and create symbols. You can pass the date in readable form via parm to DFSORT and it will create the dates with -1 and +1 to the passed date. I assumed your input is FB and Lrecl=80 with the date being replaced at 10, 25 and 40

Code:

//   SET PASSDATE='2011120'                             
//STEP0100 EXEC PGM=SORT,PARM='JP1"&PASSDATE"'           
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                         
1AAAAAAAAYDATBBBBBBBBBBBTDATCCCCCCCCCCCFDAT             
2AAAAAAAAYDATBBBBBBBBBBBTDATCCCCCCCCCCCFDAT             
3AAAAAAAAYDATBBBBBBBBBBBTDATCCCCCCCCCCCFDAT             
4AAAAAAAAYDATBBBBBBBBBBBTDATCCCCCCCCCCCFDAT             
5AAAAAAAAYDATBBBBBBBBBBBTDATCCCCCCCCCCCFDAT             
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                         
  SORT FIELDS=COPY                                       
  INREC IFOUTLEN=80,IFTHEN=(WHEN=INIT,OVERLAY=(81:JP1)),
  IFTHEN=(WHEN=INIT,                                     
  OVERLAY=(10:81,7,Y4T,SUBDAYS,+1,TOJUL=Y4U,             
           25:81,7,Y4T,TOJUL=Y4U,                       
           40:81,7,Y4T,ADDDAYS,+1,TOJUL=Y4U))           
//*                                                     
Back to top
View user's profile Send private message
mohitsaini
Warnings : 1

New User


Joined: 15 May 2006
Posts: 87

PostPosted: Fri Jul 08, 2011 9:42 pm    Post subject:
Reply with quote

Thanks Sqlcode1,

Right now I am at home and don't have access to Mainframes. So I will try this out tomorrow morning.

Also my i/p file is VB and the date is in S9(7) Comp-3.

Also I want the user to enter the date via a JCL and then it will be passed as a symbolic parameter in the proc.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jul 08, 2011 9:44 pm    Post subject:
Reply with quote

mohitsaini wrote:
Thanks Sqlcode1,

Right now I am at home and don't have access to Mainframes. So I will try this out tomorrow morning.

Also my i/p file is VB and the date is in S9(7) Comp-3.

Also I want the user to enter the date via a JCL and then it will be passed as a symbolic parameter in the proc.


How hard is to explain that simple fact in the very first post itself? Even now we are not sure what the position of the date is. Please provide all the positions of the dates to be replaced and the LRECL also.
Back to top
View user's profile Send private message
mohitsaini
Warnings : 1

New User


Joined: 15 May 2006
Posts: 87

PostPosted: Fri Jul 08, 2011 9:50 pm    Post subject:
Reply with quote

Thanks Sokolusu.

Sorry I missed to mention that I am dealing with a VB file. Not an FB file.

Also, as mentioned in my query, the dates in input and output files are in S 9(7) COMP-3 format. I just wrote them in readable format for easy understanding.

I hope now I have made myself clearer.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Jul 08, 2011 9:52 pm    Post subject:
Reply with quote

Skolusu wrote:
How hard is to explain that simple fact in the very first post itself? Even now we are not sure what the position of the date is. Please provide all the positions of the dates to be replaced and the LRECL also.


Life is tough even when you are helping ... I wish I could be Psychic... icon_sad.gif


I thinks if fair is to let mohitsaini to convert card for VB
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Fri Jul 08, 2011 9:55 pm    Post subject:
Reply with quote

mohitsaini,
your first post shows expected output as replaced date, replaced date+1,replaced date+2 and then you agree to Escapa's statement which doesn't match your expected output. Now you are saying your input is VB!!!.

I wonder what is your DFSort Function level!!

Escapa,
I was initially using 2 different OVERLAY statements, first to populate date in the symname and then to do the date arithmetics. Later I decided to use it all in one OVERLAY but forgot to got rid of IFTHEN.

mohitsaini,
After seeing your reply,you need to provide LRECL for your VB file.

Thanks,
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Jul 08, 2011 9:57 pm    Post subject:
Reply with quote

sqlcode1 wrote:
Escapa,
I was initially using 2 different OVERLAY statements, first to populate date in the symname and then to do the date arithmetics. Later I decided to use it all in one OVERLAY but forgot to got rid of IFTHEN.

Thanks,

Yeah, I guessed that.. It would have been this way...
Back to top
View user's profile Send private message
mohitsaini
Warnings : 1

New User


Joined: 15 May 2006
Posts: 87

PostPosted: Fri Jul 08, 2011 9:57 pm    Post subject:
Reply with quote

Sorry guys ...

Was so much focused on the replacing dates thing that I simply missed to mentioned simple things.

the LRECL is 378

and for dates you can consider the same positions as stated in my query.

Thanks a ton.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jul 08, 2011 9:58 pm    Post subject:
Reply with quote

mohitsaini wrote:
Thanks Sokolusu.


mohitsaini,

The least you can do is spell my username right.

mohitsaini wrote:

I hope now I have made myself clearer.


No you did not. What part of this question did you not understand?
skolusu wrote:
Even now we are not sure what the position of the date is. Please provide all the positions of the dates to be replaced and the LRECL also.
Back to top
View user's profile Send private message
mohitsaini
Warnings : 1

New User


Joined: 15 May 2006
Posts: 87

PostPosted: Fri Jul 08, 2011 10:12 pm    Post subject:
Reply with quote

Sorry Skolusu for misspelling your name.

Actually you have replied on an older post of mine. I have provided you with what you were looking for in my last post which was submitted just before your latest post.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jul 08, 2011 11:10 pm    Post subject: Reply to: Replacing date with another date
Reply with quote

mohitsaini wrote:
Actually you have replied on an older post of mine. I have provided you with what you were looking for in my last post which was submitted just before your latest post.


No you haven't and your last post is

mohitsaini wrote:
and for dates you can consider the same positions as stated in my query.


Nowhere in your query you specify the POSITIONS of the date fields to be replaced except that they are past, current and future dates in comp-3 fomart.

Sqlcode assumed "your date fields starts at 10,23 and 36th position respectively."

Escapa assumed "date fields starts at 10,25 and 39th position respectively".

I assumed "date being replaced at 10, 25 and 40 "


None of the above positions would be true since your input is a VB file. And remember that a VB solution is completely different from a FB solution. If you applied that VB solution to a FB dataset you will ruin the very concept of VB file having varying lengths.

I am outta of this
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 TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
This topic is locked: you cannot edit posts or make replies. Get correct date and time when curren... balaji81_k DB2 24 Fri Oct 14, 2016 10:40 pm
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm
No new posts Add system date inside of a PS file a... pramitdas DFSORT/ICETOOL 5 Sun Aug 28, 2016 12:06 am


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