cancel
Showing results for 
Search instead for 
Did you mean: 

0 to Unbounded

Former Member
0 Kudos

I have a scenario where I am taking one source file and based on certain conditions writing one or two target files... Now I have it configured quite nicely the only problem is that even when the condition is to only write one file the second file although blank is still written and coming with the values.

<xml version="1.0" encoding="UTF-8" ?>

<ns1:Messages xmlns:ns1="http://sap.com/xi/XI/SplitandMerge">

<ns1:Message1/>

</ns1:Messages>

I noticed that these only appeared once I started to change the occurence of my message type in the message mapping to 0 to unbounded (NOTE I HAVENT YET CHANGED THE OCCURENCE IN MY INTERFACE MAPPING).

I had to include this header in my outbound payload in order for me scenario to work annd now I it is always coming even when thhe message type is not written... Is there a way around this??

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

In outbound side while executing the scenario, dont give <messages>, <message1> elements. Just remove those two elements from the payload and give the input.

Regards,

P.Venkat

Former Member
0 Kudos

when I do this then the targets are not mapped at all why is this? Could it be that I need to change the occurences in the interfacce mapping?

Former Member
0 Kudos

Hi,

first make your msg mapping and interface mapping have the same occurance of 0..unbounded

yes, use your source condition on source node which decide whether second target file needs to be generated.....then output of this condition should be either true or false.......then use creatif function......then map it to target message1 node.

Thanks,

Rajeev Gupta

Former Member
0 Kudos

OK I have nearly solved it thanks to rajeev...

One problem remains....

My conditions only work if it falls within the first occurence of the item...

Basically my conditions are createif and it is to created if Error = True in one of my items...

So this works when there is an error in the first item but does not when an error occurs in like the 2nd or 3rd iitem...

I think I need a function to sort or look through the entire queue to see if error occurs anywhere in the queue because at the moment it is only looking at the first line of the queue so even if an error occurs later if there is no error in the first item then the target will not get written correctly...

Could someone help? Is there a standard function for this? or Could someone give me a UDF that can do this?

by the way I have already played with the context changes.....

So basically I want a function that can look through an entire queue and see whether the value True occurs anywhere... if it does occur then the result should be True else False

Former Member
0 Kudos

Hi,

ok.....after your conditon and before creatif.........put a sort function and put it in descending order......so it will be like below:

conditon -> sort ->creatif -> target

Thanks,

Rajeev Gupta

Former Member
0 Kudos

I thought I did...

I need a function to look through the entire queue of field Error.

If it finds the Value True anywhere in the Queue then it has to return the result True

If it does not find the Value True then it returns Result False

Former Member
0 Kudos

hi ,

pass this as input to ur UDF as context.

in UDF take the input values int to string array and loop the string array and check if it equals to true or until end of the all values and stores this values into result string and pass it output which will have true or flase.

Regards

Sreeram.G.Reddy

Former Member
0 Kudos

Thanks again Rajeev... I think that should work... but the problem is that our mock up system is only SP9 and hence doesnt have a sort function....

I think this will work when it comes to our development system which is PI7 but we have to do the Proof of Concept on the SP9 system...

Could someone please give me a UDF that does this function?

Former Member
0 Kudos

pass this as input to ur UDF as context.

in UDF take the input values int to string array and loop the string array and check if it equals to true or until end of the all values and stores this values into result string and pass it output which will have true or flase.

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

{

if (input<i>== true)

{

string str= "true";

list .addValue(str);

}

}

str= "flase";

list .addValue(str);

more of this sort not exactly the same code

Regards

Sreeram.G.Reddy

Message was edited by:

Sreeram Reddy

Former Member
0 Kudos

Hi,

create a UDF with one input argument String a[] and type context..

in UDF write:

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

if (<b>a(i)</b> =="true")

result.addValue("true");

}

result.addValue("false");

Note <b>a(i)</b> is a[] with i in it.

Thanks,

Rajeev Gupta

Message was edited by:

RAJEEV GUPTA

Former Member
0 Kudos

what do you mean type context? Do you mean Cache entire queue?

Former Member
0 Kudos

while creating a UDF when you enter name of the UDF below you have option their check that option of context and look into my code .

please reward points

Regards

Sreeram.G.Reddy

Former Member
0 Kudos

Hi,

When you create a udf, then it asks for what type of udf will it be for cache:

value

context

queue.

you will have to use context because you will send a array of input data and you will output a resultlist variable.

Thanks,

Rajeev Gupta

Message was edited by:

RAJEEV GUPTA

Former Member
0 Kudos

HI,

Did yu checked ????

See here condition is it should chekc the value in the entire queue if it is existed the true or fales..

--first you have to change the input node context to its parent node.. (The input node occurrences should be 0..unbound)

--UDF -- iam checking the input list with the first value..

Input node -- (with change context)-- UDF -- target node..

