# EssListCalcFunctions

Description

EssListCalcFunctions() lists all calculator functions available in the active application. The list of available functions includes all native functions and all custom-defined functions (CDFs) and custom-defined macros (CDMs).

Syntax

    ESS_FUNC_M EssListCalcFunctions (hCtx, pCalcFunc);

ESS_HCTX_T | hCtx
ESS_PSTR_T | pCalcFunc

Parameters

hCtx | Essbase API context handle.
pCalcFunc | Pointer to the string containing the available calculator functions. The string is in the form of XML.

Return Value

Returns zero if successful; error code if unsuccessful.

Notes

EssListCalcFunctions() requires supervisor privilege (usually granted to the administrator). The user must also have database access to receive this list. To avoid an error, the user must have both supervisor privilege and access to the database to run a program with EssListCalcFunctions().

The contents of the string returned by EssGetCalcList is formatted as XML and must be either rendered in an XML utility or parsed to display only the actual text. All XML tags are enclosed in angle brackets (for example, <xml_tag>).
Here is a pared-down example of a typical XML output file:

    ESSBASE API v.62000
    1051034: Logging in user admin
    1051035: Last login on Tuesday, May 22, 2001 10:31:19 AM
    <list>
    <group name="Boolean">
      <function>
        <name><![CDATA[@ISACCTYPE]]></name>
        <syntax>
           <![CDATA[@ISACCTYPE(tag)]]>
        </syntax>
        <comment>
           <![CDATA[returns TRUE if the current member has the associated accounts tag]]>
        </comment>
      </function>
    </group>
    <group name="Relationship Functions">
      <function>
        <name><![CDATA[@ANCESTVAL]]></name>
        <syntax>
           <![CDATA[@ANCESTVAL (dimName, genLevNum [, mbrName])]]>
        </syntax>
        <comment>
           <![CDATA[returns the ancestor values of a specified member combination]]>
        </comment>
    </group>
    <group name="Custom">
    </group>

    </list>

Example

    #include
    #include
    #include "windows.h"
    #include "essbase.h"
    #include "essapi.h"
    #include "essotl.h"
    #include "stdio.h"

    /* globals - handles to different ESS objects */

    ESS_HINST_T     hInst = 0;
    ESS_HCTX_T      hCtx = 0;

    ESS_APPNAME_T      szAppName;
    ESS_DBNAME_T       szDbName;

    ESS_HOUTLINE_T  hOutline = 0;

    /* end globals */

    /* forward declarations of functions */
    void apiInit();
    void apiTerm();

    ESS_STS_T apiAutoLogin();
    ESS_STS_T apiLogout();
    /* end forward declarations */

    ESS_FUNC_M      MessageHandler (ESS_PVOID_T     UserContext,     /* user context pointer */
                                    ESS_LONG_T      MessageNumber,   /* Essbase message number */
                                    ESS_USHORT_T    Level,           /* message level */
                                    ESS_STR_T       LogString,       /* message log string */
                                    ESS_STR_T       MessageString    /* message string */)
    {
       printf( "%d: %s\n", MessageNumber, MessageString );
       return 0;
    }

    void apiInit()
    {
       ESS_STS_T    sts;
       ESS_INIT_T InitStruct = {
          ESS_API_VERSION,
          NULL,
          0L,
          255,
          NULL,
          NULL,
          NULL,
          NULL,
          NULL,
          (ESS_PFUNC_T)MessageHandler,
          NULL,
          0L
       };

       printf( "ESSBASE API v.%x\n", ESS_API_VERSION );

       if ((sts = EssInit(&InitStruct, &hInst)) != ESS_STS_NOERR)
       {
          printf( "API init failure: %d\n", sts);
          exit(1);
       }

    }

    ESS_STS_T apiAutoLogin ()
    {
       ESS_CHAR_T SvrName[ESS_SVRNAMELEN];
       ESS_CHAR_T UserName[ESS_USERNAMELEN];
       ESS_CHAR_T Password[ESS_PASSWORDLEN];

       ESS_USHORT_T   Option;
       ESS_ACCESS_T   Access ;

       /* Initialize parameters */
       strcpy(SvrName,"localhost");
       strcpy(UserName, "");
       strcpy(Password, "");
       strcpy(szAppName, "");
       strcpy(szDbName, "");

       Option = AUTO_DEFAULT;

       /* Login to Essbase server */
       return EssAutoLogin (hInst, SvrName, UserName, Password,
          szAppName, szDbName, Option, &Access, &hCtx);

    }

    void apiTerm()
    {
       ESS_STS_T sts = ESS_STS_NOERR;

       if ( hCtx )
          sts = apiLogout();

       if ( !sts && hInst )
          sts = EssTerm(hInst);

       if ( sts )
       {
          printf( "API shutdown failure: %d\n", sts );
          exit(1);
       }
    }

    ESS_STS_T apiLogout()
    {
       return EssLogout(hCtx);
    }

    int main(int argc, char **argv)
    {
       ESS_STS_T       status;
       ESS_STR_T       pszCalcFunctionList;

       apiInit();

       status = apiAutoLogin();
       if ( status )
          return 1;

       status = EssListCalcFunctions( hCtx, &pszCalcFunctionList );
       if ( status )
          return 1;

       printf( "%s\n", pszCalcFunctionList );

       apiTerm();

       return 0;
    }

See Also

EssGetFilterList()