Aangepaste communicatiehandler
In Anveo EDI Connect kunt u aangepaste codeunits gebruiken om de gegevensuitwisseling te verwerken. U kunt ervoor kiezen om alleen de methoden te implementeren die u nodig hebt en bijvoorbeeld alleen het verzenden van bestanden toe te staan.
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.
Als u de Dynamics Extension versie van Anveo EDI Connect gebruikt, kunt u als alternatief een HTTP/HTTPs-service in elke programmeertaal aanbieden zonder Dynamics Extension aan te maken. De API-definitie is op aanvraag beschikbaar bij ons EDI-supportteam.
Het gebruik van een aangepaste communicatiehandler
Als uw systeem een aangepaste communicatiehandler heeft, heeft u de codeunit nodig om het communicatiekanaal in te stellen. U kunt het instellen als elke geïntegreerde communicatiehandler, maar u zult de Codeunit ID met de hand moeten invoeren. De lookup laat u niet toe om uw aangepaste handler te selecteren. Daarna verversen we de pagina en configureren we het kanaal, indien nodig door te klikken op Configure.
Basisvoorwaarden
De aangepaste codeunit krijgt een speciaal record “ANVEDI Format Control” van de module die aan de OnRun-trigger wordt doorgegeven. Je moet de gevraagde communicatie-actie uit dat record halen en je code dienovereenkomstig bellen.
Voorbeeld
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
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 u een aangepaste communicatiehandler wilt maken in AL, moet u een afhankelijkheid toevoegen aan de Anveo EDI Connect-module.
De waarden voor de OnPremise Extension zijn:
1 2 3 4 5 6 |
{ "appId": "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 Extension zijn:
1 2 3 4 5 6 |
{ "appId": "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.