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 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 |
|
|
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 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 |
|
|
prafull
New User
Joined: 08 Dec 2006 Posts: 48
|
|
|
|
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 |
|
|
nileshp
New User
Joined: 25 Feb 2006 Posts: 31
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 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 |
|
|
|