Page 1 of 1

Condition Checking

Posted: Mon May 25, 2009 7:58 pm
by ushasribandaru
Hi all,

Please any one help to suggest me on the looping.
Here is the requirement.

IF(Condition,RUN map1,IF(Condtition,
IF(condition,RUN( map2)&IF(condition,RUN(map3)))))

If the first If is true,it will call the map1.no need to check for the remaining conditions.
If the second If is true,then i need to check third and fourth IF conditions to call both map2 and map3.

I am using Websphere transformation Extender 8.2.0.2

I have one input file with multiple type of records.
each map is going to translate the each type of record from the input.

Thank You.

Re: Condition Checking

Posted: Thu May 28, 2009 4:50 pm
by rep
This does work;

IF(field="x", RUN("MAP1", PACKAGE(DATA),
IF(field="Y", RUN("MAP2", PACKAGE(DATA),
IF(field="Z", RUN("MAP3", PACKAGE(DATA) ) )

There are many ways to do this.

Let me ask though;

Are you saying that your input has 3 different types of records, and depending on which type of record it is, you would like to run a particular map....is that correct?

Re: Condition Checking

Posted: Fri May 29, 2009 12:14 am
by ushasribandaru
Yes ..that's correct

I have one file with header and message body
If(Field_header="aaa",call(map1),If(Field_header!="aaa",If(condition,call(map2)) and If(condition),call(map3))

From your condition
IF(field="Y", RUN("MAP2", PACKAGE(DATA),
IF(field="Z", RUN("MAP3", PACKAGE(DATA)

It will check for field="Y" if it's returns true then it won't check for the ( field="Z") condition as it's in else part.
For my scenarion,If the condition for second IF is TRUE then need to check both 3rd and 4th if conditions to call map3 and map4

IF{
Field_header="aaa"
call(map1)

IF{
Field_header!="aaa"

IF{
condition
call(map2)
}/*Third IF is Closed */

and

IF{
condition
call(map3)
}/*Fourth IF is Closed */
}/*Second IF is Closed */
}/*First IF is Closed */




[quote="rep"]This does work;

IF(field="x", RUN("MAP1", PACKAGE(DATA),
IF(field="Y", RUN("MAP2", PACKAGE(DATA),
IF(field="Z", RUN("MAP3", PACKAGE(DATA) ) )

There are many ways to do this.

Let me ask though;

Are you saying that your input has 3 different types of records, and depending on which type of record it is, you would like to run a particular map....is that correct?[/quote]

Posted: Fri May 29, 2009 8:23 am
by rep
I'm not sure if I'm reading your post correctly, but I'll give it a shot;


IF{ Field_header="aaa", call(map1)
IF{ Field_header!="aaa"
IF{ condition call(map2)


First, you don't need Field_header!="aaa"; you already asked IF Field_header="aaa". If the record makes it past "IF Field_header="aaa"", you already know that Field_header!="aaa". Know what I mean?

So what I THINK you want is;



IF{ Field_header="aaa", call(map1)
if(condition1, call(map2))
If(condition2),call(map3))
else,

PUT("EMAIL", -TO you@yourdomain.com -SUBJECT 'record in X system does not meet data structure', PACKAGE(THE RECORD ITSELF SO YOU CAN SEE IT))

Does that sound right? That may be how I handle it.

Still, with the little information I know, another method MAY BE to use partitioning, where rather then reading a record one by one, querying some field in it, you define each type of record in the file, and tell the map that every time it reads a record, it could be one type of many.

Like;

File
RecordGroup
RecordAAA
RecordBBB
RecordCCC


Where "Recordgroup" has partitioned set to "on" in the type tree. Then the same peice of code you where using for "condition 1", you put in the type tree. If the condition was field2=XXX, you put the "identifier" on in the type tree to Field 2, and put the component rule $="XXX". The map will read a record, see if it's RecordAAA. If it's not, it validates against RecordBBB. If that doesn't match, it validates against RecordCCC, and so on. There's information in the Type Tree designer guide, but better yet, if you have verions 7.5 or eariler, there section on it in the Tutorial, but if you're past the version, IBM, being the bloodthirsty, ultra-greed ridden company it is, removed it from shipping with the package. Oh, you can pay IBM for it, even though they didn't create it themselves, and the company that did offered it for free with the product. I hate them.