April 11, 2008, 09:37 AM
janRemove CTRLF char in a string
I am trying to remove a carriage control carriage in a varchar string that I am retrieving fron a db2 table. I used the bytval function to determine the dec character value '13', and then I tried to replace it using CTRAN with a dec char value of a space which is '32'. I then used the CTRAN function as follows:
LOAN_PROD_DESC_A/A255=
CTRAN(255,LOAN_PROD_A, 13, 32, 'LOAN_PROD_DESC_A);
This seems to work, but when I run the report that outputs in COM format, the record breaks in the middle of a record to a new line.
I also tried the STRREP function, using the characters that display in db2, which is '..', but again the record breaks in the middle.
LOAN_PROD_DESC_A/A255=
STRREP(255,LOAN_PROD_A,2,'..',1,' ',255,LOAN_PROD_DESC_A);
I can not change the output format either case
Varchar field on the table looks like this
N 4 ..Th in hex it looks like this
50 LOAN_PROD_A VARCHAR(255) N 4
X'0D25E388'
I need to get this to work ASAP, any assistance would be great
April 11, 2008, 11:17 AM
smithsJan,
I believe that you should also need to CTRAN character 10 to 32 (in addition to character 13). You need to replace the carriage return (13) AND the line feed character (10) with spaces.
Sean
April 11, 2008, 11:51 AM
mgrackinI agree with smiths. You need to replace both characters (CR and LF).