# Enterprise Communication Interface (ECI)

## Call of different ECI Functions for Test Purposes

    1
    2           #include <stdio.h>
    264         #include <stdlib.h>
    411         #include <ecipar.h2>
    506         #include <ecicon.h2>
    742         main (argc,argv)
    744         int argc;
    745         char * argv[];
    748    1    char *f_code;
    749    1    char data[200];
    750    1    char w_code[20];
    752    1    char ca_in[EDBIPC_MAX_DATA_LENGTH] ;
    753    1    char ca_out[EDBIPC_MAX_DATA_LENGTH];
    ..754 ....1...
    755    1    eci_param fun_par;
    756    1    eci_param ret_par;
    757    1    eci_param_len l_in, l_out;
    ..758  1
    759    1    edb_data_header my_header;
    760    1
    ..761  1    int jumpto;
    762    1    int iret;
    763    1
    764    1
    ..765  1    if(argc != 4)
    766    1
    767    2      printf("%s usage: TRANSPORTMODE NODENAME IDSTRING",argv[0]);
    768    2      exit(-3);
    769    2      }
    770    1    l_out = sizeof(ca_out);
    771    1    l_in = sizeof(ca_in);
    772    1
    773    1    iret = eci_connect(&my_header,atoi(argv[1]),argv[2],argv[3],"EDB","EDB_CAD");
    774    1
    775    1    if (iret)
    776    1    {
    777    2      printf("Connect-Error: %d\n", iret);
    778    2      exit(-3);
    779    2    }
    780    1
    781    1    while(1)
    782    1    {
    783    2      printf("ECI-Function (End: 'exit') >>");
    784    2      gets(data);
    785    2      sscanf(data,"%s",w_code);
    786    2
    787    2
    788    2
    789    2      if (!strcmp(w_code,"exit"))
    790    2        jumpto=99;
    791    2      else if (!strcmp(w_code,"eci_sel_ent"))
    792    2        jumpto=1;
    793    2      else if (!strcmp(w_code,"eci_ins_ent"))
    794    2        jumpto=2;.....
    893    2      else
    894    2        jumpto=0;
    895    2
    896    2
    897    2      switch (jumpto)
    898    2      {
    899    3      case  0: printf("Function %s not available \n",w_code);
    900    3               break;
    901    3
    902    3      case  1: /* ===== eci_sel_ent ===== */
    903    3               eci_def_par(&fun_par,ca_in,l_in);
    904    3               eci_def_par(&ret_par,ca_out,l_out);
    905    3
    906    3               eci_add_par(&fun_par,"EDB-ARTICLE");
    907    3               eci_end_par(&fun_par);
    908    3               eci_add_par(&fun_par,"EDB-ART-SLI");
    909    3               eci_end_par(&fun_par);
    910    3               eci_add_par(&fun_par,"off");
    911    3               eci_end_par(&fun_par);
    912    3               eci_add_par(&fun_par,"list");
    913    3               eci_end_par(&fun_par);
    914    3               eci_add_par(&fun_par,"int");
    915    3               eci_end_par(&fun_par);
    916    3               eci_add_par(&fun_par,"off");
    917    3               eci_end_par(&fun_par);
    918    3               eci_add_par(&fun_par,"on");
    919    3               eci_end_par(&fun_par);
    920    3               eci_add_par(&fun_par,"T_MASTER_DAT.PART_ID");
    921    3               eci_add_par(&fun_par,"T_MASTER_DAT.LEV_IND");
    922    3               eci_end_par(&fun_par);
    923    3               eci_add_par(&fun_par,"test%");
    924    3               eci_add_par(&fun_par,"120");
    925    3               eci_end_par(&fun_par);
    926    3               eci_add_par(&fun_par,"");
    927    3               eci_end_par(&fun_par);
    928    3               eci_add_par(&fun_par,"");
    929    3               eci_end_par(&fun_par);
    930    3               eci_add_par(&fun_par,"off");
    931    3               eci_end_par(&fun_par);
    932    3
    933    3               /**** eci_call ****/
    934    3               eci_call(&my_header,w_code,&fun_par,&f_code,&ret_par);
    935    3
    936    3               if(!strcmp(f_code,"eci_sel_ent"))
    938
    937    3
    938    4               {
    939    4               char buffer[200];
    940    4               printf("==== Return value(s) ====\n");
    941    4                 eci_set_par(&ret_par,1);
    942    4                 eci_get_par(&ret_par,buffer);
    943    4               printf("Number of records \n",buffer);    : >>%s<<
    944    4               eci_set_par(&ret_par,2);
    945    4                 while (!eci_get_par(&ret_par,buffer))
    946    4               printf("T_MASTER_DAT.C_ID: >>%s<<\n",buffer);
    947    4               }
    948    3               else
    949    3               {
    950    4                char buffer[200];
    951    4
    952    4                printf("ERROR : %s \n",f_code);
    953    4                 eci_set_par(&ret_par,1);
    954    4                 eci_get_par(&ret_par,buffer);
    955    4                 printf("Function: >>%s<< \n",buffer);
    956    4                 eci_get_par(&ret_par,buffer);
    957    4                 printf("Error-message:>>%s<< \n",buffer);
    958    4                 eci_get_par(&ret_par,buffer);
    959    4                 printf("Error number: >>%s<< \n",buffer);
    960    4               }
    961    3               break;
    962    3               case  2: /* ===== eci_ins_ent ===== */
    963    3               eci_def_par(&fun_par,ca_in,l_in);
    964    3               eci_def_par(&ret_par,ca_out,l_out);
    965    3
    966    3               eci_add_par(&fun_par,"EDB-ARTICLE");
    967    3               eci_end_par(&fun_par);
    968    3               eci_add_par(&fun_par,"EDB-ART-SFR");
    969    3               eci_end_par(&fun_par);
    970    3               eci_add_par(&fun_par,"form");
    971    3               eci_end_par(&fun_par);
    972    3               eci_add_par(&fun_par,"int");
    973    3               eci_end_par(&fun_par);
    974    3               eci_add_par(&fun_par,"T_MASTER_DAT.PART_ID");
    975    3               eci_end_par(&fun_par);
    976    3               eci_add_par(&fun_par,"test001");
    977    3               eci_end_par(&fun_par);
    978    3               eci_add_par(&fun_par,"T_MASTER_DAT.PART_ID");
    979    3               eci_add_par(&fun_par,"T_MASTER_DAT.PART_NAME");
    980    3               eci_add_par(&fun_par,"T_MASTER_DAT.CHK_NAME");
    981    3               eci_end_par(&fun_par);
    982    3               eci_add_par(&fun_par,"test001");
    983    3               eci_add_par(&fun_par,"article test001");
    984    3               eci_add_par(&fun_par,"STANDARD");
    985    3               eci_end_par(&fun_par);
    986    3               eci_add_par(&fun_par,"T_MASTER_DAT.C_ID");
    987    3               eci_end_par(&fun_par);
    988    3
    989    3               /**** eci_call ****/
    990    3               eci_call(&my_header,w_code,&fun_par,&f_code,&ret_par);
    991    3
    992    3               if(!strcmp(f_code,"eci_ins_ent"))
    993    3               {
    994    4                 char buffer[200];
    995    4
    996    4                 printf("==== Return value(s) ====\n");
    997    4                 eci_set_par(&ret_par,1);
    998    4                 eci_get_par(&ret_par,buffer);
    999    4                printf("T_MASTER_DAT.C_ID: >>%s<<\n",buffer);
    1000    4               }
    1001    3               else
    1002    3               {
    1003    4                 char buffer[200];
    1004    4
    1005    4                 printf("ERROR : %s \n",f_code);
    1006    4                 eci_set_par(&ret_par,1);
    1007    4                 eci_get_par(&ret_par,buffer);
    1008    4                 printf("Function: >>%s<< \n",buffer);
    1009    4                 eci_get_par(&ret_par,buffer);
    1010    4                 printf("Error-message:>>%s<< \n",buffer);
    1011    4                 eci_get_par(&ret_par,buffer);
    1012    4                 printf("Error number: >>%s<< \n",buffer);
    1013    4                 }
    1014    3                 break;
    4451    3
    4452    3
    4453    3                 case 99: /* ===== exit ===== */
    4454    3                 eci_close(&my_header);
    4455    3                 printf("Connection closed \n");
    4456    3                 exit(0);
    4457    3                 break;
    4458    3                 }
    4459    2                 }
    4460    1                 }
    4461