public String splitPallet(String oldSSCC, BigDecimal splitQuantity)
{
String result = "";
JDBPallet p = new JDBPallet(getHostID(), getSessionID());
JEANBarcode bc = new JEANBarcode(getHostID(), getSessionID());
p.setSSCC(oldSSCC);
if (p.getPalletProperties())
{
if ((splitQuantity.compareTo(BigDecimal.ZERO) > 0))
{
if (splitQuantity.compareTo(p.getQuantity()) < 0)
{
// Generate a Transaction No and Write Original Pallet
// Details to History
Long txn = p.writePalletHistory(0, "SPLIT", "BEFORE");
// Write back Transaction No so we don't create a new one
// next time.
p.setTransactionRef(txn);
// Amend Quantity of Original Pallet
p.setQuantity(p.getQuantity().subtract(splitQuantity));
// Save amended record for Original Pallet
p.update();
// Write Amended records to history;
p.writePalletHistory(txn, "SPLIT", "AFTER");
// Create a new SSCC for split quantity
result = bc.generateNewSSCC();
// Update original pallet record with new SSCC
p.setSSCC(result);
// Change quantity to that of the split
p.setQuantity(splitQuantity);
// Create the new pallet and write to history at the same