---
title: "Codeunit 6406 EDoc Prepare Purch. Draft, extension points 29"
author: "JOP-AL"
url: https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/points/
object: https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/
app: "E-Document Core"
major: 29
source: https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/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 6406 EDoc Prepare Purch. Draft, extension points 29

JOP-AL, https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/points/

9 procedures and triggers with a step in src/Apps/W1/EDocument/App/src/Processing/Import/PrepareDraft/EDocPreparePurchDraft.Codeunit.al, in source order, read from the text, not from a run.

## PrepareDraft

[Line 29](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L29).

- [53](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L53) calls [Codeunit 6175 E-Doc. Activity Log Session](https://jonas-paprotka.de/ref/codeunit/6175-e-doc-activity-log-session/) `CreateSession`
- [55](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L55) calls [Table 6100 E-Document Purchase Header](https://jonas-paprotka.de/ref/table/6100-e-document-purchase-header/) `GetFromEDocument`
- [59](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L59) calls `GetVendor`
- [67](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L67) writes [Table 6100 E-Document Purchase Header](https://jonas-paprotka.de/ref/table/6100-e-document-purchase-header/) Modify
- [69](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L69) calls [Codeunit 6120 E-Doc. Purchase Hist. Mapping](https://jonas-paprotka.de/ref/codeunit/6120-e-doc-purchase-hist-mapping/) `FindRelatedPurchaseHeaderInHistory`
- [70](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L70) calls [Codeunit 6120 E-Doc. Purchase Hist. Mapping](https://jonas-paprotka.de/ref/codeunit/6120-e-doc-purchase-hist-mapping/) `UpdateMissingHeaderValuesFromHistory`
- [71](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L71) writes [Table 6100 E-Document Purchase Header](https://jonas-paprotka.de/ref/table/6100-e-document-purchase-header/) Modify
- [73](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L73) calls [Codeunit 6122 E-Doc. Imp. Session Telemetry](https://jonas-paprotka.de/ref/codeunit/6122-e-doc-imp-session-telemetry/) `SetBool`
- [77](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L77) calls [Codeunit 6122 E-Doc. Imp. Session Telemetry](https://jonas-paprotka.de/ref/codeunit/6122-e-doc-imp-session-telemetry/) `SetText`
- [79](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L79) calls [Codeunit 6122 E-Doc. Imp. Session Telemetry](https://jonas-paprotka.de/ref/codeunit/6122-e-doc-imp-session-telemetry/) `SetText`
- [81](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L81) calls [Codeunit 6122 E-Doc. Imp. Session Telemetry](https://jonas-paprotka.de/ref/codeunit/6122-e-doc-imp-session-telemetry/) `SetText`
- [83](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L83) calls [Codeunit 6122 E-Doc. Imp. Session Telemetry](https://jonas-paprotka.de/ref/codeunit/6122-e-doc-imp-session-telemetry/) `SetText`
- [94](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L94) writes [Table 6101 E-Document Purchase Line](https://jonas-paprotka.de/ref/table/6101-e-document-purchase-line/) Modify
- [98](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L98) calls `ResolveVATProductPostingGroups`
- [100](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L100) calls `CopilotLineMatching`
- [111](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L111) calls [Codeunit 6122 E-Doc. Imp. Session Telemetry](https://jonas-paprotka.de/ref/codeunit/6122-e-doc-imp-session-telemetry/) `SetLine`
- [114](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L114) calls `ComputeAndApplyVATAmountDifference`
- [115](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L115) writes [Table 6100 E-Document Purchase Header](https://jonas-paprotka.de/ref/table/6100-e-document-purchase-header/) Modify
- [117](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L117) calls `LogAllActivitySessionChanges`
- [119](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L119) calls [Codeunit 6175 E-Doc. Activity Log Session](https://jonas-paprotka.de/ref/codeunit/6175-e-doc-activity-log-session/) `EndSession`

## OpenDraftPage

[Line 130](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L130).

- [134](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L134) calls `EnsureDraftHeaderExistsForFailedExtraction`

## EnsureDraftHeaderExistsForFailedExtraction

[Line 140](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L140), internal.

- [148](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L148) calls [Table 6100 E-Document Purchase Header](https://jonas-paprotka.de/ref/table/6100-e-document-purchase-header/) `InsertForEDocument`

## CleanUpDraft

[Line 151](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L151).

- [158](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L158) writes [Table 6100 E-Document Purchase Header](https://jonas-paprotka.de/ref/table/6100-e-document-purchase-header/) DeleteAll(true)
- [162](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L162) writes [Table 6101 E-Document Purchase Line](https://jonas-paprotka.de/ref/table/6101-e-document-purchase-line/) DeleteAll(true)

## LogAllActivitySessionChanges

[Line 165](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L165), local.

- [167](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L167) calls `Log`
- [167](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L167) calls [Codeunit 6175 E-Doc. Activity Log Session](https://jonas-paprotka.de/ref/codeunit/6175-e-doc-activity-log-session/) `AccountNumberTok`
- [168](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L168) calls `Log`
- [168](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L168) calls [Codeunit 6175 E-Doc. Activity Log Session](https://jonas-paprotka.de/ref/codeunit/6175-e-doc-activity-log-session/) `DeferralTok`
- [169](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L169) calls `Log`
- [169](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L169) calls [Codeunit 6175 E-Doc. Activity Log Session](https://jonas-paprotka.de/ref/codeunit/6175-e-doc-activity-log-session/) `ItemRefTok`
- [170](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L170) calls `Log`
- [170](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L170) calls [Codeunit 6175 E-Doc. Activity Log Session](https://jonas-paprotka.de/ref/codeunit/6175-e-doc-activity-log-session/) `TextToAccountMappingTok`
- [171](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L171) calls `Log`
- [171](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L171) calls [Codeunit 6175 E-Doc. Activity Log Session](https://jonas-paprotka.de/ref/codeunit/6175-e-doc-activity-log-session/) `ItemDescriptionTok`

## Log

[Line 174](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L174), local.

- [181](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L181) calls [Codeunit 6175 E-Doc. Activity Log Session](https://jonas-paprotka.de/ref/codeunit/6175-e-doc-activity-log-session/) `GetAll`
- [183](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L183) calls [Codeunit 3111 Activity Log Builder](https://jonas-paprotka.de/ref/codeunit/3111-activity-log-builder/) `Log`

## ResolveVATProductPostingGroups

[Line 186](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L186), local.

- [199](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L199) calls [Table 6100 E-Document Purchase Header](https://jonas-paprotka.de/ref/table/6100-e-document-purchase-header/) `GetBCVendor`
- [225](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L225) calls `FindVATProductPostingGroup`
- [226](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L226) writes [Table 6101 E-Document Purchase Line](https://jonas-paprotka.de/ref/table/6101-e-document-purchase-line/) Modify
- [228](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L228) calls [Table 6101 E-Document Purchase Line](https://jonas-paprotka.de/ref/table/6101-e-document-purchase-line/) `LogVATRateMismatch`
- [230](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L230) calls [Table 6101 E-Document Purchase Line](https://jonas-paprotka.de/ref/table/6101-e-document-purchase-line/) `LogVATRateResolved`

## FindVATProductPostingGroup

[Line 235](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L235), local.

- [242](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L242) calls [Codeunit 6402 E-Doc. Purch. Doc. Helper](https://jonas-paprotka.de/ref/codeunit/6402-e-doc-purch-doc-helper/) `SetNormalReverseChargeFilter`

## CopilotLineMatching

[Line 252](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L252), local.

- [265](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L265) runs [Codeunit 6177 E-Doc. Historical Matching](https://jonas-paprotka.de/ref/codeunit/6177-e-doc-historical-matching/)
- [274](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L274) runs [Codeunit 6126 E-Doc. GL Account Matching](https://jonas-paprotka.de/ref/codeunit/6126-e-doc-gl-account-matching/)
- [283](https://jonas-paprotka.de/ref/codeunit/6406-edoc-prepare-purch-draft/source/#L283) runs [Codeunit 6129 E-Doc. Deferral Matching](https://jonas-paprotka.de/ref/codeunit/6129-e-doc-deferral-matching/)

## Source

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

JOP-AL, 2026-11-20.
