View previous topic :: View next topic
Author
Message
useit Active User Joined: 05 Oct 2006Posts: 152
input file has 1 X type record and multiple Y type record for the same key combination. ( key-1-16)
INPUT FILE:
0102031050006618 2010-12-10X 10.00.00############555555555FFFFFFFFFFFFFFF
0102031050006618 2010-12-11Y 10.00.00
0102031050006618 2010-12-12Y 20.00.00
0102031050006618 2010-12-13Y 30.00.00
0102031050006618 2010-12-14Y 40.00.00
0102031050006618 2010-12-15Y 50.00.00
0102031050006618 2010-12-16Y 60.00.00
0102031050006666 2010-12-10X 11.00.00############555555555FFFFFFFFFFFFFFF
0102031050006666 2010-12-11Y 12.00.00
0102031050006666 2010-12-12Y 13.00.00
0102031050006666 2010-12-13Y 14.00.00
0102031050006666 2010-12-14Y 15.00.00
OUTPUT FILE:
my output shud be as shown below.
X type record should be as it is.
And for Y type qty field(after Y) should append as shown.
0102031050006618 2010-12-10X 10.00.00############555555555FFFFFFFFFFFFFFFFFFF
0102031050006618 2010-12-11Y 10.00.0020.00.0030.00.0040.00.0050.00.0060.00.00
0102031050006666 2010-12-10X 11.00.00############555555555FFFFFFFFFFFFFFFFFFF
0102031050006666 2010-12-11Y 12.00.0013.00.0014.00.0015.00.00
i want to achieve this only using DFSORT. not thru icetool/program.i would be very thankful to you if somecan can provide me the solution.please help me regarding the same
Back to top
useit Active User Joined: 05 Oct 2006Posts: 152
someone please provide me the solution:(
Back to top
expat Global Moderator Joined: 14 Mar 2007Posts: 8797 Location: Welsh Wales
useit wrote:
someone please provide me the solution:(
Please remember that the answers to your requests are on a volunteer basis, if you need the speed of instant assistance then you will need to pay for it.
Do you not realise that our DFSORT experts might be in a different time zone to you and are currently enjoying their sleep.
You could use the time difference to read some of the DFSORT materials.
Back to top
nelson.pandian Active User Joined: 09 Apr 2008Posts: 133 Location: Phoenix, AZ
Hi useit,
What is the LRECL & RECFM of your Input and Output File?
How many Y type records (MAX Count) will be present for a single X type records?
Back to top
useit Active User Joined: 05 Oct 2006Posts: 152
input LRECL=60
output LRECL=100
UNDER 1 X maximum 15 Y TYPE records can come
Back to top
useit Active User Joined: 05 Oct 2006Posts: 152
remaining bytes should be filled with spaces. and if it reaches the maximum record lenght then IT SHOULD COMTINUE WRITING IN NEXT LINE FROM THE 23TH POSITION.
examle:
input:
0102031050006618 2010-12-11Y 10.00.00
0102031050006618 2010-12-11Y 20.00.00
0102031050006618 2010-12-11Y 30.00.00
0102031050006618 2010-12-11Y 40.00.00
0102031050006618 2010-12-11Y 50.00.00
output
--------------------------------------------------------------------
0102031050006618 2010-12-11Y 10.00.0020.00.0030.00.00
40.00.0050.00.00
Back to top
dbzTHEdinosauer Global Moderator Joined: 20 Oct 2006Posts: 6966 Location: porcelain throne
changing your requirements midstream is not very nice.
also, learn to use the bbcode CODE tags, so that spacing is preserved.
and learn to use the preview button.
your example does not show an X record,
nor is the spacing preserved.
Back to top
useit Active User Joined: 05 Oct 2006Posts: 152
sorry for that.its very critical requirement and i have to achieve it thru dfsort..i would be very thankful to you if you can provide me the answer.
Back to top
dbzTHEdinosauer Global Moderator Joined: 20 Oct 2006Posts: 6966 Location: porcelain throne
useit wrote:
i want to achieve this only using DFSORT. not thru icetool
why the restriction on ICETOOL?
useit wrote:
i would be very thankful to you if you can provide me the answer.
i am sure.
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19244 Location: Inside the Matrix
Hello,
You may receive a working solution in the next hour or 2, but maybe not. . .
If this is critical, a forum is not the place to depend for a quick answer - the reply may not be posted as quickly as you need.
As soon as you realized you didn't have sufficient sort knowledge and posted the question, it would have been far more productive to write the code in some programming language - to write the code would have taken 1 or 2 hours at most . . .
This would have been working hours ago. . . Then, the sort alternative could have been pursued but if the process had to run, there would be a means to do so.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Useit,
So if you had these input records:
Code:
0102031050006618 2010-12-10X 10.00.00############555555555FFFFFFFFFFFFFFF
0102031050006618 2010-12-11Y 01.00.01
0102031050006618 2010-12-12Y 02.00.02
0102031050006618 2010-12-13Y 03.00.03
0102031050006618 2010-12-14Y 04.00.04
0102031050006618 2010-12-15Y 05.00.05
0102031050006618 2010-12-16Y 06.00.06
0102031050006618 2010-12-17Y 07.00.07
0102031050006618 2010-12-18Y 08.00.08
0102031050006618 2010-12-19Y 09.00.09
0102031050006618 2010-12-20Y 10.00.10
0102031050006618 2010-12-21Y 11.00.11
0102031050006618 2010-12-22Y 12.00.12
0102031050006618 2010-12-23Y 13.00.13
0102031050006618 2010-12-24Y 14.00.14
0102031050006618 2010-12-25Y 15.00.15
would want these output records?
Code:
0102031050006618 2010-12-10X 10.00.00############555555555FFFFFFFFFFFFFFF
0102031050006618 2010-12-11Y 01.00.0102.00.0203.00.0304.00.0405.00.0506.00.0607.00.0708.00.08
09.00.0910.00.1011.00.1112.00.1213.00.1314.00.1415.00.15
or something else (what)?
Back to top
Hariharan Ramachandran New User Joined: 30 Nov 2010Posts: 28 Location: Chennai, Tamilnadu,INDIA
Your requirement is totally incorrect. There is no possibility of your given input record's
Quote:
2010-12-11Y
2010-12-12Y
2010-12-13Y
2010-12-14Y
2010-12-15Y
2010-12-16Y
could produce an output record like below
Quote:
0102031050006618 2010-12-11Y 10.00.0020.00.0030.00.0040.00.0050.00.0060.00.00
.
does not the date field 2010-12-11(whatsoever) should be the same for all the Y type records. Confirmed this with your next post as below
Quote:
0102031050006618 2010-12-11Y 10.00.00
0102031050006618 2010-12-11Y 20.00.00
0102031050006618 2010-12-11Y 30.00.00
0102031050006618 2010-12-11Y 40.00.00
0102031050006618 2010-12-11Y 50.00.00
Due to your incorrect requirement Frank has also assumed incorrectly.Please make your requirement clear before you post any questions.
Frank please change your input such that all Y type records has the same date
Quote:
its very critical requirement and i have to achieve it thru dfsort.
If its critical make sure you show importance to it.
Kind Regards,
Hari
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Hari,
I think it's you who misunderstands.
Quote:
input file has 1 X type record and multiple Y type record for the same key combination. ( key-1-16)
This says to me that each group of records begins with an X record and has the same key value in 1-16. I don't see where the date in the Y record is relevant since it isn't in 1-16, except that he appears to want the Y output record for a group to have the date from the first Y record of the group. Why do YOU assume the date field is relevant for grouping? I really don't understand the point YOU are trying to make about the data.
Back to top
Hariharan Ramachandran New User Joined: 30 Nov 2010Posts: 28 Location: Chennai, Tamilnadu,INDIA
Apologies...Frank and useit...It makes a different feel when the spec changes as i was working with the first consideration and suddenly came to see some change in data...
Kind Regards,
Hari
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
I think it was more of an attempt by the OP to illustrate how to handle overflow of one output line, rather than a change in data. I'm still not clear on how exactly the overflow should be handled, so I showed a "better" example of input and output to get clarification.
Back to top
Hariharan Ramachandran New User Joined: 30 Nov 2010Posts: 28 Location: Chennai, Tamilnadu,INDIA
As OP has requested only by sort functioality and not icetool its going quite tedious for me..Frank how do i sum up two values 10.00.00 and 000000 using sumfields. Is it possible ??
Kind Regards,
Hari
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
You would have to use UFF to convert the dd.dd.dd value to a ZD value of dddddd, use ZD for SUM. and then use edit to get back dd.dd.dd
However, my choice for the solution here would involve SPLICE and/or GROUP. I would ignore the OP's statement about ICETOOL. He probably doesn't know that ICETOOL is available to him as part of DFSORT (has been since 1991).
The tricky part here is the overflow, so I'm waiting for clarification on that.
Back to top
Hariharan Ramachandran New User Joined: 30 Nov 2010Posts: 28 Location: Chennai, Tamilnadu,INDIA
Thanks Frank..Almost early morning here ill just go for a sleep and then get back to this ..Thanks much..
Kind Regards,
Hari
Back to top
useit Active User Joined: 05 Oct 2006Posts: 152
Apologies..i ll provide you another examples for more clarity..
input file:
MY input will have X type record(header) and for each "X" there will be multiple "Y" record under that for the same key combination.
ex:
INPUT FILE:(LRECL 30):
------------------------------------
KEY1XQTYA.....
KEY1YQTY1
KEY1YQTY2
KEY1YQTY3
KEY1YQTY4
KEY1YQTY5
KEY2XQTYB.....
KEY2YQTY6
KEY2YQTY7
KEY2YQTY8
KEY2YQTY9
KEY2YQTY10
and my output should look like this
OUTPUT FILE (LRECL 80):
------------------------------------------
KEY1XQTYA.....
KEY1YQTY1QTY2QTY3QTY4QTY5
KEY2XQTYB.....
KEY2YQTY6QTY7QTY8QTY9QTY10
Back to top
Hariharan Ramachandran New User Joined: 30 Nov 2010Posts: 28 Location: Chennai, Tamilnadu,INDIA
Hi useit,
Firstly its quite hard to bring up the solution you requested for in DFSORT, as Frank said making use of ICETOOL is always easy and convinient.
However i have bought up the solution for using DFSORT (I have tested it too..)
STEP1 - Split your I/P into three files. File1 will have the X records and File2 and File3 will have the Y records(same data in both File2 and File3).
Code:
//S010 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
0102031050006618 2010-12-11X 12345678
0102031050006618 2010-12-11X 12
0102031050006618 2010-12-11Y 13
0102031050006618 2010-12-11Y 14
0102031050006618 2010-12-11Y 15
//SORTOF1 DD SYSOUT=FILE1,DISP=XXX,DCB=XXX
//SORTOF2 DD SYSOUT=FILE2,DISP=XXX,DCB=XXX
//SORTOF3 DD SYSOUT=FILE3,DISP=XXX,DCB=XXX
//SYSIN DD *
SORT FIELDS=(1,16,CH,A)
OUTFIL FNAMES=(FILE1),INCLUDE=(28,1,CH,EQ,C'X')
OUTFIL FNAMES=(FILE2),INCLUDE=(28,1,CH,EQ,C'Y')
OUTFIL FNAMES=(FILE3),INCLUDE=(28,1,CH,EQ,C'Y')
OPTION COPY
/*
The O/P of the above code is as follows -
File1 -
Code:
0102031050006618 2010-12-11X 12345678
File2 -
Code:
0102031050006618 2010-12-11Y 12
0102031050006618 2010-12-11Y 13
0102031050006618 2010-12-11Y 14
0102031050006618 2010-12-11Y 15
File3 -
Code:
0102031050006618 2010-12-11Y 12
0102031050006618 2010-12-11Y 13
0102031050006618 2010-12-11Y 14
0102031050006618 2010-12-11Y 15
STEP2 - Insert the sequence number for both File2 and File3. This is to fetch the data exactly when using JOINKEYS.
Code:
//SYSIN DD *
INREC FIELDS=(01,32,SEQNUM,03,ZD,RESTART=(1,16),START=00000)
OPTION COPY
//*
The O/P of the above condition will produce the below results -
File2 -
Code:
0102031050006618 2010-12-11Y 12 001
0102031050006618 2010-12-11Y 13 002
0102031050006618 2010-12-11Y 14 003
0102031050006618 2010-12-11Y 15 004
File3 -
Code:
0102031050006618 2010-12-11Y 12 001
0102031050006618 2010-12-11Y 13 002
0102031050006618 2010-12-11Y 14 003
0102031050006618 2010-12-11Y 15 004
STEP3 - Using Joinkeys we could bring 80% of your expexted output
Code:
//S030 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD *
0102031050006618 2010-12-11Y 12 001
0102031050006618 2010-12-11Y 13 002
0102031050006618 2010-12-11Y 14 003
0102031050006618 2010-12-11Y 15 004
//SORTJNF2 DD *
0102031050006618 2010-12-11Y 12 001
0102031050006618 2010-12-11Y 13 002
0102031050006618 2010-12-11Y 14 003
0102031050006618 2010-12-11Y 15 004
//SORTOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(01,16,A)
JOINKEYS FILE=F2,FIELDS=(01,16,A)
REFORMAT FIELDS=(F1:01,35,
F2:01,35)
INCLUDE COND=(01,16,CH,EQ,036,16,CH,AND,
33,03,CH,EQ,68,03,CH)
SORT FIELDS=(01,16,CH,A)
OUTREC IFTHEN=(WHEN=(33,3,CH,EQ,C'001'),
BUILD=(1,31,32:C'00',34:C'00',36:C'00')),
IFTHEN=(WHEN=(33,3,CH,EQ,C'002'),
BUILD=(30:C'00',32:30,2,34:C'00',36:C'00')),
IFTHEN=(WHEN=(33,3,CH,EQ,C'003'),
BUILD=(30:C'00',32:C'00',34:30,2,36:C'00')),
IFTHEN=(WHEN=(33,3,CH,EQ,C'004'),
BUILD=(30:C'00',32:C'00',34:C'00',36:30,2))
/*
The output of the above code would be as below -
Code:
0102031050006618 2010-12-11Y 12000000
0102031050006618 2010-12-11Y 00130000
0102031050006618 2010-12-11Y 00001400
0102031050006618 2010-12-11Y 00000015
STEP4 - Using sum fields to add up and bring the iutput in single line.
Code:
//S040 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
0102031050006618 2010-12-11Y 12000000
0102031050006618 2010-12-11Y 00130000
0102031050006618 2010-12-11Y 00001400
0102031050006618 2010-12-11Y 00000015
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(01,16,CH,A)
SUM FIELDS=(30,11,ZD)
/*
Please find the Output of the above code -
Code:
0102031050006618 2010-12-11Y 12131415
STEP5 - concatenate the File1(obtained in STEP1) with the output obtained in STEP4. YIPYYYYYYYYYYYYYYYYYYYY her is your requested O/P
Code:
//S050 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=FILE1,DISP=SHR
// DSN=FILE2,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(01,16,CH,A)
/*
The O/P of the above code would bring you the final output.
Code:
0102031050006618 2010-12-11X 12345678
0102031050006618 2010-12-11Y 12131415
If you need any further help regarding this let me know..I have spoon feeded you and make best use of the code..
Regards,
Hari
Back to top
useit Active User Joined: 05 Oct 2006Posts: 152
thanks a lot Hariharan, I am grateful to you for your help i ll test this jcl and get back to you..
Back to top
useit Active User Joined: 05 Oct 2006Posts: 152
u have used sum fields to add up and bring the output in single line.but in my case i have ZD, as well as charecter fields,
ex:
0102031050006618 2010-12-11Y 12AB
0102031050006618 2010-12-11Y 13CD
0102031050006618 2010-12-11Y 14DE
And my output should be
0102031050006618 2010-12-11Y 12AB13CD14DE
DO WE HAVE ANYOTHER METHOD TO BRING THE OUTPUT IN SINGLE LINE?
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
useit,
You are just wasting your time. Provide the following details.
1. What is the cobol layout of input and output file. I need the definition and format of the fields involved to be merged.
2. Answer frank's question about the final output here
ibmmainframes.com/viewtopic.php?p=256827#256827
Hariharan Ramachandran,
I know you are eager to help , but please understand the question first and then try to answer and please do NOT complicate a simple requirement.
Back to top
useit Active User Joined: 05 Oct 2006Posts: 152
skolusu/hari/frank,
please find the below details
input layout(input lrecl=82)
01 input rec.
05 key data pic x(12).
05 value 1 pic s9(2) v (99) comp-3.
05 value 2 pic s9(2) v (99) comp-3.
05 value 3 pic s9(2) v (99) comp-3.
05 filler pic x(58).
input file:
012010X..............................................
012010Y+10.00+38.00+14.93
012010Y+18.00+30.00+14.09
012010Y+10.00+20.00+15.94
012010Y+20.00+10.00+17.67
012010Y+10.00+10.00+17.36
012010Y+20.00+30.00+47.36
012010Y+40.00+10.00+17.36
012010X..............................................
012010Y+10.00+20.00+15.94
012010Y+10.00+10.00+17.36
output layout:(input lrecl=48)
01 outputrec.
05 key data pic x(12).
05 value 1a pic s9(2) v (99) comp-3.
05 value 2a pic s9(2) v (99) comp-3.
05 value 3a pic s9(2) v (99) comp-3.
05 value 1b pic s9(2) v (99) comp-3.
05 value 2b pic s9(2) v (99) comp-3.
05 value 3b pic s9(2) v (99) comp-3.
05 value 1c pic s9(2) v (99) comp-3.
05 value 2c pic s9(2) v (99) comp-3.
05 value 3c pic s9(2) v (99) comp-3.
output file should be:
012010X..............................................
012010Y+10.00+38.00+14.93+18.00+30.00+14.09+10.00+20.00+15.94
..............+20.00+10.00+17.67+10.00+10.00+17.36+20.00+30.00+47.36
..............+40.00+10.00+17.36
012010X..............................................
012010Y+10.00+20.00+15.94+10.00+10.00+17.36
treat "............" as spaces
regards,
useit
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19244 Location: Inside the Matrix
Hello,
Suggest you review what you have posted and correct or clarify. . .
The input record layout does not appear to be length 82. . .
The input data has no packed-decimal fields, but the layout shows 3 fields that are packed-decimal (comp-3).
You need to post the "rules" you want folllowed also. . .
Back to top
Please enable JavaScript!