View previous topic :: View next topic |
Author |
Message |
vijay Beginner
Joined: 09 May 2003 Posts: 131 Topics: 64
|
Posted: Thu May 20, 2004 1:52 pm Post subject: EZT help with stripping leading zeros |
|
|
Hi ,
Do we've any statement similar to cobol's INSPECT statement in EZT.I need to strip leading zeros off from some of the feilds before writing to another file.
Thanks,
VIjay |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Thu May 20, 2004 2:35 pm Post subject: |
|
|
Vijay,
Easytrieve does not have the function INSPECT. How ever you can acheive the results using DO UNTIL.
The following code will strip off the leading zeroes from the 10 byte numeric field
Code: |
FILE FILEIN
IN-KEY 01 03 A
IN-QTY 05 10 N 0
FILE FILEOUT
OUT-KEY 01 03 A
OUT-QTY 05 10 A
W-SUB W 02 N 0
W-NUM-FOUND W 01 A
W-STRING W 10 A
W-STR W-STRING 1 N OCCURS 10
JOB INPUT FILEIN
W-STRING = IN-QTY
W-SUB = 1
W-NUM-FOUND = 'N'
DO UNTIL W-SUB GT 10 OR W-NUM-FOUND = 'Y'
IF W-STR (W-SUB) > 0
W-NUM-FOUND = 'Y'
ELSE
MOVE ' ' TO W-STR(W-SUB)
END-IF
W-SUB = W-SUB + 1
END-DO
OUT-KEY = IN-KEY
OUT-QTY = W-STRING
PUT FILEOUT
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
|
|