on 11-27-2008 5:11 AM
Hi Experts,
Scenario : IDOC to File
When any of the repeated source segment value has Name = "WEL" then target segment will occur once, else as many time as that of source segment.
How to do this mapping?
Regards
Sara
Hi,
Name--->Split By Value(Value change)--->Collapse Context---->Targetsegment
The above mapping removes the repeating segment and produces a single target for those segments provided the input is in sorted order.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gaurav,
It is not working.
I need the output like below.
Case 1: If Name = WEL then only one target segment.
Source Data:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT1_N xmlns:ns0="http://tec.com/pymnt">
<Details>
<Name>WEL</Name>
<Date/>
<Time/>
</Details>
<Details>
<Name>SE</Name>
<Date/>
<Time/>
</Details>
</ns0:MT1_N>
Target Data:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT2_N xmlns:ns0="http://tec.com/pymnt">
<Details>
<Name>WEL</Name>
<Date/>
<Time/>
</Details>
</ns0:MT2_N>
Case 2: ( If Name = !WEL then as many of source to target segment.)
Source Data:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT1_N xmlns:ns0="http://tec.com/pymnt">
<Details>
<Name>SA</Name>
<Date/>
<Time/>
</Details>
<Details>
<Name>RE</Name>
<Date/>
<Time/>
</Details>
</ns0:MT1_N>
Target Data:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT2_N xmlns:ns0="http://tec.com/pymnt">
<Details>
<Name>SA</Name>
<Date/>
<Time/>
</Details>
<Details>
<Name>RE</Name>
<Date/>
<Time/>
</Details>
</ns0:MT2_N>
Please let me know, how to do this mapping?
Regards
Sara
Hi,
Use two If (without else) conditions and one If (with else)..
First If (without else) will chekc whether your Name = WELL...second If(without else) will check whether Name != WELL...use a constant and EqualS function for both these checks...a boolean not has also to be used.
Use the output of first If (without else) as input to If-Else....else part will come from second If(without else)....
Now map this to the Details node.....
Alternately (Preferred by me):
Also since your Details node seems to be 0...unbounded you can use the Duplicate Subtree option to create two different Details node and then impose the conditions (= WELL, !=WELL) separately...it will help....
Regards,
Abhishek.
Edited by: abhishek salvi on Dec 4, 2008 12:08 PM
Hi Sara,
A small change..This works perfectly
for the first case the udf is changed to
public void check(String[] a,ResultList result,Container container)
{
//write your code here
int i = 0;
int j = 0;
for( i = 0; i != a.length ; i++)
{
if(a<i>.equals("WE"))
{
j = 0;
k++;
break;
}
else
j = 1;
}
result.addValue(Integer.toString(j));
}
Here k is a global variable initialized to 0.
second case
Name>check1->createif--->Details
public void check1(String[] a,ResultList result,Container container)
{
{
if((!(a<i>.equals("WE"))) && k == 0)
{
j = 1;
result.addValue(Integer.toString(j));
}
}
}
Change the context of name to higher level
Hi
The below solution works 4r ur input
Duplicate the target node Details
Name-->check-->not--->Createif--->Details(1st target node)
Create udf check(use cache parameter as context)
public void check(String[] a,ResultList result,Container container)
{
int i = 0;
int j = 0;
for( i = 0; i != a.length ; i++)
{
if(a<i>.equals("WE"))
j = 0;
else
j = 1;
}
result.addValue(Integer.toString(j));
}
Name--->Name
date--->date
time--->time
for second case
Name----------------->equalsS------>not---->createif---->Details(2nd target node)
Constant[WE]------>
Change the context of name here to its higher level.
Map other fields correspondingly..
Hope u can understand..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
u can use split by value and select the option value change so when there is a value change in ur source element only then ur target segment will be created.
chirag
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Use UseOneAsMany for only one occurance.
look use of this point 7
/people/sravya.talanki2/blog/2005/12/08/message-mapping-simplified-150-part-ii
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> When any of the repeated source segment value has Name = "WEL" then target segment will occur once, >else as many time as that of source segment.
for first condition, try using CollapseContext...
for second condition; you can use UseOneAsMany.. ..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.