cancel
Showing results for 
Search instead for 
Did you mean: 

UDF to identify if a field has hyphen in it or not

former_member188885
Active Participant
0 Kudos

Hi All,

I need some help in writing a UDF function for one of my mapping. I have a numeric field, which may sometimes have hyphen in it and sometimes not.

My requirement is to check if this field has a length of 9 and has no hyphens in it. Can this check be done using standard mapping or if a UDF needs to be written can you help me out with the UDF?

Regards,

Lavanya R

Accepted Solutions (1)

Accepted Solutions (1)

Harish
Active Contributor
0 Kudos

Hi Lavanya,

your mapping logic is not very clear. If you only want to check the field length without hyphen then use the below logic

Input --> index of (hyphen) --> Greater then (-1) --> Not

Then check the length of input field using length function in text.

regards,

Harish

former_member188885
Active Participant
0 Kudos

If the field's length is equal to 9 and contains NO hyphens, insert hyphens at positions 3 and 7.

If this condition is not satisfied then a mapping exception needs to be raised.

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Lavanya,

Here's a sample code:

Display queue with 12345679 as input

Display queue with 123456789 as input

Mapping test tab outputs are also the same

Regards,

Mark

Answers (1)

Answers (1)

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Lavanya,

Yes, this can be achieved with udf.

But first let's check with standard graphical functions, can you let us know according to your requirement, what should happen if the field has hyphens?

I am thinking, let's check whether the field has hyphens or not, if it is there then replace them with blank value, then find the length of the field is 9 or not. Please find below the screen shot for this:

Can you check this and let us know if this fulfill your requirement or not.

Regards

Vishnu