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
 

 

DFSORT logic problem
Goto page 1, 2, 3, 4  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
useit

Active User


Joined: 05 Oct 2006
Posts: 141

PostPosted: Fri Dec 10, 2010 2:17 pm    Post subject: DFSORT logic problem
Reply with quote

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
View user's profile Send private message

useit

Active User


Joined: 05 Oct 2006
Posts: 141

PostPosted: Fri Dec 10, 2010 3:04 pm    Post subject: :(:(
Reply with quote

someone please provide me the solution:(
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Dec 10, 2010 3:07 pm    Post subject: Re: :(:(
Reply with quote

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
View user's profile Send private message
nelson.pandian

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Fri Dec 10, 2010 4:10 pm    Post subject:
Reply with quote

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
View user's profile Send private message
useit

Active User


Joined: 05 Oct 2006
Posts: 141

PostPosted: Fri Dec 10, 2010 4:16 pm    Post subject: record length
Reply with quote

input LRECL=60
output LRECL=100

UNDER 1 X maximum 15 Y TYPE records can come
Back to top
View user's profile Send private message
useit

Active User


Joined: 05 Oct 2006
Posts: 141

PostPosted: Fri Dec 10, 2010 4:21 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Dec 10, 2010 5:00 pm    Post subject:
Reply with quote

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
View user's profile Send private message
useit

Active User


Joined: 05 Oct 2006
Posts: 141

PostPosted: Fri Dec 10, 2010 5:07 pm    Post subject: please sir
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Dec 10, 2010 5:20 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Dec 10, 2010 9:09 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Dec 10, 2010 10:28 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Hariharan Ramachandran

New User


Joined: 30 Nov 2010
Posts: 28
Location: Chennai, Tamilnadu,INDIA

PostPosted: Sat Dec 11, 2010 1:26 am    Post subject: Re: tricky dfsort problem
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Sat Dec 11, 2010 2:22 am    Post subject:
Reply with quote

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
View user's profile Send private message
Hariharan Ramachandran

New User


Joined: 30 Nov 2010
Posts: 28
Location: Chennai, Tamilnadu,INDIA

PostPosted: Sat Dec 11, 2010 3:13 am    Post subject:
Reply with quote

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...

12.gif


Kind Regards,
Hari
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Sat Dec 11, 2010 3:35 am    Post subject:
Reply with quote

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
View user's profile Send private message
Hariharan Ramachandran

New User


Joined: 30 Nov 2010
Posts: 28
Location: Chennai, Tamilnadu,INDIA

PostPosted: Sat Dec 11, 2010 3:56 am    Post subject:
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Sat Dec 11, 2010 4:05 am    Post subject:
Reply with quote

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
View user's profile Send private message
Hariharan Ramachandran

New User


Joined: 30 Nov 2010
Posts: 28
Location: Chennai, Tamilnadu,INDIA

PostPosted: Sat Dec 11, 2010 4:11 am    Post subject:
Reply with quote

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
View user's profile Send private message
useit

Active User


Joined: 05 Oct 2006
Posts: 141

PostPosted: Mon Dec 13, 2010 10:26 am    Post subject:
Reply with quote

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
View user's profile Send private message
Hariharan Ramachandran

New User


Joined: 30 Nov 2010
Posts: 28
Location: Chennai, Tamilnadu,INDIA

PostPosted: Mon Dec 13, 2010 12:56 pm    Post subject:
Reply with quote

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..) icon_wink.gif

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
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
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts How to get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am
No new posts Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm
No new posts DB2 Streaming Batch Processing Problem Manshadi DB2 4 Sat Sep 24, 2016 12:14 pm
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm


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