Skip to Content
0

UDF to pick only numeric part in input value in SAP PI

Nov 29, 2017 at 09:59 AM

48

avatar image

Hi Experts,

Mapping requirement is to pick the numeric part from input & populate it in the target field.

Say if in input we get value like 'Box 23' then output value should be '23'.

Eg:

Box 23 [Input] - 23 [Output]

Postfach 1261 [Input] - 1261 [Output]

Thanks,

Ramu.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

avatar image
Former Member Nov 29, 2017 at 10:05 AM
0

Hi Ramu,

try this in your UDF:

return var1.matches(“.*[0-9]{10}.*”);


or use this blog

The power of regular expressions in graphical mapping (XI)


Regards,

Alex

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Nov 29, 2017 at 07:04 PM
0

Hi Ramu,

You can use regex and delete non-digits.

str = str.replaceAll("\\D+","");
Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Xinjiang,Alexander,

Thank you for your reply.

My input queue and output queue of UDF should look like below:

Input queue:

Output queue:

Can you help with UDF.

Thanks,

Ramu.

input.jpg (6.6 kB)
output1.jpg (6.9 kB)
0