Custom out

This communication method gives you the option of creating and writing custom designed EDI-C programs to send/place messages in to a third party system or communications software.

 

An EDI-C program written for the Inobiz Integration Server must call a predefined set of functions to achieve the send functionality. To do this requires some knowledge of how EDI-C programs are, which it is assumed that the reader possesses.

mceclip0.png

Name

Name of the adapter and the filename of the adapter then it saved.

Comment

Optional comment about the adapter.

Tags

Tags that's are searchable from the files view.

 

Cep File

Drag and drop a cep file here. That's build for Custom In adapter, se bottom of this page.

Cep Arguments

To add arguments to the program, write the argument value in this field - then click the Add button to put/enter the value into the argument list. Max. 16 arguments can be specified.

 

Schedule 

Drag and drop a schedule for the adapter. If no schedule is there the adapter is event driven.

Event policy

Drag and drop a event policy if you don't want to use the default policy.

Extra process

Drag and drop a cep holder here. More info about extra process.

Arguments

Arguments for the extra process.

 

Advanced Settings

Error Handling Settings

Trace Settings

 

 

How to Write a Custom Output EDI-C Program

The following functions must exist in a custom output EDI-C program. If a function is missing or has the wrong number of parameters, the program will not start.

void main ()

The main function is not used in the Integration Server environment; it must exist for the compilation only.

integer ibzPutMessage(string sMessage, integer iDataSetID)

This function is to send/put data into the third party application/system. The Variable "sMessage" contains the message while "iDataSetID" is a unique ID for the transaction.

integer ibzInitJob(integer iJobID)

This function is executed before you start sending messages. Its purpose is to carry out the initialization before starting the send job. The "iJobID" variable is an unique id for the send job.

integer ibzDeinitJob(integer iJobID)

This function is executed after the messages have been sent. Its purpose is to carry out de-initialization once the send job is completed. The "iJobID" variable is a unique id for the send job.

string ibzGetRemoteID()

This function is to return the remote ID for the third party application

integer VerifyInparameters()

This function is to validate the output parameters and returns true if everything is OK

integer ConformanceLevel()

This function returns the program conformance level. Today there is only one conformance level, which is "1". In future releases, this may be changed.

integer Initilize()

This function executes when the program starts. Here you can carry out all the initialization, before entering the send loop.

void Terminate()

This function is executed when the program is shuts down. Here you can carry out all of the de-initialization before exiting the program.

 

Custom Program for Output Adapters

 

The following functions must exist in the custom EDI-C program. If some function doesn't exist or has the wrong number of parameters the program will not start. The functions will be executed by the server in the order described below.

integer VerifyInparameters()

This function shall validate in parameters and return true if everything is OK

integer Initialize()

This function is executed before you start fetching messages. The purpose is to do initialization before the fetch job is started. The iIbzSessionJobID variable is a unique id for the send job.

integer Send()

This function shall send/put data into the third party application/system. The vriable sIbzMessage contains the message. The variable sIbzMessageRemoteID is to be set the output filename.  The Send function is executed by the server once for each message in the output queue.

integer Terminate()

This function is executed when the program is shutdown and here you can do all of the de-initialization before exiting the program.

void main ()

The main function is not used in the Integration Server environment it must exist for the compilation only.

 

//

//

// This program example below sends a file to a FTP server

//

//

 

object g_objFtp; // FTP object

// The variables below are mandatory

string sIbzMessage;               // Sting containing the message that is to be sent
integer iIbzMessageLength;        // Lenght of the string that is to be sent
string sIbzMessageFile;           
integer bIbzMemoryTransferMode =1;  
integer iIbzSessionJobID;         // ID identifying the  session.
string sIbzMessageAdapterMetaData;
string sIbzMessageMetaData;       
integer iIbzMessageMetaDataLength;
string sIbzReceivedRequestMessageId;
string sIbzReceivedReplyCorrelationId;
integer iIbzTransactionID;
string sIbzMessageRemoteID;  
string sIbzMessageID;             
string sIbzMessageCorrelationID;  
string sSendMessageRemoteID;
string sSendMessageID;    
string sIbzSendRequestMessageId;
string sIbzCorrelationId;
integer iIbzMessageAdapterMetaDataLength;

//

string  m_sFtpHost;
integer m_iFtpPort;
string  m_sFtpLoginName;
string  m_sFtpPassword;
string  m_iTransferMode;
integer m_iPassiveMode, bRenameFile, bFileAppend;
string  m_TargetPath;
string  m_sLocalPath,  m_TempTransferPath;
integer g_bDebugMode, bContinue;
string m_sActivityFileName, g_sMessageName, g_sTransDir;
integer g_iLargeFile;
integer iDebug;

 

