> For the complete documentation index, see [llms.txt](https://docs.solutioo.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.solutioo.de/entwicklerdokumentationen-business-central-dhl-connector/dhl-connector-entwicklerdokumentation/codeunit-referenz/72242984-72242985-box-inventory.md).

# 72242984/72242985 Box Inventory

## Objekte

* `72242984 SOUDHL Box Inventory Mgt`: Orchestrierung und Status
* `72242985 SOUDHL Box Inventory Post`: isolierter Posting-Worker mit `TableNo = SOUDHL Package Header`

Beide Codeunits liegen fachlich zusammen, damit ein erfolgreicher DHL-Upload nicht durch eine fehlerhafte lokale Artikelbuchung zurückgerollt wird.

## Öffentliche API der Management-Codeunit

### `PostAfterSuccessfulLabel(var PackageHeader: Record "SOUDHL Package Header"; var WarningText: Text): Boolean`

Ablauf:

1. Paket sperren und erneut lesen.
2. prüfen, dass das Label hochgeladen ist.
3. Setup und Box-Inventarartikel validieren.
4. bereits vorhandene Buchung erkennen.
5. Status auf Pending und Startzeit setzen.
6. committen.
7. Worker über `Codeunit.Run` ausführen.
8. Status auf Posted oder Error setzen.

`false` bedeutet nicht, dass das DHL-Label fehlgeschlagen ist. Der Fehler wird in `WarningText` und am Paket gespeichert.

### `InventoryDocumentNo(PackageHeader: Record "SOUDHL Package Header"): Code[20]`

Erzeugt eine idempotente Belegnummer im Format `DHLBOX-<Paket-ID>`, auf 20 Zeichen begrenzt.

## Interne Management-Methoden

* `TryCompleteExistingPosting`: findet einen bereits gebuchten Item Ledger Entry und repariert den Status.
* `ValidateSetup`: prüft Setupflag, Journal Template/Batch, Location, Item und UoM.
* `FailValidation` / `SetError`: speichern Fehlerzustände.

## Worker 72242985

`OnRun` delegiert an `PostBoxInventory`. Der Worker:

* sucht zuerst nach einem bestehenden ILE mit der Dokumentnummer,
* erzeugt eine Item Journal Line vom Typ Negative Adjmt., Menge 1,
* bucht über `Item Jnl.-Post Line`,
* entfernt die temporäre Journalzeile.

## Idempotenz und Parallelität

* Posted ist terminal.
* Pending jünger als fünf Minuten gilt als laufend.
* Ein vorhandener ILE verhindert Doppelbuchung.
* LockTable schützt die Statusentscheidung.

## Externe Verwendung

Retry-Aktionen dürfen `PostAfterSuccessfulLabel` erneut aufrufen. Status- und ILE-Felder niemals manuell auf Posted setzen.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.solutioo.de/entwicklerdokumentationen-business-central-dhl-connector/dhl-connector-entwicklerdokumentation/codeunit-referenz/72242984-72242985-box-inventory.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
