Custom in

 

mceclip1.png

This communication adapter gives you the possibility to create and write custom designed EDI-C programs to fetch messages from third party systems or communication software.

An EDI-C program written for the Inobiz Integration Server must call upon a predefined set of functions to achieve the fetch functionality.

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.

 

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

 

Example Custom Program for Input Adapters

 

This communication adapter gives the possibility to create and write custom designed EDI-C programs to fetch messages from third party systems or communication software.

 

The following functions must exist in a custom EDI-C program for an input adapter. If any function is missing 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 is to validate the input parameters and returns true if everything is OK

integer Initialize()

This function is executed before GetMessagedata starts. The function shall initialize all needed resources in the GetMessagedata function

integer WaitForMessage (integer iWaitTime)

This function is called when the custom adapter is set to be event driven. The function waits for the message in a maximum number of seconds.

integer GetMessageData()

Inserts the message to the conversion engine.  The variable sIbzMessage have to contain the source message as a string or the path to the input file depending on the conversion program. iIbzMessageLength contains the lenght of the string in the sIbzMessage variable. The function will be called in a loop to fetch several messages as long as the returncode is 12; When  the return code is 13 and no more messages exists the system will continue to next function.

integer RemoveSourceMessage()

Removes the source message that is used in GetMessageData function. This function is executed directly after the GetMessageData function. The returncode is supposed to be 12 to continue.

integer RestoreSourceMessage()

Restores the source message that is used in GetMessageData function. This function is useful if the source message is removed and a rollback function is used and the source message has to be restored. The returncode is supposed to be 12 to continue.

integer GetAllMessages()

This function is called once when the adapter is started. The function returns 12 if data exists or 13 if no data exists in function GetMessageData(void)

integer Terminate()

This function is executed when the program is shutting down. Here you can perform all of the de-initialization required, before exiting the program.

void main ()

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

//

//

// The program example below connects to a FTP server and retrieves

// the files to a local directory for conversion

//

//

 

object g_objFtp;
string sIniParameterFile, sSearchPath, sFilter;
integer iDebug, iFileHandle;
integer iMessExists=0;
const rcOK = 0;
                   

const rcError = 3;               

const rcFatal = 11;    
const rcMessagesExists = 12;      
const rcNoMessagesExists = 13;  
const rcTimeout = 14;             

object   objFolderEvent;
integer  bIsFirstFileProcessed;


// The variables below are mandatory

string sIbzMessage;               // ´The vaiable should contian the data that is going to be sent to the conversion engine
IbzMemoryTransferMode == true.
integer iIbzMessageLength;        // The length of the string in variable sIbzMessage
string sIbzMessageFile;           // The filename of the input file
integer bIbzMemoryTransferMode =1;  
integer iIbzSessionJobID;         // ID which identifies the  session.
string sIbzMessageAdapterMetaData;
string sIbzMessageMetaData;       
integer iIbzMessageMetaDataLength;
string sIbzReceivedRequestMessageId;
string sIbzReceivedReplyCorrelationId;
integer iIbzTransactionID;
string sIbzMessageRemoteID;       


string  m_sFtpHost;
integer m_iFtpPort;
string  m_sFtpLoginName;
string  m_sFtpPassword;
string  m_iTransferMode;
integer m_iPassiveMode, bRenameFile, bFileAppend;
string  m_sFtpDir;
string  m_sFileMask;
string  m_sLocalPath, m_sFileName;
integer g_bDebugMode, bContinue;
string m_sActivityFileName;          
string g_sMessageName;
string g_sTransDir;
integer g_iLargeFile;

 

// Testvariabler
integer iSleepIndex = 1000;

 

///////////////////
//
// Verifyparameters
//
///////////////////

 

integer Verifyparameters()
{
g_bDebugMode = ("trace_on" == tolower(argv[10]));
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_sFtpDir = argv[7];
m_sFileMask = argv[8];
m_sLocalPath = argv[9];

return 0;

}

 

////////////
//
//Initialize

//
////////////

 

integer Initialize()
{
trace(1);
string sMsg;

g_bDebugMode = ("trace_on" == tolower(argv[10]));
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_sFtpDir = argv[7];
m_sFileMask = argv[8];
m_sLocalPath = argv[9];

// 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(m_sFtpDir != "")
    {
    bContinue = g_objFtp.ChangeDir(m_sFtpDir);
   if (!bContinue)
      {
      sLogMsg = "FTP - Failed to change to the following remote directory: " & m_sFtpDir & " FTP component message:" &               

        GetFTPErrorString();  
     log(sLogMsg);

      }
    }
 }

if(bContinue == -1) // VB_TRUE = -1
  return rcOK; // OK
return rcError; // Fel

}

 

////////////////////
//
// GetFTPErrorString

//
////////////////////

 

string GetFTPErrorString()
{
string sFTPError;
if(g_objFtp.m_sErrorString == "")
  sFTPError = "<No message>";
else
  sFTPError = g_objFtp.m_sErrorString; 
 

return sFTPError;

}

 

//////////////////////
//
// RemoveSourceMessage

//
//////////////////////

 

integer RemoveSourceMessage(void)
{
return rcOK;

}

 

////////////
//
// Terminate
//
////////////

 

void Terminate()
{
if(g_bDebugMode)
  trace(1);
integer bContinue;
integer iRetval;
string sText;

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

}

 

/////////////////
//
// WaitForMessage

//
/////////////////

 

integer WaitForMessage(integer iWaitTime)
{
return rcOK;
}

 

/////////////////
//
// GetMessageData
//
/////////////////

 

integer GetMessageData (void)
{
bContinue = g_objFtp.ReceiveFiles (m_sFileMask, m_sLocalPath, m_iTransferMode);

if (!bContinue)
  {
  log("FTP - Error occured during file reception. FTP component message: " & GetFTPErrorString());
  return rcError;
  }

m_sFileName = findfirst (m_sLocalPath & m_sFileMask);
// If no files were found on FTP Server
if (m_sFileName == "")
  return rcNoMessagesExists;

if (!g_objFtp.DeleteFile (m_sFtpDir & m_sFileName))
  {
  log("FTP - Error deleting remote file: " & GetFTPErrorString() & ", FTP directory: " & m_sFtpDir & " - Filename:" & m_sFileName);
  }         

sIbzMessage = (m_sLocalPath & m_sFileName);
iIbzMessageLength = strlen (sIbzMessage);        

sIbzMessageRemoteID = m_sLocalPath & m_sFileName;   

filemove(m_sLocalPath & m_sFileName, m_sLocalPath & field(m_sFileName, ".",1) & ".DONE");      

return rcMessagesExists;

}

 

///////////////////////////////////////////////////////////////////
//
// GetAllMessages
//
///////////////////////////////////////////////////////////////////

integer GetAllMessages(void)
{
return rcMessagesExists;  

}

 

///////////////////////
//
// RestoreSourceMessage
//
///////////////////////

 

integer RestoreSourceMessage(void)
{
return rcOK;
}

 

///////////////
//
// LogDebugInfo
//
///////////////

 

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

  }
}

 

///////////////
//
// main

//
///////////////

 

void main()
{

;

}

 

 

 

 

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk