Własna obsługa komunikacji
W Anveo EDI Connect możesz użyć niestandardowych codeunits do obsługi wymiany danych. Możesz wybrać implementację tylko tych metod, które są Ci potrzebne i pozwolić np. tylko na wysyłanie plików.
Niestandardowe codeunits komunikacji są obsługiwane na wszystkich wersjach naszego modułu. Zilustrujemy to na podstawie Dynamics Extension napisanego w AL, ale to samo dotyczy starszych platform programistycznych.
Używanie niestandardowego manipulatora komunikacji
Jeśli twój system ma niestandardowy handler komunikacyjny, będziesz potrzebował jego codeunit, aby skonfigurować kanał komunikacyjny. Możesz go skonfigurować jak każdy zintegrowany handler komunikacji, ale będziesz musiał ręcznie wprowadzić Codeunit ID. Lookup nie pozwoli ci wybrać twojego niestandardowego handler’a. Następnie odśwież stronę i skonfiguruj kanał, jeśli to konieczne, klikając na Configure.
Wymagania podstawowe
Custom communication codeunit otrzyma specjalny zapis „ANVEDI Format Control” z modułu przekazanego do wyzwalacza OnRun. Będziesz musiał uzyskać żądaną akcję komunikacyjną z tego rekordu i odpowiednio wywołać swój kod.
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ć niestandardowy handler komunikacji w AL, musisz dodać zależność do modułu Anveo EDI Connect.
Wartości dla Extension OnPremise to:
{
"appId": "25286BD2-B08A-49F9-B613-64122CCEE4E1",
"name": "Anveo EDI Connect - OnPremise",
"publisher": "conion media GmbH",
"version": "5.x.y.z"
}
Upewnij się, że zastąpisz x, y, z prawidłowym numerem wersji.
Wartości dla Extension Business Central Online to:
{
"appId": "FC195C4F-19BF-4167-BFE8-6D1FF7D266BC",
"name": "Anveo EDI Connect",
"publisher": "conion media GmbH",
"version": "5.x.y.z"
}
Upewnij się, że zastąpisz x, y, z prawidłowym numerem wersji.