Data validation in the SalesTable Form

I have a need to validate the sales line data entered in the SalesTable form. So far I have entered the following code in the canClose() method

public boolean canClose()
    InventDim     salesLineInvDimensions;
    SalesLine     thisSalesOrderLines;
    date          salesLineModifiedDate;

    //STEVOYDEV385 03/10/2018 PaulF -Begin
    //If the current sales order status is not "Invoiced" then check if any of the new lines
    //contain references to the Credit/Billings warehouse. If so, then ensure a reason
    //code has been specified.
    if (salesTable.SalesStatus == SalesStatus::Backorder ||
        salesTable.SalesStatus == SalesStatus::Delivered)
        while select thisSalesOrderLines
            join salesLineInvDimensions
            where thisSalesOrderLines.SalesId == salesTable.SalesId
                && salesLineInvDimensions.inventDimId == thisSalesOrderLines.InventDimId
            salesLineModifiedDate = DateTimeUtil::date(thisSalesOrderLines.modifiedDateTime);
            if (salesLineInvDimensions.InventLocationId == "Cred_Bill"
                && salesLineModifiedDate == systemDateGet()
                && !salesTable.ReturnReasonCodeId)
                warning("A credit reason code must be specified when sales lines reference the Credit/Billings warehouse");
                return false;
    //STEVOYDEV385 03/10/2018 PaulF -End

    if (!salesLine.PBAItemLine::checkMandatory() )
        return false;

    ret = super();

    // The user needs to be able to modify an exchange order associated to a return and
    // go back to returns without completing the exchange order (this order).  The returns
    // logic will prevent the order from remaining open.  A return must always be completed
    // therefore, the exchange order will never be left open.
    ret = ret && element.mcrCheckOpenOrder();

    if (element.closedCancel() && ret)
        ret = salesTableForm.canClose(salesTable);
    return ret;

Whilst this works perfectly if data is saved within the form, when the data is entered and the user immediately clicks "Close", the code doesn't identify the new data (Because it hasn't been saved at this point) and the check doesn't validate the data as I expect.

Putting my code block after the call to the super() method, simply results in the sales header information being lost all together.

Can anyone please advise where I should place my code to correctly validate the entered data, but also stop the form from closing if it doesn't satisfy the check?