MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Leading zeros in Alphanumeric field

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
Ravee_pisini
Beginner


Joined: 16 Oct 2012
Posts: 6
Topics: 3

PostPosted: Sat Dec 21, 2013 8:36 am    Post subject: Leading zeros in Alphanumeric field Reply with quote

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
View user's profile Send private message
William Collins
Supermod


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Sat Dec 21, 2013 5:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Sat Dec 21, 2013 9:07 pm    Post subject: Reply with quote

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
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Mon Dec 23, 2013 12:46 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group