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 

Converting fraction to percent

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


Joined: 25 May 2005
Posts: 59
Topics: 20

PostPosted: Wed Apr 04, 2007 9:43 am    Post subject: Converting fraction to percent Reply with quote

...sorry an other problem,

I need to convert a field where there is a fraction (as text), in a percent.

For example I have:
Code:

AA 1/3
BB 1/2
CC 121/1251

I would like to have
Code:

AA 33.33
BB 50.00
CC 9.67

the fraction separator is allways a '/' and the precision of the fraction shoul be 2 position.

Do you have any idea?

Wish a good one!
_________________
Maxisnowhere
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Apr 04, 2007 10:07 am    Post subject: Reply with quote

maxisnowhere,


Try this job

Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD *                                             
AA 1/3                                                     
BB 1/2                                                     
CC 121/1251                                                 
//SORTOUT DD SYSOUT=*                                       
//SYSIN   DD *                                             
  SORT FIELDS=COPY                                         
                                                           
  INREC PARSE=(%01=(ABSPOS=3,ENDBEFR=C'/',FIXLEN=8),       
               %02=(ENDBEFR=C' ',FIXLEN=8)),               
         BUILD=(1,3,%01,UFF,EDIT=(TTTTTTTT),X,             
                    %02,UFF,EDIT=(TTTTTTTT))               
                                                           
  OUTREC FIELDS=(1,3,                                       
                 4,8,ZD,MUL,+10000,DIV,13,8,ZD,EDIT=(IT.TT))
/* 


Hope this helps...

Cheers

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


Joined: 25 May 2005
Posts: 59
Topics: 20

PostPosted: Wed Apr 04, 2007 10:18 am    Post subject: Reply with quote

Koluso,

I recive a return code 16:

B
Code:
LOCKSET     COPY  TECHNIQUE SELECTED                                         
VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AND MORE 
- CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R5 - 17:13 ON WED APR 04, 200
  SORT FIELDS=COPY                                                           
                                                                             
  INREC PARSE=(%01=(ABSPOS=3,ENDBEFR=C'/',FIXLEN=8),                         
        $                                                                     
INVALID INREC OR OUTREC STATEMENT OPERAND                                     
               %02=(ENDBEFR=C' ',FIXLEN=8)),                                 
               $                                                             
SYNTAX ERROR                                                                 
         BUILD=(1,3,%01,UFF,EDIT=(TTTTTTTT),X,                               
         $                                                                   
STATEMENT DEFINER ERROR                                                       
                    %02,UFF,EDIT=(TTTTTTTT))                                 
                    $                                                         
SYNTAX ERROR                                                                 
                                                                             
  OUTREC FIELDS=(1,3,                 
                   4,8,ZD,MUL,+10000,DIV,13,8,ZD,EDIT=(IT.TT))       
C5-K05352 C6-Q95214 C7-K90000 C8-K05352 E7-K90000                 
END OF DFSORT


Is my SORT version too old?
Embarassed

Thank you!
_________________
Maxisnowhere
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Apr 04, 2007 10:36 am    Post subject: Reply with quote

maxisnowhere,

I think you are missing the latest PTFs UK90007 and UK90006 (April, 2006) which supports PARSE, %nn. Ask your systems programmers to update as the PTF is free

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: Wed Apr 04, 2007 11:11 am    Post subject: Reply with quote

Max,

You are running z/OS DFSORT V1R5, so you need PTF UK90007 in order to use PARSE. For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:

www.ibm.com/servers/storage/support/software/sort/mvs/peug/
_________________
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: Wed Apr 04, 2007 11:22 am    Post subject: Reply with quote

FWIW, here's another way to do this with DFSORT using just INREC (instead of INREC and OUTREC):

Code:

//S2 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD *                                                 
AA 1/3                                                         
BB 1/2                                                         
CC 121/1251                                                     
//SORTOUT DD SYSOUT=*                                           
//SYSIN   DD *                                                 
  SORT FIELDS=COPY                                             
  INREC IFOUTLEN=8,                                             
        IFTHEN=(WHEN=INIT,                                     
          PARSE=(%01=(ABSPOS=3,ENDBEFR=C'/',FIXLEN=8),         
              %02=(ENDBEFR=C' ',FIXLEN=8)),                     
          OVERLAY=(4:%01,UFF,EDIT=(TTTTTTTT),                   
            12:%02,UFF,EDIT=(TTTTTTTT),                         
            4:4,8,ZD,MUL,+10000,DIV,12,8,ZD,EDIT=(IT.TT)))     
/*                                                             

_________________
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
maxisnowhere
Beginner


Joined: 25 May 2005
Posts: 59
Topics: 20

PostPosted: Thu Apr 05, 2007 2:09 am    Post subject: Reply with quote

Thanks a lot guys!
Have a good one!!
_________________
Maxisnowhere
Back to top
View user's profile Send private message
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