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

Meaningful word split in SAP BODS using Custom Function

$
0
0


Summary:

This document provides Custom function capability in SAP BODS, when existing transforms doesn't provide solution for requirement where Input Field with Large data set to be divided into multiple Output Fields with equal length.

 

Constraint:


1.   Input data set would be having single space in between the words.

2.   Output data in each field should be of meaningful words & No splitting in-between the words.

 

Introduction:

In BODS, we don't have any specific Logic or Transform or rules to split words equally into meaningful manner. So as per the requirement, we need to develop a Custom Function to provide possible solution.

 

Case Study:

Input Field            – TEXT varchar (160)

Output Fields        – Output1 varchar (40),   Output2 varchar (40),   Output3 varchar (40),   Output4 varchar (40)

 

Custom Function Logic:

 

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

$Input = ‘’;

$Input_Len = 0;

$Incr = 1;

$Output1 = '';

$SubStr1 = '';

$SubStr2 = '';

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

While ($Incr < $Input_Len)

                Begin

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

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

                                Begin

$Output1 = $SubStr1;

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

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

$Output1 = rtrim_blanks (rtrim_blanks ($Output1));

Return $Output1;

Return $Text_Output;

                                End

                                Else

                                Begin

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

$SubStr1 = rtrim_blanks ($SubStr1);

$Output1 = $SubStr1;

$Output1 = ltrim_blanks (rtrim_blanks ($Output1));

                                End

                                             

$Incr = $Incr+1;  

End

Return $Output1;

Return $Text_Output;

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

 

Implementation in SAP BODS:

 

Step1:    Right click on Custom Functions Library in SAP BODS & Click for New & provide Function Name to

Meaningful name. (Example: DS_WordSplit.)

 

1.jpg


Step2:    Copy Paste above Custom Function Code inside the window.

2.jpg

 

Step3:    Declare all the below Parameters & Local Variables.


 

Return     Int
$Input      Varchar (8000)
$Output1  Varchar (8000)
$Text_Output           Varchar (8000)
$Incr        Int
$Input_LenInt
$SubStr1  Varchar (8000)
$SubStr2  Varchar (8000)
$T_Len     Int

3.jpg

 

Step4:    Create a BODS Batch Job & create a dataflow.

4.jpg

 

Step5:    Create an Input File or table to extract Input Field value data.

5.jpg

 

Step6:    Call Custom Function DS_WordSplit separately for Output1, Output2, & Output3 Fields to store accordingly.

6.jpg

7.jpg8.jpg

Step7:    Validate & Run the Job to check the results.

 

9.jpg


Final Analysis: 

Input Text is of total 120 characters & its divide into 3 different fields of approx. 40 character length depending on the split mechanism in meaningful words.


Viewing all articles
Browse latest Browse all 4013

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>