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
Request clarification before answering.
Thank you both!!.. will continue with above code
I was just looking for another solution..:)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
I do not think this should be considered as a tem fix but rather the design which works.
Thank you,
Viacheslav.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I agree your decode function solution .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.