cancel
Showing results for 
Search instead for 
Did you mean: 

Maintain Constant length at target field

Former Member
0 Kudos

Hi,

I have one requirement in mapping.

One of my input field length is 8 and i need to maintain some conditions here.

If the incoming field comes 4 digits then i need to add 4 zeroes before to that field and send to target.

for eg., inut field : 1234 then target should be : 00001234

If the field is coming morethan 8 digits then it should read last 8 digits

for eg., inut field : 123456789 then target should be : 23456789

Please help me how can i maintain this.

Kind Regards,

Y.Raj.

Accepted Solutions (1)

Accepted Solutions (1)

GabrielSagaya
Active Contributor
0 Kudos

Please use the following udf for your requirement

function myudf(String a, Container container)
{
int len = a.length();
String resut="";
if (len < 8)
{
int sub = 8 - len;
for (int i=0;i< sub;i++)
result=result+"0";
result=result+a;
}
else
{
result=a.substring(len-8,len);
}
return result;
}

Former Member
0 Kudos

Thanks a lot..

It's working fine.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi ,

You can write the UDF ,

Regards,

B.Jude