Trying to extract substring from file

Rio38

New Member
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:

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.
 

doreynie

Member
Leave out the "CHARACTER" expression in your substring expression.

Progress defaults a "CHARACTER" expression to 8 characters. So it returns you a string containing all the needed characters, but displays/put/exports only 8 of them.
 

Rio38

New Member
Thank you for your response. I removed the "CHARACTER" from the SUBSTRING function and I still only get 8 characters.
 
Top