Aangepaste communicatie afhandelaar
In Anveo EDI Connect kunt u aangepaste codeunits gebruiken om gegevensuitwisseling af te handelen. Je kunt ervoor kiezen om alleen de methoden te implementeren die je nodig hebt en bijvoorbeeld alleen het verzenden van bestanden toestaan.
Aangepaste codeunits worden ondersteund op alle versies van onze module. We zullen het illustreren aan de hand van een Dynamics Extension geschreven in AL, maar hetzelfde geldt voor de oudere ontwikkelplatformen.
Een aangepaste communicatie afhandelaar gebruiken
Als je systeem een aangepaste communicatiehandler heeft, dan heb je zijn codeunit nodig om het communicatiekanaal in te stellen. Je kunt het instellen als elke geïntegreerde communicatie handler, maar je moet de Codeunit ID met de hand invoeren. De lookup staat je niet toe om je aangepaste handler te selecteren. Vernieuw daarna de pagina en configureer het kanaal, indien nodig, door op Configure te klikken.
Basisvereisten
Aangepaste communicatie codeunit krijgt een speciaal record “ANVEDI Format Control” van de module die wordt doorgegeven aan de OnRun trigger. Je moet de gevraagde communicatie-actie uit dat record halen en je code dienovereenkomstig aanroepen.
Voorbeeld
codeunit 50000 "My Anveo File Handler"
{
TableNo = "ANVEDI Format Control";
trigger OnRun()
var
EDICommunicationChannel: Record "ANVEDI Communication Channel";
EDITransmission: Record "ANVEDI Transmission";
ProcessingQueue: Record "ANVEDI Processing Queue";
begin
ProcessingQueue.Get("Processing Queue Entry No.");
ProcessingQueue.TestField("Communication Channel");
EDICommunicationChannel.Get(ProcessingQueue."Communication Channel");
if Action in [Action::Receive, Action::Send,="" Action::Archive,="" Action::Delete]=""] then begin
EDITransmission.Get(ProcessingQueue."Transmission Entry No.");
end;
case Action of
Action::Connect:
// Call your code to establish a connection
;
Action::Close:
// Your code to close a connection
;
Action::"Configure Comm.":
// Show configuration options
;
Action::"Receive/List":
ListFiles(EDICommunicationChannel);
Action::Receive:
ReceiveFile(EDICommunicationChannel, EDITransmission);
Action::Send:
SendFile(EDICommunicationChannel, EDITransmission);
Action::Archive:
ArchiveFile(EDICommunicationChannel, EDITransmission);
Action::Delete:
DeleteFile(EDICommunicationChannel, EDITransmission);
else
Error(NotSupportedErr);
end;
end;
var
NotSupportedErr: Label 'Not supported by communication codeunit.';
EDICommunicationMgmt: Codeunit "ANVEDI Communication Mgmt";
local procedure ListFiles(EDICommunicationChannel: Record "ANVEDI Communication Channel")
var
Transmission: Record "ANVEDI Transmission";
begin
// Create one transmission per message you want to import.
// We recommend to check the transmission table for the same comm. channel with the same "Tag 1" and "Tag 2"
// to prevent receiving the same message again, before inserting a new transmission
Transmission.Init;
Transmission."Entry No." := 0;
Transmission.Validate(Direction, Transmission.Direction::Incoming);
Transmission.Validate("Communication Channel Code", EDICommunicationChannel.Code);
Transmission.Validate(Description, 'Example file');
Transmission.Validate("Tag 1", 'Some data to identify');
Transmission.Validate("Tag 2", 'More data');
Transmission.Validate("Transmission Date/Time", CURRENTDATETIME);
EDICommunicationMgmt.InsertTransmissionAndReceive(EDICommunicationChannel, Transmission);
end;
local procedure ReceiveFile(EDICommunicationChannel: Record "ANVEDI Communication Channel";EDITransmission: Record "ANVEDI Transmission")
var
EDIMessage: Record "ANVEDI Message";
EDIProcessingQueue: Record "ANVEDI Processing Queue";
MessageFile: File;
InS: InStream;
OutS: OutStream;
begin
EDIMessage.Init;
EDIMessage.Validate("Transmission Entry No.", EDITransmission."Entry No.");
EDIMessage.CreateOutStream(OutS);
// Get the data and write it to OutS
EDIMessage.Insert(true);
// If you want to call archive afterwards:
EDIProcessingQueue."Processing Type" := EDIProcessingQueue."Processing Type"::Archive;
EDIProcessingQueue."Communication Channel" := EDICommunicationChannel.Code;
EDIProcessingQueue."Transmission Entry No." := EDITransmission."Entry No.";
EDIProcessingQueue.Insert(true);
// If you want to call delete afterwards
EDIProcessingQueue."Processing Type" := EDIProcessingQueue."Processing Type"::Delete;
EDIProcessingQueue."Communication Channel" := EDICommunicationChannel.Code;
EDIProcessingQueue."Transmission Entry No." := EDITransmission."Entry No.";
EDIProcessingQueue.Insert(true);
// Release the message
EDIMessage.Release();
end;
local procedure DeleteFile(EDICommunicationChannel: Record "ANVEDI Communication Channel";EDITransmission: Record "ANVEDI Transmission")
begin
// Your code here
end;
local procedure ArchiveFile(EDICommunicationChannel: Record "ANVEDI Communication Channel";EDITransmission: Record "ANVEDI Transmission")
begin
// Your code here
end;
local procedure SendFile(EDICommunicationChannel: Record "ANVEDI Communication Channel";EDITransmission: Record "ANVEDI Transmission")
var
EDIMessage: Record "ANVEDI Message";
InS: InStream;
begin
EDIMessage.SetRange(EDIMessage."Transmission Entry No.", EDITransmission."Entry No.");
if EDIMessage.FindSet then begin
repeat
if EDIMessage.CREATEINSTREAM(InS) then begin
// Send the data using the stream
end;
EDIMessage.CLOSE();
until EDIMessage.Next = 0;
end;
end;
}
Afhankelijkheden
Als je een aangepaste communicatiehandler wilt maken in AL, moet je een afhankelijkheid toevoegen aan de Anveo EDI Connect-module.
De waarden voor de OnPremise Extension zijn:
{
"id": "25286BD2-B08A-49F9-B613-64122CCEE4E1",
"name": "Anveo EDI Connect - OnPremise",
"publisher": "conion media GmbH",
"version": "5.x.y.z"
}
Zorg ervoor dat u x, y, z vervangt door het juiste versienummer.
De waarden voor de Business Central Online en Universele Code Extension zijn:
{
"id": "FC195C4F-19BF-4167-BFE8-6D1FF7D266BC",
"name": "Anveo EDI Connect",
"publisher": "conion media GmbH",
"version": "5.x.y.z"
}
Zorg ervoor dat u x, y, z vervangt door het juiste versienummer.