EssPerformCustomCalcASO

Performs or verifies a custom calculation on an aggregate storage database.

Syntax

ESS_FUNC_M EssPerformCustomCalcASO (hCtx, verifyOnly, errorList, calcStruct);
ParameterData TypeDescription

hCtx

ESS_HCTX_T

API context handle.

verifyOnly

ESS_BOOL_T

Flag to indicate whether the calculation will be validated without executing it. If it is set to ESS_TRUE, the calculation is validated only. If it is ESS_FALSE, the calculation is validated and executed.

errorList

ESS_PERF_ALLOC_ERROR_T**

A pointer to the linked list of error structures that will be populated and returned by the API containing error information about the custom calculation. This argument cannot be 0. The linked list must be freed by the client.

calcStruct

ESS_PERF_CUSTCALC_T*

Pointer to a client-allocated custom calculation structure and parameters.

Return Value

Returns 0 if successful; otherwise, returns an error.

Example

void HandleErrors(ESS_HINST_T hInst, ESS_PERF_ALLOC_ERROR_T **pErrorList)
{
   if (pErrorList)
   {
      ESS_PERF_ALLOC_ERROR_T *errorList = *pErrorList;
      ESS_PERF_ALLOC_ERROR_T *nextError;

      while (errorList)
      {
         printf("Error number %ld occurred\n", errorList->messageNumber);
         if (errorList->argument != ESS_PERF_ALLOC_ARG_NA)
            printf("  in argument %d\n", errorList->argument);
         if (errorList->lineNumber)
            printf("  on line %ld\n", errorList->lineNumber);
         if (errorList->token[0] != '\0')
            printf("  on token %s\n", errorList->token);

         nextError = errorList->nextError;
         ESS_STS_T sts = EssFree (hInst, errorList);
         printf("\nEssFree sts for errorList %ld\n",sts);
         errorList = nextError;
      }

      *pErrorList = NULL;
   }
}

void ESS_GLCustomCalc()
{
   ESS_STS_T sts = ESS_STS_NOERR;
   ESS_BOOL_T verifyOnly;
   ESS_PERF_ALLOC_ERROR_T *errorList = ESS_NULL;
   ESS_PERF_CUSTCALC_T *calcStruct;

   sts = EssAlloc (hInst, sizeof(ESS_PERF_CUSTCALC_T), (ESS_PPVOID_T)&calcStruct);
   printf("EssAlloc sts for calcStruct: %ld\n", sts);

   sts = EssAlloc (hInst, sizeof(ESS_PERF_CUSTCALC_T), (ESS_PPVOID_T)&calcStruct);
   printf("EssAlloc sts: %ld\n", sts);

   verifyOnly = ESS_FALSE; 
   errorList = ESS_NULL;
   calcStruct->pov = "{[1120], [1130]}";
   calcStruct->script = "[Jan-96] := ([Feb-08], [041509GR PL2], [00], [[All Department Values]].[000]]], [0000],  [[All Product Values]].[000]]], [Actual], [Beginning Balance Dr], [BASE], [USD], [Total]);";
   calcStruct->target = "([041509GR PL2], [00], [[All Department Values]].[000]]], [0000],  [[All Product Values]].[000]]], [Actual], [BASE], [USD], [Total])";
   calcStruct->debitMember = "[Beginning Balance Dr]";
   calcStruct->creditMember = "[Beginning Balance Cr]";
   calcStruct->offset = "";
   calcStruct->sourceRegion = "{([Feb-08], [041509GR PL2], [00], [[All Department Values]].[000]]], [0000],  [[All Product Values]].[000]]], [Actual], [Beginning Balance Dr], [BASE], [USD], [Total])}";
   calcStruct->groupID = 0;
   calcStruct->ruleID = 0;

   sts = EssPerformCustomCalcAso(hCtx, verifyOnly, &errorList, calcStruct);
   printf("EssPerformCustomCalcAso sts: %ld\n",sts);

   HandleErrors(hInst, &errorList);

   if(calcStruct)
   {
      sts = EssFree (hInst, calcStruct);
      printf("EssFree sts for allocStruct %ld\n",sts);
   }
}