// ****************************************************************
//  General functions
// ****************************************************************

// Possible return codes: rcOK, rc Error, rcFatal.
integer Verifyparameters()
{
g_bDebugMode = ("trace_on" == tolower(argv[9]));
if(g_bDebugMode)
  trace(1);

m_sFtpHost = argv[1];
m_iFtpPort = argv[2];
m_sFtpLoginName = argv[3];
m_sFtpPassword = argv[4];
if(tolower(argv[5]) == "bin")
 m_iTransferMode = 1; // BINARY
else
  m_iTransferMode = 0; //ASCII (default)
if(tolower(argv[6]) == "active")
  m_iPassiveMode = 0; //Active
else
  m_iPassiveMode = 1; // Passive
m_TargetPath = CheckBackslash(argv[7]);
m_TempTransferPath = CheckBackslash(argv[8]);  

  return 0;

}

 

integer Initialize()
{
g_bDebugMode = ("trace_on" == tolower(argv[9]));
if(g_bDebugMode)
 trace(1);

m_sFtpHost = argv[1];
m_iFtpPort = argv[2];
m_sFtpLoginName = argv[3];
m_sFtpPassword = argv[4];

if(tolower(argv[5]) == "bin")
  m_iTransferMode = 1; // BINARY
else
  m_iTransferMode = 0; //ASCII (default)
if(tolower(argv[6]) == "active")
  m_iPassiveMode = 0; //Active
else
  m_iPassiveMode = 1; // Passive
m_TargetPath = CheckBackslash(argv[7]);
m_TempTransferPath = CheckBackslash(argv[8]);   

string sMsg;

// Create FTP object
g_objFtp = createobject("ibzftpcli.Adapter");
if(objectresult != "")
  {
 sMsg = "Unable to get COM component '"
    & "ibzftpcli.Adapter"
    & "'. Error code '"
    & objectresult
    & "'. Is component registered correctly?";
  log(sMsg);
 return 3;

  }

bContinue = true;
string sLogMsg;  

if (g_bDebugMode)
  g_objFtp.FtpTrace (getcwd() & "\\TraceDir\\" & "CustomFTP-LargeFile.log");  

// Make ftp login
if (bContinue)
  {
 bContinue = g_objFtp.LogIn(m_sFtpHost, m_sFtpLoginName, m_sFtpPassword, m_iFtpPort, m_iPassiveMode);

  if (bContinue == 0)
    {
    log("Login failed, PrintExportFTP file transfer aborted, will retry later. ");
    sLogMsg = "FTP port number: '" & m_iFtpPort &
      "', FTP address: '" & m_sFtpHost &
      "', User name: '" & m_sFtpLoginName &
      "', Password: '" & m_sFtpPassword & "'";

    log(sLogMsg);
    bContinue = false;
    }

  }

if(bContinue == -1) // VB_TRUE = -1
  return 0; // OK

return 3; // Fel

}

 

void Terminate()
{
if(g_bDebugMode)
  trace(1);

integer bContinue, iRetval;
string sText;

// Log out from FTP server
if (!g_objFtp.LogOut())
  {
  sText = "PrintExportFTP log off failed! ";
  log(sText);
  }

}

 

// ****************************************************************
//  Output functions
// ****************************************************************

 

// Possible return codes: rcOK, rcError, rcFatal

integer Send()
{
if(g_bDebugMode)
  trace(1);

m_TargetPath = CheckBackslash(argv[7]);
m_TempTransferPath = CheckBackslash(argv[8]);
m_sLocalPath = sIbzMessage;
m_TempTransferPath = m_TempTransferPath & filename(sIbzMessage);
m_TargetPath = m_TargetPath & filename(sIbzMessage);

// Send file
bContinue = g_objFtp.SendFile (m_TempTransferPath, m_sLocalPath, bRenameFile, m_iTransferMode, bFileAppend);

if (bContinue == 0)
  {
  log("Failed sending file, PrintExportFTP file transfer aborted, will retry later.");
  return 3;
  }
else
  {
 bContinue = g_objFtp.Rename (m_TempTransferPath, m_TargetPath);

    filedelete(sIbzMessage);
 }
return 0;

}

 

//*********************************************
// Debug info
//*********************************************

void LogDebugInfo( string s )
{
if ( iDebug == 1 )
  {
 loginfo( s );

  }

}

 

// ****************************************************************
//  Main function
// ****************************************************************

 

void main()
{

;

}

 

string CheckBackslash(string sPath)
{
// Add backslash to path if doesn't exist
if (substr(sPath, strlen(sPath),1) != "//")
   sPath = sPath & "//";
return sPath;
}

 

 

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk