/* @(#) $Id: //bas/710_REL/src/ca/cad/cadsampl.c#1 $ SAP*/ /*--------------------------------------------------------------------*/ /* */ /* SAP AG Walldorf */ /* SAP Systeme, Anwendungen und Produkte in der Datenverarbeitung */ /* */ /* (C) Copyright SAP AG 1995 */ /* */ /*--------------------------------------------------------------------*/ /* File: cadsampl.c */ /*--------------------------------------------------------------------*/ /* This program shows how to use the CAD-Toolbox functions. */ /* */ /* Attention: Emulation mode is no longer supported by SAP! */ /* This program will no longer run without an R/3 system. */ /*--------------------------------------------------------------------*/ /* cadsampl (opt ) */ /* */ /* usage: 0: all */ /* 1: get long text for SAP message (R/3) */ /* 2: online help */ /* 3: possible values */ /* 4: material create with/without classification data */ /* 5: material display with/without classification data */ /* 6: material change with/without classification data */ /* 7: search material via clas */ /* 8: search class generically (R/3) */ /* 9: search class without predecessor (R/3) */ /* 10: search superior and subordinate classes (R/3) */ /* 11: example for SapDeleteTableEntry */ /* 12: find class via matchcode (R/3) */ /* 13: set class scope (R/3) */ /* 14: explode class hierarchy (R/2) */ /* 15: list classes on next hierarchy level (R/2) */ /* 16: generic class list of hierarchy classes (R/2) */ /* 17: generic class list of real and dummy classes (R/2) */ /* 18: equipment create with/without classification data R/3 */ /* 19: equipment display with/without classification data R/3 */ /* 20: equipment change with/without classification data R/3 */ /* 21: search material via matchcode R/3 */ /*--------------------------------------------------------------------*/ /* Test of functions in TOOLBOX */ /*--------------------------------------------------------------------*/ /* 4.0A */ /* BINK123452 050997 new function tool21 */ /* BINK110955 150597 get rid of compiler warnings */ /* 3.0E */ /* BINK090600 110796 Funktionsdefinitionen nach ANSI-C Standard */ /*--------------------------------------------------------------------*/ #include #include #include #include #include "caddialg.h" #include "cadtoolc.h" #define R2 1 #define R3 2 /*------------------*/ /* global variables */ /*------------------*/ char sap_version[4]; char plant_value[5]; int VERSION; char trenner[2]; char CIM[21], CID[21], CIU[21], NAME_TASK[21]; /*----------------------*/ /* function declaration */ /*----------------------*/ int online00(void); /* 150597 */ int online01(void); int online02(void); int tool01(void); int tool02(void); int tool03(void); int tool04(void); int tool05(void); int tool06(void); int tool07(void); int tool08(void); int tool09(void); int tool10(void); int tool11(void); int tool12(void); int tool13(void); int tool14(void); int tool15(void); int tool16(void); int tool17(void); int tool18(void); int tool19(void); int tool20(void); int tool21(void); /* 050997*/ int ErrorHandling(SAPHD, char*); int ToolErrorHandling(int); int GetClasdata(int, int, char**, int*); int GetCharacteristicValues(int, char*,int); int GetMatchcodeValues(int, char*, char*, int, char*);/* 050997 */ int GetPossibleSmlValues(int); int GetFullMessageText(char*, int); int SetClasScope(void); /* 150597 */ /*--------------------------------------------------------------------*/ /* main */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : argc */ /* argv */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ /* BINK090600 110796 */ main (int argc,char *argv[]) { char *version; int order=0; int toolok=0; /*----------------*/ /* Initialization */ /*----------------*/ strcpy(CIM, "./cadcim.dat"); strcpy(CID, "./cadcid.dat"); strcpy(CIU, "./cadciu.dat"); strcpy(NAME_TASK, "./cadsampl"); order=0; (void) strcpy(sap_version,"R/3"); if (argc==1) { printf("Usage:\n"); printf("cadsampl \n"); printf("\n"); printf(" usage 0: all \n"); printf(" 1: get long text for SAP message (R/3)\n"); printf(" 2: online help\n"); printf(" 3: possible values\n"); printf(" 4: material create with/without classification data\n"); printf(" 5: material display with/without classification data\n"); printf(" 6: material change with/without classification data\n"); printf(" 7: search material via clas\n"); printf(" 8: search class generically (R/3)\n"); printf(" 9: search class without predecessor (R/3)\n"); printf(" 10: search superior and subordinate classes (R/3)\n"); printf(" 11: example for SapDeleteTableEntry \n"); printf(" 12: find class via matchcode (R/3)\n"); printf(" 13: set class scope (R/3)\n"); printf(" 14: explode class hierarchy (R/2)\n"); printf(" 15: list classes on next hierarchy level (R/2)\n"); printf(" 16: generic class list of hierarchy classes (R/2)\n"); printf(" 17: generic class list of real and dummy classes (R/2)\n"); printf(" 18: equipment create with/without classification data R/3\n"); printf(" 19: equipment display with/without classification data R/3\n"); printf(" 20: equipment change with/without classification data R/3\n"); printf(" 21: search material via matchcode R/3\n"); printf("\n"); exit(1); } if (argc>1) order=atoi(argv[1]); if (argc>2) { (void) strcpy(sap_version,argv[2]); } if (strcmp(sap_version,"R/2")==0) { (void) strcpy(plant_value,"01"); } else { (void) strcpy(plant_value,"0001"); } toolok=SapToolboxVersion(&version); printf("SAP-Toolboxlibrary Interface-Version: %s\n",version); printf("---------------------------------------------\n"); printf("\n"); /* all funtions */ if (order==0) { printf("function : all functions\n"); printf("------------------------\n"); toolok=online00(); if (VERSION == R2) { if (toolok == 0 ) toolok=tool02(); if (toolok == 0 ) toolok=tool03(); if (toolok == 0 ) toolok=tool04(); if (toolok == 0 ) toolok=tool05(); if (toolok == 0 ) toolok=tool06(); if (toolok == 0 ) toolok=tool07(); if (toolok == 0 ) toolok=tool11(); if (toolok == 0 ) toolok=tool14(); if (toolok == 0 ) toolok=tool15(); if (toolok == 0 ) toolok=tool16(); if (toolok == 0 ) toolok=tool17(); } else { if (toolok == 0 ) toolok=tool01(); if (toolok == 0 ) toolok=tool02(); if (toolok == 0 ) toolok=tool03(); if (toolok == 0 ) toolok=tool04(); if (toolok == 0 ) toolok=tool05(); if (toolok == 0 ) toolok=tool06(); if (toolok == 0 ) toolok=tool07(); if (toolok == 0 ) toolok=tool08(); if (toolok == 0 ) toolok=tool09(); if (toolok == 0 ) toolok=tool10(); if (toolok == 0 ) toolok=tool11(); if (toolok == 0 ) toolok=tool12(); if (toolok == 0 ) toolok=tool13(); if (toolok == 0 ) toolok=tool18(); if (toolok == 0 ) toolok=tool19(); if (toolok == 0 ) toolok=tool20(); if (toolok == 0 ) toolok=tool21(); /* 050997 */ } } /* get long text for SAP message */ if (order==1) { printf("function : get long text for SAP message\n"); printf("----------------------------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool01(); } /* online help */ if (order==2) { printf("function : online help\n"); printf("----------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool02(); } /* possible values */ if (order==3) { printf("function : possible values\n"); printf("--------------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool03(); } /* material create with classification data */ if (order==4) { printf("function : create material with/without classification data\n"); printf("-----------------------------------------------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool04(); } /* material display with classification data */ if (order==5) { printf("function : display material with/without classification data\n"); printf("------------------------------------------------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool05(); } /* material change with classification data */ if (order==6) { printf("function : change material with/without classification data\n"); printf("-----------------------------------------------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool06(); } /* search objects via clas */ if (order==7) { printf("function : search object via class\n"); printf("---------------------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool07(); } /* search class generically */ if (order==8) { printf("function : search class gernerically\n"); printf("------------------------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool08(); } /* search class without predecessor */ if (order==9) { printf("function : search class without predecessor\n"); printf("-------------------------------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool09(); } /* search superior and subordinate classes */ if (order==10) { printf("function : search superior and subordinate classes\n"); printf("--------------------------------------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool10(); } /* function SapDeleteTabelEntry */ if (order==11) { printf("function : SapDeleteTableEntry\n"); printf("------------------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool11(); } /* find class via matchcode */ if (order==12) { printf("function : find class via matchcode\n"); printf("-----------------------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool12(); } /* set class scope */ if (order==13) { printf("function : set class scope\n"); printf("--------------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool13(); } /* explode class hierarchy (R/2) */ if (order==14) { printf("function : explode class hierarchy (R/2)\n"); printf("----------------------------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool14(); } /* list classes on next hierarchy level (R/2) */ if (order==15) { printf("function : list classes on next hierarchy level (R/2)\n"); printf("-----------------------------------------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool15(); } /* generic class list of hierarchy classes (R/2) */ if (order==16) { printf("function : generic class list of hierarchy classes (R/2)\n"); printf("--------------------------------------------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool16(); } /* generic class list of real and dummy classes (R/2) */ if (order==17) { printf("function : generic class list of real and dummy classes (R/2)\n"); printf("-------------------------------------------------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool17(); } /* equipment create with/without classification data (R/3) */ if (order==18) { printf("function : equipment create with/without classification data (R/3)\n"); printf("------------------------------------------------------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool18(); } /* equipment display with/without classification data (R/3) */ if (order==19) { printf("function : equipment display with/without classification data (R/3)\n"); printf("-------------------------------------------------------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool19(); } /* equipment change with/without classification data (R/3) */ if (order==20) { printf("function : equipment change with/without classification data (R/3)\n"); printf("------------------------------------------------------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool20(); } /* search material via matchcode (R/3) */ if (order==21) { /* 050997 */ printf("function : serach material via matchcode (R/3) \n"); printf("-----------------------------------------------\n"); toolok=online00(); if (toolok == 0 ) toolok=tool21(); } return(0); } /*--------------------------------------------------------------------*/ /* online00 - online connection with SAP (master function) */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : argc */ /* argv */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int online00() { int toolok; toolok=online01(); if (toolok== 0 ) toolok = online02(); return (toolok); } /*--------------------------------------------------------------------*/ /* online01 - online connection with SAP (sub function 1) */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : argc */ /* argv */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int online01() { SAPHD hd; char *rcvstr,*sapmes, *string=NULL; char *argv[1],pstart_path[20], str[3]; int rcvlen,toolok=0; trenner[0] = '\0'; /*-----------*/ /* CONNC --> */ /*-----------*/ printf("\n--> S A P (CONNC)\n"); /* Establish connection. The paramter for the function will be read from */ /* the configuration file caddialg.ini */ (void) strcpy(pstart_path,NAME_TASK); argv[0] = pstart_path; hd = SapConnc(argv,"","","","","","","",&sapmes); /*-----------*/ /* CONNC <-- */ /*-----------*/ printf("<-- S A P (CONNC)\n"); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*-------------------------*/ /* TOOL Initialize toolbox */ /*-------------------------*/ toolok=SapInitToolbox(1); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*--------------*/ /* SYSRQ PA --> */ /*--------------*/ printf("\n--> S A P (SYSRQ PA)\n"); /*-----------------------*/ /* SAP get configuration */ /*-----------------------*/ hd=SapSysrq("PA","",&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------------*/ /* SYSRQ PA <-- */ /*--------------*/ printf("<-- S A P (SYSRQ PA)\n"); rcvstr[hd.datalen]='\0'; printf("reveivestring: %s\n",rcvstr); /*--------------------------*/ /* TOOL store configuration */ /*--------------------------*/ rcvlen= (int) hd.datalen; toolok=SapFillInterface(rcvstr,rcvlen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*--------------------*/ /* TOOL get seperator */ /*--------------------*/ str[0] = '\0'; toolok = SapDescribeInterface(1,&string); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); if (string != NULL) { (void) strncpy(str, string,1); str[1] = '\0'; strcpy(trenner,str); } /*----------------------*/ /* TOOL Get SAP Release */ /*----------------------*/ str[0] = '\0'; toolok = SapDescribeInterface(2,&string); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); if (string != NULL) { (void) strncpy(str, string,2); str[2] = '\0'; } if ( strcmp(str, "50") == 0 || strcmp(str, "5.") == 0 || strcmp(str, "60") == 0 || strcmp(str, "6.") == 0) VERSION = R2; else if ( strcmp(str, "21") == 0 || strcmp(str, "22") == 0 || strcmp(str, "2.") == 0 || strcmp(str, "30") == 0 || strcmp(str, "3.") == 0) VERSION = R3; else VERSION = R3; return(0); } /*--------------------------------------------------------------------*/ /* online02 - online connection with SAP (sub function 2) */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : argc */ /* argv */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int online02() { SAPHD hd; char *rcvstr,*sapmes; int rcvlen,toolok=0; /*---------------*/ /* SYSRQ CIM --> */ /*---------------*/ printf("\n--> S A P (SYSRQ - CIM)\n"); /*-------------------------------*/ /* SAP get tables TCIM,TCID,TCIU */ /*-------------------------------*/ hd=SapSysrq("TB","",&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*---------------*/ /* SYSRQ CIM <-- */ /*---------------*/ printf("<-- S A P (SYSRQ - CIM)\n"); printf("Status : OK\n"); /*----------------------*/ /* TOOL store table CIM */ /*----------------------*/ rcvstr[hd.datalen]='\0'; rcvlen= (int) hd.datalen; toolok=SapWriteKonfiguration(3,rcvstr,rcvlen,CIM); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*---------------*/ /* SYSRQ CIU --> */ /*---------------*/ printf("\n--> S A P (SYSRQ - CIU)\n"); /*-----------------------------------*/ /* SAP get CIU table from SAP system */ /*-----------------------------------*/ hd=SapSysrq("","",&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*---------------*/ /* SYSRQ CIU --> */ /*---------------*/ printf("<-- S A P (SYSRQ - CIU)\n"); printf("Status : OK\n"); /*----------------------*/ /* TOOL store table CIU */ /*----------------------*/ rcvstr[hd.datalen]='\0'; rcvlen= (int) hd.datalen; toolok=SapWriteKonfiguration(1,rcvstr,rcvlen,CIU); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*---------------*/ /* SYSRQ CID --> */ /*---------------*/ printf("\n--> S A P (SYSRQ - CID)\n"); /*-----------------------------------*/ /* SAP get CID table from SAP system */ /*-----------------------------------*/ hd=SapSysrq("","",&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*---------------*/ /* SYSRQ CID --> */ /*---------------*/ printf("<-- S A P (SYSRQ - CID)\n"); printf("Status : OK\n"); /*----------------------*/ /* TOOL store table CID */ /*----------------------*/ rcvstr[hd.datalen]='\0'; rcvlen= (int) hd.datalen; toolok=SapWriteKonfiguration(2,rcvstr,rcvlen,CID); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); return(0); } /*--------------------------------------------------------------------*/ /* tool01 - get long text for SAP-message R/3 */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int tool01() { int toolok=0; if (VERSION == R2) { printf("\nfunction 01 is only supported for R/3 connection\n"); return 0; } /*-----------------------*/ /* get full message text */ /*-----------------------*/ toolok = GetFullMessageText("E00058Entry does not exist",26); if (toolok != 0 ) return(-99); return 0; } /*--------------------------------------------------------------------*/ /* tool02 - online help */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int tool02() { SAPHD hd; SAPSML smldata; char *rcvstr,*sapmes; char *sendstr; int row,index,rcvlen,toolok=0; /*--------------------------*/ /* TOOL generate sendstring */ /*--------------------------*/ toolok = SapCreateSendstrHelp("MATRQ","MR","U","MATERIAL", &sendstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*--------*/ /* SD --> */ /*--------*/ printf("\n--> S A P (HLPRQ SD)\n"); printf("sendstring: %s\n",sendstr); /*---------------------*/ /* SAP get online help */ /*---------------------*/ hd=SapHlprq("SD",sendstr,&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* SD <-- */ /*--------*/ printf("\n<-- S A P (HLPRQ SD)\n"); rcvstr[hd.datalen] = '\0'; /*-------------------------------------*/ /* TOOL store received data in toolbox */ /*-------------------------------------*/ rcvlen= (int) hd.datalen; toolok=SapCreateHlpTable(2,rcvstr,rcvlen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*--------------------------------------------*/ /* TOOL get number of entries in online table */ /*--------------------------------------------*/ toolok=SapGetHlpDescription(2,&rcvstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*-------------------------------*/ /* TOOL get online documentation */ /*-------------------------------*/ row=atoi(rcvstr); for (index=1;index<=row;index++) { toolok=SapGetHlpData(1,1,index,&smldata); if (toolok==0) printf("%2d,%s\n",index,smldata.value); } return(0); } /*--------------------------------------------------------------------*/ /* tool03 - possible values */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int tool03() { SAPHD hd; SAPSML smldata; char *rcvstr,*sapmes; char string[101],*sendstr; int column,row,i,j,rcvlen,toolok=0,sel_col=0; /*--------------------------*/ /* TOOL generate sendstring */ /*--------------------------*/ toolok = SapCreateSendstrHelp("MATCR","MR","U","MAT_TYPE", &sendstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*--------*/ /* SE --> */ /*--------*/ printf("\n--> S A P (HLPRQ SE)\n"); printf("sendstring: %s\n",sendstr); /*-----------------------------------------------*/ /* SAP get column description of possible values */ /*-----------------------------------------------*/ hd=SapHlprq("SE",sendstr,&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* ST <-- */ /*--------*/ printf("\n<-- S A P (HLPRQ ST)\n"); rcvstr[hd.datalen] = '\0'; /*-------------------------------------*/ /* TOOL store received data in toolbox */ /*-------------------------------------*/ rcvlen= (int) hd.datalen; toolok=SapCreateHlpTable(1,rcvstr,rcvlen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*-------------------------*/ /* SAP get possible values */ /*-------------------------*/ hd=SapHlprq("","",&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* SE <-- */ /*--------*/ printf("\n<-- S A P (HLPRQ SE)\n"); rcvstr[hd.datalen] = '\0'; /*-------------------------------------*/ /* TOOL store received data in toolbox */ /*-------------------------------------*/ rcvlen= (int) hd.datalen; toolok=SapFillHlpTable(1,rcvstr,rcvlen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*----------------------------*/ /* TOOL get number of columns */ /*----------------------------*/ toolok=SapGetHlpDescription(1,&rcvstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); column=atoi(rcvstr); /*------------------------*/ /* TOOL get number of row */ /*------------------------*/ toolok=SapGetHlpDescription(2,&rcvstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); row=atoi(rcvstr); /*-------------------------------*/ /* TOOL print column description */ /*-------------------------------*/ string[0]=0x0; for (j=1;j<=column;j++) { toolok=SapGetHlpData(1,j,1,&smldata); if (toolok==0) { (void) strcat(string,smldata.name); (void) strcat(string," "); } } toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); printf("\npossible values\n"); printf("----------------\n"); /*----------------------------*/ /* TOOL print possible values */ /*----------------------------*/ for (i=1;i<=row;i++) { string[0]=0x0; for (j=1;j<=column;j++) { toolok=SapGetHlpData(1,j,i,&smldata); if (toolok==0) { (void) strcat(string,smldata.value); (void) strcat(string," "); } } printf ("%s\n",string); } toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*******/ /* R/3 */ /*******/ if (VERSION == R3) { /*---------------------------------------*/ /* TOOL get column with selectable value */ /*---------------------------------------*/ toolok = SapGetHlpDescription(3,&rcvstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); sel_col=atoi(rcvstr); printf ("\ncolumn with selectable value: %s\n",rcvstr); /*--------------------*/ /* TOOL get 1st value */ /*--------------------*/ toolok = SapGetHlpData(1,sel_col,1,&smldata); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); string[0]='\0'; (void) strcpy(string,smldata.value); printf("\n1st value: %s\n",string); } return(0); } /*--------------------------------------------------------------------*/ /* tool04 - material create with/without classification data */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int tool04() { SAPHD hd; int toolok; char *sndstr,*rcvstr,*sapmes; char ucode[3]; /*---------------------------------------*/ /* TOOL create internal table for upload */ /*---------------------------------------*/ toolok=SapCreateTable(1,"MATCR","MR",CIM,CIU); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*------------------------*/ /* TOOL fill upload table */ /*------------------------*/ SapWriteTableValue(1,"MAT_TYPE","HALB",1); SapWriteTableValue(1,"INDUSTRY","M",1); SapWriteTableValue(1,"BASE_UNIT","PC",1); if ( VERSION == R3 ) { SapWriteTableValue(1,"MATERIAL","NUT-01",1); SapWriteTableValue(1,"DESCRIPT_M","metric nut",1); SapWriteTableValue(1,"CLASS_TYPE","001",1); SapWriteTableValue(1,"CLASS_NO","PP-NUTS",1); SapWriteTableValue(1,"PLANT","0001",1); SapWriteTableValue(1,"LVL_CLASS","X",1); SapWriteTableValue(1,"LVL_MRP_1","X",1); SapWriteTableValue(1,"LVL_MRP_2","X",1); SapWriteTableValue(1,"LVL_MRP_3","X",1); SapWriteTableValue(1,"LVL_ENGIN","X",1); SapWriteTableValue(1,"REQUIRED","X",1); SapWriteTableValue(1,"OPTIONAL","X",1); SapWriteTableValue(1,"UNASSIGNED","X",1); SapWriteTableValue(1,"ASSIGNED","X",1); SapWriteTableValue(1,"INHERITED","X",1); } else { SapWriteTableValue(1,"MATERIAL","",1); SapWriteTableValue(1,"DESCRIPT_M","screw",1); SapWriteTableValue(1,"CLASS","TERRAM",1); SapWriteTableValue(1,"COMPANY_CD","01",1); SapWriteTableValue(1,"BASIC_MAT","IRON",1); SapWriteTableValue(1,"BILD1","1",1); SapWriteTableValue(1,"GROES","12*12",1); SapWriteTableValue(1,"NORMT","1",1); } /*------------------------*/ /* TOOL create sendstring */ /*------------------------*/ toolok=SapCreateSendstr(&sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*--------*/ /* MR --> */ /*--------*/ printf("\n--> S A P (MATCR MR)\n"); printf("sendstring: %s\n",sndstr); /*----------------------------*/ /* SAP create material master */ /*----------------------------*/ hd = SapMatcr("MR", sndstr, &rcvstr, &sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); rcvstr[hd.datalen] = '\0'; strncpy(ucode,hd.ucode,2); ucode[2] = '\0'; /*--------*/ /* MR <-- */ /* create material without classification data */ /*--------*/ if ( strcmp(ucode,"MR") == 0 ) { printf("\n<-- S A P (MATCR MR)\n"); printf("reveivestring: %s\n",rcvstr); return 0; } /*--------*/ /* RF <-- */ /* create material with classification data */ /*--------*/ /*-----------------------*/ /* TOOL create SML table */ /*-----------------------*/ if (strcmp(ucode,"RF")==0) { printf("\n<-- S A P (MATCR RF)\n"); toolok=SapCreateSmlTable(2,rcvstr,(int)hd.datalen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); } /*-------------------------------*/ /* SAP get characteristic values */ /*-------------------------------*/ /*--------*/ /* CR <-- */ /*--------*/ hd = SapMatcr("","",&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); printf("\n<-- S A P (MATCR CR)\n"); rcvstr[hd.datalen] = '\0'; /*-----------------------------------------*/ /* TOOL fill SML table with default values */ /*-----------------------------------------*/ if (hd.datalen > 0 ) { toolok = SapFillSmlTable(2,rcvstr,(int)hd.datalen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); } /*---------------------------------*/ /* TOOL Write new values to table */ /*---------------------------------*/ if ( VERSION == R3 ) { toolok=SapWriteSmlValue(1,0,"PP-STANDARD",33,"DIN_934",1); toolok=SapWriteSmlValue(1,0,"PP-NUT_SHAPE",33,"Hexagon",1); toolok=SapWriteSmlValue(1,0,"PP-THREAD_DIAMETER",33,"6,00 mm",1); } else { toolok=SapWriteSmlValue(1,0,"4LENGTT",10,"10",1); toolok=SapWriteSmlValue(1,0,"4WIDTH",10,"20",1); toolok=SapWriteSmlValue(1,0,"4NOMLEN",10,"12",1); } /*-----------------------------------------------------*/ /* TOOL create sendstring with new classification data */ /*-----------------------------------------------------*/ toolok = SapCreateSendstrSml(2, &sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*----------------------------------*/ /* SAP send new classification data */ /*----------------------------------*/ /*--------*/ /* CR --> */ /*--------*/ printf("\n--> S A P (MATCR CR)\n"); printf("sendstring: %s\n",sndstr); hd = SapMatcr("CR",sndstr, &rcvstr,&sapmes); printf("\n<-- S A P (MATCR MR)\n"); /*--------*/ /* MR <-- */ /*--------*/ toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); return(0); } /*--------------------------------------------------------------------*/ /* tool05 - material display with/without classification data */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int tool05() { SAPHD hd; int toolok,rcvlen,i; int clasnum; char *sndstr,*rcvstr,*sapmes,*chardata=NULL; char ucode[3]; /*----------------------------------*/ /* create internal table for upload */ /*----------------------------------*/ toolok=SapCreateTable(1,"MATRQ","MC",CIM,CIU); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*-------------------*/ /* fill upload table */ /*-------------------*/ if ( VERSION == R3 ) { SapWriteTableValue(1,"MATERIAL","NUT-01",1); SapWriteTableValue(1,"PLANT","0001",1); SapWriteTableValue(1,"LVL_ENGIN","X",1); SapWriteTableValue(1,"LVL_CLASS","X",1); SapWriteTableValue(1,"LVL_MRP_1","X",1); SapWriteTableValue(1,"LVL_MRP_2","X",1); SapWriteTableValue(1,"LVL_MRP_3","X",1); SapWriteTableValue(1,"REQUIRED","X",1); SapWriteTableValue(1,"OPTIONAL","X",1); SapWriteTableValue(1,"UNASSIGNED","X",1); SapWriteTableValue(1,"ASSIGNED","X",1); SapWriteTableValue(1,"INHERITED","X",1); } else { SapWriteTableValue(1,"MATERIAL","5/0001010",1); SapWriteTableValue(1,"CLASS","TERRAM",1); SapWriteTableValue(1,"COMPANY_CD","01",1); SapWriteTableValue(1,"PLANT","01",1); } /*------------------------*/ /* TOOL create sendstring */ /*------------------------*/ toolok=SapCreateSendstr(&sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); printf("\n--> S A P (MATRQ MC)\n"); printf("sendstring: %s\n",sndstr); /*-------------------------*/ /* SAP get material master */ /*-------------------------*/ /*--------*/ /* MC --> */ /*--------*/ hd = SapMatrq("MC", sndstr, &rcvstr, &sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* MC <-- */ /* material master data */ /*--------*/ printf("\n<-- S A P (MATRQ MC)\n"); rcvstr[hd.datalen] = '\0'; printf("reveivestring: %s\n",rcvstr); /*----------------------------------*/ /* TOOL save data in internal table */ /*----------------------------------*/ toolok=SapCreateFillTable(2,"MATRQ", "MC",CIM, CID, rcvstr,(int)hd.datalen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*-----------------------------*/ /* SAP get klassification data */ /*-----------------------------*/ hd = SapMatrq("", "", &rcvstr, &sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); strncpy(ucode,hd.ucode,2); ucode[2] = '\0'; /*--------*/ /* RF <-- */ /* characteristics for class when one specified or avaiable */ /*--------*/ if (strcmp(ucode,"RF")==0) { printf("\n<-- S A P (MATRQ RF)\n"); rcvstr[hd.datalen] = '\0'; /*---------------------------*/ /* get characteristic values */ /*---------------------------*/ toolok = GetCharacteristicValues(1,rcvstr,(int) hd.datalen); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); return 0; } /*--------*/ /* RC <-- */ /* list of all classes */ /*--------*/ if (strcmp(ucode,"RC")==0) { printf("\n<-- S A P (MATRQ RC)\n"); rcvstr[hd.datalen] = '\0'; /*------------------------------*/ /* TOOL create fill class table */ /*------------------------------*/ toolok=SapCreateFillClasTableR3(2,rcvstr,hd.datalen,&clasnum); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*------------------------*/ /* get data for each clas */ /*------------------------*/ for ( i=1; i <= clasnum; i++ ) { /*------------------------------*/ /* get one clas out of claslist */ /*------------------------------*/ toolok = GetClasdata(1,i, &chardata, &rcvlen); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*---------------------------*/ /* get characteristic values */ /*---------------------------*/ toolok = GetCharacteristicValues(1,chardata,rcvlen); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); } } /* break function */ hd=SapBreak(&sapmes); return (0); } /*--------------------------------------------------------------------*/ /* tool06 - material change with/without classification data */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int tool06() { SAPHD hd; int toolok, rcvlen, smlnum, index; int clasnum; char *sndstr,*rcvstr,*sapmes,*value,*chardata=NULL; char ucode[3]; SAPSML_R3 smldata_R3; SAPSML smldata_R2; SAPATT attstr; /*----------------------------------*/ /* create internal table for upload */ /*----------------------------------*/ toolok=SapCreateTable(1,"MATCH","MC",CIM,CIU); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*-------------------*/ /* fill upload table */ /*-------------------*/ if ( VERSION == R3 ) { SapWriteTableValue(1,"MATERIAL","NUT-01",1); SapWriteTableValue(1,"LVL_ENGIN","X",1); SapWriteTableValue(1,"LVL_CLASS","X",1); SapWriteTableValue(1,"REQUIRED","X",1); SapWriteTableValue(1,"OPTIONAL","X",1); SapWriteTableValue(1,"UNASSIGNED","X",1); SapWriteTableValue(1,"ASSIGNED","X",1); SapWriteTableValue(1,"INHERITED","X",1); } else { SapWriteTableValue(1,"MATERIAL","5/0001010",1); SapWriteTableValue(1,"COMPANY_CD","01",1); SapWriteTableValue(1,"PLANT","01",1); } /*------------------------*/ /* TOOL create sendstring */ /*------------------------*/ toolok=SapCreateSendstr(&sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); printf("\n--> S A P (MATCH MC)\n"); printf("sendstring: %s\n",sndstr); /*-------------------------*/ /* SAP get material master */ /*-------------------------*/ /*--------*/ /* MC --> */ /*--------*/ hd = SapMatch("MC", sndstr, &rcvstr, &sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* MC <-- */ /* material master data */ /*--------*/ printf("\n<-- S A P (MATCH MC)\n"); rcvstr[hd.datalen] = '\0'; printf("reveivestring: %s\n",rcvstr); /*----------------------------------*/ /* TOOL save data in internal table */ /*----------------------------------*/ toolok=SapCreateFillTable(2,"MATCH", "MD",CIM, CID, rcvstr,(int)hd.datalen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*----------------------------------*/ /* create internal table for upload */ /*----------------------------------*/ toolok=SapCreateTable(1,"MATCH","MD",CIM,CIU); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*-------------------------------------------*/ /* TOOL fill upload table with download data */ /*-------------------------------------------*/ index=1; while ( SapGetAttributName(1,"MATCH","MD",CIM,CIU,index,&attstr)== 0 ) { /* get attribut value for upload attribut from CID */ toolok=SapGetTableValue(2,attstr.attname,1,&value); if ( toolok==0) { toolok=SapModifyTableValue(1,attstr.attname,value,1); if ( toolok!=0) SapWriteTableValue(1,attstr.attname,value,1); } index++; } /*----------------------------------*/ /* TOOL Change material master data */ /*----------------------------------*/ if (VERSION == R3) { toolok = SapModifyTableValue(1,"DESCRIPT_M","metric hex nut",1); if ( toolok != 0 ) SapWriteTableValue(1,"DESCRIPT_M","metric hex nut",1); } else { toolok = SapModifyTableValue(1,"DESCRIPT_M","screw 6*12 3",1); if ( toolok != 0 ) SapWriteTableValue(1,"DESCRIPT_M","screw 6*12 3",1); } /*------------------------------------------*/ /* TOOL Create sendstring with changed data */ /*------------------------------------------*/ toolok = SapCreateSendstr(&sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); printf("\n--> S A P (MATCH MD)\n"); printf("sendstring: %s\n",sndstr); /*-----------------------------------------*/ /* SAP send changed material master to SAP */ /*-----------------------------------------*/ /*--------*/ /* MD --> */ /*--------*/ hd = SapMatch("MD", sndstr, &rcvstr, &sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); strncpy(ucode,hd.ucode,2); ucode[2] = '\0'; /*--------*/ /* RF <-- */ /* characteristics for class when one specified or available */ /*--------*/ if (strcmp(ucode,"RF")==0) { printf("\n<-- S A P (MATCH RF)\n"); rcvstr[hd.datalen] = '\0'; /*---------------------------*/ /* get characteristic values */ /*---------------------------*/ toolok = GetCharacteristicValues(2,rcvstr,(int) hd.datalen); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); } /*--------*/ /* RC <-- */ /* list of all classes */ /*--------*/ if (strcmp(ucode,"RC")==0) { printf("\n<-- S A P (MATCH RC)\n"); rcvstr[hd.datalen] = '\0'; /*------------------------------*/ /* TOOL create fill class table */ /*------------------------------*/ toolok=SapCreateFillClasTableR3(2,rcvstr,hd.datalen,&clasnum); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*--------------------------------*/ /* get first clas out of claslist */ /*--------------------------------*/ toolok = GetClasdata(2, 1, &chardata, &rcvlen); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*---------------------------*/ /* get characteristic values */ /*---------------------------*/ toolok = GetCharacteristicValues(2, chardata,rcvlen); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); } /*----------------------------------------*/ /* get possible values of characteristics */ /*----------------------------------------*/ if (VERSION == R3) { toolok=GetPossibleSmlValues(2); } /*----------------------*/ /* TOOL change SML data */ /*----------------------*/ smlnum = 1; if ( VERSION == R3 ) { while (SapGetSmlDataR3(2,smlnum,1,&smldata_R3)==0) { if (strcmp(smldata_R3.name,"PP-STANDARD")==0) { SapWriteSmlValue(1,0,"PP-STANDARD",33,"DIN_931",1); } if (strcmp(smldata_R3.name,"PP-THREAD_DIAMETER")==0) { SapWriteSmlValue(1,0,"PP-THREAD_DIAMETER",33,"10,00 mm",1); } smlnum++; } } else { while (SapGetSmlData(1,smlnum,1,&smldata_R2)==0) { smlnum++; if (strcmp(smldata_R2.feldname,"4LENGTT")==0) SapWriteSmlValue(1,0,"4LENGTT",10,"15",1); if (strcmp(smldata_R2.feldname,"4WIDTH")==0) SapWriteSmlValue(1,0,"4WIDTH",10,"30",1); if (strcmp(smldata_R2.feldname,"4NOMLEN")==0) SapWriteSmlValue(1,0,"4NOMLEN",10,"20",1); } } /*-----------------------------------------------------*/ /* TOOL create sendstring with new classification data */ /*-----------------------------------------------------*/ toolok = SapCreateSendstrSml(2, &sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*----------------------------------*/ /* SAP send new classification data */ /*----------------------------------*/ /*--------*/ /* CR --> */ /*--------*/ printf("\n--> S A P (MATCH CR)\n"); printf("sendstring: %s\n",sndstr); hd = SapMatch("CR",sndstr, &rcvstr,&sapmes); printf("\n<-- S A P (MATCH MC)\n"); /*--------*/ /* MC <-- */ /*--------*/ toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /* break function */ hd=SapBreak(&sapmes); return (0); } /*--------------------------------------------------------------------*/ /* tool07 - search objects via clas */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int tool07() { SAPHD hd; SAPSML smldata; SAPSML_R3 smldata_R3; SAPOBJ_R3 objdata_R3; char *rcvstr,*sndstr,*sapmes,*c_sml_num,*c_obj_num,*value; int rcvlen,toolok,sml_num=0,obj_num=0,i,j, value_num=0,v=0; /*********/ /* R/2 */ /*********/ if ( VERSION == R2 ) { /*------------------------------------------*/ /* TOOL interne Tabelle anlegen fuer upload */ /*------------------------------------------*/ toolok=SapCreateTable(1,"SLOBJ","RI",CIM,CIU); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*---------------------------------------*/ /* TOOL store attribut in internal table */ /*---------------------------------------*/ toolok=SapWriteTableValue(1,"CLASS","TERRAM",1); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); toolok=SapWriteTableValue(1,"CLASS_TYPE","S",1); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); toolok=SapWriteTableValue(1,"TABLE","MARA",1); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*------------------------*/ /* TOOL create sendstring */ /*------------------------*/ toolok=SapCreateSendstr(&sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); } /*********/ /* R/3 */ /*********/ else { /*-----------------------------------------------------*/ /* create sendstring for class specification and scope */ /*-----------------------------------------------------*/ toolok = SapCreateSendstrClasSelectR3("001", "PP-NUTS", "", "X", "X", "X", "X", "X", "X", "X", "X", &sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); } /*--------*/ /* RI --> */ /* identifying string */ /*--------*/ printf("\n--> S A P (SLOBJ RI)\n"); printf("sendstring: %s\n",sndstr); /*-----------------------------*/ /* SAP send identifying string */ /*-----------------------------*/ hd=SapSlobj("RI",sndstr,&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* RF <-- */ /* characteristics */ /*--------*/ printf("\n<-- S A P (SLOBJ RF)\n"); rcvstr[hd.datalen] = '\0'; /*********/ /* R/2 */ /*********/ if (VERSION == R2) { /*-----------------------------------------------------*/ /* TOOL create internal structure with characteristics */ /*-----------------------------------------------------*/ rcvlen=(int)hd.datalen; toolok=SapCreateSmlTable(1,rcvstr,rcvlen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*--------------------------------*/ /* TOOL store selection criterion */ /*--------------------------------*/ toolok=SapWriteSmlValue(1,0,"4LENGTT",11,"*",1); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); toolok=SapWriteSmlValue(1,0,"4LENGTT",12,"MASK",1); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); } /*********/ /* R/3 */ /*********/ else { /*-------------------------------*/ /* SAP get characteristic values */ /*-------------------------------*/ toolok = GetCharacteristicValues(3,rcvstr,(int) hd.datalen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*---------------------------------*/ /* get name of 1st characteristics */ /*---------------------------------*/ toolok = SapGetSmlDataR3(2,1,1,&smldata_R3); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*-----------------------------------------*/ /* get possible values for characteristics */ /*-----------------------------------------*/ GetPossibleSmlValues(1); /*--------------------------------*/ /* TOOL store selection criterion */ /*--------------------------------*/ toolok=SapWriteSmlValue(1,0,"PP-NUT_SHAPE",34,"Hexagon",1); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); toolok=SapWriteSmlValue(1,0,"PP-NUT_SHAPE",35,"INCL",1); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); } /*------------------------------------------------*/ /* TOOL create sendstring with selection criteria */ /*------------------------------------------------*/ toolok=SapCreateSendstrSml(1,&sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*--------*/ /* CR --> */ /* selection criteria */ /*--------*/ printf("\n--> S A P (SLOBJ CR)\n"); printf("sendstring: %s\n",sndstr); /*---------------------*/ /* SAP start selection */ /*---------------------*/ hd=SapSlobj("CR",sndstr,&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* RI <-- */ /* list of objects */ /*--------*/ printf("\n<-- S A P (SLOBJ RI)\n"); rcvstr[hd.datalen] = '\0'; /*---------------------------------------------*/ /* TOOL create and fill structure with objects */ /*---------------------------------------------*/ rcvlen=(int)hd.datalen; toolok=SapFillSmlTable(1,rcvstr,rcvlen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*--------------------------------*/ /* TOOL get number of objects */ /*--------------------------------*/ toolok=SapGetSmlDescription(1,&c_sml_num); sml_num=atoi(c_sml_num); /*------------------------------------*/ /* TOOL get number of characteristics */ /*------------------------------------*/ toolok=SapGetSmlDescription(2,&c_obj_num); obj_num=atoi(c_obj_num); /*--------------------------------*/ /* TOOL print SML name and values */ /*--------------------------------*/ /*********/ /* R/2 */ /*********/ if (VERSION == R2) { for (i=1;i<=obj_num ;i++) { printf("\nObject No. %d\n",i); printf("---------------\n"); for (j=1;j<=sml_num ;j++) { SapGetSmlData(1,j,i,&smldata); printf("name : %15s value : %s\n",smldata.name,smldata.value); } } } /*********/ /* R/3 */ /*********/ else { for (i=1;i<=obj_num ;i++) { printf("\nObject No. %d\n",i); printf("---------------\n"); /* get object description data */ SapGetObjectDataR3(1,i,&objdata_R3); printf("class/object (K/O) : %s\n",objdata_R3.id); printf("object key : %s\n",objdata_R3.objkey1); printf("object description : %s\n",objdata_R3.objtext); printf("-------------------------------\n"); for (j=1;j<=sml_num ;j++) { /* get characteristics */ SapGetSmlDataR3(1,j,i,&smldata_R3); printf("\nname : %s\n",smldata_R3.name); /* get nomber of characteristics */ toolok=SapGetSmlValueDescriptionR3(1,i,smldata_R3.name,&value_num); /* get aditional values for characteristics */ for (v=1;v<=value_num;v++) { SapGetSmlDataValueR3(1,smldata_R3.name,0,i,v,&value); printf("value %d : %s\n",v,value); } } } } /* break function */ hd=SapBreak(&sapmes); return(0); } /*--------------------------------------------------------------------*/ /* tool08 - search clas generically R/3 */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int tool08() { SAPHD hd; SAPCLAS_S_R3 clasdata_R3; char *sndstr=NULL, *rcvstr=NULL, *sapmes=NULL; int toolok=0, i; int clasnum=0; if (VERSION == R2) { printf("\nfunction 08 is only supported for R/3 connection\n"); return 0; } /*----------------------------------------------------------*/ /* TOOL create sendstring with selection criteria for class */ /*----------------------------------------------------------*/ toolok = SapCreateSendstrClasSearchR3(1,"001","PP-N*","","E","X","","",&sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*--------*/ /* HM --> */ /* selection criteria for class */ /*--------*/ printf("\n--> S A P (SLCLS HM)\n"); printf("sendstring: %s\n",sndstr); /*---------------------*/ /* SAP start selection */ /*---------------------*/ hd=SapSlcls("HM",sndstr,&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* HM <-- */ /* list of classes */ /*--------*/ printf("\n<-- S A P (SLCLS HM)\n"); rcvstr[hd.datalen] = '\0'; /*---------------------------------------------*/ /* TOOL create and fill table with classes */ /*---------------------------------------------*/ toolok = SapCreateFillClasTableR3(3,rcvstr,hd.datalen,&clasnum); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*-----------------------*/ /* TOOL printf clas data */ /*-----------------------*/ for (i=1; i<=clasnum; i++) { toolok = SapGetClasSearchDataR3(1,i,&clasdata_R3); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); printf("\nclas type : %s\n",clasdata_R3.art); printf("clas name : %s\n",clasdata_R3.name); printf("catchword : %s\n",clasdata_R3.schlagwort); } return (0); } /*--------------------------------------------------------------------*/ /* tool09 - search class without predecessor R/3 */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int tool09() { SAPHD hd; SAPCLAS_S_R3 clasdata_R3; char *sndstr=NULL, *rcvstr=NULL, *sapmes=NULL; int toolok=0,i,clasnum=0; if (VERSION == R2) { printf("\nfunction 09 is only supported for R/3 connection\n"); return 0; } /*----------------------------------------------------------*/ /* TOOL create sendstring with selection criteria for class */ /*----------------------------------------------------------*/ toolok = SapCreateSendstrClasSearchR3(2,"001","PP-*","","E","","","",&sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*--------*/ /* HS --> */ /* class data */ /*--------*/ printf("\n--> S A P (SLCLS HS)\n"); printf("sendstring: %s\n",sndstr); /*---------------------*/ /* SAP start selection */ /*---------------------*/ hd=SapSlcls("HS",sndstr,&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* HS <-- */ /* list of classes */ /*--------*/ printf("\n<-- S A P (SLCLS HS)\n"); rcvstr[hd.datalen] = '\0'; /*---------------------------------------------*/ /* TOOL create and fill table with classes */ /*---------------------------------------------*/ toolok = SapCreateFillClasTableR3(3,rcvstr,hd.datalen,&clasnum); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*-----------------------*/ /* TOOL printf clas data */ /*-----------------------*/ printf("\nlist of classes\n"); printf("---------------\n\n"); for (i=1; i<=clasnum; i++) { toolok = SapGetClasSearchDataR3(1,i,&clasdata_R3); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); printf("clas name : %s\n",clasdata_R3.name); } return (0); } /*--------------------------------------------------------------------*/ /* tool10 - search superior and subordinate classes R/3 */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int tool10() { SAPHD hd; SAPCLAS_H_R3 clas_hier_R3; char *sndstr=NULL, *rcvstr=NULL, *sapmes=NULL; int toolok=0,i,num_entries=0; if (VERSION == R2) { printf("\nfunction 10 is only supported for R/3 connection\n"); return 0; } /*----------------------------------------------------------*/ /* TOOL create sendstring with selection criteria for class */ /*----------------------------------------------------------*/ toolok = SapCreateSendstrClasSearchR3(3,"001","PP-NUTS","","D","","1","3",&sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*--------*/ /* RH --> */ /* class data */ /*--------*/ printf("\n--> S A P (SLCLS RH)\n"); printf("sendstring: %s\n",sndstr); /*---------------------*/ /* SAP start selection */ /*---------------------*/ hd=SapSlcls("RH",sndstr,&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* RH <-- */ /* list of classes */ /*--------*/ printf("\n<-- S A P (SLCLS RH)\n"); rcvstr[hd.datalen] = '\0'; /*-----------------------------------------------------*/ /* TOOL create and fill table with class hierarchy */ /*-----------------------------------------------------*/ toolok = SapCreateFillClasHierarchTableR3(1,rcvstr,hd.datalen,&num_entries); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*----------------------*/ /* TOOL print clas data */ /*----------------------*/ printf("\nclass sturcture\n"); printf("-----------------\n"); for (i=1; i<=num_entries; i++) { toolok = SapGetClasHierarchDataR3(1,i,&clas_hier_R3); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); printf("\nlevel : %s\n",clas_hier_R3.stufe); printf("superior class : %s\n",clas_hier_R3.vorg_klas); printf("subordinate class : %s\n",clas_hier_R3.nach_klas); } return (0); } /*--------------------------------------------------------------------*/ /* tool11 - delete table entry */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int tool11() { int toolok; toolok=0; /*-----------------------------------*/ /* TOOL Create table for BOM entries */ /*-----------------------------------*/ toolok=SapCreateTable(1,"BOMCR","SP",CIM, CIU); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*--------------------------*/ /* TOOL fill internal table */ /*--------------------------*/ SapWriteTableValue(1,"ITEM_NO","1",1); SapWriteTableValue(1,"MATERIAL","4711",1); SapWriteTableValue(1,"QUANTITY","1",1); SapWriteTableValue(1,"ITEM_NO","2",2); SapWriteTableValue(1,"MATERIAL","4712",2); SapWriteTableValue(1,"QUANTITY","1",2); SapWriteTableValue(1,"ITEM_NO","3",3); SapWriteTableValue(1,"MATERIAL","4713",3); SapWriteTableValue(1,"QUANTITY","1",3); /*-------------------*/ /* delete entry no 2 */ /*-------------------*/ printf("delete entry no. 2\n"); toolok = SapDeleteTableEntry(1,2); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*----------------------*/ /* TOOL print new table */ /*----------------------*/ printf("new table printed -> CIU.DAT\n"); SapPrintTable(1, "ciu.dat"); return(0); } /*--------------------------------------------------------------------*/ /* tool12 - find class via catchword */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int tool12() { int toolok=0,number=0,clasnum=0; char *rcvstr=NULL, *sapmes=NULL; char id[2],subid[3],text01[101],text02[101]; char sendstr[100], *sndstr=NULL; int rcvlen=0, index=0,i=0; SAPHD hd; SAPCLAS_S_R3 clasdata_R3; if (VERSION == R2) { printf("\nfunction 12 is only supported for R/3 connection\n"); return 0; } /*--------*/ /* GM --> */ /*--------*/ printf("\n--> S A P (SLCLS RH)\n"); /*---------------------*/ /* SAP start selection */ /*---------------------*/ hd=SapSlcls("GM","",&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* ID <-- */ /* list of matchcode ID's */ /*--------*/ printf("\n<-- S A P (SLCLS RH)\n"); rcvstr[hd.datalen] = '\0'; /*---------------------------------------------*/ /* TOOL fill matchcode table with matchcode ID */ /*---------------------------------------------*/ rcvlen=(int)hd.datalen; toolok=SapCreateFillTableMcd(1,rcvstr,rcvlen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*--------------------------------------*/ /* TOOL get number of defined machcodes */ /*--------------------------------------*/ toolok=SapGetMcdDescription(1,&rcvstr); number=atoi(rcvstr); /*----------------------*/ /* print Matchcode ID`s */ /*----------------------*/ for (index=1;index<=number;index++) { toolok=SapGetMcdValue("ID",index,&rcvstr); (void) strcpy(id,rcvstr); toolok=SapGetMcdValue("SUBID",index,&rcvstr); (void) strcpy(subid,rcvstr); toolok=SapGetMcdValue("TEXT01",index,&rcvstr); (void) strcpy(text01,rcvstr); printf("%3s %5s %s\n",id,subid,text01); } /*-------------------------------------*/ /* TOOL get matchcode ID with number 1 */ /*-------------------------------------*/ index=1; sendstr[0]='\0'; toolok=SapGetMcdValue("ID",index,&rcvstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); (void) strcat(sendstr,rcvstr); (void) strcat(sendstr,trenner); /*----------------------------------------*/ /* TOOL get matchcode SUBID with number 1 */ /*----------------------------------------*/ index=1; toolok=SapGetMcdValue("SUBID",index,&rcvstr); (void) strcat(sendstr,rcvstr); /*--------*/ /* ID --> */ /*--------*/ printf("\n--> S A P (SLCLS ID)\n"); /*---------------------------------------------------*/ /* SAP get characteristics of the selected matchcode */ /*---------------------------------------------------*/ hd=SapSlcls("ID",sendstr,&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* RF <-- */ /* list of matchcode fields */ /*--------*/ printf("\n<-- S A P (SLCLS RF)\n"); rcvstr[hd.datalen] = '\0'; /*-------------------------------------*/ /* TOOL store received data in toolbox */ /*-------------------------------------*/ rcvlen=(int)hd.datalen; toolok=SapCreateFillTableMcd(2,rcvstr,rcvlen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*------------------------------------*/ /* TOOL get number of characteristics */ /*------------------------------------*/ toolok=SapGetMcdDescription(1,&rcvstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); number=atoi(rcvstr); /*-------------------------------*/ /* print defined characteristics */ /*-------------------------------*/ for (index=1;index<=number;index++) { toolok=SapGetMcdValue("TEXT02",index,&rcvstr); (void) strcpy(text02,rcvstr); printf("%s\n",text02); } /*-------------------------------*/ /* TOOL store selection in table */ /*-------------------------------*/ toolok=SapWriteMcdValue(1,1,"hex*"); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*------------------------*/ /* TOOL create sendstring */ /*------------------------*/ toolok=SapCreateSendstrMcd(1,"SLCLS","RF",&sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*--------*/ /* RF --> */ /*--------*/ printf("\n--> S A P (SLCLS RF)\n"); printf("sendstring: %s\n",sndstr); /*--------------------------*/ /* SAP get selected classes */ /*--------------------------*/ hd=SapSlcls("RF",sndstr,&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* GM <-- */ /* list of selected classes */ /*--------*/ printf("\n<-- S A P (SLCLS GM)\n"); rcvstr[hd.datalen] = '\0'; /*---------------------------------------------*/ /* TOOL create and fill table with classes */ /*---------------------------------------------*/ toolok = SapCreateFillClasTableR3(4,rcvstr,hd.datalen,&clasnum); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*-----------------------*/ /* TOOL printf clas data */ /*-----------------------*/ for (i=1; i<=clasnum; i++) { toolok = SapGetClasSearchDataR3(1,i,&clasdata_R3); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); printf("\nno : %d\n",i); printf("clas type : %s\n",clasdata_R3.art); printf("clas name : %s\n",clasdata_R3.name); } /* break function */ hd = SapBreak(&sapmes); return 0; } /*--------------------------------------------------------------------*/ /* tool13 - set class scope */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int tool13() { int toolok; if (VERSION == R2) { printf("\nfunction 13 is only supported for R/3 connection\n"); return 0; } /*-----------------*/ /* set class scope */ /*-----------------*/ toolok = SetClasScope(); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); return 0; } /*--------------------------------------------------------------------*/ /* tool14 - explode class hierarchy (R/2) */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int tool14() { SAPHD hd; char *rcvstr,*sndstr,*sapmes; char parnam[ATTNAM_SIZE+1]; int pos,row=0,index,rcvlen,toolok=0; /*-----------------------*/ /* only available in R/2 */ /*-----------------------*/ if (VERSION == R3) { printf("\nfunction 14 only supported for R/2 connection\n"); return(0); } /*------------------------------*/ /* TOOL create table for upload */ /*------------------------------*/ toolok=SapCreateTable(1,"SLCLS","RH",CIM,CIU); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*----------------------------------------*/ /* TOOL store attributs in internal table */ /*----------------------------------------*/ toolok=SapWriteTableValue(1,"CLASS","CP-HIER",1); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); toolok=SapWriteTableValue(1,"CLASS_TYPE","S",1); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); toolok=SapWriteTableValue(1,"TABLE","MARA",1); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*------------------------*/ /* TOOL create sendstring */ /*------------------------*/ toolok=SapCreateSendstr(&sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*--------*/ /* RH --> */ /*--------*/ printf("\n--> S A P (SLCLS RH)\n"); printf("sendstring: %s\n",sndstr); /*-----------------------------*/ /* SAP send identifying string */ /*-----------------------------*/ hd=SapSlcls("RH",sndstr,&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* RH <-- */ /*--------*/ printf("\n<-- S A P (SLCLS RH)\n"); rcvstr[hd.datalen] = '\0'; /*---------------------------------------*/ /* TOOL create and fill table in toolbox */ /*---------------------------------------*/ rcvlen= (int) hd.datalen; toolok=SapCreateFillTable(4,"SLCLS","RH","","",rcvstr,rcvlen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*----------------------------*/ /* TOOL get number of entries */ /*----------------------------*/ toolok=SapDescribeTable(4,&rcvstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); row=atoi(rcvstr); /*--------------------------*/ /* TOOL print table entries */ /*--------------------------*/ for (pos=1;pos<=row;pos++) { index=1; printf("\nposition: %d\n",pos); while(SapGetAttributNameValue (4,index,pos,parnam,&rcvstr)==0) { index++; printf("name: %6s value: %s\n",parnam,rcvstr); } } return(0); } /*--------------------------------------------------------------------*/ /* tool15 - list classes on next hierarchy level (R/2) */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int tool15() { SAPHD hd; char *rcvstr,*sndstr,*sapmes; char parnam[ATTNAM_SIZE+1]; int pos,row=0,index,rcvlen,toolok=0; /* only available in R/2 */ if (VERSION == R3){ printf("\nfunction 15 only supported for R/2 connection\n"); return(0); } /*------------------------------*/ /* TOOL create table for upload */ /*------------------------------*/ toolok=SapCreateTable(1,"SLCLS","RL",CIM,CIU); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*---------------------------------------*/ /* TOOL store attribut in internal table */ /*---------------------------------------*/ toolok=SapWriteTableValue(1,"CLASS","CP-HIER",1); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); toolok=SapWriteTableValue(1,"CLASS_TYPE","S",1); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); toolok=SapWriteTableValue(1,"TABLE","MARA",1); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*------------------------*/ /* TOOL create sendstring */ /*------------------------*/ toolok=SapCreateSendstr(&sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*--------*/ /* RL --> */ /*--------*/ printf("\n--> S A P (SLCLS RL)\n"); printf("sendstring: %s\n",sndstr); /*-----------------------------*/ /* SAP send identifying string */ /*-----------------------------*/ hd=SapSlcls("RL",sndstr,&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* RL <-- */ /*--------*/ printf("\n<-- S A P (SLCLS RL)\n"); rcvstr[hd.datalen] = '\0'; /*---------------------------------------*/ /* TOOL create and fill table in toolbox */ /*---------------------------------------*/ rcvlen= (int) hd.datalen; toolok=SapCreateFillTable(4,"SLCLS","RL","","",rcvstr,rcvlen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*----------------------------------*/ /* TOOL get number of table entries */ /*----------------------------------*/ toolok=SapDescribeTable(4,&rcvstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); row=atoi(rcvstr); /*--------------------------*/ /* TOOL print table entries */ /*--------------------------*/ for (pos=1;pos<=row;pos++) { index=1; printf("\nposition: %d\n",pos); while(SapGetAttributNameValue (4,index,pos,parnam,&rcvstr)==0) { index++; printf("name: %6s value: %s\n",parnam,rcvstr); } } return(0); } /*--------------------------------------------------------------------*/ /* tool16 - generic class list of hierarchy classes (R/2) */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int tool16() { SAPHD hd; char *rcvstr,*sndstr,*sapmes; char parnam[ATTNAM_SIZE+1]; int pos,row=0,index,rcvlen,toolok=0; /* only available in R/2 */ if (VERSION == R3) { printf("\nfunction 16 only supported for R/2 connection\n"); return 0; } /*------------------------------*/ /* TOOL create table for upload */ /*------------------------------*/ toolok=SapCreateTable(1,"SLCLS","RH",CIM,CIU); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*---------------------------------------*/ /* TOOL store attribut in internal table */ /*---------------------------------------*/ toolok=SapWriteTableValue(1,"CLASS","*",1); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); toolok=SapWriteTableValue(1,"CLASS_TYPE","S",1); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); toolok=SapWriteTableValue(1,"TABLE","MARA",1); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*------------------------*/ /* TOOL create sendstring */ /*------------------------*/ toolok=SapCreateSendstr(&sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*--------*/ /* HS --> */ /*--------*/ printf("\n--> S A P (SLCLS HS)\n"); printf("sendstring: %s\n",sndstr); /*-----------------------------*/ /* SAP send identifying string */ /*-----------------------------*/ hd=SapSlcls("HS",sndstr,&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* HS <-- */ /*--------*/ printf("\n<-- S A P (SLCSL HS)\n"); rcvstr[hd.datalen] = '\0'; /*---------------------------------------*/ /* TOOL create and fill table in toolbox */ /*---------------------------------------*/ rcvlen= (int) hd.datalen; toolok=SapCreateFillTable(4,"SLCLS","HS","","",rcvstr,rcvlen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*----------------------------------*/ /* TOOL get number of table entries */ /*----------------------------------*/ toolok=SapDescribeTable(4,&rcvstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); row=atoi(rcvstr); /*--------------------------*/ /* TOOL print table entries */ /*--------------------------*/ for (pos=1;pos<=row;pos++) { index=1; printf("\nposition: %d\n",pos); while(SapGetAttributNameValue (4,index,pos,parnam,&rcvstr)==0) { index++; printf("name: %6s value: %s\n",parnam,rcvstr); } } return(0); } /*--------------------------------------------------------------------*/ /* tool17 - generic class list of real and dummy classes (R/2) */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int tool17() { SAPHD hd; char *rcvstr,*sndstr,*sapmes; char parnam[ATTNAM_SIZE+1]; int pos,row=0,index,rcvlen,toolok=0; /* only available in R/2 */ if (VERSION == R3) { printf("\nfunction 17 only supported for R/2 connection\n"); return 0; } /*------------------------------*/ /* TOOL create table for upload */ /*------------------------------*/ toolok=SapCreateTable(1,"SLCLS","HM",CIM,CIU); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*---------------------------------------*/ /* TOOL store attribut in internal table */ /*---------------------------------------*/ toolok=SapWriteTableValue(1,"CLASS","*",1); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); toolok=SapWriteTableValue(1,"CLASS_TYPE","S",1); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); toolok=SapWriteTableValue(1,"TABLE","MARA",1); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*------------------------*/ /* TOOL create sendstring */ /*------------------------*/ toolok=SapCreateSendstr(&sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*--------*/ /* HM --> */ /*--------*/ printf("\n--> S A P (SLCSL HM)\n"); printf("sendstring: %s\n",sndstr); /*-----------------------------*/ /* SAP send identifying string */ /*-----------------------------*/ hd=SapSlcls("HM",sndstr,&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* HS <-- */ /*--------*/ printf("\n<-- S A P (SLCLS HS)\n"); rcvstr[hd.datalen] = '\0'; /*---------------------------------------*/ /* TOOL create and fill table in toolbox */ /*---------------------------------------*/ rcvlen= (int) hd.datalen; toolok=SapCreateFillTable(4,"SLCLS","HM","","",rcvstr,rcvlen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*----------------------------------*/ /* TOOL get number of table entries */ /*----------------------------------*/ toolok=SapDescribeTable(4,&rcvstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); row=atoi(rcvstr); /*--------------------------*/ /* TOOL print table entries */ /*--------------------------*/ for (pos=1;pos<=row;pos++) { index=1; printf("\nposition: %d\n",pos); while(SapGetAttributNameValue (4,index,pos,parnam,&rcvstr)==0) { index++; printf("name: %6s value: %s\n",parnam,rcvstr); } } return(0); } /*--------------------------------------------------------------------*/ /* tool18 - equipment create with/without classification data (R/3) */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int tool18() { SAPHD hd; int toolok; char *sndstr,*rcvstr,*sapmes; char ucode[3]; /* only available in R/3 */ if (VERSION == R2) { printf("\nfunction 18 only supported for R/3 Rel. 3.0\n"); return 0; } /*---------------------------------------*/ /* TOOL create internal table for upload */ /*---------------------------------------*/ toolok=SapCreateTable(1,"EQICR","MR",CIM,CIU); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*------------------------*/ /* TOOL fill upload table */ /*------------------------*/ SapWriteTableValue(1,"EQUIPMENT","",1); SapWriteTableValue(1,"EQUI_CATEG","M",1); SapWriteTableValue(1,"DESCRIPT_E","valve",1); SapWriteTableValue(1,"CLASS_TYPE","002",1); SapWriteTableValue(1,"CLASS_NO","EQUI_SERV",1); SapWriteTableValue(1,"REQUIRED","X",1); SapWriteTableValue(1,"OPTIONAL","X",1); SapWriteTableValue(1,"UNASSIGNED","X",1); SapWriteTableValue(1,"ASSIGNED","X",1); SapWriteTableValue(1,"INHERITED","X",1); /*------------------------*/ /* TOOL create sendstring */ /*------------------------*/ toolok=SapCreateSendstr(&sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*--------*/ /* MR --> */ /*--------*/ printf("\n--> S A P (EQICR MR)\n"); printf("sendstring: %s\n",sndstr); /*-----------------------------*/ /* SAP create equipment master */ /*-----------------------------*/ hd = SapEqicr("MR", sndstr, &rcvstr, &sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); rcvstr[hd.datalen] = '\0'; strncpy(ucode,hd.ucode,2); ucode[2] = '\0'; /*--------*/ /* MR <-- */ /* create equipment without classification data */ /*--------*/ if ( strcmp(ucode,"MR") == 0 ) { printf("\n<-- S A P (EQICR MR)\n"); printf("reveivestring: %s\n",rcvstr); return 0; } /*--------*/ /* RF <-- */ /* create equipment with classification data */ /*--------*/ /*-----------------------*/ /* TOOL create SML table */ /*-----------------------*/ if (strcmp(ucode,"RF")==0) { printf("\n<-- S A P (EQICR RF)\n"); toolok=SapCreateSmlTable(2,rcvstr,(int)hd.datalen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); } /*-------------------------------*/ /* SAP get characteristic values */ /*-------------------------------*/ /*--------*/ /* CR <-- */ /*--------*/ hd = SapEqicr("","",&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); printf("\n<-- S A P (EQICR CR)\n"); rcvstr[hd.datalen] = '\0'; /*-----------------------------------------*/ /* TOOL fill SML table with default values */ /*-----------------------------------------*/ if (hd.datalen > 0 ) { toolok = SapFillSmlTable(2,rcvstr,(int)hd.datalen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); } /*---------------------------------*/ /* TOOL Write new values to table */ /*---------------------------------*/ toolok=SapWriteSmlValue(1,0,"REFERENCE_CUSTOMER",33,"X",1); toolok=SapWriteSmlValue(1,0,"VISITING_HOURS",33,"12-17",1); toolok=SapWriteSmlValue(1,0,"PRIORITY_CUSTOMER",33,"X",1); /*-----------------------------------------------------*/ /* TOOL create sendstring with new classification data */ /*-----------------------------------------------------*/ toolok = SapCreateSendstrSml(2, &sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*----------------------------------*/ /* SAP send new classification data */ /*----------------------------------*/ /*--------*/ /* CR --> */ /*--------*/ printf("\n--> S A P (EQICR CR)\n"); printf("sendstring: %s\n",sndstr); hd = SapEqicr("CR",sndstr, &rcvstr,&sapmes); printf("\n<-- S A P (EQICR MR)\n"); /*--------*/ /* MR <-- */ /*--------*/ toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); return(0); } /*--------------------------------------------------------------------*/ /* tool19 - equipment diaplay with/without classification data (R/3) */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int tool19() { SAPHD hd; int toolok,rcvlen,i; int clasnum; char *sndstr,*rcvstr,*sapmes,*chardata=NULL; char ucode[3]; /* only available in R/3 */ if (VERSION == R2) { printf("\nfunction 19 only supported for R/3 Rel. 3.0\n"); return 0; } /*----------------------------------*/ /* create internal table for upload */ /*----------------------------------*/ toolok=SapCreateTable(1,"EQIRQ","MC",CIM,CIU); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*-------------------*/ /* fill upload table */ /*-------------------*/ SapWriteTableValue(1,"EQUIPMENT","VALVE01",1); SapWriteTableValue(1,"EQUI_CATEG","M",1); SapWriteTableValue(1,"REQUIRED","X",1); SapWriteTableValue(1,"OPTIONAL","X",1); SapWriteTableValue(1,"UNASSIGNED","X",1); SapWriteTableValue(1,"ASSIGNED","X",1); SapWriteTableValue(1,"INHERITED","X",1); /*------------------------*/ /* TOOL create sendstring */ /*------------------------*/ toolok=SapCreateSendstr(&sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); printf("\n--> S A P (EQIRQ MC)\n"); printf("sendstring: %s\n",sndstr); /*--------------------------*/ /* SAP get equipment master */ /*---------------------------*/ /*--------*/ /* MC --> */ /*--------*/ hd = SapEqirq("MC", sndstr, &rcvstr, &sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* MC <-- */ /* equipment master data */ /*--------*/ printf("\n<-- S A P (EQIRQ MC)\n"); rcvstr[hd.datalen] = '\0'; /*----------------------------------*/ /* TOOL save data in internal table */ /*----------------------------------*/ toolok=SapCreateFillTable(2,"EQIRQ", "MC",CIM, CID, rcvstr,(int)hd.datalen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*-----------------------------*/ /* SAP get klassification data */ /*-----------------------------*/ hd = SapEqirq("", "", &rcvstr, &sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); strncpy(ucode,hd.ucode,2); ucode[2] = '\0'; /*--------*/ /* RF <-- */ /* characteristics for class when one specified or avaiable */ /*--------*/ if (strcmp(ucode,"RF")==0) { printf("\n<-- S A P (EQIRQ RF)\n"); rcvstr[hd.datalen] = '\0'; /*---------------------------*/ /* get characteristic values */ /*---------------------------*/ toolok = GetCharacteristicValues(4,rcvstr,(int) hd.datalen); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); return 0; } /*--------*/ /* RC <-- */ /* list of all classes */ /*--------*/ if (strcmp(ucode,"RC")==0) { printf("\n<-- S A P (EQIRQ RC)\n"); rcvstr[hd.datalen] = '\0'; /*------------------------------*/ /* TOOL create fill class table */ /*------------------------------*/ toolok=SapCreateFillClasTableR3(2,rcvstr,hd.datalen,&clasnum); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*------------------------*/ /* get data for each clas */ /*------------------------*/ for ( i=1; i <= clasnum; i++ ) { /*------------------------------*/ /* get one clas out of claslist */ /*------------------------------*/ toolok = GetClasdata(3,i, &chardata, &rcvlen); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*---------------------------*/ /* get characteristic values */ /*---------------------------*/ toolok = GetCharacteristicValues(4,chardata,rcvlen); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); } } /* break function */ hd=SapBreak(&sapmes); return (0); } /*--------------------------------------------------------------------*/ /* tool20 - equipment change with/without classification data R/3 */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int tool20() { SAPHD hd; int toolok, rcvlen, smlnum, index; int clasnum; char *sndstr,*rcvstr,*sapmes,*value,*chardata=NULL; char ucode[3]; SAPSML_R3 smldata_R3; SAPATT attstr; /* only available in R/3 */ if (VERSION == R2) { printf("\nfunction 20 only supported for R/3 Rel. 3.0\n"); return 0; } /*----------------------------------*/ /* create internal table for upload */ /*----------------------------------*/ toolok=SapCreateTable(1,"EQICH","MC",CIM,CIU); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*-------------------*/ /* fill upload table */ /*-------------------*/ SapWriteTableValue(1,"EQUIPMENT","VALVE01",1); SapWriteTableValue(1,"EQUI_TYPE","M",1); SapWriteTableValue(1,"REQUIRED","X",1); SapWriteTableValue(1,"OPTIONAL","X",1); SapWriteTableValue(1,"UNASSIGNED","X",1); SapWriteTableValue(1,"ASSIGNED","X",1); SapWriteTableValue(1,"INHERITED","X",1); /*------------------------*/ /* TOOL create sendstring */ /*------------------------*/ toolok=SapCreateSendstr(&sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); printf("\n--> S A P (EQICH MC)\n"); printf("sendstring: %s\n",sndstr); /*--------------------------*/ /* SAP get equipment master */ /*--------------------------*/ /*--------*/ /* MC --> */ /*--------*/ hd = SapEqich("MC", sndstr, &rcvstr, &sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* MC <-- */ /* equipment master data */ /*--------*/ printf("\n<-- S A P (EQICH MC)\n"); rcvstr[hd.datalen] = '\0'; printf("receivestr: %s",rcvstr); /*----------------------------------*/ /* TOOL save data in internal table */ /*----------------------------------*/ toolok=SapCreateFillTable(2,"EQICH", "MD",CIM, CID, rcvstr,(int)hd.datalen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*----------------------------------*/ /* create internal table for upload */ /*----------------------------------*/ toolok=SapCreateTable(1,"EQICH","MD",CIM,CIU); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*-------------------------------------------*/ /* TOOL fill upload table with download data */ /*-------------------------------------------*/ index=1; while ( SapGetAttributName(1,"EQICH","MD",CIM,CIU,index,&attstr)== 0 ) { /* get attribut value for upload attribut from CID */ toolok=SapGetTableValue(2,attstr.attname,1,&value); if ( toolok==0) { toolok=SapModifyTableValue(1,attstr.attname,value,1); if ( toolok!=0) SapWriteTableValue(1,attstr.attname,value,1); } index++; } /*----------------------------------*/ /* TOOL Change material master data */ /*----------------------------------*/ toolok = SapModifyTableValue(1,"DESCRIPT_E","new valve",1); if ( toolok != 0 ) SapWriteTableValue(1,"DESCRIPT_E","new valve",1); /*------------------------------------------*/ /* TOOL Create sendstring with changed data */ /*------------------------------------------*/ toolok = SapCreateSendstr(&sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); printf("\n--> S A P (EQICH MD)\n"); printf("sendstring: %s\n",sndstr); /*------------------------------------------*/ /* SAP send changed equipment master to SAP */ /*------------------------------------------*/ /*--------*/ /* MD --> */ /*--------*/ hd = SapEqich("MD", sndstr, &rcvstr, &sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); strncpy(ucode,hd.ucode,2); ucode[2] = '\0'; /*--------*/ /* RF <-- */ /* characteristics for class when one specified or available */ /*--------*/ if (strcmp(ucode,"RF")==0) { printf("\n<-- S A P (EQICH RF)\n"); rcvstr[hd.datalen] = '\0'; /*---------------------------*/ /* get characteristic values */ /*---------------------------*/ toolok = GetCharacteristicValues(5,rcvstr,(int) hd.datalen); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); } /*--------*/ /* RC <-- */ /* list of all classes */ /*--------*/ if (strcmp(ucode,"RC")==0) { printf("\n<-- S A P (EQICH RC)\n"); rcvstr[hd.datalen] = '\0'; /*------------------------------*/ /* TOOL create fill class table */ /*------------------------------*/ toolok=SapCreateFillClasTableR3(2,rcvstr,hd.datalen,&clasnum); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*--------------------------------*/ /* get first clas out of claslist */ /*--------------------------------*/ toolok = GetClasdata(4, 1, &chardata, &rcvlen); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*---------------------------*/ /* get characteristic values */ /*---------------------------*/ toolok = GetCharacteristicValues(5, chardata,rcvlen); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); } /*----------------------------------------*/ /* get possible values of characteristics */ /*----------------------------------------*/ toolok=GetPossibleSmlValues(2); /*----------------------*/ /* TOOL change SML data */ /*----------------------*/ smlnum = 1; while (SapGetSmlDataR3(2,smlnum,1,&smldata_R3)==0) { if (strcmp(smldata_R3.name,"REFERENCE_CUSTOMER")==0) { SapWriteSmlValue(1,0,"REFERENCE_CUSTOMER",33,"",1); } if (strcmp(smldata_R3.name,"VISITING_HOURS")==0) { SapWriteSmlValue(1,0,"VISITING_HOURS",33,"17",1); } smlnum++; } /*-----------------------------------------------------*/ /* TOOL create sendstring with new classification data */ /*-----------------------------------------------------*/ toolok = SapCreateSendstrSml(2, &sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*----------------------------------*/ /* SAP send new classification data */ /*----------------------------------*/ /*--------*/ /* CR --> */ /*--------*/ printf("\n--> S A P (EQICH CR)\n"); printf("sendstring: %s\n",sndstr); hd = SapEqich("CR",sndstr, &rcvstr,&sapmes); printf("\n<-- S A P (EQICH MC)\n"); /*--------*/ /* MC <-- */ /*--------*/ toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /* break function */ hd=SapBreak(&sapmes); return (0); } /*--------------------------------------------------------------------*/ /* tool21 - search material via matchcode R/3 */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : ---- */ /* ---- */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ /* 050997 */ int tool21() { SAPHD hd; int toolok, index, retcod, rowmax; char *sndstr,*rcvstr,*sapmes, mcdstr[200], mcd_send[20], ucode [3], *string; /*--------*/ /* RL --> */ /*--------*/ printf("\n--> S A P (MATRQ RL)\n"); printf(" Get Matchcode-IDs\n"); /*-----------------------*/ /* SAP get Matchcode-IDs */ /*-----------------------*/ hd = SapMatrq( "RL", "", &rcvstr, &sapmes); /*--------*/ /* ID <-- */ /*--------*/ printf("\n<-- S A P (MATRQ ID)\n"); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*-----------------------------------------------*/ /* TOOL create internal table with received data */ /*-----------------------------------------------*/ toolok = SapCreateFillTableMcd( 1, rcvstr, (int) hd.datalen ); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*------------------------*/ /* print Matchcode ID's */ /*------------------------*/ index=1; while ((retcod=GetMatchcodeValues(1,"","",index,mcdstr))==0) { printf("%s\n",mcdstr); index++; } /*-------------------------------------------------------*/ /* TOOL select 9th Matchcode-ID -> serach via short text */ /*-------------------------------------------------------*/ toolok=SapGetMcdValue("ID",9,&string); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); strcpy(mcd_send,string); strcat(mcd_send,trenner); /*----------------------------*/ /* select 9th Matchcode-SUBID */ /*----------------------------*/ toolok=SapGetMcdValue("SUBID",9,&string); if ( toolok != 0 ) return( toolok ); strcat(mcd_send,string); strcat(mcd_send,trenner); /*--------*/ /* ID --> */ /*--------*/ printf("\n--> S A P (MATRQ ID)\n"); printf("sendstring: %s\n",mcd_send); /*-------------------------------*/ /* SAP get matchcode description */ /*-------------------------------*/ hd = SapMatrq("ID",mcd_send,&rcvstr,&sapmes); /*--------*/ /* RF <-- */ /*--------*/ printf("\n<-- S A P (MATRQ RF)\n"); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*-----------------------------------------------*/ /* TOOL create and fill internal matchcode table */ /*-----------------------------------------------*/ toolok = SapCreateFillTableMcd(2,rcvstr,(int) hd.datalen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*-------------------------------------------*/ /* TOOL get number of rows in internal table */ /*-------------------------------------------*/ toolok = SapGetMcdDescription(1,&string); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); rowmax=atoi(string); /*----------------------------------*/ /* print matchcode selection fields */ /*----------------------------------*/ for (index = 1; index <= rowmax ;index ++) { retcod = GetMatchcodeValues(2,"","", index, mcdstr); if ( retcod == 0) printf("%s\n",mcdstr); } /*-------------------------------------------------*/ /* TOOL write selection criteria to internal table */ /*-------------------------------------------------*/ toolok = SapWriteMcdValue(1, 1, "screw"); /* first field (short text) */ toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*--------------------------------------*/ /* TOOL create sendstring for selection */ /*--------------------------------------*/ toolok=SapCreateSendstrMcd(1,"MATRQ","RF",&sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*--------*/ /* RF --> */ /*--------*/ printf("\n--> S A P (MATRQ RF)\n"); printf("sendstring: %s\n", sndstr); /*---------------------*/ /* SAP start selection */ /*---------------------*/ hd = SapMatrq("RF",sndstr,&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); strncpy(ucode,hd.ucode,2); ucode[2] = '\0'; if (strcmp(ucode,"CL") == 0) /*--------*/ /* CL <-- */ /*--------*/ printf("\n<-- S A P (MATRQ CL)\n"); /* not all entries read */ else /*--------*/ /* RL <-- */ /*--------*/ printf("\n<-- S A P (MATRQ RL)\n"); /*---------------------------------------------------*/ /* create and fill internal table with selected data */ /*---------------------------------------------------*/ toolok = SapCreateFillTable(3,"MATRQ",ucode,CIM,CID,rcvstr,(int) hd.datalen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); /*-----------------------------*/ /* get number of rows in table */ /*-----------------------------*/ toolok=SapDescribeTable(3,&string); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); rowmax=atoi(string); /*--------------------------------------------------------------------*/ /* print selected material master records -> see field set definition */ /* in SAP table CID. */ /*--------------------------------------------------------------------*/ for (index=1;index<=rowmax;index++) { retcod = GetMatchcodeValues(3, "MATRQ", ucode, index, mcdstr ); if (retcod == 0) printf("%s\n",mcdstr); } while( strcmp(ucode, "CL") == 0) { /*--------*/ /* CL --> */ /*--------*/ printf("\n--> S A P (MATRQ CL)\n"); /*--------------------------*/ /* SAP receive next entries */ /*--------------------------*/ hd = SapMatrq("CL","",&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); strncpy(ucode,hd.ucode,2); ucode[2] = '\0'; if (strcmp(ucode,"CL") == 0) /*--------*/ /* CL <-- */ /*--------*/ printf("\n<-- S A P (MATRQ CL)\n"); /* not all entries read */ else /*--------*/ /* RL <-- */ /*--------*/ printf("\n<-- S A P (MATRQ RL)\n"); /*-----------------------------*/ /* get number of rows in table */ /*-----------------------------*/ toolok=SapDescribeTable(3,&string); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); rowmax=atoi(string); /*----------------------------------------*/ /* print selected material master records */ /*----------------------------------------*/ for (index=1;index<=rowmax;index++) { retcod = GetMatchcodeValues(3, "MATRQ", ucode, index, mcdstr ); if (retcod == 0) printf("%s\n",mcdstr); } } /*--------------------*/ /* SAP Break function */ /*--------------------*/ hd=SapBreak(&sapmes); return( 0 ); } /*--------------------------------------------------------------------*/ /* SetClasScope */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : sapmes SAP message */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int SetClasScope( ) { int toolok=0; char *rcvstr=NULL, *sapmes=NULL, *sndstr=NULL; SAPHD hd; /*------------------------------------*/ /* TOOL create sendstring class scope */ /*------------------------------------*/ toolok = SapCreateSendstrClasScopeR3("001","X","X","X","X","X", &sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*--------*/ /* SC --> */ /*--------*/ printf("\n--> S A P (SLOBJ SC)\n"); printf("sendstring: %s\n",sndstr); /*----------------*/ /* SAP send scope */ /*----------------*/ hd=SapSlobj("SC",sndstr,&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* SC <-- */ /* message */ /*--------*/ printf("\n<-- S A P (SLOBJ SC)\n"); sapmes[hd.meslen] = '\0'; printf("SAP message: %s\n",sapmes); return 0; } /*--------------------------------------------------------------------*/ /* GetFullMessageText */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : sapmes SAP message */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ int GetFullMessageText(char *sapmessage, int meslen) { int toolok=0, row=0, index=0, rcvlen=0; char *sndstr=NULL, *rcvstr=NULL, *sapmes=NULL; SAPHD hd; SAPSML smldata; /*----------------------------------------------------------------*/ /* TOOL create sendstr out of SAP message (extract ID and number) */ /*----------------------------------------------------------------*/ toolok = SapCreateSendstrMessageR3(sapmessage, meslen, &sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*--------*/ /* MT --> */ /* Message ID and number */ /*--------*/ printf("\n--> S A P (HLPRQ MT)\n"); printf("sendstring: %s\n",sndstr); /*---------------------*/ /* SAP start selection */ /*---------------------*/ hd=SapHlprq("MT",sndstr,&rcvstr,&sapmes); /*--------*/ /* MT <-- */ /* full message */ /*--------*/ toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return (-99); if (hd.datalen == 0) { printf("no long text available for this message\n"); return 0; } /*-----------------------------*/ /* TOOL create table with text */ /*-----------------------------*/ rcvlen = (int) hd.datalen; rcvstr[hd.datalen]='\0'; toolok=SapCreateHlpTable(2,rcvstr,rcvlen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*-------------------------------*/ /* TOOL get number of text lines */ /*-------------------------------*/ toolok=SapGetHlpDescription(2,&rcvstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*---------------------*/ /* TOOL get text lines */ /*---------------------*/ row=atoi(rcvstr); for (index=1;index<=row;index++) { toolok=SapGetHlpData(1,1,index,&smldata); if (toolok==0) printf("%2d,%s\n",index,smldata.value); } return 0; } /*--------------------------------------------------------------------*/ /* GetMatchcodeValues */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : order order */ /* pcode process code */ /* ucode sub process code */ /* line line in internal table */ /* OUTPUT e_string returned string */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ /* 050997 */ int GetMatchcodeValues(int order, char *pcode, char *ucode, int line, char *e_string) { int retsta=0,toolok=0,index=0; char *string=NULL; char attnam[31], *value; e_string[0]=0x0; /* values for matchcode ID's */ if (order==1) { if (toolok==0) { toolok=SapGetMcdValue("ID",line,&string); if (toolok==0) strcat(e_string,string); strcat(e_string,"\t"); } if (toolok==0) { toolok=SapGetMcdValue("SUBID",line,&string); if (toolok==0) strcat(e_string,string); strcat(e_string,"\t"); } if (toolok==0) { toolok=SapGetMcdValue("TEXT01",line,&string); if (toolok==0) strcat(e_string,string); } } /* matchcode texts */ else if (order==2) { if (toolok==0) { toolok=SapGetMcdValue("TEXT02",line,&string); if (toolok==0) { strcpy(e_string,string); strcat(e_string,"\t"); } } if (toolok==0) { toolok=SapGetMcdValue("WERT",line,&string); if (toolok==0) strcat(e_string,string); } } /* list of selected objects */ else if (order==3) { index=1; strcpy(e_string,""); while ( SapGetAttributNameValue (3,index,line,attnam,&value) == 0) { strcat(e_string, value); strcat(e_string,"\t"); index++; } } return(toolok); } /*--------------------------------------------------------------------*/ /* GetPossibleSmlValues */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : order 1 - SML of Objectlist */ /* 2 - SML of Object */ /* 3 - of self defined characteristics */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ /* BINK090600 110796 */ int GetPossibleSmlValues(int order) { int toolok,v, num_values; char *sndstr, *rcvstr, *sapmes, *value; SAPHD hd; SAPSML_R3 smldata_R3; if ( order == 1 || order == 2 ) { /*---------------------------------------------*/ /* TOOL create sendstring characteristic names */ /*---------------------------------------------*/ toolok = SapCreateSendstrPosSmlValuesR3(order, &sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); } else { return (-1); } /*--------*/ /* SC --> */ /* characteristic names */ /*--------*/ printf("\n--> S A P (HLPRQ SC)\n"); printf("sendstring: %s\n",sndstr); /*---------------------*/ /* SAP start selection */ /*---------------------*/ hd=SapHlprq("SC",sndstr,&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* SC <-- */ /* possible values for characteristics */ /*--------*/ printf("\n<-- S A P (HLPRQ SC)\n"); rcvstr[hd.datalen] = '\0'; /*---------------------------------------------*/ /* TOOL store possible values in internal table*/ /*---------------------------------------------*/ toolok = SapCreateFillPosSmlValueTableR3(1, rcvstr, (int)hd.datalen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*-------------------------------*/ /* TOOL get first characteristic */ /*-------------------------------*/ toolok=SapGetSmlDataR3(2,1,1,&smldata_R3); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*-----------------------------------------------------------*/ /* TOOL get number of possible values for 1st characteristic */ /*-----------------------------------------------------------*/ toolok=SapGetSmlValueDescriptionR3(3,0,smldata_R3.name,&num_values); toolok=ToolErrorHandling(toolok); if (toolok!=0) return (-99); /*-------------------------------------*/ /* TOOL get values of characteristic */ /*-------------------------------------*/ printf("\nPossible values \n"); printf("--------------- \n"); for (v=1; v<=num_values; v++) { SapGetSmlDataValueR3(3,smldata_R3.name,0,0,v,&value); printf("value no %d: %s\n",v,value); } return 0; } /*--------------------------------------------------------------------*/ /* GetClasdata */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : order 1 - MATRQ */ /* 2 - MATCH */ /* 3 - EQIRQ */ /* 4 - EQICH */ /* pos number of clas to get */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ /* BINK090600 110796 */ int GetClasdata(int order, int im_pos, char **ex_rcvstr, int *ex_rcvlen) { int toolok; char *sndstr, *rcvstr, *sapmes; SAPHD hd; SAPCLAS_R3 clasdata_R3; /*------------------------*/ /* TOOL get attribut data */ /*------------------------*/ toolok = SapGetClasDataR3(2,im_pos,&clasdata_R3); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); printf("\nclass no: %d\n",im_pos); printf("-----------\n"); printf("class type : %s\n",clasdata_R3.art); printf("class name : %s\n",clasdata_R3.name); printf("class descr.: %s\n",clasdata_R3.bezeichnung); printf("class stat. : %s\n",clasdata_R3.statustext); printf("class mark : %s\n",clasdata_R3.knz_standard); /*------------------------------------------------*/ /* TOOL create sendstring with clasification data */ /*------------------------------------------------*/ toolok = SapCreateSendstrClasR3( clasdata_R3.art, clasdata_R3.name, "X","X","X","X","X","X",&sndstr); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-1); printf("\n--> S A P (RC)\n"); printf("sendstring: %s\n",sndstr); /*----------------------------*/ /* SAP get clasification data */ /*----------------------------*/ /*--------*/ /* RC --> */ /*--------*/ if (order==1) hd = SapMatrq("RC", sndstr, &rcvstr, &sapmes); else if (order==2) hd = SapMatch("RF", sndstr, &rcvstr, &sapmes); else if (order==3) hd = SapEqirq("RC", sndstr, &rcvstr, &sapmes); else if (order==4) hd = SapEqich("RF", sndstr, &rcvstr, &sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); /*--------*/ /* RF <-- */ /*--------*/ printf("\n<-- S A P (RF)\n"); rcvstr[hd.datalen] = '\0'; *ex_rcvstr = rcvstr; *ex_rcvlen = (int)hd.datalen; return(0); } /*--------------------------------------------------------------------*/ /* GetCharacteristicValues */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : order 1 - MATRQ */ /* 2 - MATCH */ /* 3 - SLOBJ */ /* 4 - EQIRQ */ /* 5 - EQICH */ /* rcvstr receivestring with character. descr. */ /* rcvlen length of rcvstr */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ /* BINK090600 110796 */ int GetCharacteristicValues(int order,char *im_rcvstr,int im_rcvlen) { int toolok, smlnum,v,value_num=0; char *rcvstr, *sapmes, *value; SAPHD hd; SAPSML_R3 smldata_R3; SAPSML smldata_R2; /*-----------------------*/ /* TOOL create SML table */ /*-----------------------*/ toolok=SapCreateSmlTable(2,im_rcvstr,im_rcvlen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-99); /*-------------------------------*/ /* SAP get characteristic values */ /*-------------------------------*/ /*--------*/ /* CR <-- */ /*--------*/ if (order == 1) hd = SapMatrq("","",&rcvstr,&sapmes); else if (order == 2) hd = SapMatch("","",&rcvstr,&sapmes); else if (order == 3) hd = SapSlobj("","",&rcvstr,&sapmes); else if (order == 4) hd = SapEqirq("","",&rcvstr,&sapmes); else if (order == 5) hd = SapEqich("","",&rcvstr,&sapmes); toolok=ErrorHandling(hd,sapmes); if (toolok!=0) return(-99); printf("\n<-- S A P (CR)\n"); rcvstr[hd.datalen] = '\0'; /*-----------------------------------------*/ /* TOOL fill SML table with default values */ /*-----------------------------------------*/ if (hd.datalen > 0 ) { toolok = SapFillSmlTable(2,rcvstr,(int)hd.datalen); toolok=ToolErrorHandling(toolok); if (toolok!=0) return(-99); } /*-----------------------*/ /* print characteristics */ /*-----------------------*/ smlnum = 1; printf("\nValues\n"); printf("--------------\n"); if ( VERSION == R3 ) { while (SapGetSmlDataR3(2,smlnum,1,&smldata_R3)==0) { smlnum++; printf("\nName : %s\n",smldata_R3.name); /* get number of characteristic values */ toolok=SapGetSmlValueDescriptionR3(2,0,smldata_R3.name,&value_num); /* get aditional values */ for (v=1;v<=value_num;v++) { SapGetSmlDataValueR3(2,smldata_R3.name,0,0,v,&value); printf("value No %d: %s\n",v,value); } } } else { while (SapGetSmlData(1,smlnum,1,&smldata_R2)==0) { smlnum++; printf("name : %15s value : %s\n",smldata_R2.name, smldata_R2.value); } } return(0); } /*--------------------------------------------------------------------*/ /* ErrorHandling */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : hd HD structrure */ /* msginput message */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ /* BINK090600 110796 */ int ErrorHandling( SAPHD hd, char *msginput) { char message[201]; /* CPIC error */ if (hd.cpicrc!=0) { printf("CPIC-RC=%ld,%s\n",hd.cpicrc,hd.cpicmes); return(-2); } /* SUBRC error */ if (hd.subrc != 0) { (void) strncpy(message,msginput,hd.meslen); message[hd.meslen]='\0'; printf("SUB-RC=%d,%s\n",hd.subrc,message); return(-1); } /* if message > 0 */ if (hd.meslen>0 ) { (void) strncpy(message,msginput,hd.meslen); message[hd.meslen] = '\0'; printf("MESSAGE=%s\n",message); return ( 0 ); } return 0; } /*--------------------------------------------------------------------*/ /* ToolErrorHandling */ /*--------------------------------------------------------------------*/ /* NAME DESCRIPTION */ /* ---------------- ------------------------------------ */ /* INPUT : toolok toolbox return value */ /* OUTPUT: ---- */ /*--------------------------------------------------------------------*/ /* RETURN: ---- */ /*--------------------------------------------------------------------*/ /* BINK090600 110796 */ int ToolErrorHandling(int toolok) { SAPMES messtr; if (toolok!=0) { (void) SapGetErrorMessage(toolok,&messtr); printf("%s\n",messtr.message); return(toolok); } return 0; }