cancel
Showing results for 
Search instead for 
Did you mean: 

UDF

Former Member
0 Kudos

Hi,

All

Iam getting a string of 600 charecters in a Filed ,In that i need to fill the 5 fileds of target data. I wrote the UDF Given below.In the mapping UDF Desigh iam getting to pass 1filed , But in the target iam not getting the UDF Split to pass 5 fields(Iam getting only on) . Could guide to pass 5 fileds.

//write your code here

String Name.

//Debit Account

String s1 = s.substring(42,52);

//Instrument Number

String s2 = s.substring(85,95);

//Check Amount

String s3 = s.substring(111,130);

//Instrument Issue Date

String s4 = s.substring(165,173);

//Customer Reference No

String s5 = s.substring(189,204);

return s1;

return s2;

return s3;

return s4;

return s5;

Regards

Kumar

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Kumar,

No need to use UDF. Your Source is Single String and you need to populate five target fileds from the string.By using standarad Substring function you can acheive this.Use the same source field for all five times and give the exact length From and To to get the desired outputs for 5 target fields.

Cheers

Veera

Answers (5)

Answers (5)

aashish_sinha
Active Contributor
0 Kudos

Hi,

>>>> UDF Desigh iam getting to pass 1filed

As per as my knowledge, i don't think this program will give you 5 different values, because when you return a value in a program, then control shifts from program and it ignores rest of retuen statement.

So, thats why its returning one value.

instead of using the Java mapping, try solving it using Graphical mapping using substring , and map the output valur of ur string to target fields.

hope this will help you.

regards

Aashish Sinha

PS : reward points if helpful

nikhil_bose
Active Contributor
0 Kudos

use Adavance UDF and make your logic in that and change the context accordingly.

thanks

nikhil

Former Member
0 Kudos

YOu are using simple UDF.

Open your UDF, and chek the return type of it. It will be String...but in code you are returning 5 different fields(or substring), but ur UDF will only store one value...

You have to create the Adavance user function, and using the ResultList object u have to map the values in the target field.

*****************************

BUT Y U CREATED UDF?

you can use standard function called substring.

source filed -


substring---target filed.

So the same for all the filed..it will solve ur problem:)

Thanks

Farooq.

Former Member
0 Kudos

Hi Kumar,

U can try using SPLITBYVALUE node function to the output of yor UDF and then pass it to target field..

I think this can solve your problem..

Regards,

Pooja

Former Member
0 Kudos

HI,

Can u please use the STD substring function which is provided by XI.

substring

Returns a substring O for a string I. Use the dialog for the function properties to specify the position of the substring. Example: substring(“Hello”, 0,1) = “H”, means that the substring from Startindex 0 to Endindex 1 (not including position 1) is shown.

Refer the Function Category: Text for more information.

http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/frameset.htm

Thnx

Chirag