Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups 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 -> Mainframe COBOL
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
References
Robert Sample

Senior Member


Joined: 06 Jun 2008
Posts: 943
Location: Atlanta, GA

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

Senior Member


Joined: 20 Oct 2006
Posts: 1639
Location: germany

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

Senior Member


Joined: 06 Jun 2008
Posts: 943
Location: Atlanta, GA

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
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL All times are GMT + 6 Hours
Page 1 of 1