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

How to supress zeros


IBM Mainframe Forums -> FAQ & Basics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
nileshp

New User


Joined: 25 Feb 2006
Posts: 31

PostPosted: Thu Jun 07, 2007 9:08 am
Reply with quote

HI,
My requirement is , I am having one variable pic x(10) suppose it contains 0000012345. I want to get only 12345 part of the number and I want to use it in computation.
I.e I don't want to get leading zeros, but I don,t want to use 'Z'.

Nilesh Padwal.
Back to top
View user's profile Send private message
prafull

New User


Joined: 08 Dec 2006
Posts: 48

PostPosted: Thu Jun 07, 2007 10:17 am
Reply with quote

simply not clear
Please post example.
Back to top
View user's profile Send private message
nileshp

New User


Joined: 25 Feb 2006
Posts: 31

PostPosted: Thu Jun 07, 2007 10:32 am
Reply with quote

05 ws-nbr pic x(10).
05 ws-nbr-1 pic x(10)
move '0000012345' to ws-nbr.
i want
ws-nbr-1 whould contain ' 12345'


prafull wrote:
simply not clear
Please post example.
Back to top
View user's profile Send private message
raak

Active User


Joined: 23 May 2006
Posts: 166
Location: chennai

PostPosted: Thu Jun 07, 2007 11:08 am
Reply with quote

Hey

Quote:
but I don,t want to use 'Z'.


But why ??

Ur requirement can be done so easily with usage of Z .. ( That is the sole purpose of declaring a variable as Zero Suppressed)
Back to top
View user's profile Send private message
nileshp

New User


Joined: 25 Feb 2006
Posts: 31

PostPosted: Thu Jun 07, 2007 11:20 am
Reply with quote

But we can't use the 'Z' in the variable which we are going to use in computation.


raak wrote:
Hey

Quote:
but I don,t want to use 'Z'.


But why ??

Ur requirement can be done so easily with usage of Z .. ( That is the sole purpose of declaring a variable as Zero Suppressed)
Back to top
View user's profile Send private message
prafull

New User


Joined: 08 Dec 2006
Posts: 48

PostPosted: Thu Jun 07, 2007 11:33 am
Reply with quote

Code:
05 WS-I                  PIC 9(2) .
05 WS-SEQ             PIC 9(2) .
05 FIRST-NONZERO PIC 9(2) .

PERFORM WS-I FROM 1 BY 1 UNTIL WS-I > 10
 IF WS-NBR-1(WS-I : 1 ) = '0'
     MOVE WS-I TO FIRST-NONZERO
 END-IF
END-PERFORM

MOVE  +1 TO WS-SEQ

PERFORM WS-I FROM FIRST-NONZERO BY 1 UNTIL WS-I > 10
MOVE WS-NBR(WS-I : 1 )  TO WS-NBR-1(WS-SEQ : 1 )
END-PERFORM


you could use this.


But,
Quote:
I want to get only 12345 part of the number and I want to use it in computation.

Did you mean numeric computations?
then tell us how are you planning to do computations with WS-NBR-1.
(WS-NBR-1 PC is X(10) -alphanumeric)


Please correct if anythingz wrong.
Back to top
View user's profile Send private message
prafull

New User


Joined: 08 Dec 2006
Posts: 48

PostPosted: Thu Jun 07, 2007 11:37 am
Reply with quote

correction (use NOT in IF )
Code:
05 WS-I                  PIC 9(2) .
05 WS-SEQ             PIC 9(2) .
05 FIRST-NONZERO PIC 9(2) .

PERFORM WS-I FROM 1 BY 1 UNTIL WS-I > 10
 IF WS-NBR-1(WS-I : 1 ) NOT = '0'
     MOVE WS-I TO FIRST-NONZERO
 END-IF
END-PERFORM

MOVE  +1 TO WS-SEQ

PERFORM WS-I FROM FIRST-NONZERO BY 1 UNTIL WS-I > 10
MOVE WS-NBR(WS-I : 1 )  TO WS-NBR-1(WS-SEQ : 1 )
END-PERFORM
Back to top
View user's profile Send private message
nileshp

New User


Joined: 25 Feb 2006
Posts: 31

PostPosted: Thu Jun 07, 2007 11:44 am
Reply with quote

Thanks ,
It's working


prafull wrote:
Code:
05 WS-I                  PIC 9(2) .
05 WS-SEQ             PIC 9(2) .
05 FIRST-NONZERO PIC 9(2) .

PERFORM WS-I FROM 1 BY 1 UNTIL WS-I > 10
 IF WS-NBR-1(WS-I : 1 ) = '0'
     MOVE WS-I TO FIRST-NONZERO
 END-IF
END-PERFORM

MOVE  +1 TO WS-SEQ

PERFORM WS-I FROM FIRST-NONZERO BY 1 UNTIL WS-I > 10
MOVE WS-NBR(WS-I : 1 )  TO WS-NBR-1(WS-SEQ : 1 )
END-PERFORM


you could use this.


But,
Quote:
I want to get only 12345 part of the number and I want to use it in computation.

Did you mean numeric computations?
then tell us how are you planning to do computations with WS-NBR-1.
(WS-NBR-1 PC is X(10) -alphanumeric)


Please correct if anythingz wrong.
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 Jun 07, 2007 3:10 pm
Reply with quote

Hello,

Please explain why you want no leading zeros in a field that is to be used in a calculation?

There is no good reason to waste system resources like this.

Use the field with the leading zeros for your arithmetic and use Zs for output that will be displayed.

If i've misunderstood something, please let me know.
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 -> FAQ & Basics

 


Similar Topics
Topic Forum Replies
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
No new posts Convert Numeric to Packed decimal and... DFSORT/ICETOOL 5
This topic is locked: you cannot edit posts or make replies. Issue in suppressing leading zeros &a... COBOL Programming 21
No new posts editting the file by inserting zeros ... DFSORT/ICETOOL 9
Search our Forums:

Back to Top