|
|
| Author |
Message |
Laxminarsimharao
New User
Joined: 08 May 2007 Posts: 26 Location: hyderabad
|
|
|
|
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 |
|
 |
References
|
|
 |
Robert Sample
Senior Member
Joined: 06 Jun 2008 Posts: 941 Location: Atlanta, GA
|
|
|
|
| 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 |
|
 |
Laxminarsimharao
New User
Joined: 08 May 2007 Posts: 26 Location: hyderabad
|
|
|
|
Thanks Robert,
But some of the records have Trailing spaces/Low values.
how to handle this one. |
|
| Back to top |
|
 |
dbzTHEdinosauer
Senior Member
Joined: 20 Oct 2006 Posts: 1639 Location: germany
|
|
|
|
| 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 |
|
 |
Robert Sample
Senior Member
Joined: 06 Jun 2008 Posts: 941 Location: Atlanta, GA
|
|
|
|
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 |
|
 |
|
|