cancel
Showing results for 
Search instead for 
Did you mean: 

UDF for iDoc

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.

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.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Solved Myself

Former Member
0 Kudos

Solved Myself

former_member181962
Active Contributor
0 Kudos

For your first requirement, try this:

String text = line.substring(line.lastIndexOf('/') + 1);
retrun text.

Regards,

ravi

Shabarish_Nair
Active Contributor
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.

>

use a UDF.

psedo code is

len = complete length of string

a = last index of ("/")

subString(a+1, len);

> 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.

>

You will need a UDF here

> 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.

http://wiki.sdn.sap.com/wiki/display/XI/CountofRecords-%27Countontheeasiestway+through%27

Former Member
0 Kudos

Hi Sir,

Thank you so much for your quick reply but I am new to UDF and don't know much about it.

One of the guy from sdn wrote a code but when I tried that code, I am getting error

Code

Execution type: Single values.

Under Signature variable:

Argument var1 string

String str = var1.toString();

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

int len = a.length;

return a(len-1);

Error

com/sap/xi/tf/_mm_xx_to_xx_xx_.java1972 cannot find symbol symbol : method a(int) location: class com.sap.xi.tf._mm_xx_to_xx_xx_ return a(len-1);

^

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

Please reply me urgently and if possible could you also write a code for me for the 2nd one as well.

Thanks

Former Member
0 Kudos
String str = var1.toString();
String a[] = str.split("/");
int len = a.length;
return a(len-1);

Use

"return a[len-1]"

in the above code instead to "return a(len-1)".

Former Member
0 Kudos

Thanks Swetha

My first problem is resolved by replacing the () to [], could you please reply to my other 2 udf.

I will give you full marks for the resolution.

Former Member
0 Kudos

Hi Reedy,

I am getting this error now when ever I clicked on any mapping item

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

Please reply me ASAP if you know the solution of this problem and if possible please reply me regarding my other 2 UDF issues.

former_member181962
Active Contributor
0 Kudos

Try this code for your second problem:

Make the UDF Cache selected to "Queue"

int textLen = input.length();
			if (textLen > 35) {
				int si = 0;
				int ei = 35;

				while (si < textLen) {
					if (ei > textLen) ei = textLen;

					result.addValue(input.substring(si, ei));
					si = ei;
					ei = ei + maxSize;
				}
			}
			else {
				result.addValue(input);
			}
		}

Regards,

Ravi

Former Member
0 Kudos

Hi Ravi,

Thank you for your reply and code but unfortunately it is not working could you please check whether or not I am doing something wrong.

Name:Splitlength

Title:Splitlength

Category: All Values of Queue

Signature Variables: Argument: input : String

Result: result : ResultList

public void Splitlength(String[] input, ResultList result, Container container) throws StreamTransformationException

{

int textLen = input.length();

if (textLen > 35)

{

int si = 0;

int ei = 35;

while (si < textLen)

{

if (ei > textLen) ei = textLen;

result.addValue(input.substring(si, ei));

si = ei;

ei = ei + maxSize;

}

}

else

{

result.addValue(input);

}

Errors

Source text of object Message Mapping: mm_xx

java[2710] cannot find symbol symbol : method length() location: class java.lang.String[] int textLen = input.length(); ^

java[2717] cannot find symbol symbol : method substring(int,int) location: class java.lang.String[] result.addValue(input.substring(si, ei)); ^

java[2719] cannot find symbol symbol : variable maxSize location: class ei = ei + maxSize; ^

java[2719] operator + cannot be applied to int,maxSize ei = ei + maxSize; ^

java[2719] incompatible types found : <nulltype> required: int ei = ei + maxSize; ^ Note:

java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. 5 errors

Please solve this problem ASAP if possible.