cancel
Showing results for 
Search instead for 
Did you mean: 

SAP BODS | String manipulation queries.

12-02-2014 2:25 PM
4077 views 4 comments
0 Likes
SAP Managed Tags
Subscribe

Here is the one requirement for string manipulation. Please share your feedback on the same.



Rule for Default name: Break at the last space prior to the 35th character (i.e. if the length is more than 35 char, we want only complete sentence/word)

For example if default name : Indian institute of management Bangalore 

which is more than 35 char, So first 35 letter will be ~ Indian institute of management Bang, But we want only complete words as name ’ Indian institute of management ’. we don’t want word ‘Bang’ at last.


Overflow of the name will be managed in Name2 so no issue with trimJ

I have put temp fix to this requirement and its working fine. Please suggest if you have any other logic to implement same in SAP BODS

decode(length(Default_Name) > 35, rtrim( substr(Default_Name, 1, 35), '()qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890-,.&*":;<>?/#@' ), Default_Name)

Thanks,

Abhishek

0 Likes

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member815899
Discoverer
0 Likes

Thank you both!!.. will continue with above code

I was just looking for another solution..:)

0 Likes

Hi Abhishek,

I tried this with a custom function and it did work perfect.

Custom Function:(CF_StringRetrieve)

# Assign the input string to a local variable

$L_Stmnt = $P_InString ;

#Initialize loop counter

$L_LoopCounter = 35;

#Reverse the statement

while ( $L_LoopCounter > 0 )

  begin

  $L_StrRev = $L_StrRev || Substr($L_Stmnt, $L_LoopCounter, 1);

  $L_LoopCounter = $L_LoopCounter - 1;

  end

#Extracting the substring of the statement after first space, so that the extra truncated part is removed

$L_StrRev = substr($L_StrRev, index( $L_StrRev, ' ', 1 ) , length( $L_StrRev ));

#Reassigning the initial value of local string

$L_Stmnt = '';

$L_LoopCounter = length( $L_StrRev );

while ( $L_LoopCounter > 0 )

  begin

  $L_Stmnt = $L_Stmnt || Substr($L_StrRev, $L_LoopCounter, 1);

  $L_LoopCounter = $L_LoopCounter - 1;

  end

Return $L_Stmnt ;

Mapping to the output field:

ifthenelse(length( Field1) < 35, Field1, ifthenelse(index( Field1, ' ',1) IS NULL, substr( Field1,1,35), rtrim_blanks(CF_StringRetrieve( Field1))))

Mapping in Query:

Note: Haven't seen the performance impact.

Cheers

Santhosh

vnovozhilov
Product and Topic Expert
Product and Topic Expert
0 Likes

I do not think this should be considered as a tem fix but rather the design which works.

Thank you,

Viacheslav.

former_member208363
Active Participant
0 Likes

I agree your decode function solution .