Komunikacja niestandardowa
W Anveo EDI Connect można używać niestandardowych codeunits do obsługi wymiany danych. Możesz zdecydować się na wdrożenie tylko tych metod, które są Ci potrzebne i zezwolić na przykład na wysyłanie tylko plików.
Niestandardowe codeunits do komunikacji są obsługiwane we wszystkich wersjach naszego modułu. Zilustrujemy to na podstawie Dynamics Extension napisanego w AL, ale to samo dotyczy starszych platform programistycznych.
Jeśli korzystasz z wersji Dynamics Extension Anveo EDI Connect, możesz alternatywnie dostarczyć usługę HTTP/HTTP w dowolnym języku programowania bez tworzenia jakiegokolwiek Dynamics Extension. Definicja API jest dostępna na żądanie od naszego zespołu wsparcia EDI.
Korzystanie z niestandardowego sterownika komunikacyjnego
Jeśli Twój system posiada niestandardowy system obsługi komunikacji, będziesz potrzebował codeunit do ustawienia kanału komunikacji. Można go skonfigurować jako dowolny zintegrowany przekaźnik komunikacyjny, ale trzeba będzie ręcznie wprowadzić Codeunit ID kodującej. Lookup nie pozwoli Ci na wybranie własnego opiekuna. Następnie należy odświeżyć stronę i skonfigurować kanał, w razie potrzeby klikając na Configure.
Podstawowe wymagania
Niestandardowa codeunit kodująca komunikację otrzyma specjalny zapis „ANVEDI Format Control” z modułu przekazywanego do wyzwalacza OnRun. Będziesz musiał uzyskać żądaną akcję komunikacyjną z tego nagrania i odpowiednio zadzwonić do swojego kodu.
Przykład
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;
}
Zależności
Jeśli chcesz stworzyć własny handler komunikacji w AL, musisz dodać zależność do modułu Anveo EDI Connect.
Wartości dla rozszerzenia OnPremise Extension są następujące:
{
"appId": "25286BD2-B08A-49F9-B613-64122CCEE4E1",
"name": "Anveo EDI Connect - OnPremise",
"publisher": "conion media GmbH",
"version": "5.x.y.z"
}
Upewnij się, że zastępujesz x, y, z prawidłowym numerem wersji.
Wartości dla Business Central Online Extension są następujące:
{
"appId": "FC195C4F-19BF-4167-BFE8-6D1FF7D266BC",
"name": "Anveo EDI Connect",
"publisher": "conion media GmbH",
"version": "5.x.y.z"
}
Upewnij się, że zastępujesz x, y, z prawidłowym numerem wersji.