Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member182455
Active Contributor

Dear users,

Here are some UDFs that might me helpful in your business scenarios.

1. UDF to remove sequential leading values of string:


This UDF can be used in scenario where we get an input string from which we intend to pass only the required part of it, removing the leading characters which appear in a sequence. UDF consists of two input fields of which first one is input field (original string) and second one is the value which is to be deleted from the original string value.  


                                                 

               Code:


                        while(InputString.startsWith(Value))

                        InputString = InputString.substring(Value.length());

                        return InputString;

                 

               Examples:

              

             a.                 InputString                          Value                               Output

  

                         

                  b.

                          

                

2. UDF to Add Leading Zeroes:


This UDF can be used in a scenario where the requirement is to add leading zeroes to a string to make the total length of the string to a fixed value (for example 10).

                            

                    Code:

                             int defaultLength = 10;

                             String valueZero = "0";

                             int strlength = givenString.length();

                             int diff = defaultLength - strlength;

                             String S = "";

                             for(int i = 0; i<diff; i++)

                             S = S + valueZero;

                             return S + givenString;

                                                                 Input                                    Output

                                           

3. UDF to remove any number of special characters:


This UDF can be used in a business scenario where the requirement is to remove any number of special characters present in a string.

                                           

                                  Code:

                                           givenString = givenString.replaceAll("[^a-zA-Z0-9]+","");

                                           return givenString;

                                                               Input                                        Output

                                         

7 Comments
Labels in this area