View previous topic :: View next topic |
Author |
Message |
Ravee_pisini Beginner
Joined: 16 Oct 2012 Posts: 6 Topics: 3
|
Posted: Sat Dec 21, 2013 8:36 am Post subject: Leading zeros in Alphanumeric field |
|
|
Hi, I have alphanuermic field, While move the value from A TO B field. The B field should contain leading zeros on left side.
Exmaples 1:
MOVE A TO B
A VALUE = 123
B VALUE = 000123
Example 2:
MOVE A TO B
A VALUE = AA12
B VALUE = 00AA12
Example 3:
MOVE A TO B
A VALUE = AA
B VALUE = 0000AA
Example :
MOVE A TO B
A VALUE = SPACES
B VALUE = 000000
Please advise how to handle. This is urgent.
Thanks,
Ravee |
|
Back to top |
|
 |
William Collins Supermod
Joined: 03 Jun 2012 Posts: 437 Topics: 0
|
Posted: Sat Dec 21, 2013 5:42 pm Post subject: |
|
|
For the data you've shown:
Code: | 01 A PIC X(6).
01 B PIC X(6) JUSTIFIED RIGHT.
UNSTRING A
DELIMITED BY ALL SPACE
INTO B
INSPECT B
REPLACING LEADING SPACE
BY ZERO |
The JUSTIFIED RIGHT will allow the variable-length field from the UNSTRING to be right-justified and left space-filled. The leading spaces then become zero with the INSPECT. |
|
Back to top |
|
 |
papadi Supermod
Joined: 20 Oct 2009 Posts: 594 Topics: 1
|
Posted: Sat Dec 21, 2013 9:07 pm Post subject: |
|
|
Suggest someone learn it is usually a bad design that calls for moving unedited alphanumeric values to a numeric field.
Values should be validated Before they are used.
Once you know the value is a valid numeric, it can easily be manipulated. _________________ All the best,
di |
|
Back to top |
|
 |
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Mon Dec 23, 2013 12:46 pm Post subject: |
|
|
By the way - it is not urgent or you would not have posted in a forum where members respond as and when they feel like and do so for free. If you want "urgent" you should expect to pay for it but it would have been better and quicker to ask your colleagues. _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
 |
|
|