Deleting End Blank Spaces

Savatage
edited 2011-09-28 in Navision Attain
I have a project I want to do because it's been bugging me forever.

When we switched to Nav a long while ago we imported our data like everyone else. All of our cust names, address, city etc. have lots of blank spaces at the end so when you put them together you get
NEW YORK__________, NY instead of
NEW YORK, NY for example.

I would like to create a report to wipe out these trailing Blanks but I am having trouble. I've read about "Hard Blanks" in previous posts so I went the Char route.

OnPreDataItem()
MyChar := 255;
MyText := FORMAT(MyChar);

OnAfterGetRecord()
FOR i := 1 TO STRLEN(Vendor.City) DO
BEGIN
IF (Vendor.City <> ' ') THEN
NewCity :=DELCHR(Vendor.City,'>',MyText);
END;

Vendor.MODIFY;

Can you help me point to where I'm going wrong?

Should I be Deleting Characters or Rebuilding the String?

Answers