Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8623

Re: SAP BODS |  String manipulation queries.

$
0
0

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:

Capture.JPG

 

Note: Haven't seen the performance impact.

 

Cheers

Santhosh


Viewing all articles
Browse latest Browse all 8623

Trending Articles