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
 

 

Convert character to numeric

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

New User


Joined: 26 Feb 2007
Posts: 3
Location: North Carolina

PostPosted: Thu Apr 12, 2012 7:22 am    Post subject: Convert character to numeric
Reply with quote

I am trying to convert the last 6 bytes of the 25 byte record to TT.TTT format

Input:

Code:
381426G6612101HZN9R     
050632AY412101HZ8WZ2.9   
57586CKH712101H0NCF2.005
773754FC512101H03VP3.85 
413627AX812101H2Q7R19.596
93974CQ7812101H238T4     

Output:
Code:
381426G6612101HZN9R00.000
050632AY412101HZ8WZ00.029
57586CKH712101H0NCF02.005
773754FC512101H03VP00.385
413627AX812101H2Q7R19.596
93974CQ7812101H238T00.004


These are my sort cards:
Code:
SORT FIELDS=COPY                           
OUTREC FIELDS=(1,19,20,6,UFF,EDIT=(TT.TTT))

Please help me, I have read the manuals, gone trough all the examples, and cannot find a similar problem.
Many Thanks!!
Back to top
View user's profile Send private message

vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1476
Location: Chennai

PostPosted: Thu Apr 12, 2012 9:07 am    Post subject:
Reply with quote

The sort cards,
Code:

SORT FIELDS=COPY
OUTREC FIELDS=(1,19,20,6,UFF,EDIT=(TT.TTT))

produces the output you have shown.
So what is the issue? Are you expecting some other output or is the job failing?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7307

PostPosted: Thu Apr 12, 2012 12:03 pm    Post subject: Re: Convert character to numeric
Reply with quote

Bettie HoTong wrote:
I am trying to convert the last 6 bytes of the 25 byte record to TT.TTT format

Input:

Code:
381426G6612101HZN9R     
050632AY412101HZ8WZ2.9   
57586CKH712101H0NCF2.005
773754FC512101H03VP3.85 
413627AX812101H2Q7R19.596
93974CQ7812101H238T4     


Output:
Code:
381426G6612101HZN9R00.000
050632AY412101HZ8WZ00.029
57586CKH712101H0NCF02.005
773754FC512101H03VP00.385
413627AX812101H2Q7R19.596
93974CQ7812101H238T00.004


These are my sort cards:
SORT FIELDS=COPY
OUTREC FIELDS=(1,19,20,6,UFF,EDIT=(TT.TTT))

Please help me, I have read the manuals, gone trough all the examples, and cannot find a similar problem.
Many Thanks!!


Is the following what you would like to see?

Code:

381426G6612101HZN9R00.000     
050632AY412101HZ8WZ02.900   
57586CKH712101H0NCF02.005
773754FC512101H03VP03.850 
413627AX812101H2Q7R19.596
93974CQ7812101H238T04.000
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 Apr 12, 2012 10:52 pm    Post subject:
Reply with quote

Bettie,

The DFSORT control statements you show give the output you say you want.

Are you showing the expected output incorrectly (see Bill's post)? If so, you need to show me the exact output you want.

Does your input file have RECFM=FB or RECFM=VB? If RECFM=VB, then we would need to account for the 4-byte RDW in each record.

At any rate, I can't answer your question until you give me accurate information about your requirement.
Back to top
View user's profile Send private message
Bettie HoTong

New User


Joined: 26 Feb 2007
Posts: 3
Location: North Carolina

PostPosted: Thu Apr 12, 2012 11:02 pm    Post subject:
Reply with quote

All , thanks for replying!

Bill,
The output you are showing is what I need.
As you see, the 2.9 became 0.029 , I was expecting 02.900. And the 4 became 00.004 instead of 04.000.

This is FB file.

So, what am I missing ?


Thanks again for your help!
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 Apr 12, 2012 11:29 pm    Post subject:
Reply with quote

It's a bit more complicated than you think.

If all of your values were normalized to dd.ddd, then your control statements would work. But you have unnormalized values of d.ddd, d.d, d.ddd, dd.dd, etc, so you have to handle the various unnormalized forms.

For example, if you have b2.9bb (b for blank), UFF treats that as 29, but you want it treated as 02900. So you have to be more clever.

Here's a DFSORT job that will give you what you want:

Code:

//S1 EXEC PGM=SORT                                             
//SYSOUT DD SYSOUT=*                                           
//SORTIN DD *                                                   
381426G6612101HZN9R                                             
050632AY412101HZ8WZ2.9                                         
57586CKH712101H0NCF2.005                                       
773754FC512101H03VP3.85                                         
413627AX812101H2Q7R19.596                                       
93974CQ7812101H238T4                                           
//SORTOUT DD SYSOUT=*                                           
//SYSIN DD *                                                   
  OPTION COPY                                                   
  INREC IFTHEN=(WHEN=INIT,                                     
    PARSE=(%01=(ABSPOS=20,ENDBEFR=C'.',FIXLEN=2),               
      %02=(FIXLEN=3)),                                         
    BUILD=(1,19,20:%01,UFF,EDIT=(TT),C'.',%02)),               
  IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=23,IN=C' ',OUT=C'0'))     
Back to top
View user's profile Send private message
Bettie HoTong

New User


Joined: 26 Feb 2007
Posts: 3
Location: North Carolina

PostPosted: Fri Apr 13, 2012 12:20 am    Post subject:
Reply with quote

Frank
Thanks so much!!! I will try it.
Bettie
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 the use of 'B3'x character in a panel Pedro TSO/ISPF 1 Thu Feb 16, 2017 3:09 am
No new posts Convert current to hex value gopurs DFSORT/ICETOOL 4 Wed Feb 15, 2017 5:40 am
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 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 Convert +9999999999999.99 to S9(12)V9(3) vnktrrd DFSORT/ICETOOL 8 Thu Nov 17, 2016 8:15 pm


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