String XYZ = node[0];

boolean ret = true;

for (int i=0;i , node.length;i++){

if (!node<i>.equals(XYZ)){

ret = false;

}else

{

ret = true;

}

result.addValue(ret);

}

Former Member
0 Kudos

Rajeev when I use your code I get illegal start of expression... about the if clause AND it is telling me that ')' is expected semewhere near the if clause?

Former Member
0 Kudos

Hi ,

can you just paste your code here.. one thing that a(i) is a[ i ].

Thanks,

Rajeev Gupta

Message was edited by:

RAJEEV GUPTA

Former Member
0 Kudos

Source code has syntax error: /usr/sap/MXA/DVEBMGS68/j2ee/cluster/server0/./temp/classpath_resolver/Map4af440a0c32111db9dd100306e0359e9/source/com/sap/xi/tf/_MMT_INT_RECV_ERROR_.java:87: cannot resolve symbol symbol : method length () location: class java.lang.String[] for (int i=0; i<a.length(); i++){ ^ /usr/sap/MXA/DVEBMGS68/j2ee/cluster/server0/./temp/classpath_resolver/Map4af440a0c32111db9dd100306e0359e9/source/com/sap/xi/tf/_MMT_INT_RECV_ERROR_.java:88: cannot resolve symbol symbol : method a (int) location: class com.sap.xi.tf._MMT_INT_RECV_ERROR_ if (a(i) =="true") ^ 2 errors

This is the error I get and this is the code

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

if (a(i) =="true")

result.addValue("true");

}

result.addValue("false");

Former Member
0 Kudos

Hi ,

Try this way...

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

if (a(i).equals("true"))

result.addValue("true");

}

result.addValue("false");

Regards,

Former Member
0 Kudos

hello,

make the following changes

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

if (a(i) =="true")

copy the below code

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

if (a<i> =="true")

Regards

Sreeram.G.Reddy

Former Member
0 Kudos

Hi,

try below:

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

if (a[ i ] =="true")

Thanks,

Rajeev Gupta

Former Member
0 Kudos

Rajeev I now get

/usr/sap/MXA/DVEBMGS68/j2ee/cluster/server0/./temp/classpath_resolver/Mapecfd01b0c32211dbc8ac00306e0359e9/source/com/sap/xi/tf/_MMT_INT_RECV_ERROR_.java:91: illegal start of expression result.addValue("false");> ^ /usr/sap/MXA/DVEBMGS68/j2ee/cluster/server0/./temp/classpath_resolver/Mapecfd01b0c32211dbc8ac00306e0359e9/source/com/sap/xi/tf/_MMT_INT_RECV_ERROR_.java:91: ';' expected result.addValue("false");> ^ 2 errors

Im sorry to be such a pain but I really need to get this working please help...

Former Member
0 Kudos

OK Rajeev I had > in the code which was casuing problems....

Thank you... I will now see if the code sorts the values

Former Member
0 Kudos

Ok even though I had true in the queue it only returned the value false?

Former Member
0 Kudos

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

{

if (a<i>.equals("true"))

{

String str="true";

result.addValue(str);

}

}

str="false";

result.addValue(str);

please make the following changes

Regards

Sreeram.G.Reddy

Former Member
0 Kudos

Hi,

can you tell me the declaration of your function means the first line of your function which XI genreted for your UDF.....have you selected context in declaring UDF...

Thanks,

Rajeev Gupta

Former Member
0 Kudos

By the way I am on SP9 so the advanced UDF only gives you the option to Cache the entire Queue or not?

Former Member
0 Kudos

Hi,

just change the if statement to below:

if (a[ i ].equals("true"))

save UDF and check output now.

Thanks,

Rajeev Gupta

Message was edited by:

RAJEEV GUPTA

Message was edited by:

RAJEEV GUPTA

Former Member
0 Kudos

Rajeev Thanks soo Much... it now works as expected and I think my mapping and scenario will also work as expected

Former Member
0 Kudos

Hi,

Cheers.......:)))))))))

Thanks,

Rajeev Gupta

Answers (3)

Answers (3)

Former Member
0 Kudos

HI,

Explain clearly your requirement ...

Regards

Chilla..

Former Member
0 Kudos

Hi,

map Messge 1 node to such a condition from source system which determines that whether the second target file needs to be generated......after this condition in graphical mapping put a creatif function .....then map it to Message1 node of target msg.

Then your second target file will not be generated.

Thanks,

Rajeev Gupta

Message was edited by:

RAJEEV GUPTA

Former Member
0 Kudos

OK so if I understand you correctly

I should take the Message 1 node from the target side and map it with the exact same conditions that I have on my message type. But the DIFFERENCE here is that after the conditions and before the message 1 node I have a createif funtion?

prabhu_s2
Active Contributor
0 Kudos

have u changed the occurence in the MM? can u post a sample payload and breif more on ur scenario