Skip to content

Developer Interface

This page is for AL developers who want to create DHL labels without the Create Label Dialog or extend the connector through events. It is not required for normal use of the app.

Every entry point described here takes the same route as the dialog: licence check, shipping rules, contract resolution, tracking entry and the hub events all apply.

Object Purpose
ALN MCDHL Label API (codeunit 73334792) Create a label for a sales order or a posted sales shipment
ALN MCDHL Label Services (codeunit 73334782) Service codes of the additional services and helpers for the service selection
ALN MCDHL Evt Publisher (codeunit 73334798) Public events of the request builder and the shipping rules
ALN MC Shipment Mgmt. (hub, codeunit 73334603) Carrier-neutral hub entry point the Label API uses internally

Creating a label

Additional services are passed as a temporary ALN MCDHL Shipment VAS record. Every field of that record is honoured, including the ones the dialog does not offer: cash on delivery, ident check, Packstation, endorsement, return address.

var
    LabelApi: Codeunit "ALN MCDHL Label API";
    TempVAS: Record "ALN MCDHL Shipment VAS" temporary;
    EntryNo: Integer;
begin
    TempVAS.Init();
    TempVAS."Visual Check of Age" := TempVAS."Visual Check of Age"::A18;
    TempVAS."Additional Insurance" := true;
    TempVAS."Insurance Amount" := 2500;
    TempVAS."Insurance Currency" := 'EUR';

    EntryNo := LabelApi.CreateLabel('SO-2026-01187', TempVAS);
end;

CreateLabelFromShipment works the same way but expects the number of a posted sales shipment. Both procedures also exist with weight in grams, product code (shipping agent service code), ship-to overrides and a hub service selection:

EntryNo := LabelApi.CreateLabel(
    'SO-2026-01187', 1850, 'PAKET', TempShipToOverrides, TempVAS, TempLabelSvcSelection);

Return value and errors

  • The return value is the Entry No. of the ALN MC Shipment Label record.
  • A provider or licence problem raises Error(); no label is created.
  • A failed DHL call does not raise an error. The label then has Status = Error and the DHL message is stored in Error Message.
  • Shipping rules run on this route as well. They add services but never overwrite values you passed in.
  • The DHL setup defaults the dialog preselects (default GoGreen Plus, default insurance and so on) are not applied. Pass them explicitly.
  • Where the VAS record and the service selection set the same field, the service selection wins.
  • A service parameter that does not match the format or is too long raises an error. No label is created with a service silently missing.

Service codes

Instead of the VAS record, services can be passed as a hub service selection (ALN MC Label Svc. Selection). This is the route the hub REST API uses as well. The codes are published by ALN MCDHL Label Services; parameters are limited to two fields of 50 characters.

var
    LabelServices: Codeunit "ALN MCDHL Label Services";
    TempLabelSvcSelection: Record "ALN MC Label Svc. Selection" temporary;
begin
    LabelServices.AddService(TempLabelSvcSelection, LabelServices.AgeCheck(), 'A18', '');
    LabelServices.AddService(TempLabelSvcSelection, LabelServices.Insurance(),
        LabelServices.FormatAmountParameter(2500), 'EUR');
    LabelServices.AddService(TempLabelSvcSelection, LabelServices.Locker(), '123', '12345678');
end;
Code Procedure Service Parameter 1 Parameter 2
GOGREEN_PLUS GoGreenPlus() GoGreen Plus
BULKY_GOODS BulkyGoods() Bulky goods
RETURN_LABEL ReturnLabel() Include return label
PREF_NEIGHBOUR PreferredNeighbour() Preferred neighbour Name and address
PREF_LOCATION PreferredLocation() Preferred location Drop-off location
NO_NEIGHBOUR NoNeighbourDelivery() No neighbour delivery
PREF_DAY PreferredDay() Preferred day Date yyyy-mm-dd
AGE_CHECK AgeCheck() Visual check of age A16 or A18
NAMED_PERSON_ONLY NamedPersonOnly() Named person only
SIGNED_BY_RECIPIENT SignedByRecipient() Signed for by recipient
INSURANCE Insurance() Transport insurance Amount, point as decimal separator ISO currency
IDENT_CHECK IdentCheck() Ident check First|Last|yyyy-mm-dd A16 or A18
LOCKER Locker() Packstation Locker ID Post number
POSTFILIALE PostOffice() Post office branch Retail ID Post number
ENDORSEMENT Endorsement() Endorsement RETURN or ABANDON
PDDP PostalDeliveryDutyPaid() Postal Delivery Duty Paid
PREMIUM Premium() Premium (international)

Parameter helpers: FormatDateParameter, FormatAmountParameter, AgeCheckParameter, BuildIdentCheckParameter. The values are independent of the session language; amounts and dates are written in XML format.

Cash on delivery

Cash on delivery needs account holder, IBAN, BIC and transfer notes and therefore has no service code. It is passed exclusively through the fields Cash on Delivery, COD Amount, COD Currency and COD * of the VAS record.


Events

Hub (ALN MC Shipment Evt Publisher, codeunit 73334602)

Event When
OnAfterCreateShipmentLabel Label created successfully, tracking entry written
OnCreateShipmentLabelError DHL call failed, label stored with status Error
OnAfterCancelShipment Shipment cancelled
OnAfterDeliveryStatusChanged Delivery status changed by tracking

DHL (ALN MCDHL MC Integration, codeunit 73334775)

Event When
OnBeforeCreateDHLLabel Before shipping rules and request building, IsReturn marks return labels
OnAfterCreateDHLLabel After a successful DHL response

DHL (ALN MCDHL Evt Publisher, codeunit 73334798)

Event When
OnAfterBuildShipmentJson The JSON of one shipment is complete and can be enriched before sending
OnBeforeApplyRuleAction Before the action of a matching shipping rule, IsHandled replaces the default action
OnAfterApplyRuleAction After the action of a matching shipping rule

The events of the same name in ALN MCDHL Request Builder and ALN MCDHL Rules Engine are obsolete. Those codeunits are internal; other apps could never subscribe to them.


Notes

  • Licence. The Label API checks the DHL licence like the dialog does. Without an active licence or demo no label is created.
  • Permissions. The calling user needs the permission set ALN MCDHL User or the execute rights on the codeunits it contains.
  • Services and participation. Services such as bulky goods or insurance need a matching DHL participation in the contract lines, see Profiles & Billing.
  • Context on abort. If the hub aborts before the label exists, no state is left behind that could affect a later label. The VAS record you pass is bound to the document number.