View previous topic :: View next topic
|
Author |
Message |
mohitsaini Warnings : 1 New User
Joined: 15 May 2006 Posts: 92
|
|
|
|
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 |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Code: |
1AAAAAAAAyestdateBBBBBBBBBBBtodaysdateCCCCCCCCCCtomorrowsdate
|
Will this be case always? |
|
Back to top |
|
|
mohitsaini Warnings : 1 New User
Joined: 15 May 2006 Posts: 92
|
|
|
|
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 |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 |
|
|
mohitsaini Warnings : 1 New User
Joined: 15 May 2006 Posts: 92
|
|
|
|
Yes Sambhaji ... that's correct. |
|
Back to top |
|
|
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
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 |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
sqlcode1 wrote: |
//SYSIN DD *
INREC IFTHEN=(WHEN=
/* [/code]
Thanks, |
Sqlcode1, Not sure why you have used IFTHEN... |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
|
mohitsaini Warnings : 1 New User
Joined: 15 May 2006 Posts: 92
|
|
|
|
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 |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
|
mohitsaini Warnings : 1 New User
Joined: 15 May 2006 Posts: 92
|
|
|
|
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 |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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...
I thinks if fair is to let mohitsaini to convert card for VB |
|
Back to top |
|
|
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
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 |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 |
|
|
mohitsaini Warnings : 1 New User
Joined: 15 May 2006 Posts: 92
|
|
|
|
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 |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
|
mohitsaini Warnings : 1 New User
Joined: 15 May 2006 Posts: 92
|
|
|
|
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 |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
|
|