cancel
Showing results for 
Search instead for 
Did you mean: 

UDF to check the / and start from right side

Former Member
0 Kudos

Hi SAP Guru's

Can somebody please tell me how to write UDF in SAP PI 7.11 because I am new to PI and struggling in regards to UDF

I want to write the UDF which counts from right hand side and display the output if find any "/" symbol

Example

"........./MARK" or "........xyz/TESTING"

I want to extract the data MARK or TESTING so can somebody please write a code or alteast tell me how to write it in 7.11

and I am also looking for counter UDF , if anyone already wrote a code before then please forward it to me.

Thanks,

Iqbal

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Ucan try this:

Execution type: Single values.

Under Signature variable:

Argument var1 string

Code:

String str = var1.toString();

String a[] = str.split("/");

int len = a.length;

return a[len-1];

(len-1 is under brackets).

UDF IN PI7.1:

/people/william.li/blog/2008/01/02/sap-pi-71-mapping-enhancements-series-share-user-defined-functions

How to write UDF:

You can find so many useful links on SDN.

/people/rohit.kalugade/blog/2009/02/09/context-and-queue-in-message-mapping-udf-150-part2

http://wiki.sdn.sap.com/wiki/display/XI/UDFExecutionType-ContextandQueue.

Thanks

Amit

Edited by: AmitSri on May 9, 2010 12:51 PM

Former Member
0 Kudos

Hi Amit,

Thank you for your reply but the code is not working and I am getting this error

Please reply me back urgently

com/sap/xi/tf/_mm_payext2002_to_iso20022_CustomerCreditTransferInitiationCiti_.java[1972] cannot find symbol symbol : method a(int) location: class com.sap.xi.tf._mm_payext2002_to_iso20022_CustomerCreditTransferInitiationCiti_ return a(len-1);

^

Note: /usr/sap/DGX/DVEBMGS66/j2ee/cluster/server0/./temp/classpath_resolver/Map78bd50805c0c11df942c7a3a33adcd0c/source/com/sap/xi/tf/_mm_payext2002_to_iso20022_CustomerCreditTransferInitiationCiti_.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. 1 error

I believe we need to define return as well please check below is the code which I wrote on 7.11

String str = var1.toString();

String a[] = str.split("/");

int len = a.length;

return a(len-1);

Former Member
0 Kudos

Hi,

Correct this step: return a(len-1);

Put len-1 under square brackets like [ ] instead of ().

Thanks

Amit

Former Member
0 Kudos

Can somebody please write 3 UDF's for me.

1. From right hand side of the field E1IDKU3-INSTEXT1, all characters upto reaching of special character "/". This is because the field may appear like "/ /MAIL" or simply "/ /". In the first case it is expected to take data MAIL and in second case blank.

Amit you resolved my issue, Full Marks to you for this one.

2. E1EDKA1-STRAS & STRS2, E1EDKA1-ORT01, PSTLZ (Qualifier : AG) . Split the full data into three lines of 35 characters each

not sure whether I need to write UDF or Splitbyvalue will work for this.

3. Count the total number of Idocs that are going to be included into the file as one idoc represents one payment instruction

not sure whether I need to write UDF or count function of Arithmetic will work.

Can somebody please reply me urgently.

Former Member
0 Kudos

Hi Amit,

I am getting this error when ever I click on mapping

the length 0 of the array 'sortedFunctionKeys' is not equal to the number 1 of functions.

Please let me know if you know the solution of this problem.

Please also reply to my other 2 UDF issues as well.

Answers (3)

Answers (3)

Former Member
0 Kudos

Ucan also try this:

Execution type: Single values.

Under Signature variable:

Argument var1 string

Code:

String s = var1

return (s.substring(s.lastIndexOf("/")+1));

Former Member
0 Kudos

Hi guys.

Last month i had a tour to Uk and i got my checkin from http://www.checkmein.eu/, Its service is really good.

Earlier i faced many problems like standing for long time in queues and not getting my preferd seat.

Shabarish_Nair
Active Contributor
0 Kudos