cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping question: How to only pass on a certain number of characters?

Former Member
0 Kudos

I'm mapping a phone number from the idoc to the XML file.

I only want to send the first 12 characters of a phone number.

For example, if the phone comes in as, "123-456-7890 Ext 44", I only want to send "123-456-7890".

I thought I could use the substring function(0 to 12), but I get an error if the phone is not exacly 12 characters long.

I need to be able to process the value of the phone number if it's:

Blank

Has text like "no phone".

1234567890

123-456-7890

Is there a std function to do this, or would I need a custom java udf?

Thanks,

jeff

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Jeff

check length and if is greater than 12 do substring else pass as it is.

Satish

Answers (3)

Answers (3)

agasthuri_doss
Active Contributor
0 Kudos

Jeff,

Are you able to resolve it by Luis Ortiz method.

Add TELF1 -


substring 0-12 -


to THEN

Add TELF1 to else.

TELF1 --Substring --THEN

Cheers

Agasthuri

Former Member
0 Kudos

Jeff,

you can write a UDF with the following conditions.

I am not so good at Java programming. Hence I am giving you the logic try to draft a UDF using Java.

for(i=0; i<=11; i++) //worst case you are interested in first 12 values in the incoming payload incl "-"

{

1. If the read character is one of the alphabets or "" do not pass //to take care of blank or no phone or NA

2. If the read character is - do not pass.

3. If the read value is digit, pass it

}

if the concatenated string == 10 then pass it to target field.

if concatenated string =="", do not pass or take corresponding action.

this ways, the "NA" or "no Phone" or "" will be filtered out

Hope its useful

Venkat.

Former Member
0 Kudos

hi jeff

You can use and UDF function , however you can mapping with standar function.

Map like this

Phone Number >> length >> greater than constant [12] >> IF >> (if length > 12 you use Substring else only pass the element)