Sample local connection entry
The following example illustrates a local connection entry named Customer.
The entry is used in a Master Template.
WITH Customer IN DID.Customer
DO
…
OD
The entry as defined in the DID document. The entry definition assumes that the C code is implemented in a DLL Example.dll.
DEFINE_ENTRY
NAME Customer
MODEL_DOC_STATEMENT WITH
DATA_RETRIEVAL "Customer@Example.dll"
KEY_RETRIEVAL "*NONE"
CALLING_CONVENTION DLL32
DEFINE_PARAMETERS
Customer_number NUMERICAL ( 9 0)
END_DEFINE_PARAMETERS
DEFINE_FIELDS
Customer_number NUMERICAL ( 9 0)
Surname C_CHAR (31 )
First_name C_CHAR (31 )
Initials C_CHAR (11 )
Date_of_birth NUMERICAL (11 0)
Date_of_death NUMERICAL (11 0)
Gender C_CHAR ( 2 )
Marital_state C_CHAR ( 2 )
Partner_number NUMERICAL ( 9 0)
END_DEFINE_FIELDS
END_DEFINE_ENTRY (* Customer *)
The following is a C code sample for data retrieval for the entry Customer. This code is generated by the C code wizard. At the comment Fill variable(s), insert your own code to retrieve the contents of the result fields.
/*
* Function: Customer
*/
#include "itpentry.h"
#include "itpcnv.h"
#ifdef __cplusplus
extern "C" {
int __stdcall _export Customer(void);
}
#endif
int __stdcall _export Customer(void){
int rc;
/* Input definition */
unsigned char InputRecord[1+1+9];
int Customernumber;
/* Output definition */
unsigned char OutputRecord[117];
int Customernumber;
unsigned char Surname[31 + 1];
unsigned char Firstname[31 + 1];
unsigned char Initials[11 + 1];
int Dateofbirth;
int Dateofdeath;
unsigned char Gender[2 + 1];
unsigned char Maritalstate[2 + 1];
int Partnernumber;
/* Initialize entryapi */
APICALL(ITPAPIR(3));
/* Read input parameter block */
APICALL(ITPRCV(InputRecord, sizeof(InputRecord)));
Customernumber = GetNumericalField(InputRecord+2, 9);
/* Prepare for sending output to ITP */
APICALL(ITPOPEN());
/* Prepare and send output (record(s)) to ITP */
..... /* Fill variable(s) */
PutNumericalField(OutputRecord + 0, Customernumber);
PutTextField(OutputRecord + 9, Surname, 31);
PutTextField(OutputRecord + 40, Firstname, 31);
PutTextField(OutputRecord + 71, Initials, 11);
PutNumericalField(OutputRecord + 82, Dateofbirth);
PutNumericalField(OutputRecord + 93, Dateofdeath);
PutTextField(OutputRecord + 104, Gender, 2);
PutTextField(OutputRecord + 106, Maritalstate, 2);
PutNumericalField(OutputRecord + 108, Partnernumber);
APICALL(ITPSND(OutputRecord, sizeof(OutputRecord)));
/* Close and return to ITP */
APICALL(ITPCLOSE(0));
return 0;
}