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
 

 

Round off a numeric data using sort

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

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Wed Aug 18, 2010 6:40 pm    Post subject: Round off a numeric data using sort
Reply with quote

Hi ,

I am trying to rounoff a data to 20 bytes . This is my sortcard

INREC FIELDS=(01:555,3,5X,09:(137,12,ZD,MUL,179,13,ZD),
EDIT=(IIIIIIIIIIIIIIIIIIII))
OUTREC IFTHEN=(WHEN=(21,1,ZD,GE,5),
OVERLAY=(20:(20,1,ZD,ADD,+1),LENGTH=1))
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(9,20,ZD)


The otput of the INREC will be as below

AHB 01647160298289062500
A93 01791791806821250000
HB0 98437802757494156997
HH1 02842752106693750000
HMR 52480104370707459375
JBR 00028693620781250000
JBY 34391005584637500000


my final output after the Overlay is

AHB 01647160298 89062500
A93 01791791806821250000
HB0 98437802757 94156997
HH1 02842752106 93750000
HMR 52480104370707459375
JBR 00028693620 81250000
JBY 34391005584637500000


My 20th byte is getting spacesd out instead of getting the rounded value.

Please advice

P.S
Assume my 20th byte can have a Max of value of 8 so the round off value wont overflow to 2 bytes.
Back to top
View user's profile Send private message

sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Wed Aug 18, 2010 7:39 pm    Post subject:
Reply with quote

cvishu,
Please use CODE tags to preserve the spacing for input records. Use TO=ZD in your IFTHEN as below to get what you wanted.
Code:

INREC FIELDS=(01:555,3,5X,09:(137,12,ZD,MUL,179,13,ZD),
EDIT=(IIIIIIIIIIIIIIIIIIII))
OUTREC IFTHEN=(WHEN=(21,1,ZD,GE,5),
OVERLAY=(20:20,1,ZD,ADD,+1,TO=ZD,LENGTH=1))
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(9,20,ZD)


Quote:
I am trying to rounoff a data to 20 bytes

I am not sure what you meant by roundoff but 2 points for your attention.

1) If you have 9 at 20the position and you add +1 it becomes 10 but since you mentioned LENGTH=1, it will have 0 in the 20th position. Not sure if this is what you want. For example, for
Code:
HH1     02842752106993750000
output will be
Code:
HH1     02842752106093750000


2) Per DFSort flow diagram, your SORT FIELDS=(1,3,CH,A) and SUM FIELDS=(9,20,ZD) will be executed before your OUTREC IFTHEN. So it will remove dups first and then perform your OUTREC conditions. Is that what you wanted? Please find below actual execution order for your sort statement.

Code:

INREC FIELDS=(01:555,3,5X,09:(137,12,ZD,MUL,179,13,ZD),
EDIT=(IIIIIIIIIIIIIIIIIIII))
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(9,20,ZD)
OUTREC IFTHEN=(WHEN=(21,1,ZD,GE,5),
OVERLAY=(20:20,1,ZD,ADD,+1,TO=ZD,LENGTH=1))


DFSort FLOW

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

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Wed Aug 18, 2010 7:53 pm    Post subject:
Reply with quote

cvishu,

Quote:
P.S
Assume my 20th byte can have a Max of value of 8 so the round off value wont overflow to 2 bytes.

Sorry I didn't look at this message earlier. Please disregard point 1 of my post.

Thanks.
Back to top
View user's profile Send private message
cvishu

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Wed Aug 18, 2010 10:05 pm    Post subject:
Reply with quote

sqlcode1

Thanks for the reply , sorry abt the CODE misplacement .

Coming to the reply , yes i am aware of the flow and yes i want the output based on the flow you have mentioned, the problem i am facing is i am getting a space in the 20th byte instead of the rounded off value (20th byte + 1).

Pls do provide your thoughts

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

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Wed Aug 18, 2010 10:09 pm    Post subject:
Reply with quote

cvishu,

I have already provided sort job to get rid of your space issue. In your OUTREC IFTHEN condition, use TO=ZD.

Please use below...

Code:
INREC FIELDS=(01:555,3,5X,09:(137,12,ZD,MUL,179,13,ZD),
EDIT=(IIIIIIIIIIIIIIIIIIII))
OUTREC IFTHEN=(WHEN=(21,1,ZD,GE,5),
OVERLAY=(20:20,1,ZD,ADD,+1,TO=ZD,LENGTH=1))
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(9,20,ZD)


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

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Wed Aug 18, 2010 10:17 pm    Post subject:
Reply with quote

oh sorry dint chk properly , am at home , will try out your solution tomorrow and get back to you .

Thanks
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: Wed Aug 18, 2010 10:58 pm    Post subject:
Reply with quote

Code:

OVERLAY=(20:(20,1,ZD,ADD,+1),LENGTH=1))


Since you didn't specify an edit mask or output format, DFSORT uses the default mask of M0 which give '2 ' (2 followed by a blank sign) for 2. Then you used LENGTH=1 so all you got was the last character (the blank). You need to use an edit mask or output format to get what you want. The easiest way would be to use:

Code:

OVERLAY=(20:(20,1,ZD,ADD,+1),EDIT=(T)))
Back to top
View user's profile Send private message
cvishu

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Thu Aug 19, 2010 5:15 pm    Post subject:
Reply with quote

Frank , thanks The EDIT option works .

sqlcode1 , i tried to TO=ZD , but the data seems to be in some other format. i am getting it as characters.

AHB 01647160298C89062500
A93 01791791806821250000
HB0 98437802757E94156997
HH1 02842752106G93750000
HMR 52480104370707459375
JBR 00028693620H81250000
JBY 34391005584637500000
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Thu Aug 19, 2010 6:52 pm    Post subject:
Reply with quote

cvishu,
I am going to take a wild guess without looking at your SYSOUT and it seems like your default ZDPRINT option is set to N.

Since you have your expected results I wouldn't ask much but If you are still curious as to why you see F,G,C in your output, try to add OPTION ZDPRINT before your sort control statement and check the results.

Not sure if you shoud get H in the second last record.

Thanks,
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: Thu Aug 19, 2010 10:47 pm    Post subject:
Reply with quote

sqlcode1,

ZDPRINT only applies to SUM. It has no effect for TO=ZD.

cvishu,

Those values for TO=ZD would indicate that you're using Syncsort, not DFSORT. DFSORT uses an F sign for TO=ZD. Syncsort uses a C sign.

This Forum is for DFSORT questions. Please ask Syncsort questions in the JCL Forum.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Thu Aug 19, 2010 11:11 pm    Post subject:
Reply with quote

Frank,
I took a wild guess because OP is using SUM FIELDS=(9,20,ZD). I wasn't sure if that could be causing the issue.

Apart from that, I had no idea how Syncsort processing is done. So couldn't think about it earlier.

Thanks for the explanation.

Thanks
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: Thu Aug 19, 2010 11:24 pm    Post subject:
Reply with quote

Perhaps you shouldn't bother to take wild guesses considering Kolusu and I are here to take educated guesses. icon_smile.gif
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Thu Aug 19, 2010 11:41 pm    Post subject:
Reply with quote

Frank,
Sure will keep that in mind.

Thanks
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 How to move a long alphanumeric data ... lind sh COBOL Programming 0 Mon Dec 05, 2016 7:51 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 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 ODPP(Optim Data privacy Provider) Iss... Rama kishore IBM Tools 1 Mon Nov 07, 2016 5:46 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


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