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 

Replacing space by zeros - Not working

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


Joined: 26 May 2016
Posts: 14
Topics: 6

PostPosted: Tue Oct 04, 2016 3:37 pm    Post subject: Replacing space by zeros - Not working Reply with quote

Hi,

I used below techniques to replace the leading zeros but not getting expected result, please advise.

Code:


01  802-ERROR-REF-TABLE-JUST2.
    05  B                          PIC X(04) JUSTIFIED RIGHT.
    05  C                          PIC X(04) JUSTIFIED RIGHT.

Method1:

 UNSTRING B DELIMITED BY ALL SPACE INTO C
 INSPECT C REPLACING LEADING LOW-VALUE BY '0'
 DISPLAY 'VALUE OF B = ' B
 DISPLAY 'VALUE OF C = ' C

Method2:

UNSTRING B DELIMITED BY ALL ' ' INTO C
 INSPECT C REPLACING LEADING SPACE BY '0'
 DISPLAY 'VALUE OF B = ' B
 DISPLAY 'VALUE OF C = ' C

I am getting results like this in spool:

VALUE OF B =  515
VALUE OF C =
VALUE OF B =  515
VALUE OF C = 0000


I want the results to be

VALUE OF B =  515
VALUE OF C = 0515
VALUE OF B =  515
VALUE OF C = 0515



I tried to replace using low-value and also by using space both methods are not working.
Back to top
View user's profile Send private message
William Collins
Supermod


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Tue Oct 04, 2016 3:48 pm    Post subject: Reply with quote

How does the data get into B, including the definition of the source field?

I think you are expecting it to be left-justified, but it is not.

When you UNSTRING, you are picking up a zero-length value (DELIMITED BY ALL SPACE is best) prior to the first space, so you get space, and space alone, in C. The LOW-VALUES was never going to work (not sure why you tried that).

Just MOVE B TO C and then do your INSPECT. For a four-byte field, INSPECT is a bit heavy, I'd just define appropriately test for one, two, three or four spaces, and MOVE ZERO to the place where the spaces have been identified as being.

More thinking, more typing (or more using of the editor) but less CPU day-in, day-out, for the next 15 years.
Back to top
View user's profile Send private message
dhansr
Beginner


Joined: 26 May 2016
Posts: 14
Topics: 6

PostPosted: Tue Oct 04, 2016 4:20 pm    Post subject: Reply with quote

Hi,

OUTSTANDING !!!

As suggested I moved B to C and did INSPECT, it works great !!, outstanding

Code:

MOVE 802-INT-ERR-CODE    TO 802-INT-ERR-CODE-B
INSPECT 802-INT-ERR-CODE-B REPLACING ALL SPACE BY '0'


Thank You.... Very Happy
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