// --------------------------------------------------------- // (c) Copyright IBM Corp. 1999 All rights reserved. // // This sample program is owned by International Business Machines // Corporation or one of its subsidiaries ("IBM") and is copyrighted // and licensed, not sold. // // You may copy, modify, and distribute this sample program in any // form without payment to IBM, for any purpose including developing, // using, marketing or distributing programs that include or are // derivative works of the sample program. // // The sample program is provided to you on an "AS IS" basis, without // warranty of any kind. IBM HEREBY EXPRESSLY DISCLAIMS ALL WARRANTIES, // EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // Some jurisdictions do not allow for the exclusion or limitation of // implied warranties, so the above limitations or exclusions may not // apply to you. IBM shall not be liable for any damages you suffer as // a result of using, modifying or distributing the sample program or // its derivatives. // // Each copy of any portion of this sample program or any derivative // work, must include the above copyright notice and disclaimer of // warranty. // --------------------------------------------------------- // This sample illustrates how to start a process passing in data. // // The sample process CreditRequest shipped with the MQWF 3.1.x // product is started. // User is prompted for a Firstname and Lastname. // // Lastname is used as the instance name // // To compile this on WindowsNT using MSVC++ 5.0, type: // cl -MD startproc.c fmcjdcom.lib fmcjdcbr.lib fmcjdcon.lib fmcjdrun.lib // dsb 12-28-98 #include #include "fmcjcrun.h" #define RESERV1 "ABC" #define RESERV2 "XYZ" int main () { //Result object FmcjResultHandle result=0; FmcjStringVectorHandle parms=0; char buffer[2000]=""; APIRET rc; FmcjExecutionServiceHandle hService=0; FmcjProcessTemplateVectorHandle hPTVector=0; FmcjProcessTemplateHandle hTemplate=0; FmcjProcessInstanceHandle hNewInstance=0; FmcjReadWriteContainerHandle hInputCont=0; unsigned long lNumItems=0; char tInfo[FMC_PROCESS_TEMPLATE_NAME_LENGTH]=""; char sFirstname[33]; char sLastname[33]; bool bKeepName=TRUE; //***Connect ********** FmcjGlobalConnect(); //***Allocate ********* FmcjExecutionServiceAllocate(&hService); //***Logon ********* rc=FmcjExecutionServiceLogon(hService, "ADMIN", "password", Fmc_SM_Default, Fmc_SA_Reset); if (rc!=FMC_OK) { printf("Error logging on. RC = %u\n", rc); return rc; } printf("logon OK\n"); //***Set a filter //***Query Process Templates to find CreditRequest process rc=FmcjExecutionServiceQueryProcessTemplates(hService, "NAME='CreditRequest'", FmcjNoSortCriteria, FmcjNoThreshold, &hPTVector); if (rc != FMC_OK) { printf("Error processing query, rc= %u\n",rc); } else { printf("Query done ok\n"); lNumItems=FmcjProcessTemplateVectorSize(hPTVector); printf("number of items found = %u\n", lNumItems); //****Assume the first one is it hTemplate=FmcjProcessTemplateVectorFirstElement(hPTVector); printf("Name of template = %s\n", FmcjProcessTemplateName(hTemplate,tInfo,FMC_PROCESS_TEMPLATE_NAME_LENGTH)); //**** prompt user for firstname and lastname printf("*************************\n"); printf("Enter a first name: "); gets(sFirstname); printf("\nEnter a last name: "); gets(sLastname); printf("\n******************\n"); //*** Get the input container for the process rc=FmcjProcessTemplateInContainer(hTemplate,&hInputCont); if (rc!=FMC_OK) { printf("Error getting template container. RC = %u\n",rc); } else { //*** set the member FirstName rc=FmcjReadWriteContainerSetStringValue(hInputCont, "FirstName", sFirstname); if (rc!=FMC_OK) printf("Error setting firstname value. rc=%u\n",rc); //*** set the member LastName rc=FmcjReadWriteContainerSetStringValue(hInputCont, "LastName", sLastname); if (rc!=FMC_OK) printf("Error setting lastname value. rc=%u\n",rc); //*** Create and Start process instance rc=FmcjProcessTemplateCreateAndStartInstance(hTemplate, sLastname, RESERV1,RESERV2, hInputCont, bKeepName, &hNewInstance); if (rc != FMC_OK) printf("Error with CreateAndStartInstance. rc = %u\n", rc); else printf("Instance %s has started.\n",sLastname); } //*** end else get container ok } //** endif query ok //***Cleanup and Logoff ********* FmcjProcessTemplateVectorDeallocate(&hPTVector); FmcjExecutionServiceLogoff(hService); //***De-allocate service ********** FmcjExecutionServiceDeallocate(&hService); //***Disconnect *************** FmcjGlobalDisconnect(); return 0; }