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

Extracting the numeric data from Alpha Numeric Field


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Mon Mar 17, 2008 10:08 am
Reply with quote

Can anyone help me on this.

My Requirement is

I should fetch the column(Interest Rate) of DB2 table which is in AlphaNumeric Format (& its field length is 40) then i should use those values for the calculation.

Scenario

Interest Rate -----------> DB2 Table
24 ------------> 4 cases
23.5 ------------> which is in alphanumeric format
17.87 ------------> Field Length is 40
34.8776

I have done some logic for the conversion of alphanumeric to numeric and got the output like

24000000 After the conversion, i have mapped these values in
23.50000 FILE-AID it maps exactly for the numeric
17.87000
34.87760

But when i using this values for the calculation say (2400000 + 1000) and just displaying the output im getting SOC7 Abend, means im moving the junk values to the variable.

Can anyone throw a light on this!!!!!!
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Mon Mar 17, 2008 10:15 am
Reply with quote

Naveen,

By looking at your examples, I believe the o/p is not a numeric one. Revisit your logic.

And also post your layout
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Mon Mar 17, 2008 10:21 am
Reply with quote

Murali,

Thanks for your input!!!!

But when i map the fields with the copybook it maps exactly for the numeric!!!!!

Db2 table field length

012345.......40
24
23.4
34.56
56.7865 The Remaining places are occupied by spaces
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Mon Mar 17, 2008 11:42 am
Reply with quote

Naveen,

As was asked in my earlier post,please post your copybook
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Mar 17, 2008 1:04 pm
Reply with quote

and the db2 table definition icon_smile.gif
Back to top
View user's profile Send private message
valishaik

New User


Joined: 26 Sep 2007
Posts: 1
Location: Hyderabad

PostPosted: Mon Mar 17, 2008 2:26 pm
Reply with quote

Naveen,

I thinks in the DB2 this column is defined as CHAR and you are getting SOC7 abend due to improoer movement values to the numeric field.
Write a simple logic to get only the non numeric values from the CHAR field ( DB2 col) and use Referrece modification logic to move exact number field.

ex:

01 WS-NUM-FIELD 9(2)V9(5) VALUE ZERO.


INSPECT ws-db2-col-name TALLYING WS-TALLY1
FOR CHARACTERS BEFORE ' '.


MOVE WS-DB2-COL-NAME(1:WS-TALLY1) to WS-NUM-FIELD

Hope this will workout..

-----------
Regards,
V A L I
Back to top
View user's profile Send private message
advith001

New User


Joined: 16 Mar 2005
Posts: 23

PostPosted: Mon Mar 17, 2008 4:11 pm
Reply with quote

Naveen,
cannt you use redefines in this case? just an idea!

Store your fetched data of 40 alphanumeric and redefine it with the record layout as you required. icon_smile.gif


Anna.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Mar 17, 2008 5:35 pm
Reply with quote

Use char columns for character data and numeric columns for numeric data!
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Tue Mar 18, 2008 9:09 am
Reply with quote

Thanks a lot dudes!!!!!!!!! 4 de replies


Actually, my previous logic was

I have used the INSPECT statement to get the counter of total length, then i will extract it using the reference modification, then im moving the extracted values to the re-defined variable then im moving that numeric value to the assume decimal point....after all these when im displaying these values and mapping with the copybook it is giving the exact value, but only it get abend when i use that for calculation.

copybook

01-inp-file
05 cust-data pic 9(10)
Back to top
View user's profile Send private message
advith001

New User


Joined: 16 Mar 2005
Posts: 23

PostPosted: Tue Mar 18, 2008 1:16 pm
Reply with quote

If you don't mind.. can you pls post the code what you did?-Anna
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Store the data for fixed length COBOL Programming 1
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top