{"title":"Codeunit 1402 Cancel Posted Purch. Cr. Memo, extension points 29","url":"https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/points/","author":"JOP-AL","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/","subject":"Microsoft Dynamics 365 Business Central","checked":"2026-11-20","changed":"2026-10-05","object":{"type":"codeunit","id":1402,"name":"Cancel Posted Purch. Cr. Memo","app":"Base Application","url":"https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/"},"major":29,"source":{"url":"https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/source/","path":"src/Layers/W1/BaseApp/Purchases/History/CancelPostedPurchCrMemo.Codeunit.al","commit":"4303e5e584d3aa5d9e98cbc615525a5396ad6ed7","lines":"a line is <source url>#L<line>"},"steps":{"event":"[line, \"event\", name, handled]: raises an event of this object; handled 1 when it has an IsHandled parameter","call":"[line, \"call\", name, arguments]: calls a procedure of this object","ext":"[line, \"ext\", type, id, name, arguments]: calls a procedure of another object, through a variable declared with that type","write":"[line, \"write\", table id, method, 1 when called with true]: Insert, Modify, ModifyAll, Delete, DeleteAll or Rename","validate":"[line, \"validate\", table id, field name]","run":"[line, \"run\", type, id]: Codeunit.Run, Page.Run, Report.Run and their kin"},"objects":{"codeunit:90":{"name":"Purch.-Post","url":"https://jonas-paprotka.de/ref/codeunit/90-purch-post/"},"codeunit:1402":{"name":"Cancel Posted Purch. Cr. Memo","url":"https://jonas-paprotka.de/ref/codeunit/1402-cancel-posted-purch-cr-memo/"},"page:138":{"name":"Posted Purchase Invoice","url":"https://jonas-paprotka.de/ref/page/138-posted-purchase-invoice/"},"page:51":{"name":"Purchase Invoice","url":"https://jonas-paprotka.de/ref/page/51-purchase-invoice/"},"table:38":{"name":"Purchase Header","url":"https://jonas-paprotka.de/ref/table/38-purchase-header/"},"codeunit:6620":{"name":"Copy Document Mgt.","url":"https://jonas-paprotka.de/ref/codeunit/6620-copy-document-mgt/"},"table:1900":{"name":"Cancelled Document","url":"https://jonas-paprotka.de/ref/table/1900-cancelled-document/"},"codeunit:408":{"name":"DimensionManagement","url":"https://jonas-paprotka.de/ref/codeunit/408-dimensionmanagement/"},"codeunit:11":{"name":"Gen. Jnl.-Check Line","url":"https://jonas-paprotka.de/ref/codeunit/11-gen-jnl-check-line/"},"codeunit:310":{"name":"No. Series","url":"https://jonas-paprotka.de/ref/codeunit/310-no-series/"},"table:27":{"name":"Item","url":"https://jonas-paprotka.de/ref/table/27-item/"},"table:252":{"name":"General Posting Setup","url":"https://jonas-paprotka.de/ref/table/252-general-posting-setup/"},"codeunit:227":{"name":"VendEntry-Apply Posted Entries","url":"https://jonas-paprotka.de/ref/codeunit/227-vendentry-apply-posted-entries/"}},"procs":[{"name":"OnRun","line":29,"kind":"trigger","steps":[[33,"call","UnapplyEntries",1],[34,"call","CreateCopyDocument",2],[36,"event","OnRunOnBeforeRunPurchPost",0],[37,"run","codeunit",90],[38,"call","SetTrackInfoForCancellation",1]]},{"name":"CancelPostedCrMemo","line":65,"kind":"procedure","params":1,"steps":[[70,"event","OnCancelPostedCrMemoOnBeforeTestCorrectCrMemoIsAllowed",0],[71,"call","TestCorrectCrMemoIsAllowed",1],[72,"run","codeunit",1402],[76,"call","ShowPostedPurchaseInvoice",1],[81,"call","ShowPurchaseInvoice",1]]},{"name":"ShowPostedPurchaseInvoice","line":90,"kind":"procedure","access":"local","params":1,"steps":[[95,"event","OnBeforeShowPostedPurchaseInvoice",1],[99,"run","page",138]]},{"name":"ShowPurchaseInvoice","line":102,"kind":"procedure","access":"local","params":1,"steps":[[107,"event","OnBeforeShowPurchaseInvoice",1],[111,"run","page",51]]},{"name":"CreateCopyDocument","line":114,"kind":"procedure","access":"local","params":2,"steps":[[121,"event","OnCreateCopyDocumentOnBeforePurchHeaderInsert",0],[122,"write",38,"Insert",1],[123,"ext","codeunit",6620,"SetPropertiesForInvoiceCorrection",1],[124,"ext","codeunit",6620,"CopyPurchDocForCrMemoCancelling",2],[126,"event","OnAfterCreateCopyDocument",0]]},{"name":"TestCorrectCrMemoIsAllowed","line":129,"kind":"procedure","params":1,"steps":[[131,"call","TestIfPostingIsAllowed",1],[132,"call","TestIfVendorIsBlocked",2],[133,"call","TestIfVendorIsBlocked",2],[134,"call","TestIfInvoiceIsCorrectedOnce",1],[135,"call","TestIfCrMemoIsCorrectiveDoc",1],[136,"call","TestVendorDimension",2],[137,"call","TestDimensionOnHeader",1],[138,"call","TestPurchLines",1],[139,"call","TestIfAnyFreeNumberSeries",1],[140,"call","TestExternalDocument",1],[141,"call","TestInventoryPostingClosed",1],[143,"event","OnAfterTestCorrectCrMemoIsAllowed",0]]},{"name":"SetTrackInfoForCancellation","line":146,"kind":"procedure","access":"local","params":1,"steps":[[153,"ext","table",1900,"InsertPurchCrMemoToInvCancelledDocument",2]]},{"name":"TestDimensionOnHeader","line":156,"kind":"procedure","access":"local","params":1,"steps":[[160,"ext","codeunit",408,"CheckDimIDComb",1],[161,"call","ErrorHelperHeader",2]]},{"name":"TestIfVendorIsBlocked","line":164,"kind":"procedure","access":"local","params":2,"steps":[[170,"call","ErrorHelperHeader",2]]},{"name":"TestIfAppliedCorrectly","line":173,"kind":"procedure","access":"local","params":2,"steps":[[179,"event","OnTestIfAppliedCorrectlyBeforeCalcPartiallyApplied",0],[182,"call","CalcDtldVendLedgEntryCount",2],[183,"call","CalcDtldVendLedgEntryCount",2],[184,"call","AnyDtldVendLedgEntriesExceptInitialAndApplicaltionExists",1],[187,"call","ErrorHelperHeader",2]]},{"name":"TestIfUnapplied","line":190,"kind":"procedure","access":"local","params":1,"steps":[[195,"event","OnBeforeTestIfUnapplied",1],[202,"call","ErrorHelperHeader",2]]},{"name":"TestVendorDimension","line":205,"kind":"procedure","access":"local","params":2,"steps":[[215,"ext","codeunit",408,"CheckDimValuePosting",3],[216,"call","ErrorHelperAccount",5]]},{"name":"TestPurchLines","line":219,"kind":"procedure","access":"local","params":1,"steps":[[231,"call","IsCommentLine",1],[236,"call","ErrorHelperLine",2],[240,"call","ErrorHelperLine",2],[245,"ext","codeunit",408,"CheckDimValuePosting",3],[246,"call","ErrorHelperAccount",5],[249,"call","TestInventoryPostingSetup",1],[252,"call","TestGenPostingSetup",1],[253,"call","TestVendorPostingGroup",2],[254,"call","TestVATPostingSetup",1],[256,"ext","codeunit",408,"CheckDimIDComb",1],[257,"call","ErrorHelperLine",2]]},{"name":"CheckGLAccount","line":262,"kind":"procedure","params":2,"steps":[[272,"call","ErrorHelperAccount",5],[278,"ext","codeunit",408,"CheckDimValuePosting",3],[279,"call","ErrorHelperAccount",5]]},{"name":"TestIfInvoiceIsCorrectedOnce","line":283,"kind":"procedure","access":"local","params":1,"steps":[[287,"ext","table",1900,"FindPurchCancelledCrMemo",1],[288,"call","ErrorHelperHeader",2]]},{"name":"TestIfCrMemoIsCorrectiveDoc","line":291,"kind":"procedure","access":"local","params":1,"steps":[[297,"event","OnBeforeTestIfCrMemoIsCorrectiveDoc",1],[301,"ext","table",1900,"FindPurchCorrectiveCrMemo",1],[302,"call","ErrorHelperHeader",2]]},{"name":"TestIfPostingIsAllowed","line":305,"kind":"procedure","access":"local","params":1,"steps":[[309,"ext","codeunit",11,"DateNotAllowed",1],[310,"call","ErrorHelperHeader",2]]},{"name":"TestIfAnyFreeNumberSeries","line":313,"kind":"procedure","access":"local","params":1,"steps":[[323,"event","OnBeforeTestIfAnyFreeNumberSeries",1],[330,"call","TryPeekNextNo",2],[331,"call","ErrorHelperHeader",2],[339,"call","TryPeekNextNo",2],[340,"call","ErrorHelperHeader",2]]},{"name":"TryPeekNextNo","line":344,"kind":"procedure","access":"local","params":2,"steps":[[348,"ext","codeunit",310,"PeekNextNo",2]]},{"name":"TestExternalDocument","line":352,"kind":"procedure","access":"local","params":1,"steps":[[358,"call","ErrorHelperHeader",2]]},{"name":"TestInventoryPostingClosed","line":361,"kind":"procedure","access":"local","params":1,"steps":[[368,"call","ErrorHelperHeader",2]]},{"name":"TestGenPostingSetup","line":371,"kind":"procedure","access":"local","params":1,"steps":[[378,"event","OnBeforeTestGenPostingSetup",1],[388,"call","CheckGLAccount",2],[390,"call","CheckGLAccount",2],[394,"call","CheckGLAccount",2],[398,"ext","table",27,"IsInventoriableType",0],[399,"call","CheckGLAccount",2],[399,"ext","table",252,"GetCOGSAccount",0]]},{"name":"TestVendorPostingGroup","line":403,"kind":"procedure","access":"local","params":2,"steps":[[409,"call","CheckGLAccount",2]]},{"name":"TestVATPostingSetup","line":412,"kind":"procedure","access":"local","params":1,"steps":[[419,"call","CheckGLAccount",2]]},{"name":"TestInventoryPostingSetup","line":423,"kind":"procedure","access":"local","params":1,"steps":[[429,"event","OnBeforeTestInventoryPostingSetup",1],[435,"call","CheckGLAccount",2]]},{"name":"UnapplyEntries","line":438,"kind":"procedure","access":"local","params":1,"steps":[[445,"call","FindVendLedgEntry",2],[446,"call","TestIfAppliedCorrectly",2],[450,"call","FindDetailedApplicationEntry",2],[453,"ext","codeunit",227,"PostUnApplyVendor",2],[454,"call","TestIfUnapplied",1]]}]}