Quantcast
Channel: SCN : All Content - Data Services and Data Quality
Viewing all articles
Browse latest Browse all 4013

SAP BODS - Custom Function to SPLIT Single Input Field Value to Multiple Fields with Meaningful Field Division

$
0
0

Custom Function - Word Split Mechanism


 

In BODS, we don't have any specific Logic or Transform to Split Words equally & meaningfully. So as per business requirement, we developed a Custom Function to provide Solution to User Requirement.

 

User Requirement:-  Input Field value to be divided into 3 Output Fields of each length - 60 varchar, using BODS Tool.

 

#################### Declaration ####################

 

#$Input = '';

 

$Input = replace_substr( $Input,'  ',' *');

 

$Input_Len = length(replace_substr( $Input,'  ',' *'));

 

$Incr = 1;

 

$Output1 = '';

$SubStr1 = '';

$SubStr2 = '';


######################################################

 

####################### Logic #########################

 

while ($Incr < $Input_Len)

 

                begin

 

                                $SubStr2 = word_ext( $Input,$Incr,'\' \'');

                                #print('1 - '||$SubStr2);

 

                                if((length($SubStr1)+length($SubStr2))>= 60)

                                begin

                                                                $Output1 = $SubStr1;

                                                                $T_Len = length(rtrim_blanks($Output1))+1;

                                                                $Text_Output = substr($Input,$T_Len,$Input_Len);

                                                                #print('2 - '||$Output1);

                                                                $Output1 = ltrim_blanks( rtrim_blanks( replace_substr( $Output1,' *','  ')));

 

                                                                return $Output1;

                                                                return $Text_Output;

                                                                #print($Text_Output);

                                end

                                else

                                begin

                                $SubStr1 = $SubStr1||' '||$SubStr2;

                                $SubStr1 = rtrim_blanks($SubStr1);

                                #print($SubStr1);

                                $Output1 = $SubStr1;

                                $Output1 = ltrim_blanks( rtrim_blanks( replace_substr( $Output1,' *','  ')));

                                #print('3 - '||$Output1);

                                end

                                                               

                                $Incr = $Incr+1;  

end

 

return $Output1;

return $Text_Output;


####################################################


Viewing all articles
Browse latest Browse all 4013

Trending Articles