MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Rounding thru ICETOOL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
hsubra
Beginner


Joined: 18 Jun 2003
Posts: 25
Topics: 11

PostPosted: Mon Feb 09, 2004 11:02 am    Post subject: Rounding thru ICETOOL Reply with quote

Hello,

I am creating TRAILER record using ICETOOL.

" ,70:TOTAL=(50,8,PD,EDIT=(SIIIIIIIIIIIII.IIII),SIGNS=(,-,,)), " . I want the total to be rounded to decimal 2 digit. i.e) SIIIIIIIIIIIII.II.

Ex: If I get 2475.7563 as a total, then in my trailer record I need 2475.76 .

Is there way in ICETOOL to round ?

Thanks,
Subra
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Mon Feb 09, 2004 11:45 am    Post subject: Reply with quote

Subra,

Do you want to round only when 3rd digit in the decimal portion exceeds 5 ? or do you want to round to the next number what ever might be the value in the 3 digit.?

i.e
Code:

2475.7563    rounded to   2475.76
2475.7533    rounded to   2475.75 ?? or
2475.7533    rounded to   2475.76


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Feb 09, 2004 12:12 pm    Post subject: Reply with quote

Subra,

Please show your DFSORT/ICETOOL job, and an example of your input records and what the output should look like.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
hsubra
Beginner


Joined: 18 Jun 2003
Posts: 25
Topics: 11

PostPosted: Mon Feb 09, 2004 2:45 pm    Post subject: Reply with quote

Frank Yaeger/kolusu,

The Job is

Code:

//SORTTTL EXEC PGM=ICETOOL                                     
//SYSOUT   DD  SYSOUT=(O,,J000)                                 
//SYSPRINT DD  SYSOUT=(O,,J000)                                 
//TOOLMSG  DD  SYSOUT=(O,,J000)                                 
//DFSMSG   DD  SYSOUT=(O,,J000)                                 
//*--------- INPUT FILE                                         
//FILEIN   DD  DSN=&&VARDATA,DISP=(OLD,PASS)                   
//DTLTTL   DD  DSN=XXXX.XXXX.NPSIVC00.FILEIN.TOTALS.DETAIL,     
//             DISP=(,CATLG,DELETE),UNIT=SYSDA,                 
//             DCB=(LRECL=133,RECFM=FB),SPACE=(CYL,(5,1),RLSE)   
//*--------- CONTROL FILES                                     
//TOOLIN   DD  *
 SORT   FROM(DETAIL)  TO(DTLTTL)   USING(MRGE) 
