BUSINESS SOFTWARE, INC. (BSI) CONFIDENTIAL AND PROPRIETARY INFORMATION

Step 4e. -- Call the Locator Function

Note: If the call to ProcessLocations returns a non-zero EmployeeStatus, a call to CommitData Source must be made to COMMIT error messages to the database. If the call to ProcessLocations returns a non-zero EmployeeStatus, a call to GetLocatorPlaces can be made to display TaxFactory-generated location choices.

Call the Locator function as follows:

 

C Instructions:

/*
** Calling the Locator engine
*/

TF9_LOCATOR_EMPLOYEE TFEmployee;
TF9_LOCATION Location[50];
TF9_PLACE Place;
BSI_SHORT LocErr;
BSI_CHAR *RunName = "LOCATION RUN 1";
TF9_SESSION Session;
BSI_SHORT msgn, msgs;
int i = 0;


/*
** Session should be defined by call to ConnectToDataSet - see Step 3
*/


memset(&LEmployee, 0, sizeof(TF9_LOCATOR_EMPLOYEE));
/*
** Populate the Employee details here
**   Employee.NumberOfLocationEntries should match the number of the Location array elements
*/


memset(&Location, 0, LEmployee.NumberOfLocationEntries * sizeof(TF9_LOCATION));
/*
** Populate the Location details here
*/

if (!ProcessLocations(&LEmployee, Location, RunName, Session, NULL))

{
printf("ProcessLocations() error\n");

if (!CommitDataSource(NULL))
printf("Commit data source error\n");

/* Retrieve messages from the Last API call */
if(GetMessages(str, Session, NULL)){
printf("ProcessLocations () returned messages of:\n");
do{
    printf("Message: %s\n", str);
}while(GetMessages(str, Session, NULL));
printf("end of messages\n");
}

/*
** Call GetLocatorPlaces
*/
while(GetLocatorPlaces(&LocErr, &Place, Session, NULL)) {
printf("Place %d code %d\n", i, Place.PCode);
printf("Place %d place name %s\n", i, Place.PlaceName);
printf("Place %d county name %s\n", i, Place.County);
printf("Place %d place type %s\n", i, Place.PlaceType);
printf("Place %d postal code %s\n", i, Place.PostalCode);
i++;
}

}

 

 

COBOL Instructions:

COPY TF9API.
.
.
.
.
.
CALL "PROCESSLOCATIONS" USING
    BY REFERENCE TF90-LOCATOR-EMPLOYEE
    BY REFERENCE TF90-LOCATION (1)
    BY REFERENCE TF90-RUN-ID
    BY REFERENCE TF90-SESSION-ID
    BY REFERENCE RTN-CODE
    BY REFERENCE RTN-STATUS.

IF TF10-LEMP-EMPLOYEE-STATUS NOT=0
    DISPLAY "LEMP-EMPLOYEE-STATUS INDICATES MESSAGES"
    CALL "COMMITDATASOURCE" USING
        BY REFERENCE RTN-CODE
        BY REFERENCE RTN-STATUS
    CALL "GETMSGS" USING
        BY REFERENCE ERROR-MESSAGE
        BY REFERENCE TF10-SESSION-ID
        RTN-STATUS
        PERFORM WITH TEST BEFORE UNTIL RTN-STATUS = 0
            DISPLAY "LOCN MESSAGE: **" ERROR-MESSAGE "**"
            CALL "GETMSGS" USING
                BY REFERENCE ERROR-MESSAGE
                BY REFERENCE TF10-SESSION-ID
                BY REFERENCE RTN-STATUS
        END-PERFORM
ELSE
    DISPLAY "LEMP-EMPLOYEE-STATUS INDICATES SUCCESS"
END-IF.

DISPLAY "NUMBER OF TAXES RETURNED: "
    TF10-LEMP-TAX-ENTRIES.
PERFORM VARYING IDX FROM 1 BY 1
        UNTIL IDX > TF10-LEMP-TAX-ENTRIES
    DISPLAY "TAX CODE(" IDX " ) =
            TF10-LTAX-TAX-CODE OF TF90-LOCATED-TAXES (IDX)
    DISPLAY "TAX TYPE(" IDX " ) =
            TF10-LTAX-USER-TAXTYPE OF TF90-LOCATED-TAXES (IDX)
    DISPLAY "ENACTED(" IDX " ) =
            TF10-LTAX-ENACTED OF TF90-LOCATED-TAXES (IDX)
END-PERFORM..

 

C# Instructions:

TF90API api = new TF90API();
MTF9_LOCATOR_EMPLOYEE LEmployee = new MTF9_LOCATOR_EMPLOYEE();
MTF9_LOCATION[] Location = new MTF9_LOCATION[3];
String RunName = "PENSIONTAXES API TEST";
String[] messages = null;
int i = 0;

/* Populate the Locator Employee details here */

/* Populate the Location details here */

/* Calling the Locations engine */
if (api.processLocations(ref LEmployee, Location, RunName) <= 0)
Console.WriteLine("processLocations() error\n");
else
{

System.Console.WriteLine("Successfully called processLocations()");
for (i = 0; i < LEmployee.Taxes.Length; i++)
{
    System.Console.WriteLine(String.Format("Tax Code {0}: {1} Tax Type: {2} Enacted: {3}", i,
    LEmployee.Taxes[i].TaxCode, LEmployee.Taxes[i].UserTaxType,
LEmployee.Taxes[i].Enacted));
}
}

/* commit messages generated by this API */
if (api.commitDataSource() <= 0)
System.Console.WriteLine("commitDataSource call failed");
else
System.Console.WriteLine("Successfully called commitDataSource");

/* retrieve messages generated by this API */
messages = api.getMessages();
if (messages != null)
{
Console.WriteLine("importPensionTaxes() returned messages of:");
   foreach (String str in messages)
        Console.WriteLine(str);
Console.WriteLine("end of messages");
}

i = 0;
Places = api.getLocatorPlaces();
if (Places != null)
{
foreach (MTF9_PLACE Place in Places)
{
       Console.WriteLine(String.Format("Place {0}: code {1} place name {2} county name {3}",
            i, Place.PCode, Place.PlaceName, Place.County));
       Console.WriteLine(String.Format("           place type {0} postal code {1}",
            Place.PlaceType, Place.PostalCode));
       i++;
}
}

 

 

©Copyright 2021 Business Software, Inc
Unpublished - Rights Reserved Under the Copyright Laws of the United States