cancel
Showing results for 
Search instead for 
Did you mean: 

UDF or Standard function

Former Member
0 Kudos

Hi All,

My scenario is Soap to RFC . A field by name ,Number , value may get a whole number or a decimal value.

The length of the field is 18.

If the value is a whole number then it should be with leading Zeros

EX:

A) Input :1234 Output :000000000000001234

If the value is a decimal number and then the output should be as such

B) Input:123.45 Output:123.45

Could any one help me out,to find whether the input value is decimal or whole number

Thanks in Advance

Lavanya.B

Accepted Solutions (1)

Accepted Solutions (1)

former_member854360
Active Contributor
0 Kudos

You can use standard function with some logic combination of the below function,

FormatNum, Indexof,If-else,Equals

input----indexof(.)--------equals(-1)--------if-else(false)---------formatnum(18 zeros) --------->Target
                                                                     if-else(true)---------Target

Answers (1)

Answers (1)

anupam_ghosh2
Active Contributor
0 Kudos

Hi,

you can try this UDF


public static String checkEmptyField(String s) {
	
		try
		{
			if(s!=null)
			{
				s=s.trim();
			}
			try
			{
				s=new Integer(s).toString();
				int l=s.length();
				for(int i=0;i<18-l;++i)
				{
					s="0"+s;
				}
				
			}
			catch(NumberFormatException e)
			{
				s=new Double(s).toString();
			}
			
		}
		catch(Exception e)
		{
			return s;
		}
		return s;
	}

inputs ->1234,2.3,null

corrosponding outputs->000000000000001234,2.3,null

regards

Anupam