Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
how to convert leading spaces to zeros without using Editing

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: how to convert leading spaces to zeros without using Editing
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: 8154
Location: East Dubuque, Illinois, USA

PostPosted: Wed Oct 08, 2008 5:09 pm    Post subject:
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    Post subject:
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: 6968
Location: porcelain throne

PostPosted: Wed Oct 08, 2008 5:19 pm    Post subject:
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: 8154
Location: East Dubuque, Illinois, USA

PostPosted: Wed Oct 08, 2008 5:24 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm
No new posts editting the file by inserting zeros ... pramodrsingh DFSORT/ICETOOL 9 Mon Aug 21, 2017 5:58 pm
No new posts Convert CLIST to REXX cvnlynn CLIST & REXX 12 Tue Jun 27, 2017 2:06 am
No new posts Format record to remove Leading zeroes Learncoholic DFSORT/ICETOOL 14 Wed Apr 05, 2017 2:43 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us