cancel
Showing results for 
Search instead for 
Did you mean: 

Help required in writing an UDF

Former Member
0 Kudos

Hi Sdners,

I have a requirement where my input field max length is 10 characters. If the length is less than 5 characters I need to take the five characters and if the length is ten characters, after first five characters I need to put '\' symbol.

Example:

input a = 12345 output b = 12345

input a = 1234567890 output b = 12345/67890.

Can anybody help me in writing UDF for this requirement.

Thanks in Advance.

Regards,

Ram.

Accepted Solutions (1)

Accepted Solutions (1)

nabendu_sen
Active Contributor
0 Kudos

Hi Ram,

You can try like below:

String grtChar;

for(int i=0;i<input_str.length;i++)

{

     if (input_str[i].length() < 6)

     {

              result.addValue(input_str[i]);

     }

     else if (input_str[i].length() < 11)

     {

                grtChar = input_str[i].substring(0,5) + "/" + input_str[i].substring(5,10);

                result.addValue(grtChar);

      }

     else 

                  result.addValue("");

}

Please find the attached screenshot.


Answers (1)

Answers (1)

smavachee
Active Contributor
0 Kudos

> If the length is less than 5 characters I need to take the five characters

?? Elaborate your query please.


> if the length is ten characters, after first five characters I need to put '\' symbol.

-Check length if its > 5

-Substring 0-4

-Set a constant '\"

-Concat

These are your requirements ?


Regards,

Sunil

Former Member
0 Kudos

Hi Sunil,

Thnx for your quick reply.

Done the changes graphically applying above logic and it is working.

Thanks,

Jayaram.g