Extra Process
Extra processing is optional and used for starting a compiled EDI-C program. As an example the Extra process program in the Input definition could decrypt the data obtained before sending it on to the conversion program. The Extra processing program is executed after receiving the data.
EDI-C program argument(s) (optional)
The arguments or text is transferred to the extra process program as a string, in argv[2]. The arguments do not have to be separated with commas. The text in the field is passed to the program as one string in argv[2]. There are three macros that can be used in this field which expands into useful information once passed to the EDI-C program.
Transaction State after Execution
The exit code of the extra process program in combination with logged values can set the message processing transaction in different states.
For logging purposes there are two EDI-C standard functions:
log (string errortext) - this function adds the "errortext" string to the integration server error log
loginfo (string infotext) - this function adds the "infotext" string to the integration server informational log
If you use any of the log functions in the extra processing program you get different behavior in the transaction state.
exitcode = 0 - will always mark the transaction state as OK, the following program in the transaction chain will be executed.
exitcode > 0 - and used the log function - marks as if an ERROR had occurred in extra processing program, the following program in the transaction chain will not be executed.
exitcode > 0 - and used the loginfo function - marks as if an ABORT had occurred in extra processing program, the following program in the transaction chain will not be executed.
Extra Process Input Program
An extra process program can be added to the input adapter to manipulate the input data before it is forward to the conversion definition(s). The difference between a pre-process program and an extra process program is that the extra process program is general for all the integrations that is connected to the same input adapter.
The extra process program is called with the following arguments:
argv[1] – Message
argv[2] – Extra argument
argv[3] – Not in use
argv[4] – Data transfer mode, 0 = memory, 1 = file
argv[5] – In remote ID
argv[6] – In message ID (DatasetID)
Exit codes from program
The following codes can be used when exiting a extra process program.
93 – UnknownMessage
0 – OK
1 – Error
Below you can see an example of what an Extra processing program can look like. The function of this example program is that is first backs up the message before replacing the character "#" with the character of the second argument, argv[2] typed in the EDI-C program argument field. The Extra processing program is programmed according to the EDI-C programming structure. For more information on programming EDI-C see The EDI-C programming language help. Beyond the specific functionality, this code can easily be reused as a framework for other Extra Process programs.
///////////////////////////////////////////////////////////////////////
//
// Inobiz Integration Server example program (Extra Processing)
//
// Program function:
// Extra process program example for an input or output definition
// This example first saves a copy of the message to a file and
// then replaces arbitrary character with "#".
//
// Arguments
// argv[1] - Message
// argv[2] - Argument string from the "EDI-C program argument" field
//
// Exit codes:
// 0 = normal execution
// 1 = Error occurred in extra process program
//
///////////////////////////////////////////////////////////////////////
void main (void)
{
// If no extra arguments is passed in the argv[2] string
// then log error and exit with error code 1.
integer nExitCode;
if(argv[2] == "")
{
log("No data in argv[2], can not run replace function!");
nExitCode = 1; // Exit error
}
else
{
// Saves a copy of the message to file before replace.
// Filename is retrieved from first field in the argv[2] string
// argv[2] is in the following format "<filename>,<replacement character>"
string sFilename;
sFilename = field (argv[2], ",", 1);
writefile(sFilename, argv[1]);
loginfo("Backup file saved!");
// Gets the replacement character from argv[2] string then makes
// the replacement.
string sReplaceChar;
sReplaceChar = field (argv[2], ",", 2);
argv[1] = replace(argv[1], "#", sReplaceChar);
loginfo("Replace is done!");
nExitCode = 0; // Exit OK
}
exit(nExitCode);
}
0 Comments