Subject: | |
From: | |
Reply To: | Shahan, Ray |
Date: | Thu, 22 Feb 2001 10:30:59 -0700 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
One COBOL method:
01 FROM-BYTE PIC S9(04) COMP.
01 THE-NUMERIC-FIELD PIC 9(9).
01 DONE-WITH-LOOP-SW PIC X(1) VALUE "N".
88 DONE-WITH-LOOP VALUE "Y".
MOVE 1 TO FROM-BYTE.
IF THE-NUMERIC-FIELD <> ZERO
IF THE-NUMERIC-FIELD(FROM-BYTE:1) <> ZERO
PERFORM UNTIL (DONE-WITH-LOOP)
IF THE-NUMERIC-FIELD(FROM-BYTE:1) <> ZERO
SET DONE-WITH-LOOP TO TRUE
ELSE
ADD 1 TO FROM-BYTE
END-IF
END-PERFORM
END-IF
MOVE THE-NUMERIC-FIELD(FROM-BYTE:) TO
A-FIELD-THAT-DOESN'T-WANT-LEADING-ZEROS
END-IF.
Another method:
01 THE-NUMERIC-FIELD PIC 9(9).
01 NO-LEADING-ZEROS PIC X(9) JUSTIFIED RIGHT.
UNSTRING THE-NUMERIC-FIELD INTO NO-LEADING-ZEROS
DELIMITED BY SIZE
END-UNSTRING.
INSPECT NO-LEADING-ZEROS
REPLACE LEADING ZEROS BY SPACES.
-----Original Message-----
From: TRAPP,RICH (Non-A-Loveland,ex1)
[SMTP:[log in to unmask]]
Sent: Thursday, February 22, 2001 10:36 AM
To: [log in to unmask]
Subject: Re: Removing leading zeros
Ram,
STEXPORT is a companion product along with the SUPRTOOL product.
If you
create a self describing file (out filename,link) from suprtool,
stexport
will read it in an create an ASCII file formatting each field using
any
number of options. I think the one you want is "ZERO NONE" which
strips
leading zeros.
If you need help, I recommend downloading the windows help file
version of
the SUPRTOOL help from the Robelle website.
RAT
Rich Trapp <mailto:[log in to unmask]>
Consulting for Agilent Technologies, Loveland, Colorado.
Managed Business Solutions <http://www.mbsnav.com/>
200 South College Avenue
Fort Collins, Colorado 80524-2811
970.679.2221 (voice)
970.669.3071 (fax)
-----Original Message-----
From: Ram Thekkekara [mailto:[log in to unmask]]
Sent: Wednesday, February 21, 2001 2:19 PM
To: [log in to unmask]
Subject: Removing leading zeros
Gurus,
Is there any way I can remove leading zeros from a field in Quiz or
Suprtool
?
(I checked the manuals for functions and I couldn't find one)
If not available, can it be done in COBOL in an efficient way ?
eg: I have an item# field which has length of 20 chars
So if I have '000021 ' how do I convert to '21
'
another example : '002323S ' to convert as '2323S
'
Thanks,
Ram Thekkekara
Hickory Farms, Inc
Phone: (419) 893 7611 xt 376 EST
Email : [log in to unmask]
|
|
|