×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

how to convert alphanumeric to numeric and perform some check

how to convert alphanumeric to numeric and perform some check

how to convert alphanumeric to numeric and perform some check

(OP)
Hi ,

I have alphanumeric value and need to convert to numeric and write to file based on condition if alphanumeric is numeric really then write to good record else write to bad record.

eg.
1. alphanumeric value pic (6) - 200    move to numeric and write to good file record
2. alphanumeric value pic (6) - 2a00     then write to good file record
 

RE: how to convert alphanumeric to numeric and perform some check


     Not tested, but I would think this should work...

CODE

IF YOURFIELD NUMERIC
    WRITE GOODREC FROM YOURFIELD
ELSE
    WRITE BADREC  FROM YOURFIELD.
 

Randy

RE: how to convert alphanumeric to numeric and perform some check

Adbhut, this is the first time you have posted on this site, and this is a really basic question.

Can I ask, is this a question set by your tutor?  

RE: how to convert alphanumeric to numeric and perform some check

(OP)
@MarcLodge - This question is not set by my tutor. I'm working on small projet. The requiements are to Ftp Excel(CSV format and Excel is user generated sheet) to mainframe and then perform some validation and convertion and write to output file.

Hi ALL,

Input file records are
1,201201,12/19/2011 0:00,0.13,2.03,26.41
122,201201,12/26/2011 0:00,2.03,26.41

Output file should have records as follows
00000120120112/26/2011-00:00:00?????????xxxxxxxxxxxxx
00012220120112/26/2011-00:00:00?????????xxxxxxxxxxxxx
where ??? and xxx- not sure of the exact value
The values 2.03 and value 26.41 should be coverted to such a fomat that when we view then through copy book of pic S9(8)V9 and
S9(9)V9(4) respectively. It should display value as 2.0 and 26.41 but when we browse output file. It displays some values like 00000005F and 000000072464E respectively( these are not exact values just for giving you all the formats).

And I also need to perform validation whether 2.03 and 26.41 fields are numeric values only.

I'm using unstring to store different comma separated values and values 2.03,26.41 are unstringed into x(10) and x(13) resp.


Waiting for your replies.

RE: how to convert alphanumeric to numeric and perform some check

Well, first you need to extract the separate fields from the CSV.  I have a canned routine to do that, there are many threads in this form discussing that very topic.

BTW, what is the vendor and version number of your compiler, and what is your o/s?

RE: how to convert alphanumeric to numeric and perform some check

Quote:

should be coverted to such a fomat that when we view then through copy book of pic S9(8)V9 and S9(9)V9(4)

Quote:

It displays some values like 00000005F and 000000072464E
These values are exactly what you want (those are signed, zoned-decimal values) for the PICtures you posted..
00000005F is the correct value for +5.6 (S9(8)V9)
000000072464E is the correct value for +72.4645 (S9(9)V9(4)

The high-order nibble of the low-order byte contains the sign in a signed, zoned-decimal field.

It would have been helpful if your examples all used the same values. . .
 

RE: how to convert alphanumeric to numeric and perform some check

(OP)
Hi Guys,

Can anyone please tell me that is there any way to check when truncation happen

Im' doing unstring of following records to separate then
HEADING - "ACCOUNT_NUM","YEAR_MONTH","WkBeDate","ACCOUNT_NAME","FORECAST_HRS,"FORECAST"
VALUE -
 - 69,201202,1/23/2012 0:00:00,"WALGREENS #13836",5.20,58.42  
 - 3212324,201202,1/23/2012 0:00:00,"WALGREENS   #13836",5.20,58.42  

I want to know the way how to check if account number has values of size more than six digit - (e.g 3212324 - it is error record ).This condition i want to catch so that all these records can be written to error file.When I do unstring then It is getting truncated . Doing unstring is requirement as i have to get each fields separately.

Waiting for your reply
Thank's
                 

RE: how to convert alphanumeric to numeric and perform some check

Use a longer field as a target and check the end (or begining if you right justify) for excess characters.

RE: how to convert alphanumeric to numeric and perform some check


Adbhut,

Did you ever resolve your original problem?
For new questions, you should start a new thread.
 

Randy

RE: how to convert alphanumeric to numeric and perform some check

(OP)
@Randy - thanks for your help. logic given by you was fine. Actually error i was doing was that i was moving alphanumeric x(6) to number 9(6). so if alphanumeric was having value like - 45a then it was getting converted to 000451. Hence validation was not working.


 

RE: how to convert alphanumeric to numeric and perform some check

Since you are using UNSTRING, check out the COUNT IN phrase to know how many characters you have processed.

Tom Morrison
Micro Focus

RE: how to convert alphanumeric to numeric and perform some check

Yes, COUNT IN should do the trick.  The problem is that the description of COUNT IN is rather esoteric and you have to read the descriptions of several other phrases to understand it, as well as frequently refering to the diagram which is a couple pages back.

As a result, I've never used COUNT IN, I've resorted to other means to accomplish the same thing.

RE: how to convert alphanumeric to numeric and perform some check

I definitely deal in esoteric COBOL phrases!  

Tom Morrison
Micro Focus

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close