10-08-2014 12:10 PM
hello, I want to replace a substr in a text to some else, somehow the following does not work. Any ideas? If I assign the string values to the temp_str and new_str, the F1 is updated as intended. Thank you,
F1 = "9999,'ABC', 110,2, 0.00, 0.00, 14, 17,1.02454, 27.9937,1";
TEMP_STR = SUBSTR(F1,1,POS-2);
NEW_STR = CAT(SUBSTR(F1,1,POS-3),'1');
F1 = TRANWRD(F1,TEMP_STR,NEW_STR);
10-08-2014 12:32 PM
It is a good idea describe the intended output instead of just "doesn't work".
You're not getting the match you expect because both TEMP_STR and NEW_STR are 200 characters long and all of them are used in the comparison.
You may want:
10-08-2014 03:37 PM
The result of CAT, and many other string functions, is 200 unless you define the variable first. But even with a defined length you would likely have the comparison for some values with the trailing blanks. So it is a good idea to STRIP values. Though you need other approaches if you want leading blanks compared...