---
title: "Codeunit 1402 Cancel Posted Purch. Cr. Memo, extension points 29"
author: "JOP-AL"
url: https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/points/
object: https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/
app: "Base Application"
major: 29
source: https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/
checked: 2026-11-20
changed: 2026-10-05
subject: "Microsoft Dynamics 365 Business Central"
license: "Metadata from Microsoft's symbol packages. AL source MIT, Copyright (c) Microsoft Corporation. Selection and wording © 2026 JOP-AL. https://jonas-paprotka.de/licenses/"
---

# Codeunit 1402 Cancel Posted Purch. Cr. Memo, extension points 29

JOP-AL, https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/points/

26 procedures and triggers with a step in src/Layers/W1/BaseApp/Purchases/History/CancelPostedPurchCrMemo.Codeunit.al, in source order, read from the text, not from a run.

## OnRun

[Line 29](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L29), trigger.

- [33](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L33) calls `UnapplyEntries`
- [34](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L34) calls `CreateCopyDocument`
- [36](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L36) raises `OnRunOnBeforeRunPurchPost`
- [37](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L37) runs [Codeunit 90 Purch.-Post](https://jonas-paprotka.de/ref/codeunit/90-purch-post/)
- [38](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L38) calls `SetTrackInfoForCancellation`

## CancelPostedCrMemo

[Line 65](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L65).

- [70](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L70) raises `OnCancelPostedCrMemoOnBeforeTestCorrectCrMemoIsAllowed`
- [71](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L71) calls `TestCorrectCrMemoIsAllowed`
- [72](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L72) runs [Codeunit 1402 Cancel Posted Purch. Cr. Memo](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/)
- [76](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L76) calls `ShowPostedPurchaseInvoice`
- [81](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L81) calls `ShowPurchaseInvoice`

## ShowPostedPurchaseInvoice

[Line 90](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L90), local.

- [95](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L95) raises `OnBeforeShowPostedPurchaseInvoice`, IsHandled
- [99](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L99) runs [Page 138 Posted Purchase Invoice](https://jonas-paprotka.de/ref/page/138-posted-purchase-invoice/)

## ShowPurchaseInvoice

[Line 102](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L102), local.

- [107](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L107) raises `OnBeforeShowPurchaseInvoice`, IsHandled
- [111](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L111) runs [Page 51 Purchase Invoice](https://jonas-paprotka.de/ref/page/51-purchase-invoice/)

## CreateCopyDocument

[Line 114](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L114), local.

- [121](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L121) raises `OnCreateCopyDocumentOnBeforePurchHeaderInsert`
- [122](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L122) writes [Table 38 Purchase Header](https://jonas-paprotka.de/ref/table/38-purchase-header/) Insert(true)
- [123](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L123) calls [Codeunit 6620 Copy Document Mgt.](https://jonas-paprotka.de/ref/codeunit/6620-copy-document-mgt/) `SetPropertiesForInvoiceCorrection`
- [124](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L124) calls [Codeunit 6620 Copy Document Mgt.](https://jonas-paprotka.de/ref/codeunit/6620-copy-document-mgt/) `CopyPurchDocForCrMemoCancelling`
- [126](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L126) raises `OnAfterCreateCopyDocument`

## TestCorrectCrMemoIsAllowed

[Line 129](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L129).

- [131](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L131) calls `TestIfPostingIsAllowed`
- [132](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L132) calls `TestIfVendorIsBlocked`
- [133](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L133) calls `TestIfVendorIsBlocked`
- [134](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L134) calls `TestIfInvoiceIsCorrectedOnce`
- [135](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L135) calls `TestIfCrMemoIsCorrectiveDoc`
- [136](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L136) calls `TestVendorDimension`
- [137](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L137) calls `TestDimensionOnHeader`
- [138](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L138) calls `TestPurchLines`
- [139](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L139) calls `TestIfAnyFreeNumberSeries`
- [140](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L140) calls `TestExternalDocument`
- [141](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L141) calls `TestInventoryPostingClosed`
- [143](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L143) raises `OnAfterTestCorrectCrMemoIsAllowed`

## SetTrackInfoForCancellation

[Line 146](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L146), local.

- [153](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L153) calls [Table 1900 Cancelled Document](https://jonas-paprotka.de/ref/table/1900-cancelled-document/) `InsertPurchCrMemoToInvCancelledDocument`

## TestDimensionOnHeader

[Line 156](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L156), local.

- [160](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L160) calls [Codeunit 408 DimensionManagement](https://jonas-paprotka.de/ref/codeunit/408-dimensionmanagement/) `CheckDimIDComb`
- [161](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L161) calls `ErrorHelperHeader`

## TestIfVendorIsBlocked

[Line 164](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L164), local.

- [170](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L170) calls `ErrorHelperHeader`

## TestIfAppliedCorrectly

[Line 173](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L173), local.

- [179](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L179) raises `OnTestIfAppliedCorrectlyBeforeCalcPartiallyApplied`
- [182](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L182) calls `CalcDtldVendLedgEntryCount`
- [183](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L183) calls `CalcDtldVendLedgEntryCount`
- [184](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L184) calls `AnyDtldVendLedgEntriesExceptInitialAndApplicaltionExists`
- [187](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L187) calls `ErrorHelperHeader`

## TestIfUnapplied

[Line 190](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L190), local.

- [195](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L195) raises `OnBeforeTestIfUnapplied`, IsHandled
- [202](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L202) calls `ErrorHelperHeader`

## TestVendorDimension

[Line 205](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L205), local.

- [215](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L215) calls [Codeunit 408 DimensionManagement](https://jonas-paprotka.de/ref/codeunit/408-dimensionmanagement/) `CheckDimValuePosting`
- [216](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L216) calls `ErrorHelperAccount`

## TestPurchLines

[Line 219](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L219), local.

- [231](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L231) calls `IsCommentLine`
- [236](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L236) calls `ErrorHelperLine`
- [240](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L240) calls `ErrorHelperLine`
- [245](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L245) calls [Codeunit 408 DimensionManagement](https://jonas-paprotka.de/ref/codeunit/408-dimensionmanagement/) `CheckDimValuePosting`
- [246](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L246) calls `ErrorHelperAccount`
- [249](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L249) calls `TestInventoryPostingSetup`
- [252](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L252) calls `TestGenPostingSetup`
- [253](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L253) calls `TestVendorPostingGroup`
- [254](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L254) calls `TestVATPostingSetup`
- [256](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L256) calls [Codeunit 408 DimensionManagement](https://jonas-paprotka.de/ref/codeunit/408-dimensionmanagement/) `CheckDimIDComb`
- [257](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L257) calls `ErrorHelperLine`

## CheckGLAccount

[Line 262](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L262).

- [272](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L272) calls `ErrorHelperAccount`
- [278](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L278) calls [Codeunit 408 DimensionManagement](https://jonas-paprotka.de/ref/codeunit/408-dimensionmanagement/) `CheckDimValuePosting`
- [279](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L279) calls `ErrorHelperAccount`

## TestIfInvoiceIsCorrectedOnce

[Line 283](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L283), local.

- [287](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L287) calls [Table 1900 Cancelled Document](https://jonas-paprotka.de/ref/table/1900-cancelled-document/) `FindPurchCancelledCrMemo`
- [288](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L288) calls `ErrorHelperHeader`

## TestIfCrMemoIsCorrectiveDoc

[Line 291](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L291), local.

- [297](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L297) raises `OnBeforeTestIfCrMemoIsCorrectiveDoc`, IsHandled
- [301](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L301) calls [Table 1900 Cancelled Document](https://jonas-paprotka.de/ref/table/1900-cancelled-document/) `FindPurchCorrectiveCrMemo`
- [302](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L302) calls `ErrorHelperHeader`

## TestIfPostingIsAllowed

[Line 305](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L305), local.

- [309](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L309) calls [Codeunit 11 Gen. Jnl.-Check Line](https://jonas-paprotka.de/ref/codeunit/11-gen-jnl-check-line/) `DateNotAllowed`
- [310](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L310) calls `ErrorHelperHeader`

## TestIfAnyFreeNumberSeries

[Line 313](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L313), local.

- [323](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L323) raises `OnBeforeTestIfAnyFreeNumberSeries`, IsHandled
- [330](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L330) calls `TryPeekNextNo`
- [331](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L331) calls `ErrorHelperHeader`
- [339](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L339) calls `TryPeekNextNo`
- [340](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L340) calls `ErrorHelperHeader`

## TryPeekNextNo

[Line 344](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L344), local.

- [348](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L348) calls [Codeunit 310 No. Series](https://jonas-paprotka.de/ref/codeunit/310-no-series/) `PeekNextNo`

## TestExternalDocument

[Line 352](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L352), local.

- [358](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L358) calls `ErrorHelperHeader`

## TestInventoryPostingClosed

[Line 361](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L361), local.

- [368](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L368) calls `ErrorHelperHeader`

## TestGenPostingSetup

[Line 371](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L371), local.

- [378](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L378) raises `OnBeforeTestGenPostingSetup`, IsHandled
- [388](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L388) calls `CheckGLAccount`
- [390](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L390) calls `CheckGLAccount`
- [394](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L394) calls `CheckGLAccount`
- [398](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L398) calls [Table 27 Item](https://jonas-paprotka.de/ref/table/27-item/) `IsInventoriableType`
- [399](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L399) calls `CheckGLAccount`
- [399](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L399) calls [Table 252 General Posting Setup](https://jonas-paprotka.de/ref/table/252-general-posting-setup/) `GetCOGSAccount`

## TestVendorPostingGroup

[Line 403](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L403), local.

- [409](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L409) calls `CheckGLAccount`

## TestVATPostingSetup

[Line 412](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L412), local.

- [419](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L419) calls `CheckGLAccount`

## TestInventoryPostingSetup

[Line 423](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L423), local.

- [429](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L429) raises `OnBeforeTestInventoryPostingSetup`, IsHandled
- [435](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L435) calls `CheckGLAccount`

## UnapplyEntries

[Line 438](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L438), local.

- [445](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L445) calls `FindVendLedgEntry`
- [446](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L446) calls `TestIfAppliedCorrectly`
- [450](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L450) calls `FindDetailedApplicationEntry`
- [453](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L453) calls [Codeunit 227 VendEntry-Apply Posted Entries](https://jonas-paprotka.de/ref/codeunit/227-vendentry-apply-posted-entries/) `PostUnApplyVendor`
- [454](https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/#L454) calls `TestIfUnapplied`

## Source

AL source 29: https://github.com/microsoft/BCApps, MIT, releases/29.x at 4303e5e584d3aa5d9e98cbc615525a5396ad6ed7.

JOP-AL, 2026-11-20.
