Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to supress zeros

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> FAQ & Off Topics
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    Post subject: How to supress zeros
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    Post subject:
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    Post subject: How to supress zero
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Thu Jun 07, 2007 3:10 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> FAQ & Off Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts editting the file by inserting zeros ... pramodrsingh DFSORT/ICETOOL 9 Mon Aug 21, 2017 5:58 pm
No new posts Join key - Populate Zeros when Unpair... rexx77 DFSORT/ICETOOL 6 Thu May 12, 2016 12:22 am
No new posts Removing Leading Spaces and Removing ... rahulpala COBOL Programming 4 Fri Sep 04, 2015 4:58 am
No new posts Extraneous Zeros added to Dataset whe... Ashish.Srivastava.123 TSO/ISPF 5 Wed Aug 06, 2014 11:28 am
This topic is locked: you cannot edit posts or make replies. How to add trailing zeros in decimal ... ShobhitVerma10april DFSORT/ICETOOL 0 Mon Jun 30, 2014 2:32 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us