on 09-14-2016 3:18 PM
Hi
I will get the values in a field where i need to,
1. add if the value has duplication(ex: 18 occurs twice - add it and get 36)
2. in addition to 36, find the maximum of values in the queues and pass to target..
Regards
Jansi
Hi Jansi,
Can you give us an example?
Regards,
Praveen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Praveen
my idoc is structure is,
E1EDL24
Field1
FIeld2
ZZEMARAM
Qty
Stock
my requirement is,
Field2 and wty will come one time for each e1edl24,
but consider Field2 value and we need to count, and sum the corresponding qty..
Ex,
Field2 - 20
qty - 50
Field2 - 40
Qty - 60
Field2 - 30
Qty - 40
Fied2 - 40
Qty - 40
Here 40 in field2 comes many times when compare to other Field2 fields..
So based on Field2(40) i need to sum the qty like(60+40 = 100) and pass it to target.
Please help..
Regards
Jansi
Hi Jansirani!
Look at this thread with similar requirement:
http://scn.sap.com/message/16860717#16860717
Regards, Evgeniy.
Hi Jansirani,
Mapping:
UDF:
Execution Type : All Value Of Queue
public void sumByKey(String[] key, String[] value, ResultList keyResult, ResultList valueResult, Container container)
throws StreamTransformationException {
double qty = 0, valueDouble = 0;
boolean isFirst = true;
Map<String, Double> map = new HashMap<String, Double>();
for (int i = 0; i < key.length; i++) {
if (!key[i].equals(ResultList.CC)) {
valueDouble = Double.parseDouble(value[i]);
qty = (map.containsKey(key[i])) ? map.get(key[i]) + valueDouble : valueDouble;
map.put(key[i], qty);
}
}
for (Map.Entry<String, Double> mapEntry : map.entrySet()) {
if (isFirst)
isFirst = false;
else {
keyResult.addContextChange();
valueResult.addContextChange();
}
keyResult.addValue(mapEntry.getKey());
valueResult.addValue(mapEntry.getValue());
}
}
Test:
Regards,
Praveen.
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
7 | |
6 | |
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.