I want to read a flat file, the record lenth of the file is 310. Some fileds of the file are COMP. When you browse the file, you will see some special characters in these fields. Actually I just want the first 20 characters, which are all digits.This file contains several millions of records.
I have an old number, for example OLDNUM = 25465465133654785956, I need to find out if the OLDNUM in the file or not.
I try to read a whole record and use SUBSTR to get the first 20 characters, and then compare these two values.
The Clist program abended with 588 error code. Because of some records contains the characters: OTHER THAN DBCS CHARACTERS FOUND IN A DBCS STRING
I can not modify the file to delete the records containing the CHARACTERS. I have to modify my clist program so that it can process these records.
Here are my codes:
SET OLDNUM = &STR(25465465133654785956)
DO WHILE &EOF = OFF OR &RCODE ¬= 0
GETFILE NEWNUM
IF &EOF=ON THEN DO
RETURN CODE(1)
END
SET SYSDVAL = &NRSTR(&NEWNUM)
READDVAL NNUM
SET NNUM = &SUBSTR(1:19,&NRSTR(&NNUM))
IF &STR(&CARDNUM) = &STR(&NNUM) THEN DO
CLOSFILE NEWNUM
FREE F(NEWNUM)
RETURN CODE(0)
END
END
DO WHILE &EOF = OFF OR &RCODE ¬= 0
GETFILE NEWNUM
IF &EOF=ON THEN DO
RETURN CODE(1)
END
SET SYSDVAL = &NRSTR(&NEWNUM)
READDVAL NNUM
SET NNUM = &SUBSTR(1:19,&NRSTR(&NNUM))
IF &STR(&CARDNUM) = &STR(&NNUM) THEN DO
CLOSFILE NEWNUM
FREE F(NEWNUM)
RETURN CODE(0)
END
END
Because the records may contain some special characters, such as: < & ^ * > , some other clist errors may happer:
900 :Single ampersand was found.
860 :Multiplication error - character data.
Does anybody let me know how to only extract the first 20 characters regardless of the rest?