cancel
Showing results for 
Search instead for 
Did you mean: 

udf code

Former Member
0 Kudos

hi i m mapping

header to buyerno

for the first occurence of header one the buyerno should be 1

and for the second occurance two and son so i developed a udf

//write your code here

for(int i=0;i < a.length; i++)

{

result.addValue( a<i> );

}

but i m unable to get the solutio

and wen i m writing i instead of a<i> it is showing error

help me out

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Can you give an example of source and expected target msg struct?

Regards,

Jai Shankar

Former Member
0 Kudos

salesorder mssg details salesordersummary

customer buyer

name buyerno

order name

id orderaccount

amount ordersum

summary

totalorders

totalamount

i found this examplein xi materail and everyt thing i got right except for the buyer no

im apped buyerno to customer and added the udf i mentioned above in b/w to get

dynamically the buyer no

in the result as of now i m getting nothing in buyer no space

Former Member
0 Kudos

Hi

If your requirement is 1 first time and 2 in the second time then take the result.addValue(i+1)

Before that you would have to change the context of source to its parent

or use removecontext, after UDF use splitbyvalue.

Chilla..

Former Member
0 Kudos

hi

chandra i m getting the following error wen i m using ur suggestion

D:/usr/sap/TXI/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapc8c2b311cdfb11dbbb520019b909a584/source/com/sap/xi/tf/_map1_.java:86: addValue(java.lang.String) in com.sap.aii.mappingtool.tf3.rt.ResultList cannot be applied to (int)

result.addValue(i+1);

the code that i used is

for(int i=0;i < a.length; i++)

{

result.addValue(i+1);

}

Former Member
0 Kudos

do as i said above copy the code and delete te code you have in ur UDF and paste this

Former Member
0 Kudos

Hi,

please change

result.addValue(i+1);

to

result.addValue(toString.valueOf(i+1));

Chilla..

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

In your code you are taking the array of string right, so it is not a , write "a(i)".

If your requirement is 1 first time and 2 in the second time then take the result.addValue(i+1)

Before that you would have to change the context of source to its parent

or use removecontext, after UDF use splitbyvalue.

Regards

Chilla..

Former Member
0 Kudos

Hi,

What are you trying?

If you need "buyerno" to be 1, then 2 etc try UDF like this


for(int j=0; j<a.length; j++){
result.addValue(String.valueOf(j+1));
}

Give input has Header.

See to that the occurence of buyerno is unbounded.

Regards,

P.Venkat

Former Member
0 Kudos

hi venkat i want exactly as u told

but i m getting errors wen do the code u suggested

/write your code here

for(int i=0;i < a.length; i++)

{

result.addValue( String.valueOf( i+1) );

}

}

errors as below

Messages:

10:26:55 Start of test

Source code has syntax error:

D:/usr/sap/TXI/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map2f212bb2cdfb11dbbe700019b909a584/source/com/sap/xi/tf/_map1_.java:84: 'class' or 'interface' expected

public static void main(String[] args) throws Exception{/!_$ClNRep_/_map1_ st = new /!_$ClNRep_/_map1_(); st.checkParams=false;st.testExecute(args); }

^

D:/usr/sap/TXI/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map2f212bb2cdfb11dbbe700019b909a584/source/com/sap/xi/tf/_map1_.java:85: 'class' or 'interface' expected

}

^

D:/usr/sap/TXI/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map2f212bb2cdfb11dbbe700019b909a584/source/com/sap/xi/tf/_map1_.java:86: 'class' or 'interface' expected

^

3 errors

10:26:56 End of test

Former Member
0 Kudos

jaya,

copy the following and remove all the prevousie code.

//write your code here

for(int i=0;i < a.length; i++)

{

result.addValue( toString.valueOf(i+1) );

}

Regards

Sreeram.g.reddy

Message was edited by:

Sreeram Reddy

null

Former Member
0 Kudos

Deleted content