The Navision Socket Bus Adapter - Receiving a Document

In this example, we use a single instance codeunit to initialize the Navision Communication Component, establish contact to a Navision Socket Bus Adapter, open the socket server to check for received messages, and read the message that is received.

For the purpose of this example, we have defined the following variables:

Variable Name

Data Type

Subtype

Length

CC2

Automation

'Navision Communication Component version 2'.CommunicationComponent

 

SBA

Automation

'Navision Socket Bus Adapter'.SocketBusAdapter

 

InMsg

Automation

'Navision Communication Component version 2'.InMessage

 

InS

InStream

 

 

txt

Text

 

1000

The WithEvents property for the CC2 variable is set to Yes. The socket server uses port 8079 on the local machine.

Example

OnRun()

  IF ISCLEAR(CC2) THEN
    CREATE(CC2);
  IF ISCLEAR(SBA) THEN
    CREATE(SBA);

  CC2.AddBusAdapter(SBA, 0);
  SBA.OpenSocket(8079, '');

CC2::MessageReceived(VAR InMessage : Automation)

  InMsg:= InMessage;

  InS:= InMsg.GetStream();

  WHILE NOT (InS.EOS) DO
  BEGIN
    InS.READ(txt);
    MESSAGE(txt);
  END;

  InMsg.CommitMessage();

More information:

Navision Socket Bus Adapter

Navision Socket Bus Adapter: Setting Up Interfaces