/*
//MRGECNTL DD  *
* DDNAME: MRGECNTL   STEP: SORTTTL  JOB: XXXDIN     
*                                                     
 SORT FIELDS=(1,6,CH,A),                             
 DYNALLOC=(SYSDA,6),FILSZ=E3000000                   
 SUM FIELDS=(50,8,PD,58,8,PD)                         
 OUTFIL FNAMES=DTLTTL,NODETAIL,                       
 TRAILER1=(1:C'TOTAL$',5X,1,6,
   70:TOTAL=(50,8,PD,EDIT=(SIIIIIIIIIIIII.II),SIGNS=(,-,,)),   
   88:TOTAL=(58,8,PD,EDIT=(SIIIIIIIIIIIII.II),SIGNS=(,-,,)),   
   106:27X))                                                   
/*

___________________________________________________

Format @ pos 50,8 = S9(11)v9(4) COMP-3
Format @ pos 58,8 = S9(11)v9(4) COMP-3

and

output should be

2475.7563 rounded to 2475.76
2475.7533 rounded to 2475.75

Input sample data

[code:1:079e728437]
1-8 50-65


A10001bbbbbb ......g*........
CFFFFF4444440003850800000000
1100010000000004707C0000000C
------------
A10001bbbbb ............
CFFFFF4444440000000000000000
110001000000000000C0000000C
------------
A10001bbbbb .....
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Mon Feb 09, 2004 3:08 pm    Post subject: Reply with quote

Subra,

Not to be critical but your job has many errors.

1. You don't require the following DD statements.
Code:

//SYSOUT   DD  SYSOUT=(O,,J000)                                 
//SYSPRINT DD  SYSOUT=(O,,J000)     


2. Your Toolin statement points to sort from DETAIL, but there is no DD name corresponding to it. You either need to change the toolin statement to the following
Code:

SORT   FROM(FILEIN)  TO(DTLTTL)   USING(MRGE) 


or change the
Code:

//FILEIN   DD  DSN=&&VARDATA,DISP=(OLD,PASS)   

to
Code:

//DETAIL   DD  DSN=&&VARDATA,DISP=(OLD,PASS)   


3. You don't require hardcoded LRECL on the Output file definition.Sort automatically calculates the output lrecl.

4. You don't require FNAMES=DTLTTL as your TOOLIN statement already specified the output dataset name.

5. I don't think FILSZ=E3000000 parameter will make any difference to a file on DASD. Frank can you correct me if this is true.


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu


Last edited by kolusu on Mon Feb 09, 2004 3:25 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Feb 09, 2004 3:18 pm    Post subject: Reply with quote

Kolusu,

4. Actually, Subra does need FNAMES=DTLTTL, but doesn't need TO(DTLTTL).

5. You're right that FILSZ=En is not needed.

Actually, SUM isn't needed.

I'm working on the DFSORT/ICETOOL job. I'll post it when I'm done testing it (unless Kolusu beats me to it).
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Feb 09, 2004 3:59 pm    Post subject: Reply with quote

Subra,

I think this DFSORT/ICETOOL job will do what you want. It's a bit tricky since you want the totals, which can be positive or negative, rounded up. Arithmetic expressions can be used in INREC and OUTREC, but not in TRAILERx, so we can't do the rounding directly when getting the totals. Also, we have to use +5 to round up positive totals and -5 to round up negative totals.

There's no reason to use SUM since TOT does the totalling. I kept your SORT statement because it will put the last key in the final total record. If you don't care which key is in the final total record, you can do this with COPY instead of SORT. Anyway, try this and see if it does what you want.

Code:

//SORTTTL EXEC PGM=ICETOOL
//TOOLMSG  DD  SYSOUT=*
//DFSMSG   DD  SYSOUT=*
//FILEIN   DD  DSN=...  input file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//DTLTTL   DD  DSN=...  output file
//TOOLIN   DD  *
 SORT   FROM(FILEIN)  USING(MRGE)
 COPY   FROM(T1)  USING(CTL1)
/*
//MRGECNTL DD  *
* Sort so record with last key is displayed in total record.
  SORT FIELDS=(1,6,CH,A)
* Create totals in the form sddddddddddddddd
* where s is + or - and each d is 0-9
  OUTFIL FNAMES=T1,NODETAIL,REMOVECC,
    TRAILER1=(1,6,11:TOT=(50,8,PD,M26),31:TOT=(58,8,PD,M26))
//CTL1CNTL DD *
* Drop the last digit from the total to give totals in the
* form sdddddddddddddd.  Create a +5 constant for a positive
* total or a -5 constant for a negative total.
   INREC FIELDS=(1,6,11:11,15,31:31,15,
     51:11,1,C'5',61:31,1,C'5')
* Round each total up by adding +5 or -5 as appropriate.
   OUTREC FIELDS=(1,6,11:11,15,FS,ADD,51,2,FS,M26,
       31:31,15,FS,ADD,61,2,FS,M26)
* Create final total record using sign and 14 digits where
* 14th digit has been rounded up if appropriate.
  OUTFIL FNAMES=DTLTTL,NODETAIL,
   OUTREC=(1,46,132:X),
  TRAILER1=(1:C'TOTAL$',5X,1,6,
    70:TOTAL=(11,15,FS,EDIT=(SIIIIIIIIIIII.II),SIGNS=(,-,,)),
    88:TOTAL=(31,15,FS,EDIT=(SIIIIIIIIIIII.II),SIGNS=(,-,,)))
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Mon Feb 09, 2004 4:20 pm    Post subject: Reply with quote

Frank,

A quick question for beating me to post the solution Smile . can you explain as to what you meant by
Quote:

Also, we have to use +5 to round up positive totals and -5 to round up negative totals.


I mean I don't understand what is so different between a positive and a negative total.

Let us say the totals are as follows(with edit mask)
Code:

ABC -24765.7766  34567.7733


Now if I undestand the requirements correctly , the rounding should be done as follows.
Code:

ABC -24765.78    34567.77


The same holds good for positive numbers.

The solution I had in mind was to use sum and add a constant(outrec fields) value of S000000000000.0100 to the totals if the 3 decimal digit is However both solutions requires 2 passes.

I would really appreciate if you can clarify this

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
hsubra
Beginner


Joined: 18 Jun 2003
Posts: 25
Topics: 11

PostPosted: Mon Feb 09, 2004 4:46 pm    Post subject: Reply with quote

Gr8,

Thanks kolusu For the inputs. Actually I tailored the JCL and pasted . So the Error #2 and 4 happened. Error#1 ,3, and 5 are implemented in my JCL. I am really impressed on the Feb 2003, DFSORT Release with SPLICE operator. So I am designing a big process thru ICETOOL.

Thanks Frank Yaeger!! . It is working for me.

Thanks for the timely help !!!

Cheers,
Subra
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Feb 09, 2004 4:48 pm    Post subject: Reply with quote

Kolusu,

Say we want to round 776 to 78 and -776 to -78.

If we add +5 to 776, we get 781. We can throw away the last digit and get the 78 we want.

If we add -5 to -776, we get -781. We can throw away the last digit and get the -78 we want.

But if we add +5 to -776, we get -771 and if we throw away the last digit, we get -77, which is not what we want.

I don't understand how adding .0100 would work. If you add .0100 to 34567.7733 and throw away the last two digits, you get 34567.78, but you want 34567.77.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Mon Feb 09, 2004 6:44 pm    Post subject: Reply with quote

Frank,

Thanks for the explanation. The solution I had in mind was as follows
Code:

SORT FIELDS=(1,6,CH,A)                                                 
SUM FIELDS=(50,8,58,8),FORMAT=PD 
OUTREC FIELDS=(C'TOTAL$',5X,1,6,                                   
               70:50,8,PD,EDIT=(STTTTTTTTTTTTTTT),SIGNS=(,-,,),     
               88:58,8,PD,EDIT=(STTTTTTTTTTTTTTT),SIGNS=(,-,,),   
               133:X)                                             
 OUTFIL FNAMES=T1,INCLUDE=(84,1,ZD,GT,5),                           
 OUTREC=(1,70,C'000000000000100',86,3,                             
         C'000000000000000',133:X)                                 
 OUTFIL FNAMES=T2,INCLUDE=(102,1,ZD,GT,5),                         
 OUTREC=(1,70,C'000000000000000',86,3,                             
         C'000000000000100',133:X)                                 
 OUTFIL FNAMES=T3                                                   


In the next step concatenate T1,T2,T3 and sum the number, so that 1 is added to the 2nd decimal digit.

However my solution is uglier when compared to yours due to the complexity involved in it.

Thanks

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Feb 09, 2004 6:49 pm    Post subject: Reply with quote

Subra,

You're welcome. I'm glad you like SPLICE. It's been a big hit all around. 8)
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group