IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

how to convert leading spaces to zeros without using Editing


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Laxminarsimharao

New User


Joined: 08 May 2007
Posts: 26
Location: hyderabad

PostPosted: Wed Oct 08, 2008 4:36 pm
Reply with quote

Please help me out.

I need to convert leading spaces/Low values to zeros.

Input X(8) - 999
output X(8) - 00000999

i do not want editing charecters in my cobol program.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Oct 08, 2008 5:09 pm
Reply with quote

Quote:
i do not want editing charecters in my cobol program.
What do you want to handicap yourself this way? There's nothing wrong with editing characters.

Assuming that you can have leading LOW-VALUES or you can have leading SPACES but not both, the following will work:
Code:
INSPECT OUT-VAR REPLACING LEADING LOW-VALUE BY ZERO.
INSPECT OUT-VAR REPLACING LEADING SPACE BY ZERO.

If there can be a mix of leading LOW-VALUES and SPACES, you'll have to check byte by byte using reference modification.
Back to top
View user's profile Send private message
Laxminarsimharao

New User


Joined: 08 May 2007
Posts: 26
Location: hyderabad

PostPosted: Wed Oct 08, 2008 5:15 pm
Reply with quote

Thanks Robert,

But some of the records have Trailing spaces/Low values.

how to handle this one.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Oct 08, 2008 5:19 pm
Reply with quote

Quote:

i do not want editing charecters in my cobol program.


don't know why you desire this -
other than this is a class project
and posters are to declare that there thread is based on a homework exercise,
so that we don't waste our time helping you,
thinking that there is a business reason for this unrealistic restriction.

there are no leading zeroes or spaces in your field, INPUT;
since it is alphanumeric, the data is left justified.

I would REDEFINE OUTPUT:
OUTPUT-WITH-EDIT-MASK PIC 99999999
and
COMPUTE OUTPUT-WITH-EDIT-MASK = NUMVAL(INPUT) END-COMPUTE
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Oct 08, 2008 5:24 pm
Reply with quote

OK, first you say LEADING values, now you're saying TRAILING values. You would get much better answers if you were clear at the beginning about what you need -- you didn't mention trailing anything in your first post.

Anyway, for trailing LOW-VALUES or SPACES:
Code:
MOVE FUNCTION REVERSE (IN-VAR) TO OUT-VAR.
INSPECT OUT-VAR REPLACING LEADING LOW-VALUE BY ZERO.
INSPECT OUT-VAR REPLACING LEADING SPACE BY ZERO.
MOVE FUNCTION REVERSE (OUT-VAR) TO OUT-VAR.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts Remove leading zeroes SYNCSORT 4
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
No new posts Cobol program with sequence number ra... COBOL Programming 5
Search our Forums:

Back to Top