# Enterprise Communication Interface (ECI)

## Integration of new ECI Userexits

Specific links to CAX systems may require the implementation of specific userexits. For an easy usage via ECI it is then necessary to call them with the standard ECI functionality.

| Using the ECI function eci_lgv_run you may already call decision tables which call userexits within Agile e6. Additional ECI function, which supports userexit calls: eci_usx_cal, eci_sel_usx, eci_nos_usx, eci_sel_men, eci_nos_men.

Here an example of how a customer specific ECI function (ecc_test_usx) is integrated via a shared library.

#### Example:

The ECI function ecc_test_usx issues a message in the Agile e6 window. This ECI function is announced to the EDC administrator with the function EciEcc_Entry by calling edb_add_function.

| Creating an ECI function (source file eci_ecc.c)
    /************************ INFORMATIONAL PART *****************************/
    /*                                                                       */
    /* MODULE         : ECI_ECC                                              */
    /* PROJECT        : ECC-CAX-Interface for Agile e6                       */
    /* AUTHOR         : SCR, Agile Software GmbH, Karlsruhe                  */
    /* DATE           : 01.01.00                                             */
    /* DESCRIPTION    : Sample how to declare a new ECI function in          */
    /*                  Agile e6                                             */
    /*                                                                       */
    /*************************************************************************/
    /*                                                                       */
    /************************ DECLARATIONAL PART *****************************/
    /*                                                                       */
    /************************ INCLUDED FILES *********************************/
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include "fncdef.h"
    #include "ecipar.h2"
    #include "eci.h2"
    #include "eci.h1"
    #include "dux.h"
    /************************ IMPLEMENTATIONAL PART **************************/
    /*                                                                       */
    /************************ Start of the function **************************/
    static int
    ecc_test_usx(char *cp_Connection, eci_param *fun_par,
                 char **cpp_RetCode, eci_param *ret_par)
    /*************************************************************************/
    /* INPUT:                                                                */
    /* cp_Connection - connection identifier                                 */
    /* fun_par       - input parameter for                                   */
    /* ECI-function ecc_test_usx                                             */
    /* IN/OUTPUT  :                                                          */
    /* OUTPUT     :                                                          */
    /* cpp_RetCode   - return code                                           */
    /*(success: name of called function, here                                */
    /* ecc_test_usx function failed: eci_error)                              */
    /* ret_par- return parameter of ECI-function                             */
    /*************************************************************************/
    /* RETURN-CODE: 0 = o.k.                                                 */
    /* DESCRIPTION: Prints message stored in                                 */
    /* Agile e6    with key "ABC"                                            */
    /* REMARKS    :                                                          */
    /* EXAMPLE    :                                                          */
    /* SEE ALSO   :                                                          */
    /* AUTHOR     : SCR                                                      */
    /* CHANGES    :                                                          */
    /*************************************************************************/
    {
     static char  *cp_FuncName = "ecc_test_usx",
                    *cp_EciError = "eci_error";
    /*************************** CODING PART *********************************/
    *cpp_RetCode = cp_FuncName;
    mes_wri("ABC", NULL, NULL, NULL);
    return (0);
    }
    /*000********************** END OF FUNCTION ecc_test_usx *****************/
    /*********** PUBLIC ******************************************************/
    /************************** START OF FUNCTION ****************************/
    /*************************************************************************/
    int
    EciEcc_Entry (Dux_Event eEvent)
    /*************************************************************************/
    /* INPUT                                                                 */
    /* eEvent  - event to process                                            */
    /* IN/OUTPUT  :                                                          */
    /* OUTPUT     :                                                          */
    /*************************************************************************/
    /* RETURN-CODE: 0 = o.k.                                                 */
    /*             >0 = error                                                */
    /*                                                                       */
    /* DESCRIPTION: This function add userexits by calling the Agile e6      */
    /*              functions                                                */
    /*              Dux_open()  and  Dux_AddCustomUsx()                      */
    /*               If this function returns an error, it MUST close the    */
    /*               handle to release the userexits added so far by calling */
    /*              Dux_close()                                              */
    /*              Possible events are:                                     */
    /*               Dux_EVENT_INIT  - library loaded, userexits may be      */
    /*                                 added                                 */
    /*               Dux_EVENT_EXIT  - library will be unloaded immediately  */
    /*               Dux_EVENT_BATCH - batch Agile e6 session started        */
    /*               Dux_EVENT_ALPHA - alphanum. Agile e6    session started */
    /*               Dux_EVENT_GRAPH - graphic Agile e6    session started   */
    /*                                                                       */
    /* REMARKS    : Only functions of the DUX interface may be called inside */
    /*              the INIT event: Agile e6 initialization is not           */
    /*              finished at this point.                                  */
    /*              If the function receives an unknown event, it should     */
    /*              return zero to be compatible with future event codes.    */
    /* EXAMPLE    :                                                          */
    /* SEE ALSO   :                                                          */
    /* AUTHOR     :                                                          */
    /* CHANGES    :                                                          */
    /*************************************************************************/
    {
      int           i_Rc = 0,
                    i;
      char          *cp_FuncName = "EciEcc_Entry";
    /**************************** CODING PART ********************************/
    if (getenv("EDB_DEBUG"))
      fprintf(stderr,
                 "[EciEcc]: Entry function called (event = %d)\n", eEvent);
     /* examine events */
     switch (eEvent)
    {
     case Dux_EVENT_INIT:
          i_Rc = edb_add_function("ecc_test_usx", ecc_test_usx, "ECIECC");
          break;

     case Dux_EVENT_EXIT:
          break;
     case Dux_EVENT_BATCH:
          break;
     case Dux_EVENT_ALPHA:
     case Dux_EVENT_GRAPH:
          break;
     default:
          break;
     }  return (i_Rc);
    }
    /*000************ END OF FUNCTION EciEcc_Entry ***************************/
    /*************************************************************************/
    /*************************** END OF MODUL ********************************/
    /*************************************************************************/
| Create .exp and .def files (e.g. copy .exp/.def) eci_ecc.def: EciEcc_Entry
| Create "shared library" libeci_ecc.so with makefile (created by copying the makefile in the custom directory).
    # this is only a sample from our development environment,
    # you have to adapt it to your environment
    include $(axalant_root)/dev/make/make.env
    # Put objects to a local directory, the lib goes to EDB_HOME
    PathOBJ       = obj/$(EDB_MACH)
    PathBIN       = $(edb_home)/bin/$(EDB_MACH)
    PathLIB       = $(edb_home)/lib/$(EDB_MACH)
    SHARED_LIB    = eci_ecc
    SHR_ARCHIVE   = 0
    OBJS          = $(PathOBJ)/eci_ecc.o
    SRCS          = eci_ecc.c
    ENTRY         = EciEcc_Entry
    IMPORTS       = -ledb$(edb_ver) \
                    -lepshr$(epshr_ver) \
                    -ldtv \
                    -lepq$(epq_ver)
    LOCAL_CC_FLAGS=
    include $(axalant_root)/dev/make/make.common.shr
    # DO NOT DELETE THIS LINE -- make depend depends on it.
| The "shared library" must be stored in the directory $axalant_home/bin/$EP_MACH (UNIX) or %axalant_home%\bin\%EP_MACH% (Windows).
| Enter the new library in the environment configuration: Start Agile e6 setup tool, "Configure environment/Customizing libraries"