IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Convert character to numeric


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 1742
Location: Tirupur, India

PostPosted: Thu Apr 12, 2012 9:07 am
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Apr 12, 2012 12:03 pm
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 Developer


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

PostPosted: Thu Apr 12, 2012 10:52 pm
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
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 Developer


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

PostPosted: Thu Apr 12, 2012 11:29 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
No new posts convert file from VB to FB and use tr... DFSORT/ICETOOL 8
Search our Forums:

Back to Top