...
Code Block | ||||
---|---|---|---|---|
| ||||
partiesGroupTags = new Array( 448, 447, 452, 2376 ); partiesNoCount = getNumField(453); partiesGrp = getGroup(453); partiesNewSize = partiesNoCount; print("[DEBUG] Initial message has " + partiesNoCount.toString() + " parties"); // for debugging if (0 < partiesNoCount && isGroupValid(partiesGrp)) { var i = 0; while (i < partiesNoCount && partiesNewSize > 0) { var partyRole = getNumField(partiesGrp, i, 452); if (partyRole == 17) { // Copy the last block to this position field by field if it exist for (var n=0; n < partiesGroupTags.length; ++n) { if( i == partiesNewSize-1) // is this is the last block { removeField(partiesGrp, i, partiesGroupTags[n]); } else { // partiesNewSize-1 - reference to the last block. lastBlockField = getStringField(partiesGrp, partiesNewSize-1, partiesGroupTags[n]) currentBlockField = getStringField(partiesGrp, i, partiesGroupTags[n]) print("[DEBUG] Current value of Field " + partiesGroupTags[n].toString() + " :" + currentBlockField + " Last Field: " + lastBlockField ); // for debugging if ( lastBlockField != null && currentBlockField != null) // swap values with last group and clean it. { swapFields(partiesGrp, partiesNewSize-1, partiesGroupTags[n], partiesGrp, i, partiesGroupTags[n]); removeField(partiesGrp, partiesNewSize-1, partiesGroupTags[n]); } else if ( lastBlockField != null) { setStringField(partiesGrp, i, partiesGroupTags[n], lastBlockField ); // assumed only field that can be converted to string can be absent } else // currentBlockField != null and should be removed. { removeField(partiesGrp, i, partiesGroupTags[n]); } } } --partiesNewSize; print("[DEBUG] Removed party block #" + i.toString() + " New parties size = " + partiesNewSize.toString() ); // for debugging // Do not increment i because copied block could have partyRole = 17 and should be rechecked. } else { ++i; } } if (partiesNewSize > 0) { setNumField(453, partiesNewSize); } else // remove parties if there are no entries; { removeField(453); } print("[DEBUG] New parties size = " + partiesNewSize.toString()); // for debugging } |
Info |
---|
Messages with the same TradeReportID (571) and PartyID (448) tags are considered as duplicates and are filtered. For changing this behavior, KeyFields in History configuration should be modified/extended |
Example of transformation
...