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
 

 

How to seperate numeric field from an alphanumeric field Dyn

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
royalchm

New User


Joined: 15 Nov 2007
Posts: 29
Location: Bangalore

PostPosted: Mon Mar 05, 2012 5:30 pm    Post subject: How to seperate numeric field from an alphanumeric field Dyn
Reply with quote

Hi,
I have a 6-byte alphanumeric field, need to get the numeric value from this field. But the values will come like 123 ABC, 123ABC,1ABCDE,1234AB... etc. I have used NUMVAL function in the program it's not working and saying "Invalid character O was found in column 4 in argument-1 for function NUNUMVAL-C in program at displacement X'0EF8' ".
Could you please give me any solution for this.
Thanks in Advance....
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6967
Location: porcelain throne

PostPosted: Mon Mar 05, 2012 5:37 pm    Post subject:
Reply with quote

as long as the numerics are in front (left side)
and the alpha is in end the (right side)
try with INSPECT CONVERTING a thru z to spaces then try the NUMVAL.

alternatively, bump an index thru the 6 bytes, and compare for 0 thru 9 otherwise convert to spaces.
if you use reference modification
use 1:1, 2:1, 3:1 == literals
if you use a variable for the postiion, you will end up with code resembling the inspect.

if you have values like '124ab2' you what would you expect as a result?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Mon Mar 05, 2012 6:02 pm    Post subject: Reply to: How to seperate numeric field from an alphanumeric
Reply with quote

Subject to the answer to dbz's last question, you can do it by only finding the first non-numeric. That would give you the length of the numeric part. Handles non-alphas in there, if that is a possibility, that way.

Use most common local method for handling parts of fields (occurs depending on, reference-modification, UNSTRING, indexes, subscripts, blind faith).

You might like to check this one.

Since you have a simple numeric, you don't "need" NUMVAL. Doesn't matter much, but the NUMVAL in the linked example is 5+ times slower than the straight code. You'd still have to do "a lot" of them to notice, however :-)
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Mon Mar 05, 2012 6:10 pm    Post subject: Reply to: How to seperate numeric field from an alphanumeric
Reply with quote

An alternative -

Define a PIC 9(17) field and initialize it to zeros.

Then define PIC 9(08) COMP fields, SUB1 and SUB2, initializing SUB1 to the LENGTH OF STRING and SUB2 to the LENGTH of the PIC 9(17) field.

Then, starting at the last byte of the STRING (SUB1), using reference modification in an in-line PERFORM, test for NUMERICS and move each numeric-byte from STRING to the current-byte of the PIC 9(17) field (then subtract 1 from SUB2). Regardless, always subtract 1 from SUB1.

When SUB1 is less than 1, then your done and the PIC 9(17) field will contain the numerics, right-justified, with high-order zeros.

Mr. Bill
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Using ICETOOL, how we can seperate th... bshkris SYNCSORT 5 Tue May 09, 2017 8:33 pm
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Alter &DATENS field in HEADER1 Angad DFSORT/ICETOOL 4 Mon Apr 24, 2017 11:49 am
No new posts Splitting of single report to seperat... abdulrafi TSO/ISPF 7 Mon Mar 27, 2017 3:59 pm


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