This codeunit has been written to perform the changes.
Before you to run this codeunit, you must change the values for the following fields:
-------------------------------------------------------------------------------------------------------------
OBJECT Codeunit 50080 Fix Transaction
{
OBJECT-PROPERTIES
{
Date=06/01/16;
Time=12:04:53 PM;
Modified=Yes;
Version List=DAV;
}
PROPERTIES
{
OnRun=BEGIN
OldStoreNo := 'S0002';
OldPOSTerminal := 'P0003';
NewStoreNo := 'S0012';
NewPOSTerminal := 'P0028';
NewTransNo := 1755; //First New Transaction No.
FOR OldTransNo := 20000161 TO 20000162 DO BEGIN
TransactionHeader.GET(OldStoreNo,OldPOSTerminal,OldTransNo);
TransactionHeaderNew := TransactionHeader;
TransactionHeaderNew."Store No." := NewStoreNo;
TransactionHeaderNew."POS Terminal No." := NewPOSTerminal;
TransactionHeaderNew."Transaction No." := NewTransNo;
TransactionHeaderNew.INSERT(TRUE); //This updates the Replication Counter field
TransSalesEntry.RESET;
TransSalesEntry.SETRANGE("Store No.",TransactionHeader."Store No.");
TransSalesEntry.SETRANGE("POS Terminal No.",TransactionHeader."POS Terminal No.");
TransSalesEntry.SETRANGE("Transaction No.",TransactionHeader."Transaction No.");
IF TransSalesEntry.FINDSET THEN REPEAT
TransSalesEntryNew := TransSalesEntry;
TransSalesEntryNew."Store No." := TransactionHeaderNew."Store No.";
TransSalesEntryNew."POS Terminal No." := TransactionHeaderNew."POS Terminal No.";
TransSalesEntryNew."Transaction No." := TransactionHeaderNew."Transaction No.";
TransSalesEntryNew.VALIDATE("Replication Counter");
TransSalesEntryNew.INSERT(FALSE);
TransSalesEntry.DELETE;
UNTIL TransSalesEntry.NEXT = 0;
TransPaymentEntry.RESET;
TransPaymentEntry.SETRANGE("Store No.",TransactionHeader."Store No.");
TransPaymentEntry.SETRANGE("POS Terminal No.",TransactionHeader."POS Terminal No.");
TransPaymentEntry.SETRANGE("Transaction No.",TransactionHeader."Transaction No.");
IF TransPaymentEntry.FINDSET THEN REPEAT
TransPaymentEntryNew := TransPaymentEntry;
TransPaymentEntryNew."Store No." := TransactionHeaderNew."Store No.";
TransPaymentEntryNew."POS Terminal No." := TransactionHeaderNew."POS Terminal No.";
TransPaymentEntryNew."Transaction No." := TransactionHeaderNew."Transaction No.";
TransPaymentEntryNew.VALIDATE("Replication Counter");
TransPaymentEntryNew.INSERT(FALSE);
TransPaymentEntry.DELETE;
UNTIL TransPaymentEntry.NEXT = 0;
TransIncomeExpenseEntry.RESET;
TransIncomeExpenseEntry.SETRANGE("Store No.",TransactionHeader."Store No.");
TransIncomeExpenseEntry.SETRANGE("POS Terminal No.",TransactionHeader."POS Terminal No.");
TransIncomeExpenseEntry.SETRANGE("Transaction No.",TransactionHeader."Transaction No.");
IF TransIncomeExpenseEntry.FINDSET THEN REPEAT
TransIncomeExpenseEntryNew := TransIncomeExpenseEntry;
TransIncomeExpenseEntryNew."Store No." := TransactionHeaderNew."Store No.";
TransIncomeExpenseEntryNew."POS Terminal No." := TransactionHeaderNew."POS Terminal No.";
TransIncomeExpenseEntryNew."Transaction No." := TransactionHeaderNew."Transaction No.";
TransIncomeExpenseEntryNew.VALIDATE("Replication Counter");
TransIncomeExpenseEntryNew.INSERT(FALSE);
TransIncomeExpenseEntry.DELETE;
UNTIL TransIncomeExpenseEntry.NEXT = 0;
TransCouponEntry.RESET;
TransCouponEntry.SETRANGE("Store No.",TransactionHeader."Store No.");
TransCouponEntry.SETRANGE("POS Terminal No.",TransactionHeader."POS Terminal No.");
TransCouponEntry.SETRANGE("Transaction No.",TransactionHeader."Transaction No.");
IF TransCouponEntry.FINDSET THEN REPEAT
TransCouponEntryNew := TransCouponEntry;
TransCouponEntryNew."Store No." := TransactionHeaderNew."Store No.";
TransCouponEntryNew."POS Terminal No." := TransactionHeaderNew."POS Terminal No.";
TransCouponEntryNew."Transaction No." := TransactionHeaderNew."Transaction No.";
TransCouponEntryNew.VALIDATE("Replication Counter");
TransCouponEntryNew.INSERT(FALSE);
TransCouponEntry.DELETE;
UNTIL TransCouponEntry.NEXT = 0;
TransInfocodeEntry.RESET;
TransInfocodeEntry.SETRANGE("Store No.",TransactionHeader."Store No.");
TransInfocodeEntry.SETRANGE("POS Terminal No.",TransactionHeader."POS Terminal No.");
TransInfocodeEntry.SETRANGE("Transaction No.",TransactionHeader."Transaction No.");
IF TransInfocodeEntry.FINDSET THEN REPEAT
TransInfocodeEntryNew := TransInfocodeEntry;
TransInfocodeEntryNew."Store No." := TransactionHeaderNew."Store No.";
TransInfocodeEntryNew."POS Terminal No." := TransactionHeaderNew."POS Terminal No.";
TransInfocodeEntryNew."Transaction No." := TransactionHeaderNew."Transaction No.";
TransInfocodeEntryNew.VALIDATE("Replication Counter");
TransInfocodeEntryNew.INSERT(FALSE);
TransInfocodeEntry.DELETE;
UNTIL TransInfocodeEntry.NEXT = 0;
TransInventoryEntry.RESET;
TransInventoryEntry.SETRANGE("Store No.",TransactionHeader."Store No.");
TransInventoryEntry.SETRANGE("POS Terminal No.",TransactionHeader."POS Terminal No.");
TransInventoryEntry.SETRANGE("Transaction No.",TransactionHeader."Transaction No.");
IF TransInventoryEntry.FINDSET THEN REPEAT
TransInventoryEntryNew := TransInventoryEntry;
TransInventoryEntryNew."Store No." := TransactionHeaderNew."Store No.";
TransInventoryEntryNew."POS Terminal No." := TransactionHeaderNew."POS Terminal No.";
TransInventoryEntryNew."Transaction No." := TransactionHeaderNew."Transaction No.";
TransInventoryEntryNew.VALIDATE("Replication Counter");
TransInventoryEntryNew.INSERT(FALSE);
TransInventoryEntry.DELETE;
UNTIL TransInventoryEntry.NEXT = 0;
TransMixMatchEntry.RESET;
TransMixMatchEntry.SETRANGE("Store No.",TransactionHeader."Store No.");
TransMixMatchEntry.SETRANGE("POS Terminal No.",TransactionHeader."POS Terminal No.");
TransMixMatchEntry.SETRANGE("Transaction No.",TransactionHeader."Transaction No.");
IF TransMixMatchEntry.FINDSET THEN REPEAT
TransMixMatchEntryNew := TransMixMatchEntry;
TransMixMatchEntryNew."Store No." := TransactionHeaderNew."Store No.";
TransMixMatchEntryNew."POS Terminal No." := TransactionHeaderNew."POS Terminal No.";
TransMixMatchEntryNew."Transaction No." := TransactionHeaderNew."Transaction No.";
TransMixMatchEntryNew.VALIDATE("Replication Counter");
TransMixMatchEntryNew.INSERT(FALSE);
TransMixMatchEntry.DELETE;
UNTIL TransMixMatchEntry.NEXT = 0;
TransDiscountEntry.RESET;
TransDiscountEntry.SETRANGE("Store No.",TransactionHeader."Store No.");
TransDiscountEntry.SETRANGE("POS Terminal No.",TransactionHeader."POS Terminal No.");
TransDiscountEntry.SETRANGE("Transaction No.",TransactionHeader."Transaction No.");
IF TransDiscountEntry.FINDSET THEN REPEAT
TransDiscountEntryNew := TransDiscountEntry;
TransDiscountEntryNew."Store No." := TransactionHeaderNew."Store No.";
TransDiscountEntryNew."POS Terminal No." := TransactionHeaderNew."POS Terminal No.";
TransDiscountEntryNew."Transaction No." := TransactionHeaderNew."Transaction No.";
TransDiscountEntryNew.VALIDATE("Replication Counter");
TransDiscountEntryNew.INSERT(FALSE);
TransDiscountEntry.DELETE;
UNTIL TransDiscountEntry.NEXT = 0;
TransDiscBenefitEntry.RESET;
TransDiscBenefitEntry.SETRANGE("Store No.",TransactionHeader."Store No.");
TransDiscBenefitEntry.SETRANGE("POS Terminal No.",TransactionHeader."POS Terminal No.");
TransDiscBenefitEntry.SETRANGE("Transaction No.",TransactionHeader."Transaction No.");
IF TransDiscBenefitEntry.FINDSET THEN REPEAT
TransDiscBenefitEntryNew := TransDiscBenefitEntry;
TransDiscBenefitEntryNew."Store No." := TransactionHeaderNew."Store No.";
TransDiscBenefitEntryNew."POS Terminal No." := TransactionHeaderNew."POS Terminal No.";
TransDiscBenefitEntryNew."Transaction No." := TransactionHeaderNew."Transaction No.";
TransDiscBenefitEntryNew.VALIDATE("Replication Counter");
TransDiscBenefitEntryNew.INSERT(FALSE);
TransDiscBenefitEntry.DELETE;
UNTIL TransDiscBenefitEntry.NEXT = 0;
MemberProcessOrderEntry.RESET;
MemberProcessOrderEntry.SETRANGE("Store No.",TransactionHeader."Store No.");
MemberProcessOrderEntry.SETRANGE("POS Terminal No.",TransactionHeader."POS Terminal No.");
MemberProcessOrderEntry.SETRANGE("Transaction No.",TransactionHeader."Transaction No.");
IF MemberProcessOrderEntry.FINDSET THEN REPEAT
MemberProcessOrderEntryNew := MemberProcessOrderEntry;
MemberProcessOrderEntryNew."Store No." := TransactionHeaderNew."Store No.";
MemberProcessOrderEntryNew."POS Terminal No." := TransactionHeaderNew."POS Terminal No.";
MemberProcessOrderEntryNew."Transaction No." := TransactionHeaderNew."Transaction No.";
MemberProcessOrderEntryNew.VALIDATE("Replication Counter");
MemberProcessOrderEntryNew.INSERT(FALSE);
MemberProcessOrderEntry.DELETE;
UNTIL MemberProcessOrderEntry.NEXT = 0;
TransTenderDeclarEntry.RESET;
TransTenderDeclarEntry.SETRANGE("Store No.",TransactionHeader."Store No.");
TransTenderDeclarEntry.SETRANGE("POS Terminal No.",TransactionHeader."POS Terminal No.");
TransTenderDeclarEntry.SETRANGE("Transaction No.",TransactionHeader."Transaction No.");
IF TransTenderDeclarEntry.FINDSET THEN REPEAT
TransTenderDeclarEntryNew := TransTenderDeclarEntry;
TransTenderDeclarEntryNew."Store No." := TransactionHeaderNew."Store No.";
TransTenderDeclarEntryNew."POS Terminal No." := TransactionHeaderNew."POS Terminal No.";
TransTenderDeclarEntryNew."Transaction No." := TransactionHeaderNew."Transaction No.";
TransTenderDeclarEntryNew.VALIDATE("Replication Counter");
TransTenderDeclarEntryNew.INSERT(FALSE);
TransTenderDeclarEntry.DELETE;
UNTIL TransTenderDeclarEntry.NEXT = 0;
TransSafeEntry.RESET;
TransSafeEntry.SETRANGE("Store No.",TransactionHeader."Store No.");
TransSafeEntry.SETRANGE("POS Terminal No.",TransactionHeader."POS Terminal No.");
TransSafeEntry.SETRANGE("Transaction No.",TransactionHeader."Transaction No.");
IF TransSafeEntry.FINDSET THEN REPEAT
TransSafeEntryNew := TransSafeEntry;
TransSafeEntryNew."Store No." := TransactionHeaderNew."Store No.";
TransSafeEntryNew."POS Terminal No." := TransactionHeaderNew."POS Terminal No.";
TransSafeEntryNew."Transaction No." := TransactionHeaderNew."Transaction No.";
TransSafeEntryNew.VALIDATE("Replication Counter");
TransSafeEntryNew.INSERT(FALSE);
TransSafeEntry.DELETE;
UNTIL TransSafeEntry.NEXT = 0;
TransCashDeclaration.RESET;
TransCashDeclaration.SETRANGE("Store No.",TransactionHeader."Store No.");
TransCashDeclaration.SETRANGE("POS Terminal No.",TransactionHeader."POS Terminal No.");
TransCashDeclaration.SETRANGE("Transaction No.",TransactionHeader."Transaction No.");
IF TransCashDeclaration.FINDSET THEN REPEAT
TransCashDeclarationNew := TransCashDeclaration;
TransCashDeclarationNew."Store No." := TransactionHeaderNew."Store No.";
TransCashDeclarationNew."POS Terminal No." := TransactionHeaderNew."POS Terminal No.";
TransCashDeclarationNew."Transaction No." := TransactionHeaderNew."Transaction No.";
TransCashDeclarationNew.VALIDATE("Replication Counter");
TransCashDeclarationNew.INSERT(FALSE);
TransCashDeclaration.DELETE;
UNTIL TransCashDeclaration.NEXT = 0;
TransactionHeader.DELETE;
NewTransNo := NewTransNo + 1;
END;
END;
}
CODE
{
VAR
OldStoreNo@1200070011 : Code[10];
NewStoreNo@1200070012 : Code[10];
OldPOSTerminal@1200070013 : Code[10];
NewPOSTerminal@1200070014 : Code[10];
OldTransNo@1200070015 : Integer;
NewTransNo@1200070016 : Integer;
TransactionHeader@1200070000 : Record 99001472;
TransactionHeaderNew@1200070017 : Record 99001472;
TransSalesEntry@1200070001 : Record 99001473;
TransSalesEntryNew@1200070018 : Record 99001473;
TransPaymentEntry@1200070002 : Record 99001474;
TransPaymentEntryNew@1200070019 : Record 99001474;
TransIncomeExpenseEntry@1200070003 : Record 99001475;
TransIncomeExpenseEntryNew@1200070020 : Record 99001475;
TransCouponEntry@1200070004 : Record 99001477;
TransCouponEntryNew@1200070021 : Record 99001477;
TransInfocodeEntry@1200070005 : Record 99001478;
TransInfocodeEntryNew@1200070022 : Record 99001478;
TransInventoryEntry@1200070006 : Record 99001490;
TransInventoryEntryNew@1200070023 : Record 99001490;
TransMixMatchEntry@1200070007 : Record 99001496;
TransMixMatchEntryNew@1200070024 : Record 99001496;
TransDiscountEntry@1200070008 : Record 99001642;
TransDiscountEntryNew@1200070025 : Record 99001642;
TransDiscBenefitEntry@1200070009 : Record 99001674;
TransDiscBenefitEntryNew@1200070026 : Record 99001674;
MemberProcessOrderEntry@1200070010 : Record 99009038;
MemberProcessOrderEntryNew@1200070027 : Record 99009038;
TransTenderDeclarEntry@1200070028 : Record 99001465;
TransTenderDeclarEntryNew@1200070029 : Record 99001465;
TransSafeEntry@1200070030 : Record 99001630;
TransSafeEntryNew@1200070032 : Record 99001630;
TransCashDeclaration@1200070031 : Record 99001626;
TransCashDeclarationNew@1200070033 : Record 99001626;
BEGIN
{
This codeunit is used to renumber POS transactions.
This should only be used on POS machines to create new transactions with the correct store and terminal to be re-sent to HO.
Before you to run this codeunit, you must change the values for the following fields:
OldStoreNo
OldPOSTerminal
NewStoreNo
NewPOSTerminal
NewTransNo
OldTransNo
}
END.
}
}
-----------------------------------------------------------------------------------------------------------