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

Truncating leading Spaces


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Krishnadeva Reddy

New User


Joined: 14 Nov 2007
Posts: 37
Location: Chennai

PostPosted: Wed Apr 22, 2009 10:56 pm
Reply with quote

Hi,

I have a table with values like

Total_Amount Paid_Amount
------------------------------------
0.01 0.00
89.50 0.01

When I am doing a unload using utility ADUUMAIN and select with the below statement:

SELECT CHAR(TOTALAMOUNT), CHAR(PAID_AMOUNT) FROM TABLE1 WITH UR;

I got the values as below in dataset:

000000.01 000000.00
000089.50 000000.01

I want the values into dataset same as in table.
0.01 0.00
89.50 0.01

Could any of you please help me out to acheive this.
Back to top
View user's profile Send private message
srikanthkailasam

New User


Joined: 13 Nov 2006
Posts: 24
Location: Bengalooru

PostPosted: Wed Apr 22, 2009 11:02 pm
Reply with quote

Can you give the variable declarations of Total_Amount Paid_Amount?
Back to top
View user's profile Send private message
Krishnadeva Reddy

New User


Joined: 14 Nov 2007
Posts: 37
Location: Chennai

PostPosted: Wed Apr 22, 2009 11:06 pm
Reply with quote

Both are of DECIMAL(9,2) datatype.
Back to top
View user's profile Send private message
srikanthkailasam

New User


Joined: 13 Nov 2006
Posts: 24
Location: Bengalooru

PostPosted: Wed Apr 22, 2009 11:51 pm
Reply with quote

Where are you getting the values from??

Total_Amount Paid_Amount
------------------------------------
0.01 0.00
89.50 0.01

Is it from Spufi or QMF??
Back to top
View user's profile Send private message
Krishnadeva Reddy

New User


Joined: 14 Nov 2007
Posts: 37
Location: Chennai

PostPosted: Wed Apr 22, 2009 11:58 pm
Reply with quote

These are the actual values stored in Db2 table.

I want it to unload to a dataset and FTP to text file.

If I am not using CHAR conversion leading Zero's are removed when extracted to dataset.

If the value is 0.01 it comes as .01 in dataset ,So I used CHAR conversion.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Thu Apr 23, 2009 1:17 am
Reply with quote

Quote:
These are the actual values stored in Db2 table.


NO!

Read the description of the char function in DB2 manuals!

DEC(9,2) are numeric data items and would be stored with leading zeros.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Apr 23, 2009 2:27 am
Reply with quote

Hello,

Quote:
These are the actual values stored in Db2 table.
Why would you believe thie?
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Thu Apr 23, 2009 2:36 am
Reply with quote

Quote:
Hello,

Quote:
These are the actual values stored in Db2 table.
Why would you believe thie?

Dick, it might be possible as when you do a select on a decimal field, it shows the value without leading zeroes. Even when i browse my table i don’t get to see the leading zeroes.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Thu Apr 23, 2009 2:57 am
Reply with quote

I think the point being made is that SPUFI, QMF, File-Aid for DB2, and any other software might suppress the leading zeros when being displayed, but the DB2 manual indicates that DECIMAL data types are stored in what COBOL refers to as packed decimal (COMP-3) which means leading zeros are present.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Apr 23, 2009 2:59 am
Reply with quote

Hello,

Keep in mind that when you "see" the values via some query, you are not seeing what is stored in the database, but rather a more "people friendly" presentation of the value.

Very much like in cobol when you move a packed-decimal field to an edited output field to get something like $12,345.88-. The currency sign, the comma, the decimal point, and the actual minus sign are not in the data field. They are inseerted for readability by the definition of the output field.
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Thu Apr 23, 2009 3:09 am
Reply with quote

Quote:
Keep in mind that when you "see" the values via some query, you are not seeing what is stored in the database, but rather a more "people friendly" presentation of the value.
That is true. Therefore i used
Quote:
it might be possible as when you do a select on a decimal field, it shows the value without leading zeroes. Even when i browse my table i don’t get to see the leading zeroes.
and as Terry indicated in SPUFI we get to see the results with suppressed zeroes.
I believe Krishnadeva is worried all about representation and not how the value is being actually stored.
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 -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts Remove leading zeroes SYNCSORT 4
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
No new posts Cobol program with sequence number ra... COBOL Programming 5
No new posts To Remove spaces (which is in hex for... JCL & VSAM 10
Search our Forums:

Back to Top