Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to convert alphanumeric to numeric and perform some check

Status
Not open for further replies.

Adbhut

Programmer
Jan 11, 2012
5
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
 

Not tested, but I would think this should work...
Code:
IF YOURFIELD NUMERIC
    WRITE GOODREC FROM YOURFIELD
ELSE
    WRITE BADREC  FROM YOURFIELD.


Randy
 
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?
 
@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.
 
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?
 
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)
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. . .
 
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
 
Use a longer field as a target and check the end (or begining if you right justify) for excess characters.
 

Adbhut,

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


Randy
 
@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.


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

Tom Morrison
Micro Focus
 
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.
 
I definitely deal in esoteric COBOL phrases!

Tom Morrison
Micro Focus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top