Page 1 of 1

Issue with trailing spaces

Posted: Tue Apr 12, 2005 10:30 am
by ds_is_fun
I earlier posted a Q with how to get rid of trailing weird characters. The issue was solved after getting a response here on DSX asking to change settings in the DS Admin, changing the variable APT_STRING_PADCHAR to space. Thanks gh_amitava.
Now after the change Im getting trailing spaces that I can't rid off by using any of the DS functions (TRIM, TRIMB,CompactWhiteSpace, TrimWhiteSpace) for the CHAR type field.
Pl. suggest. THanks!

Posted: Tue Apr 12, 2005 12:55 pm
by ds_is_fun
Im answering to my own post,
The problem seemed in PX 7.5.1 itself.
The fields with the CHAR datatype and that had string values got padded with SPACES. Ironically, number values din't get pad with SPACES in the same CHAR field type. Once, I changed all the datatypes to VARCHAR I tweaked the problem. Looks like PX 7.5.1 behaves differently in these type of cases. But I still don't have the answer to the problem although I tweaked it.
Thanks to myself!

Posted: Wed Apr 13, 2005 1:12 am
by roy
Hi,
This is more of a C++ issue.
when you define a string of 50 characters you'll get 50 characters even if you actually only use 10.
(I think DS should usually puts a binary zero or the pad char for the reminder space, but I'm not sure.)
now if you don't initialize the entire 50 characters you'll most likely get 10 characters then string termination '\0' and the rest will be garbage data.
So if some one put a unseen charcter string in the pad character you might get what you had.
You can now see what putting a space, as you did, resulted in.

A you found out using varchar usually prevents such issues, tough you might need the occasion conversion/transformation applied.

IHTH,