on 01-11-2012 8:10 AM
Hi gurus!
My input structure is
<IN_MT>
<SHIPMENT>
<SHIPMENT></SHIPMENT>
<DELIVERY></DELIVERY>
</SHIPMENT>
</IN_MT>
I need to remove duplicates like this.
INPUT:
<IN_MT>
<SHIPMENT>
<SHIPMENT>11</SHIPMENT>
<DELIVERY>123</DELIVERY>
</SHIPMENT>
<SHIPMENT>
<SHIPMENT>11</SHIPMENT>
<DELIVERY>456</DELIVERY>
</SHIPMENT>
<SHIPMENT>
<SHIPMENT>33</SHIPMENT>
<DELIVERY>678</DELIVERY>
</SHIPMENT>
</IN_MT>
OUTPUT:
<OUT_MT>
<SHIPMENT>
<SHIPMENT>11</SHIPMENT>
<DELIVERY>123</DELIVERY>
<DELIVERY>456</DELIVERY>
</SHIPMENT>
<SHIPMENT>
<SHIPMENT>33</SHIPMENT>
<DELIVERY>678</DELIVERY>
</SHIPMENT>
</OUT_MT>
Here is my UDF RemoveDuplicates:
Vector vProd = new Vector();
int i;
for (i =0;i < var1.length;i++)
if(!vProd.contains(var1<i>))
vProd.add(var1<i>);
Collections.sort(vProd);
for(i=0;i<vProd.size();i++)
result.addValue((String)vProd.get(i));
Here is my mapping:
IN_MT -
> OUT_MT
SHIPMENT -
> SHIPMENT
SHIPMENT -
> RemoveContext ---> RemoveDuplicates -
> SplitByValue -
> SHIPMENT
DELIVERY -
> DELIVERY
DELIVERY -
> DELIVERY
I got:
<OUT_MT>
<SHIPMENT>
<SHIPMENT>11</SHIPMENT>
<DELIVERY>
<DELIVERY>123</DELIVERY>
</DELIVERY>
</SHIPMENT>
<SHIPMENT>
<SHIPMENT>22</SHIPMENT>
<DELIVERY>
<DELIVERY>456</DELIVERY>
</DELIVERY>
</SHIPMENT>
<SHIPMENT>
<DELIVERY>
<DELIVERY>678</DELIVERY>
</DELIVERY>
</SHIPMENT>
</OUT_MT>
What's wrong?
u can achieve ur req using standard functions only..
chk this:
SHIPMENT--REMOVECONTEXT---sort---splitbyvalue(value change)---collapse context----SHIPMNET (node)
SHIPMENT--REMOVECONTEXT---sort---splitbyvalue(value change)---collapse context---splitbyvalue(each value)-SHIPMNET (element)
SHIPMENT--REMOVECONTEXT---
-----------sortbykey----------------------------------------\
DELIVERY--REMOVECONTEXT--- \
------formatByexample------DELIEVERY
/
SHIPMENT--REMOVECONTEXT---sort---splitbyvalue(value change)--
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Amit,
Now I got only first shipment:
<OUT_MT>
<SHIPMENT>
<SHIPMENT>11</SHIPMENT>
<DELIVERY>123</DELIVERY>
<DELIVERY>456</DELIVERY>
</SHIPMENT>
This segment is missing:
<SHIPMENT>
<SHIPMENT>33</SHIPMENT>
<DELIVERY>678</DELIVERY>
</SHIPMENT>
</OUT_MT>
To avoid misunderstandig I changed my structure field SHIPMENT to SHIPMENT_NUM:
<SHIPMENT>
<SHIPMENT_NUM></SHIPMENT_NUM>
<DELIVERY></DELIVERY>
<DELIVERY></DELIVERY>
</SHIPMENT>
Can you please correct you mapping due to this change
hi ,
you need to see Fig.31 and Fig.32 in below link(equal to ur requirement) and same as what was i posted previousaly.
http://www.saptechnical.com/Tutorials/XI/NodeFunctions/Page7.htm
thanks,
the mapping logic wont change apart from the source/target element/node names
chk this:
SHIPMENT_NUM--REMOVECONTEXT---sort---splitbyvalue(value change)---collapse context----SHIPMNET
SHIPMENT_NUM--REMOVECONTEXT---sort---splitbyvalue(value change)---collapse context---splitbyvalue(each value)-SHIPMNET_NUM
SHIPMENT_NUM--REMOVECONTEXT---
-----------sortbykey----------------------------------------\
DELIVERY--REMOVECONTEXT--- \
------formatByexample------DELIEVERY
/
SHIPMENT_NUM--REMOVECONTEXT---sort---splitbyvalue(value change)--
Solved!
Thanks all!
Edited by: Dani_K on Jan 11, 2012 3:08 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi.
Try this.
SHIPMENT( change context)->SplitbyValue(ValueChanged)->CollapseContext-->Shipment (Node)
SHIPMENT( change context)>SplitbyValue(ValueChanged)->CollapseContext->SplitbyValue (each Value)--->Shipment (Node)
***SHIPMENT = Element
***( change context) = Node.
Delivery ( change context)--->SplitbyValue(ValueChanged)-->Delivery
This will be solved your problem
Regards.
hi dani,
dont need to write any udf . that is very simple by using NODE Func.
SHIPMENT -> remove context -> Sort -> splitByValue(valuue change) ->collapse context ->splitByValue(each value) -> Shipment
delivery ->
shipment -> remove context-> Sort -> splitByValue(valuue change) -> formatBYExample ->DELIVERy.
if you have any doubt , just see fig32
http://www.saptechnical.com/Tutorials/XI/NodeFunctions/Page7.htm
thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
It'll be little difficult removing duplicates and keeping the context as it is with exixting standard functions. Removing duplicates irrespective of context changes, we can do with available functions. Please try with this UDF code which may help you...
source>sort>UDF-->Target
execution type of UDF is Allvalues of a context.
public void UDF(String[] var1, ResultList result, Container container) throws StreamTransformationException{
ArrayList aList = new ArrayList();
aList.add(var1(0));
result.addValue(var1(0));
for(int i=1; i<var1.length; i++){
if(aList.contains(var1(i)))
continue;
else{
aList.add(var1(i));
result.addValue(var1(i));
}
}
}
regards,
ganesh.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ganesh, thanks for help.
There are some errors if UDF Code:
Function Remove_Duplicates, Line 2:
cannot find symbol
symbol : method var1(int)
location: class com.sap.xi.tf._RSHAR_SHIPMENTS_FILE_TO_IDOC3_MM_
aList.add(var1(0));
^
Function Remove_Duplicates, Line 3:
cannot find symbol
symbol : method var1(int)
location: class com.sap.xi.tf._RSHAR_SHIPMENTS_FILE_TO_IDOC3_MM_
result.addValue(var1(0));
^
Function Remove_Duplicates, Line 6:
cannot find symbol
symbol : method var1(int)
location: class com.sap.xi.tf._RSHAR_SHIPMENTS_FILE_TO_IDOC3_MM_
if(aList.contains(var1(i)))
^
Function Remove_Duplicates, Line 9:
cannot find symbol
symbol : method var1(int)
location: class com.sap.xi.tf._RSHAR_SHIPMENTS_FILE_TO_IDOC3_MM_
aList.add(var1(i));
^
Function Remove_Duplicates, Line 10:
cannot find symbol
symbol : method var1(int)
location: class com.sap.xi.tf._RSHAR_SHIPMENTS_FILE_TO_IDOC3_MM_
result.addValue(var1(i));
User | Count |
---|---|
86 | |
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.