cancel
Showing results for 
Search instead for 
Did you mean: 

How to trim Spaces!!!

Former Member
0 Kudos

Hi Gurus,

Actually I am totally new to SAP Information steward. Trying to trim the spaces but unable to do can you please help me to do so as I am using LTRIM function in the Rule Expression can any one help me with the complete Syntax in the Rule Expression.

I Am trying with below:

BEGIN

ltrim($SPACES_TRIM, ' ');

END

Can any one please give the correct Expression for the rule which I am creating.

Thanks in Advance,

DJ

Accepted Solutions (0)

Answers (1)

Answers (1)

NielsWeigel
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Deepak,

as mentioned in your other post with the same question (http://scn.sap.com/thread/3604793😞

So your expression above returns a VARCHAR string, as you can read in the User guide, you are replacing leading nothing '' at the beginning of your string $SPACES_TRIM.

If you have an variable $Input_String and you want to do within the Rule Expression an LTRIM to e.g. compare WITHIN the Rule the trimmed string with another field variable, you can use LTRIM function to create an internal variable $Input_String_without_leading_spaces that has no Spaces at the beginning:

$Input_String_without_leading_spaces=ltrim($Input_String, ' ');

or you want to use the LTRIM directly in an comparison to check if the trimmed content of FieldA is identical with the trimmed content of FieldB:

BEGIN

ltrim($FieldA, ' ')=ltrim($FieldB,' ');

END

This expression block for a validation rule validated FieldA agains FieldB for every record of a bound data source record. Everytime the trimmed content of FieldA equals the trimmed content of FieldB the expression and with that the whole rule returns TRUE (=Record is compliant with your requirement that the content of the two fields is identical, even if there are different numbers of leadign Spaces in the two fields; '   Johnson, Smith' equals '                              Johnson, Smith') otherwise it returns FALSE as the trimmed content is not identical (' Meyer, Paul' not equal ' West, John' even if they both have a leading Space)

As noted earlier (http://scn.sap.com/thread/3604795), please keep in mind, that IS is not the tool to upadet data in your sources, to cleanse data in your sources. You can not use a rule expression to create a "standardized field" where content from a field is corrected, parsed or standardized and stored in another field of a table. That is a standardization or cleansing activity, that is done with SAP Data Services.

Niels