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
 

 

Converting a character field to numeric in sort

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

New User


Joined: 06 Jun 2007
Posts: 58
Location: Hyderabad

PostPosted: Wed Jun 30, 2010 2:41 pm    Post subject: Converting a character field to numeric in sort
Reply with quote

Hi,

I have the following requirement:
I need to extract a file form an input file based on a specific condition.But the input file has some character data which I want to convert to numeric.How can I achieve this?
The following is the sort card iam using:
Code:
OPTION COPY                                               
INCLUDE COND=((171,3,CH,EQ,C'ZZZ',AND,223,4,CH,EQ,C'ABCD'),
OR,(171,3,CH,EQ,C'P11',AND,223,4,CH,EQ,C'EFGH'))           
OUTFIL FNAMES=SORTOUT,VTOF,                               
OUTREC=(1:247,15,16:227,15)

The characters in the out file should be converted to numeric.
Back to top
View user's profile Send private message

Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 991
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Wed Jun 30, 2010 3:04 pm    Post subject:
Reply with quote

Quote:
The characters in the out file should be converted to numeric.

...and have you any rules regarding how the conversion should be achieved? Do you want any numeric value or is there a specific correlation between characters and numbers?

Garry.
Back to top
View user's profile Send private message
shchan

New User


Joined: 06 Jun 2007
Posts: 58
Location: Hyderabad

PostPosted: Wed Jun 30, 2010 3:10 pm    Post subject:
Reply with quote

No, I have to use the out file in another program to search these records in anotherfile.As the out file is containing character data and Iam comparing it in my program with numeric data Iam getting a Soc7.I want to avoid this by converting the data in the out file to numeric type.
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 991
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Wed Jun 30, 2010 3:26 pm    Post subject:
Reply with quote

I can't see how just making the characters numeric can be of any benefit. What if you change every nonumeric character to the number '1' - how does that help you? There are 26+ different characters that are non-numeric and, if you just change them randomly, how can you do any valid comparison.

You shouldn't use any means possible to avoid a S0C7 abend - you need to fix the data properly or amned the program to do an character compare.

Garry.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Wed Jun 30, 2010 6:30 pm    Post subject: Re: Converting a character field to numeric in sort
Reply with quote

shchan wrote:
But the input file has some character data which I want to convert to numeric.How can I achieve this?
Can you be a little less helpful?
What needs to be converted?
Provide more details......
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Jun 30, 2010 8:17 pm    Post subject:
Reply with quote

Hello,

Quote:
I want to avoid this by converting the data in the out file to numeric type.
The proper resolution is to have the process that creates the data fixed. . .

If you arbitrarily change some values to "something numeric" you have created a much worse situation than the 0c7. Anything that uses this "patched up" data will produce corrupt results and should not be used for anything needed by the organization.
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 Jun 30, 2010 10:05 pm    Post subject:
Reply with quote

Code:
OUTREC=(1:247,15,16:227,15)


Quote:
The characters in the out file should be converted to numeric.


Sigh.

The OUTREC operand will give you an output record with the bytes in positions 247,15 and 227,15. We have no idea what those bytes look like in the input record or what you want them to look like in the output record, so how do you expect us to help you? We can't read your mind.

If you want to convert the bytes in 247,15 to numeric, you have to show what they look like in the input record and what you want them to look like in the output record. Likewise for the bytes in 227,15.
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 INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm


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