cancel
Showing results for 
Search instead for 
Did you mean: 

Question regarding the If-then-else function

Former Member
0 Kudos

Hi folks ,

I have been constantly putting threads on this subject for the past day, hope it doesn't annoy any one here.

My scenario is really simple, and i am almost close to the solution, but there is just 1 thing missing and i know that is a very small thing, could be the context too. Hope some one can help by pointing it out>

Mapping:

In my source i have a header(0-unbounded) & detail(0-unbounded). At a given instant either header / detail will occur in source, depending on that the target node "response" will occur(0-n times)

i have achieved this in the mapping.

the problem is this:

Both the Header/Detail have a field in it called Sequence# which is mandatory and can occur only once in the Header/Detail node.

Now depending on what occurs: ie Header/Detail i need to map that particular seq# into my Target Respone's SEQ_#.

I have done the mapping for this and have done a standalone testing.

Mapping: Check if HEADER EXISTS, if yes? then map the HEADER.Seq# to TARGET.Seq#

Here are my findings:

Scenario1: 3 header nodes(No Detaili) each with a seq # in it. Out put 3 Target node each with 3 seq # in it.

Scenario2: 2 Detail Nodes(No header) each with a seq # in it. Output fails to produce the 2nd Target Structure's Seq# and Fails

When i look into the Display Queue in the mapping , i examine the iF-Then-Else function:

Since HEADER doesn't exist i c 1 Suppress in my If-Condition hence the if condition becomes FALSE., now since its false its supposed to map the seq# from my detail. (This case i have 2 ).

But in the output of the IF-Then Else, i get out only 1 seq # which is the 1st one,

What i am thinking is that the exists condition is giving out only 1 FALSE instead of 2, If there were 2 false from the exists then i would have had both the seq # in my output,

I hope my question is clear, Would appreciate anysort of help . And i apologize if I seem to be brigning up the same question over again experts.

I don't wnt to create a UDF for this matter because i know there is something i am not doing right,

Hank

Accepted Solutions (1)

Accepted Solutions (1)

former_member581827
Participant
0 Kudos

Hi,

Can you change the context of header to upper most level and check in display queue.

Regards,

Chandra.

Former Member
0 Kudos

Yes i have done this, thanks

This is my map:

Check if (1)Header.Seq# exists? if yes (2)Header.Seq# -> Target.Seq# else (3)Detail.Seq#->Target.Seq#

Context of 1 & 2 is the highest

Context of 3 is to Detail .

So in my Scenario 2, since Header never occurs, i am gettin only 1 Suppress. Which is what i thnk is the issue

Former Member
0 Kudos

Hi Jovani,

YOu can do like this. You can use a user defined function along with standard functions. I tested and it is working for me.

For the target root node map like this:

header-->OR --> exists --> target node

detail-->

and for seqence no. you can map like this:

seqno(header)>udf1> if --> then put sequno header --> else put seqno. detail

seqno(detail)

Regards,

---Satish

Former Member
0 Kudos

Sorry I could not give my udf in my last post.

Udf1:

Create a context udf and name it as RemoveSuppress. Take two input arguments a and b. Imports: java.*;

Add this code:

//write your code here

boolean found = false;

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

if (a<i>.equals(b[0])) {

found = true;

break;

}

}

if (found == true)

result.addValue("true");

else

result.addValue("false");

Then it should work.

Regards,

---Satish

Former Member
0 Kudos

Thanks Satish,

Answers (1)

Answers (1)

Former Member
0 Kudos

if ur target structure is


response-----------------1 to unbounded
  SEQ_#.

after testing the conditions 
use removeContext standard node function just  before mapping to *response* node
and use same condition u used for responce node but insted of removeContext function use
 splitByValue(each Value)  just before mapping to *SEQ_#.*