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

How to suppress the leading zeros


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

New User


Joined: 28 Sep 2006
Posts: 56

PostPosted: Wed Aug 29, 2007 12:22 pm
Reply with quote

i have a variable with 9(9), when i pass value

for example 37 , i am getting as 000000037, i should not get leading zero,
i should get only 37, Please suggest the solution using cobol.

Thanks
Back to top
View user's profile Send private message
Aji

New User


Joined: 03 Feb 2006
Posts: 53
Location: Mumbai

PostPosted: Wed Aug 29, 2007 12:36 pm
Reply with quote

Declare a variable
01 edit_var pic z(8)9.

and move the value to be edited to edit_var.


Aji
Back to top
View user's profile Send private message
jaspal

New User


Joined: 22 May 2007
Posts: 68
Location: mumbai

PostPosted: Thu Aug 30, 2007 11:26 am
Reply with quote

HI
YOU CAN USE :
READ FILE:
MOVE FIELD TO WW-FILELD
MOVE ZEROES TO WW-COUNT
INSPECT WW-FIELD TALLYING WW-COUNT FOR LEADING
ZEROES.
( WHERE WW-FIELD= 000000037 AND WW-COUNT=NUMBER OF ZEROES,DECLARATION IN WORKING STORAGE AS
01 WW-COUNT PIC 9(2) VALUE ZEROES.
01 WW-FIELD PIC 9(15) VALUE ZEROES. )

THEN
COMPUTE WW-LEN = 15 - WW-COUNT
MOVE WW-FIELD(WW-COUNT:WW-LEN) TO WW-COUNT-O


EXPECTED RESULT WOULD BE WW-COUNT-O = 37
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Thu Aug 30, 2007 11:31 am
Reply with quote

jaspal wrote:
HI
YOU CAN USE :
READ FILE:
MOVE FIELD TO WW-FILELD
MOVE ZEROES TO WW-COUNT
INSPECT WW-FIELD TALLYING WW-COUNT FOR LEADING
ZEROES.
( WHERE WW-FIELD= 000000037 AND WW-COUNT=NUMBER OF ZEROES,DECLARATION IN WORKING STORAGE AS
01 WW-COUNT PIC 9(2) VALUE ZEROES.
01 WW-FIELD PIC 9(15) VALUE ZEROES. )

THEN
COMPUTE WW-LEN = 15 - WW-COUNT
MOVE WW-FIELD(WW-COUNT:WW-LEN) TO WW-COUNT-O


EXPECTED RESULT WOULD BE WW-COUNT-O = 37



you must be joking icon_eek.gif
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Thu Aug 30, 2007 12:52 pm
Reply with quote

I've re-read the original question and I can see it's not clear if the desired output for '000000037' is ' 37' or '37'.
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Thu Aug 30, 2007 1:46 pm
Reply with quote

I meant:
Code:

000000037
       37
37
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 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 How to display the leading zeros of a... DB2 7
This topic is locked: you cannot edit posts or make replies. Suppressing only leading zeros (not s... DFSORT/ICETOOL 9
Search our Forums:

Back to Top