View previous topic :: :: View next topic

Author 
Message 
nileshp
New User
Joined: 25 Feb 2006 Posts: 31




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 




prafull
New User
Joined: 08 Dec 2006 Posts: 48




simply not clear
Please post example. 

Back to top 


nileshp
New User
Joined: 25 Feb 2006 Posts: 31




05 wsnbr pic x(10).
05 wsnbr1 pic x(10)
move '0000012345' to wsnbr.
i want
wsnbr1 whould contain ' 12345'
prafull wrote: 
simply not clear
Please post example. 


Back to top 


raak
Active User
Joined: 23 May 2006 Posts: 166 Location: chennai




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 


nileshp
New User
Joined: 25 Feb 2006 Posts: 31




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 


prafull
New User
Joined: 08 Dec 2006 Posts: 48




Code: 
05 WSI PIC 9(2) .
05 WSSEQ PIC 9(2) .
05 FIRSTNONZERO PIC 9(2) .
PERFORM WSI FROM 1 BY 1 UNTIL WSI > 10
IF WSNBR1(WSI : 1 ) = '0'
MOVE WSI TO FIRSTNONZERO
ENDIF
ENDPERFORM
MOVE +1 TO WSSEQ
PERFORM WSI FROM FIRSTNONZERO BY 1 UNTIL WSI > 10
MOVE WSNBR(WSI : 1 ) TO WSNBR1(WSSEQ : 1 )
ENDPERFORM 
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 WSNBR1.
(WSNBR1 PC is X(10) alphanumeric)
Please correct if anythingz wrong. 

Back to top 


prafull
New User
Joined: 08 Dec 2006 Posts: 48




correction (use NOT in IF )
Code: 
05 WSI PIC 9(2) .
05 WSSEQ PIC 9(2) .
05 FIRSTNONZERO PIC 9(2) .
PERFORM WSI FROM 1 BY 1 UNTIL WSI > 10
IF WSNBR1(WSI : 1 ) NOT = '0'
MOVE WSI TO FIRSTNONZERO
ENDIF
ENDPERFORM
MOVE +1 TO WSSEQ
PERFORM WSI FROM FIRSTNONZERO BY 1 UNTIL WSI > 10
MOVE WSNBR(WSI : 1 ) TO WSNBR1(WSSEQ : 1 )
ENDPERFORM 


Back to top 


nileshp
New User
Joined: 25 Feb 2006 Posts: 31




Thanks ,
It's working
prafull wrote: 
Code: 
05 WSI PIC 9(2) .
05 WSSEQ PIC 9(2) .
05 FIRSTNONZERO PIC 9(2) .
PERFORM WSI FROM 1 BY 1 UNTIL WSI > 10
IF WSNBR1(WSI : 1 ) = '0'
MOVE WSI TO FIRSTNONZERO
ENDIF
ENDPERFORM
MOVE +1 TO WSSEQ
PERFORM WSI FROM FIRSTNONZERO BY 1 UNTIL WSI > 10
MOVE WSNBR(WSI : 1 ) TO WSNBR1(WSSEQ : 1 )
ENDPERFORM 
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 WSNBR1.
(WSNBR1 PC is X(10) alphanumeric)
Please correct if anythingz wrong. 


Back to top 


dick scherrer
Site Director
Joined: 23 Nov 2006 Posts: 19270 Location: Inside the Matrix




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 


