I am attempting to extract a substring from an external file. I have an external .txt file which contains records of different lengths and type on each line. I import each line of the text file into a temporary table. Each line of text may be up to 200 characters long.
I then use a FOR EACH statement to select records that begin with the text "B1" in order to get the records I desire. I need to get a substring of this record that begins on character 175 and is 16 characters in length. I use the substring function, but it is only returning 8 characters.
I need to know what I am doing wrong or if there is a limitation to the length of the character variable type.
The following is my code:
I then use a FOR EACH statement to select records that begin with the text "B1" in order to get the records I desire. I need to get a substring of this record that begins on character 175 and is 16 characters in length. I use the substring function, but it is only returning 8 characters.
I need to know what I am doing wrong or if there is a limitation to the length of the character variable type.
The following is my code:
Code:
DEFINE TEMP-TABLE tt_renewals
FIELD tt_record AS CHARACTER FORMAT "x(300)".
INPUT FROM /app/pbs/exchange/cm/renewals082207-001 no-echo.
repeat:
CREATE tt_renewals.
IMPORT UNFORMATTED tt_record.
END.
INPUT CLOSE.
OUTPUT TO /app/pbs/exchange/cm/renewalimport.txt.
FOR EACH tt_renewals WHERE tt_record BEGINS "B1":
EXPORT
SUBSTRING(tt_record,175,16,"CHARACTER").
END.