Hai, Need help..Im having a problem where my code should exclude if the value is NULL and jump to function that Write_PR_DataFile..I have higlighted the part .Kindly help My code as below: Code: int Generate_PR_Report( char* startDate, char* endDate, struct parameters* parms) { /*************************************************** * Preparation ***************************************************/ /* Variable declaration */ int skipLotCntr = 0; int numOfFiles = 0; int compQty = 0; int indexOfComp = 0; int indexOfCarHistRecord = 0; vc2_LotSK lot_sk; vc2_TxnSK txn_sk; vc2_Operation action; vc2_LotId lot; vc2_StepId stepId; vc2_StepId sorterAction; vc2_Stage stage; vc2_Recipe recipe; vc2_Operation operation; vc2_Operation subOperation; vc2_WaferQty qtyIn; vc2_WaferQty qtyOut; vc2_WaferQty actualQty; vc2_EqpId eqpId; vc2_Device device; vc2_Technology tech; vc2_DateTime toTime; vc2_DateTime tiTime; vc2_DateTime createTime; vc2_UserId employee; vc2_CarrierId carrierId; vc2_LotId finalLotId; vc2_GroupHistKey groupHistKey; vc2_PlanId planId; vc2_SlotPosition slot; vc2_CarrierId origCass; vc2_VScriberId inHouseScribe; vc2_VScriberId vendorScribe; vc2_CarrierId finalCass; vc2_SlotPosition origSlotArray[MAX_WAFERQTY_PER_LOT]; vc2_CarrierId origCassArray[MAX_WAFERQTY_PER_LOT]; vc2_VScriberId inHouseScribeArray[MAX_WAFERQTY_PER_LOT]; vc2_VScriberId vendorScribeArray[MAX_WAFERQTY_PER_LOT]; vc2_SlotPosition finalSlotArray[MAX_WAFERQTY_PER_LOT]; vc2_CarrierId finalCassArray[MAX_WAFERQTY_PER_LOT]; vc2_VScriberId scribeId; vc2_SysId carHistSysId; vc2_SysId carHistTxnTime; vc2_SysId carHistSysIdArray[MAX_CARHISTRECORD_NUM]; vc2_SysId carHistTxnTimeArray[MAX_CARHISTRECORD_NUM]; int finalFlag = FALSE; char currDateTime[20]; char* pTmp = NULL; /* Reset memory */ memset(scribeId, 0, sizeof(scribeId)); memset(currDateTime, 0, sizeof(currDateTime)); memset(carHistSysId, 0, sizeof(carHistSysId)); memset(carHistTxnTime, 0, sizeof(carHistTxnTime)); memset(carHistSysIdArray, 0, sizeof(carHistSysIdArray)); memset(carHistTxnTimeArray, 0, sizeof(carHistTxnTimeArray)); /*************************************************** * Query data ***************************************************/ /* Get 'Sorter Action' lot (lot_sk, txn_sk) list */ EXEC SQL DECLARE wsSaCursor1 CURSOR FOR SELECT wip.lot_sk, wip.txn_sk FROM hdbxuser.fwhdbwipstephistory@hdbsil sh, hdbxuser.fwhdbwiptransaction@hdbsil wip WHERE wip.wipstep_sk = sh.wipstep_sk AND wip.activity = 'TrackIn' AND wip.txntime = sh.trackintime AND sh.trackouttime BETWEEN :startDate AND :endDate; /* Open cursor */ EXEC SQL OPEN wsSaCursor1; /* Loop, fetching all salesperson's statistics. * Cause the program to break the loop when no more * data can be retrieved on the cursor. */ EXEC SQL WHENEVER NOT FOUND DO break; for( ; ;) { /* Reset memory */ memset(lot_sk, NULL, sizeof(lot_sk)); memset(txn_sk, NULL, sizeof(txn_sk)); memset(action, NULL, sizeof(action)); memset(lot, NULL, sizeof(lot)); memset(stepId, NULL, sizeof(stepId)); memset(sorterAction, NULL, sizeof(sorterAction)); memset(stage, NULL, sizeof(stage)); memset(recipe, NULL, sizeof(recipe)); memset(operation, NULL, sizeof(operation)); memset(subOperation, NULL, sizeof(subOperation)); memset(qtyIn, NULL, sizeof(qtyIn)); memset(qtyOut, NULL, sizeof(qtyOut)); memset(actualQty, NULL, sizeof(actualQty)); memset(eqpId, NULL, sizeof(eqpId)); memset(device, NULL, sizeof(device)); memset(tech, NULL, sizeof(tech)); memset(toTime, NULL, sizeof(toTime)); memset(tiTime, NULL, sizeof(tiTime)); memset(createTime, NULL, sizeof(createTime)); memset(employee, NULL, sizeof(employee)); memset(carrierId, NULL, sizeof(carrierId)); memset(finalLotId, NULL, sizeof(finalLotId)); memset(groupHistKey, NULL, sizeof(groupHistKey)); memset(planId, NULL, sizeof(planId)); memset(origSlotArray, NULL, sizeof(origSlotArray)); memset(origCassArray, NULL, sizeof(origCassArray)); memset(inHouseScribeArray, NULL, sizeof(inHouseScribeArray)); memset(vendorScribeArray, NULL, sizeof(vendorScribeArray)); memset(finalSlotArray, NULL, sizeof(finalSlotArray)); memset(finalCassArray, NULL, sizeof(finalCassArray)); /* Get txn_sk */ EXEC SQL FETCH wsSaCursor1 INTO :lot_sk, :txn_sk; /* Skip it if no data found */ EXEC SQL WHENEVER NOT FOUND GOTO NOTFOUND; /* To check whether the lot perform 'Sorter Action' or not */ EXEC SQL SELECT LOWER (recipe), transportid, stage, device INTO :recipe, :carrierId, :stage, :device FROM (SELECT lotrecipe.attrvalue recipe, lottransportid.attrvalue transportid, lotstage.attrvalue stage, lotdevice.attrvalue device FROM hdbxuser.fwhdbwiplotattrinstance@hdbsil lotrecipe, hdbxuser.fwhdbwiplotattrinstance@hdbsil lotstage, hdbxuser.fwhdbwiplotattrinstance@hdbsil lottransportid, hdbxuser.fwhdbwiplotattrinstance@hdbsil lotdevice WHERE lotrecipe.lot_sk = :lot_sk AND :txn_sk BETWEEN lotrecipe.startsequence AND lotrecipe.stopsequence AND lotrecipe.attrname = 'Recipe' AND ( LOWER (lotrecipe.attrvalue) LIKE '%verify%' OR (LOWER (lotrecipe.attrvalue) LIKE '%random%') OR (LOWER (lotrecipe.attrvalue) LIKE '%reorder%') ) AND lotstage.lot_sk = :lot_sk AND :txn_sk BETWEEN lotstage.startsequence AND lotstage.stopsequence AND lotstage.attrname = 'Stage' AND lottransportid.lot_sk = :lot_sk AND :txn_sk BETWEEN lottransportid.startsequence AND lottransportid.stopsequence AND lottransportid.attrname = 'transportId' AND lotdevice.lot_sk = :lot_sk AND :txn_sk BETWEEN lotdevice.startsequence AND lotdevice.stopsequence AND lotdevice.attrname = 'partProgId' UNION ALL SELECT lotsorteraction.attrvalue recipe, lottransportid.attrvalue transportid, lotstage.attrvalue stage, lotdevice.attrvalue device FROM hdbxuser.fwhdbwiplotattrinstance@hdbsil lotsorteraction, hdbxuser.fwhdbwiplotattrinstance@hdbsil lotstage, hdbxuser.fwhdbwiplotattrinstance@hdbsil lottransportid, hdbxuser.fwhdbwiplotattrinstance@hdbsil lotdevice WHERE lotsorteraction.lot_sk = :lot_sk AND :txn_sk BETWEEN lotsorteraction.startsequence AND lotsorteraction.stopsequence AND lotsorteraction.attrname = 'SorterAction' AND lotsorteraction.attrvalue IN ('REORDER', 'VERIFY') AND lotstage.lot_sk = :lot_sk AND :txn_sk BETWEEN lotstage.startsequence AND lotstage.stopsequence AND lotstage.attrname = 'Stage' AND lottransportid.lot_sk = :lot_sk AND :txn_sk BETWEEN lottransportid.startsequence AND lottransportid.stopsequence AND lottransportid.attrname = 'transportId' AND lotdevice.lot_sk = :lot_sk AND :txn_sk BETWEEN lotdevice.startsequence AND lotdevice.stopsequence AND lotdevice.attrname = 'partProgId'); /* Get lot detail information */ EXEC SQL SELECT wipin.lotid, wipout.userid, wipin.txntime, wipin.lotqtyout, wipout.txntime totime, wipout.lotid finallotid, wipin.grouphistkey, sh.LOCATION, sh.stepid, sh.planid, sh.productname tech, lot.createtxntime INTO :lot, :employee, :tiTime, :actualQty, :toTime, :finalLotId, :groupHistKey, :eqpId, :stepId, :planId, :tech, :createTime FROM hdbxuser.fwhdblot@hdbsil lot, hdbxuser.fwhdbwipstephistory@hdbsil sh, hdbxuser.fwhdbwiptransaction@hdbsil wipout, hdbxuser.fwhdbwiptransaction@hdbsil wipin WHERE lot.lot_sk = wipin.lot_sk AND wipout.grouphistkey = wipin.grouphistkey AND wipout.activity = 'TrackOut' AND sh.wipstep_sk = wipout.wipstep_sk AND wipin.txn_sk = :txn_sk; /* Get component Id list */ EXEC SQL DECLARE comp1_Cursor CURSOR FOR SELECT lot.lotid || '.' || comp.POSITION inhousescribe, comp.componentid vendorscribe FROM hdbxuser.fwhdblot@hdbsil lot, hdbxuser.fwhdbwipcomponent@hdbsil comp WHERE lot.lot_sk = comp.originallot_sk AND comp.lot_sk = :lot_sk AND :txn_sk BETWEEN startsequence AND stopsequence AND comp.status <> 'Scrapped' AND comp.position IS NULL ORDER BY comp.componentid; EXEC SQL OPEN comp1_Cursor; EXEC SQL WHENEVER NOT FOUND DO break; indexOfComp = 0; for(; ;) { memset(inHouseScribe, NULL, sizeof(inHouseScribe)); memset(vendorScribe, NULL, sizeof (vendorScribe)); EXEC SQL FETCH comp1_Cursor INTO :inHouseScribe, :vendorScribe; strcpy(inHouseScribeArray[indexOfComp], inHouseScribe); strcpy(vendorScribeArray[indexOfComp], vendorScribe); indexOfComp++; } compQty = indexOfComp; EXEC SQL CLOSE comp1_Cursor; /* * The following is to retrieve component Id slot-map * information: orignal -- final position * * 1. Get SysId/TxnTime list from FwCarrierHistory in desc order; * Time range: create time ~ to time * SysId list is stored in an array that size is 10. * 2. Loop: wafer by wafer * 2.1 Get final position (FwCarrierHistory_PN2M) * 2.1.1 Make sure TxnTime is between TiTime and ToTime * 2.1.2 Get final position by using the lastest sysId * 2.2 Get original position by using the latest SysId; * 2.2.1 Make sure TxnTime is earlier TiTime. * If not, skip to previous record (SysId); * 2.2.2 Get original position by using SysId. If not found, * skip to previous record (SysId) */ /* VERY IMPORTANT */ /* Minus 1 min (60 seconds) to create time */ /* We may fail to get data if using create time in some cases * because CARRIER transaction is done eariler than WIP. * For example, one child is created (split) in '20090806 152152000', * but the Assign Component happen in 20090806 152151000 */ AddSeconds( createTime, -60 ); /* Get SysId/TxnTime list from FwCarrierHistory */ EXEC SQL DECLARE carhist_Cursor1 CURSOR FOR SELECT sysid, txntime FROM caruser.fwcarrierhistory WHERE carrierid = :carrierId AND activity IN ('FwCarrierAssignComponentTxn', 'FwCarrierModifyComponentPositionTxn', 'ReAssociateTo' ) AND txntime BETWEEN :createTime AND :toTime ORDER BY txntime DESC; EXEC SQL OPEN carhist_Cursor1; EXEC SQL WHENEVER NOT FOUND DO break; memset(carHistSysIdArray, 0, sizeof(carHistSysIdArray)); memset(carHistTxnTimeArray, 0, sizeof(carHistTxnTimeArray)); for(indexOfCarHistRecord = 0; indexOfCarHistRecord < MAX_CARHISTRECORD_NUM; indexOfCarHistRecord++) { memset(carHistSysId, 0, sizeof(carHistSysId)); memset(carHistTxnTime, 0, sizeof(carHistTxnTime)); EXEC SQL FETCH carhist_Cursor1 INTO :carHistSysId, :carHistTxnTime; strcpy(carHistSysIdArray[indexOfCarHistRecord], carHistSysId); strcpy(carHistTxnTimeArray[indexOfCarHistRecord], carHistTxnTime); } EXEC SQL CLOSE carhist_Cursor; /* To get final & original position for each wafer */ for (indexOfComp = 0; indexOfComp < compQty; indexOfComp++) { finalFlag = FALSE; memset(scribeId, NULL, sizeof(scribeId)); strcpy(scribeId, vendorScribeArray[indexOfComp]); /* Loop: to find original-final slot position */ for(indexOfCarHistRecord = 0; indexOfCarHistRecord < MAX_CARHISTRECORD_NUM; indexOfCarHistRecord++) { memset(slot, NULL, sizeof(slot)); memset(carHistSysId, 0, sizeof(carHistSysId)); strcpy(carHistSysId, carHistSysIdArray[indexOfCarHistRecord]); EXEC SQL WHENEVER NOT FOUND CONTINUE; EXEC SQL SELECT valdata slot INTO :slot FROM caruser.fwcarrierhistory_pn2m WHERE fromid = :carHistSysId AND linkname = 'components' AND keydata = :scribeId; if (strlen(slot) > 0) { if (strcmp(carHistTxnTimeArray[indexOfCarHistRecord], tiTime) > 0) { /* Finalflag is to make sure to get the correst slot position (latest). * To handle abnormal case: namely that there are multiple slot * mapping changes during the period of Track-In and Track-Out. */ if (finalFlag == FALSE) { /* Final position */ strcpy(finalSlotArray[indexOfComp], slot); strcpy(finalCassArray[indexOfComp], carrierId); finalFlag = TRUE; } } else { /* Original position */ strcpy(origSlotArray[indexOfComp], slot); strcpy(origCassArray[indexOfComp], carrierId); /* If final position value is NULL, it is assumed that * the slot position does not change, same as original one */ if (strlen(finalSlotArray[indexOfComp]) == 0) { strcpy(finalSlotArray[indexOfComp], slot); strcpy(finalCassArray[indexOfComp], carrierId); } break; } } } } /* Assign value to 'action', 'operation', 'suboperation' */ if (strstr(recipe, "random")) { strcpy(action, OPERATION_RANDOMIZE); strcpy(operation, stepId); /* Strip out XX stage stuff/sortorder in stage name */ pTmp = strchr(stage, ':'); if (pTmp != NULL) strcpy(subOperation, Trim_End(++pTmp)); else strcpy(subOperation, stage); } else if (strstr(recipe, "reorder")) { strcpy(action, OPERATION_REORDER); strcpy(operation, "reorder"); strcpy(subOperation, "reorder"); } else if (strstr(recipe, "verify")) { /* if (strstr(stepId, "SorterAction")) { strcpy(action, OPERATION_VERIFY); } else { strcpy(action, OPERATION_INLINEVERIFY); } */ strcpy(action, OPERATION_VERIFY); strcpy(operation, "verify"); strcpy(subOperation, "verify"); } else { strcpy(action, recipe); strcpy(operation, recipe); strcpy(subOperation, recipe); } [COLOR="Red"] if (strlen (inHouseScribeArray[indexOfComp]) == 0) { return ; } else {[/COLOR] Write_PR_DataFile(startDate, endDate, action, lot, operation, subOperation, actualQty, eqpId, device, tech, toTime, employee, origSlotArray, origCassArray, inHouseScribeArray, vendorScribeArray, finalSlotArray, finalCassArray, parms); numOfFiles++; #ifdef DEBUG printf(" #%d lot data is extracted\n", numOfFiles); #endif continue; NOTFOUND: skipLotCntr++; #ifdef DEBUG printf(" #%d lot is skipped\n", skipLotCntr); #endif ; } } /* Close cursor */ EXEC SQL CLOSE wsSaCursor1; return(numOfFiles); } /* Generate_PR_Report */
Your test for NULL is incorrect. You do not use either indicators or NVL(), one of which must be used if you want to accurately determine if a field is NULL. However as inHouseScribe is lot.lotid || '.' || comp.POSITION, the result will never be NULL; performed a quick test as follows: create table t(a varchar2(10),b varchar2(10)); insert into t values('Hello','World'); insert into t values(NULL,'<- NULL'); insert into t values('NULL->',NULL); insert into t values(NULL,NULL); select a||'.'||b from t; Output: Hello.World .<- NULL NULL->. . Therefore strlen (inHouseScribeArray[indexOfComp]) will never be zero. Also is this test supposed to be within the for (indexOfComp = 0; indexOfComp < compQty; indexOfComp++) loop? It's outside it, therefore at this point indexOfComp=compQty, i.e. after the end of the array, and also therefore any result you get from this will be undefined.
Dear expert ,thanks for the quick reply. My scenario as below... I have to filter out the value if the com.position is Null and write into different log file..I have created function called Code: int Generate_PR_Report (char*, char*, struct parameters*); void Write_PR_DataFile(char*, char*, char*, char*, char*, char*, char*, char*, char*, char*, char*, char*, vc2_SlotPosition [], vc2_CarrierId [], vc2_VScriberId [], vc2_VScriberId [], vc2_SlotPosition [], vc2_CarrierId [], struct parameters*); I had attached the code for your reference..I would like confirm whether im doing the correct thing.Kindly help
Dear Expert, I’m really having issue when filtering out the data. My scenario as below. I need to filter out the data if the comp.position is missing. I had handle the scenario as below: the int Generate_SA_Report function will check comp.position is NULL Code: EXEC SQL DECLARE comp_Cursor CURSOR FOR SELECT lot.lotid || '.' || comp.POSITION inhousescribe, comp.componentid vendorscribe FROM hdbxuser.fwhdblot@hdbsil lot, hdbxuser.fwhdbwipcomponent@hdbsil comp WHERE lot.lot_sk = comp.originallot_sk AND comp.lot_sk = :lot_sk AND :txn_sk BETWEEN startsequence AND stopsequence AND comp.status <> 'Scrapped' AND comp.position IS NOT NULL ORDER BY comp.componentid; write the output in datafeed.track folder If its null i had called int Generate_PR_Report and called the sql Code: EXEC SQL DECLARE comp_Cursor CURSOR FOR SELECT lot.lotid || '.' || comp.POSITION inhousescribe, comp.componentid vendorscribe FROM hdbxuser.fwhdblot@hdbsil lot, hdbxuser.fwhdbwipcomponent@hdbsil comp WHERE lot.lot_sk = comp.originallot_sk AND comp.lot_sk = :lot_sk AND :txn_sk BETWEEN startsequence AND stopsequence AND comp.status <> 'Scrapped' AND comp.position IS NULL ORDER BY comp.componentid; and write the output in the AbnormalData. The issue now i had called the 2 function in main Code: */ cntr = 0; cntr = Generate_SA_Report(startDate, endDate, ¶meters); sprintf(tmpBuff, "%d lot 'Sorter Action' history files created", cntr); Log_Error(tmpBuff, parameters.errorLog); /* *** Generate 'Problamatic Lot report */ cntr = 0; cntr = Generate_PR_Report(startDate, endDate, ¶meters); sprintf(tmpBuff, "%d lot 'Problematic wafer lot file created.", cntr); Log_Error(tmpBuff, parameters.errorLog); Every Time it will write the output in both of the file and does't do the checking. The file is created in abnormal data folder since it go thru the function. I need some logic that it filter out the data if comp positon is NULL --->write the output in abnormal data directory. If no issue write the file in datafeed.track.. I had attached the sample of output and the file format is <lotid>.<time> Dear expert kindly help..give me some hint so that i can handle the scenario
Dear Expert, Attach is sample of output for the problematic one..The output shouldn't write into datafeed.track.It should go into abnormaldata folder Code: #Date range 20110228 0600 - 20110228 0700 Revision 1 Action randomize Lot ILN53091.1 Operation TTN2-Dep-VRandom.1 Suboperation GA_TTN2Dep actualqty 25 equipment F1HNAT01 device I9481AM-81AM technology C16T Date 20110228 063608000 Employee abc %wafer orig_slot orig_cass in_house_scribe vendor_scribe final_slot final_cass wafer 6 19873 ILN53091.1. DYJ17069SHF0 21 19873 wafer 1 19873 ILN53091.1. DYJ17073SHG1 15 19873 wafer 9 19873 ILN53091.1. DYJ17086SHB2 25 19873 wafer 21 19873 ILN53091.1. DYJ17090SHC3 11 19873 wafer 24 19873 ILN53091.1. DYJ17093SHA3 23 19873 wafer 5 19873 ILN53091.1. DYJ17094SHE5 2 19873 wafer 25 19873 ILN53091.1. DYJ17113SHA3 7 19873 wafer 11 19873 ILN53091.1. DYJ17116SHF6 14 19873 wafer 4 19873 ILN53091.1. DYJ17143SHG4 16 19873 wafer 15 19873 ILN53091.1. DYJ17185SHD4 22 19873 wafer 12 19873 ILN53091.1. DYJ17186SHA3 3 19873 wafer 17 19873 ILN53091.1. DYJ17212SHC5 10 19873 wafer 8 19873 ILN53091.1. DYJ17216SHE7 13 19873 wafer 19 19873 ILN53091.1. DYJ17227SHG2 12 19873 wafer 18 19873 ILN53091.1. DYJ17228SHD1 6 19873 wafer 20 19873 ILN53091.1. DYJ17234SHF3 18 19873 wafer 22 19873 ILN53091.1. DYJ17235SHC2 17 19873 wafer 3 19873 ILN53091.1. DYJ17252SHF7 8 19873 wafer 10 19873 ILN53091.1. DYJ17282SHE5 9 19873 wafer 2 19873 ILN53091.1. DYJ17331SHG4 1 19873 wafer 13 19873 ILN53091.1. DYJ17355SHD0 24 19873 wafer 23 19873 ILN53091.1. DYJ17356SHH2 4 19873 wafer 16 19873 ILN53091.1. EYJ1Q171SHB1 19 19873 wafer 14 19873 ILN53091.1. EYJ1Q207SHB5 20 19873 The second scenario only certain comp.position is missing Code: #Date range 20110314 0600 - 20110314 0700 Revision 1 Action randomize Lot CNP04023.1 Operation IMD3-SRO-CAP-VRandom.0 Suboperation GA_IMD3Cln actualqty 25 equipment F1HNAT04 device C20588A-CX88 technology C18 Date 20110314 062624000 Employee hk %wafer orig_slot orig_cass in_house_scribe vendor_scribe final_slot final_cass wafer 7 44712 CNP04023.1.1 P9JXS011SHD4 12 44712 wafer 3 44712 CNP04023.1. 2 P9JXS013SHE5 18 44712 wafer 22 44712 CNP04023.1.4 P9JXS048SHC4 2 44712 wafer 6 44712 CNP04023.1.5 P9JXS073SHC1 22 44712 wafer 2 44712 CNP04023.1. 7 P9JXS085SHA3 8 44712 wafer 14 44712 CNP04023.1.8 P9JXS088SHF6 6 44712 wafer 15 44712 CNP04023.1. 9 P9JXS090SHF6 21 44712 wafer 21 44712 CNP04023.1. 3 P9JXS116SHB6 7 44712 wafer 17 44712 CNP04023.1.4 P9JXS130SHA0 9 44712 wafer 23 44712 CNP04023.1. 9 P9JXS133SHF3 14 44712 wafer 5 44712 CNP04023.1. P9JXS148SHB5 16 44712 wafer 12 44712 CNP04023.1. P9JXS166SHC1 4 44712 wafer 13 44712 CNP04023.1. P9JXS195SHE0 15 44712 wafer 20 44712 CNP04023.1. P9JXS197SHF1 17 44712 wafer 24 44712 CNP04023.1. P9JXS199SHG2 19 44712 wafer 16 44712 CNP04023.1. P9JXS210SHE7 10 44712 wafer 19 44712 CNP04023.1. P9JXS215SHE0 11 44712 wafer 1 44712 CNP04023.1. P9JXS233SHE4 5 44712 wafer 4 44712 CNP04023.1. P9JXS287SHH1 1 44712 wafer 9 44712 CNP04023.1. P9JXS298SHB1 3 44712 wafer 18 44712 CNP04023.1. P9JXS318SHB1 23 44712 wafer 11 44712 CNP04023.1. P9JXS345SHB7 20 44712 wafer 8 44712 CNP04023.1. P9JXS351SHE1 13 44712 wafer 10 44712 CNP04023.1. P9JXS383SHE0 25 44712 wafer 25 44712 CNP04023.1. P9JXS387SHG2 24 44712 so my code should keep the complete 1 in datafeed.track and the write the incomplete 1 in abnormaldata folder . Kindly help
Sir really need help cuz im new to C..By the way i create the function but its doesn't fulfill the criteria.. Kindly help.. Appreciate that
Code: if ((strlen(inHouseScribeArray[indexOfComp]) = = 11) -[I]-if the length of inhousescribe[/I] { Write_PR_DataFile(startDate, endDate, action, lot, operation, subOperation, actualQty, eqpId, device, tech, toTime, employee, origSlotArray, origCassArray, inHouseScribeArray, vendorScribeArray, finalSlotArray, finalCassArray, parms); else { Write_SA_DataFile(startDate, endDate, action, lot, operation, subOperation, actualQty, eqpId, device, tech, toTime, employee, origSlotArray, origCassArray, inHouseScribeArray, vendorScribeArray, finalSlotArray, finalCassArray, parms); } Dear xpi0t0s, i have to set condition if there is one value with missing comp.position..i have to write the entire file into abnormal data.Lets say. #Date range 20110225 0600 - 20110225 0700 Revision 1 Action randomize Lot AUP05078.1 Operation Pst-PSD-Imp-RsStrp-Random.0 Suboperation GA_PSDImRS actualqty 25 equipment D1HNNT01 device ARODINA-AU1B technology C16 Date 20110225 064924000 Employee som %wafer orig_slot orig_cass in_house_scribe vendor_scribe final_slot final_cass wafer 5 6594 AUP05078.1. UXJZ3031SHC1 24 6594 wafer 18 6594 AUP05078.1.18 UXJZ3035SHE3 3 6594 wafer 12 6594 AUP05078.1.25 UXJZ3036SHB2 6 6594 wafer 19 6594 AUP05078.1. UXJZ3117SHD0 12 6594 wafer 8 6594 AUP05078.1.9 UXJZ3197SHC1 5 6594 wafer 16 6594 AUP05078.1.13 UXJZ3202SHF7 9 6594 wafer 20 6594 AUP05078.1.16 UXJZ3203SHC6 10 6594 wafer 9 6594 AUP05078.1.15 UXJZ3204SHH0 11 6594 wafer 23 6594 AUP05078.1.20 UXJZ3205SHD7 18 6594 wafer 25 6594 AUP05078.1.21 UXJZ3206SHA6 8 6594 wafer 21 6594 AUP05078.1.19 UXJZ3207SHF0 19 6594 wafer 2 6594 AUP05078.1.14 UXJZ3208SHB7 22 6594 wafer 24 6594 AUP05078.1.17 UXJZ3209SHG1 15 6594 wafer 14 6594 AUP05078.1.12 UXJZ3210SHB7 16 6594 wafer 4 6594 AUP05078.1.11 UXJZ3211SHG1 23 6594 wafer 17 6594 AUP05078.1. UXJZ3213SHH2 2 6594 wafer 10 6594 AUP05078.1.10 UXJZ3216SHF2 7 6594 wafer 11 6594 AUP05078.1. UXJZ3264SHE4 14 6594 wafer 15 6594 AUP05078.1.8 UXJZ3265SHB3 13 6594 wafer 3 6594 AUP05078.1.7 UXJZ3267SHC4 17 6594 wafer 6 6594 AUP05078.1.1 UXJZ3268SHG6 20 6594 wafer 7 6594 AUP05078.1. UXJZ3271SHD5 1 6594 wafer 13 6594 AUP05078.1.24 UXJZ3281SHA6 4 6594 wafer 1 6594 AUP05078.1.22 UXJZ3282SHF0 25 6594 wafer 22 6594 AUP05078.1.23 UXJZ3283SHB7 21 6594 All this values are missing ..The code should do the checking if one of the value has missing comp.position during that period ,it should write entire file in abnormal data file. Kindly help...need someone guidance and im trying my best level to finish up the code
My suggestion is to use indicators, and not to combine two columns with lot.lotid || '.' || comp.POSITION. Fetch back lot.lotid and comp.POSITION as separate columns, with an indicator for wherever you need to check for NULL, then you can always strcat the two columns later on in the C code if you really do need "lotid.position". You cannot rely on a specific value in host variables if NULL is returned, because the actual byte pattern written can and does change from version to version. For more information on how to use indicators, read the Pro*C documentation (basically: "select into :var:ind" where var is the host variable for the data and ind is the host variable for the indicator. But RTFM for the full detail, there's no point me duplicating it here).
Code: EXEC SQL DECLARE comp_Cursor CURSOR FOR SELECT lot.lotid || '.' || comp.POSITION inhousescribe, comp.POSITION, comp.componentid vendorscribe FROM hdbxuser.fwhdblot@hdbsil lot, hdbxuser.fwhdbwipcomponent@hdbsil comp WHERE lot.lot_sk = comp.originallot_sk AND comp.lot_sk = :lot_sk AND :txn_sk BETWEEN startsequence AND stopsequence AND comp.status <> 'Scrapped' ORDER BY comp.componentid; EXEC SQL OPEN comp_Cursor; EXEC SQL WHENEVER NOT FOUND DO break; indexOfComp = 0; for(; ;) { memset(inHouseScribe, NULL, sizeof(inHouseScribe)); memset(vendorScribe, NULL, sizeof(vendorScribe)); memset (POSITION,NULL,sizeof (POSITION)); EXEC SQL FETCH comp_Cursor INTO :inHouseScribe, :vendorScribe, :POSITION; strcpy(inHouseScribeArray[indexOfComp], inHouseScribe); strcpy(vendorScribeArray[indexOfComp], vendorScribe); strcpy (POSITIONArray[indexOfComp],POSITION); indexOfComp++; I had separated the sql to get comp.position Code: int Generate_SA_Report( char* startDate, char* endDate, struct parameters* parms) { /*************************************************** * Preparation ***************************************************/ /* Variable declaration */ int skipLotCntr = 0; int numOfFiles = 0; int compQty = 0; int indexOfComp = 0; int indexOfCarHistRecord = 0; vc2_LotSK lot_sk; vc2_TxnSK txn_sk; vc2_Operation action; vc2_LotId lot; vc2_StepId stepId; vc2_StepId sorterAction; vc2_Stage stage; vc2_Recipe recipe; vc2_Operation operation; vc2_Operation subOperation; vc2_WaferQty qtyIn; vc2_WaferQty qtyOut; vc2_WaferQty actualQty; vc2_EqpId eqpId; vc2_Device device; vc2_Technology tech; vc2_DateTime toTime; vc2_DateTime tiTime; vc2_DateTime createTime; vc2_UserId employee; vc2_CarrierId carrierId; vc2_LotId finalLotId; vc2_GroupHistKey groupHistKey; vc2_PlanId planId; vc2_SlotPosition slot; vc2_CarrierId origCass; vc2_VScriberId inHouseScribe; vc2_VScriberId vendorScribe; vc2_VScriberId POSITION; vc2_CarrierId finalCass; vc2_SlotPosition origSlotArray[MAX_WAFERQTY_PER_LOT]; vc2_CarrierId origCassArray[MAX_WAFERQTY_PER_LOT]; vc2_VScriberId inHouseScribeArray[MAX_WAFERQTY_PER_LOT]; vc2_VScriberId vendorScribeArray[MAX_WAFERQTY_PER_LOT]; vc2_VScriberId POSITIONArray[MAX_WAFERQTY_PER_LOT]; vc2_SlotPosition finalSlotArray[MAX_WAFERQTY_PER_LOT]; vc2_CarrierId finalCassArray[MAX_WAFERQTY_PER_LOT]; vc2_VScriberId scribeId; vc2_SysId carHistSysId; vc2_SysId carHistTxnTime; vc2_SysId carHistSysIdArray[MAX_CARHISTRECORD_NUM]; vc2_SysId carHistTxnTimeArray[MAX_CARHISTRECORD_NUM]; int finalFlag = FALSE; char currDateTime[20]; char* pTmp = NULL; /* Reset memory */ memset(scribeId, 0, sizeof(scribeId)); memset(currDateTime, 0, sizeof(currDateTime)); memset(carHistSysId, 0, sizeof(carHistSysId)); memset(carHistTxnTime, 0, sizeof(carHistTxnTime)); memset(carHistSysIdArray, 0, sizeof(carHistSysIdArray)); memset(carHistTxnTimeArray, 0, sizeof(carHistTxnTimeArray)); #ifdef DEBUG printf("%s: Start to retrieve Sorter Action Information\n", GetCurrDateTime(currDateTime)); printf(" Start Date [%s] ~ End Date [%s]\n", startDate, endDate); #endif /*************************************************** * Query data ***************************************************/ /* Get 'Sorter Action' lot (lot_sk, txn_sk) list */ EXEC SQL DECLARE wsSaCursor CURSOR FOR SELECT wip.lot_sk, wip.txn_sk FROM hdbxuser.fwhdbwipstephistory@hdbsil sh, hdbxuser.fwhdbwiptransaction@hdbsil wip WHERE wip.wipstep_sk = sh.wipstep_sk AND wip.activity = 'TrackIn' AND wip.txntime = sh.trackintime AND sh.trackouttime BETWEEN :startDate AND :endDate; /* Open cursor */ EXEC SQL OPEN wsSaCursor; /* Loop, fetching all salesperson's statistics. * Cause the program to break the loop when no more * data can be retrieved on the cursor. */ EXEC SQL WHENEVER NOT FOUND DO break; for( ; ;) { /* Reset memory */ memset(lot_sk, NULL, sizeof(lot_sk)); memset(txn_sk, NULL, sizeof(txn_sk)); memset(action, NULL, sizeof(action)); memset(lot, NULL, sizeof(lot)); memset(stepId, NULL, sizeof(stepId)); memset(sorterAction, NULL, sizeof(sorterAction)); memset(stage, NULL, sizeof(stage)); memset(recipe, NULL, sizeof(recipe)); memset(operation, NULL, sizeof(operation)); memset(subOperation, NULL, sizeof(subOperation)); memset(qtyIn, NULL, sizeof(qtyIn)); memset(qtyOut, NULL, sizeof(qtyOut)); memset(actualQty, NULL, sizeof(actualQty)); memset(eqpId, NULL, sizeof(eqpId)); memset(device, NULL, sizeof(device)); memset(tech, NULL, sizeof(tech)); memset(toTime, NULL, sizeof(toTime)); memset(tiTime, NULL, sizeof(tiTime)); memset(createTime, NULL, sizeof(createTime)); memset(employee, NULL, sizeof(employee)); memset(carrierId, NULL, sizeof(carrierId)); memset(finalLotId, NULL, sizeof(finalLotId)); memset(groupHistKey, NULL, sizeof(groupHistKey)); memset(planId, NULL, sizeof(planId)); memset(origSlotArray, NULL, sizeof(origSlotArray)); memset(origCassArray, NULL, sizeof(origCassArray)); memset(inHouseScribeArray, NULL, sizeof(inHouseScribeArray)); memset(POSITIONArray,NULL,sizeof(POSITIONArray)); memset(vendorScribeArray, NULL, sizeof(vendorScribeArray)); memset(finalSlotArray, NULL, sizeof(finalSlotArray)); memset(finalCassArray, NULL, sizeof(finalCassArray)); /* Get txn_sk */ EXEC SQL FETCH wsSaCursor INTO :lot_sk, :txn_sk; /* Skip it if no data found */ EXEC SQL WHENEVER NOT FOUND GOTO NOTFOUND; /* To check whether the lot perform 'Sorter Action' or not */ EXEC SQL SELECT LOWER (recipe), transportid, stage, device INTO :recipe, :carrierId, :stage, :device FROM (SELECT lotrecipe.attrvalue recipe, lottransportid.attrvalue transportid, lotstage.attrvalue stage, lotdevice.attrvalue device FROM hdbxuser.fwhdbwiplotattrinstance@hdbsil lotrecipe, hdbxuser.fwhdbwiplotattrinstance@hdbsil lotstage, hdbxuser.fwhdbwiplotattrinstance@hdbsil lottransportid, hdbxuser.fwhdbwiplotattrinstance@hdbsil lotdevice WHERE lotrecipe.lot_sk = :lot_sk AND :txn_sk BETWEEN lotrecipe.startsequence AND lotrecipe.stopsequence AND lotrecipe.attrname = 'Recipe' AND ( LOWER (lotrecipe.attrvalue) LIKE '%verify%' OR (LOWER (lotrecipe.attrvalue) LIKE '%random%') OR (LOWER (lotrecipe.attrvalue) LIKE '%reorder%') ) AND lotstage.lot_sk = :lot_sk AND :txn_sk BETWEEN lotstage.startsequence AND lotstage.stopsequence AND lotstage.attrname = 'Stage' AND lottransportid.lot_sk = :lot_sk AND :txn_sk BETWEEN lottransportid.startsequence AND lottransportid.stopsequence AND lottransportid.attrname = 'transportId' AND lotdevice.lot_sk = :lot_sk AND :txn_sk BETWEEN lotdevice.startsequence AND lotdevice.stopsequence AND lotdevice.attrname = 'partProgId' UNION ALL SELECT lotsorteraction.attrvalue recipe, lottransportid.attrvalue transportid, lotstage.attrvalue stage, lotdevice.attrvalue device FROM hdbxuser.fwhdbwiplotattrinstance@hdbsil lotsorteraction, hdbxuser.fwhdbwiplotattrinstance@hdbsil lotstage, hdbxuser.fwhdbwiplotattrinstance@hdbsil lottransportid, hdbxuser.fwhdbwiplotattrinstance@hdbsil lotdevice WHERE lotsorteraction.lot_sk = :lot_sk AND :txn_sk BETWEEN lotsorteraction.startsequence AND lotsorteraction.stopsequence AND lotsorteraction.attrname = 'SorterAction' AND lotsorteraction.attrvalue IN ('REORDER', 'VERIFY') AND lotstage.lot_sk = :lot_sk AND :txn_sk BETWEEN lotstage.startsequence AND lotstage.stopsequence AND lotstage.attrname = 'Stage' AND lottransportid.lot_sk = :lot_sk AND :txn_sk BETWEEN lottransportid.startsequence AND lottransportid.stopsequence AND lottransportid.attrname = 'transportId' AND lotdevice.lot_sk = :lot_sk AND :txn_sk BETWEEN lotdevice.startsequence AND lotdevice.stopsequence AND lotdevice.attrname = 'partProgId'); /* Get lot detail information */ EXEC SQL SELECT wipin.lotid, wipout.userid, wipin.txntime, wipin.lotqtyout, wipout.txntime totime, wipout.lotid finallotid, wipin.grouphistkey, sh.LOCATION, sh.stepid, sh.planid, sh.productname tech, lot.createtxntime INTO :lot, :employee, :tiTime, :actualQty, :toTime, :finalLotId, :groupHistKey, :eqpId, :stepId, :planId, :tech, :createTime FROM hdbxuser.fwhdblot@hdbsil lot, hdbxuser.fwhdbwipstephistory@hdbsil sh, hdbxuser.fwhdbwiptransaction@hdbsil wipout, hdbxuser.fwhdbwiptransaction@hdbsil wipin WHERE lot.lot_sk = wipin.lot_sk AND wipout.grouphistkey = wipin.grouphistkey AND wipout.activity = 'TrackOut' AND sh.wipstep_sk = wipout.wipstep_sk AND wipin.txn_sk = :txn_sk; /* Get component Id list */ EXEC SQL DECLARE comp_Cursor CURSOR FOR SELECT lot.lotid || '.' || comp.POSITION inhousescribe, comp.POSITION, comp.componentid vendorscribe FROM hdbxuser.fwhdblot@hdbsil lot, hdbxuser.fwhdbwipcomponent@hdbsil comp WHERE lot.lot_sk = comp.originallot_sk AND comp.lot_sk = :lot_sk AND :txn_sk BETWEEN startsequence AND stopsequence AND comp.status <> 'Scrapped' ORDER BY comp.componentid; EXEC SQL OPEN comp_Cursor; EXEC SQL WHENEVER NOT FOUND DO break; indexOfComp = 0; for(; ;) { memset(inHouseScribe, NULL, sizeof(inHouseScribe)); memset(vendorScribe, NULL, sizeof(vendorScribe)); memset (POSITION,NULL,sizeof (POSITION)); EXEC SQL FETCH comp_Cursor INTO :inHouseScribe, :vendorScribe, :POSITION; strcpy(inHouseScribeArray[indexOfComp], inHouseScribe); strcpy(vendorScribeArray[indexOfComp], vendorScribe); strcpy (POSITIONArray[indexOfComp],POSITION); indexOfComp++; } compQty = indexOfComp; EXEC SQL CLOSE comp_Cursor; /* * The following is to retrieve component Id slot-map * information: orignal -- final position * * 1. Get SysId/TxnTime list from FwCarrierHistory in desc order; * Time range: create time ~ to time * SysId list is stored in an array that size is 10. * 2. Loop: wafer by wafer * 2.1 Get final position (FwCarrierHistory_PN2M) * 2.1.1 Make sure TxnTime is between TiTime and ToTime * 2.1.2 Get final position by using the lastest sysId * 2.2 Get original position by using the latest SysId; * 2.2.1 Make sure TxnTime is earlier TiTime. * If not, skip to previous record (SysId); * 2.2.2 Get original position by using SysId. If not found, * skip to previous record (SysId) */ /* VERY IMPORTANT */ /* Minus 1 min (60 seconds) to create time */ /* We may fail to get data if using create time in some cases * because CARRIER transaction is done eariler than WIP. * For example, one child is created (split) in '20090806 152152000', * but the Assign Component happen in 20090806 152151000 */ AddSeconds( createTime, -60 ); /* Get SysId/TxnTime list from FwCarrierHistory */ EXEC SQL DECLARE carhist_Cursor CURSOR FOR SELECT sysid, txntime FROM caruser.fwcarrierhistory WHERE carrierid = :carrierId AND activity IN ('FwCarrierAssignComponentTxn', 'FwCarrierModifyComponentPositionTxn', 'ReAssociateTo' ) AND txntime BETWEEN :createTime AND :toTime ORDER BY txntime DESC; EXEC SQL OPEN carhist_Cursor; EXEC SQL WHENEVER NOT FOUND DO break; memset(carHistSysIdArray, 0, sizeof(carHistSysIdArray)); memset(carHistTxnTimeArray, 0, sizeof(carHistTxnTimeArray)); for(indexOfCarHistRecord = 0; indexOfCarHistRecord < MAX_CARHISTRECORD_NUM; indexOfCarHistRecord++) { memset(carHistSysId, 0, sizeof(carHistSysId)); memset(carHistTxnTime, 0, sizeof(carHistTxnTime)); EXEC SQL FETCH carhist_Cursor INTO :carHistSysId, :carHistTxnTime; strcpy(carHistSysIdArray[indexOfCarHistRecord], carHistSysId); strcpy(carHistTxnTimeArray[indexOfCarHistRecord], carHistTxnTime); } EXEC SQL CLOSE carhist_Cursor; /* To get final & original position for each wafer */ for (indexOfComp = 0; indexOfComp < compQty; indexOfComp++) { finalFlag = FALSE; memset(scribeId, NULL, sizeof(scribeId)); strcpy(scribeId, vendorScribeArray[indexOfComp]); /* Loop: to find original-final slot position */ for(indexOfCarHistRecord = 0; indexOfCarHistRecord < MAX_CARHISTRECORD_NUM; indexOfCarHistRecord++) { memset(slot, NULL, sizeof(slot)); memset(carHistSysId, 0, sizeof(carHistSysId)); strcpy(carHistSysId, carHistSysIdArray[indexOfCarHistRecord]); EXEC SQL WHENEVER NOT FOUND CONTINUE; EXEC SQL SELECT valdata slot INTO :slot FROM caruser.fwcarrierhistory_pn2m WHERE fromid = :carHistSysId AND linkname = 'components' AND keydata = :scribeId; if (strlen(slot) > 0) { if (strcmp(carHistTxnTimeArray[indexOfCarHistRecord], tiTime) > 0) { /* Finalflag is to make sure to get the correst slot position (latest). * To handle abnormal case: namely that there are multiple slot * mapping changes during the period of Track-In and Track-Out. */ if (finalFlag == FALSE) { /* Final position */ strcpy(finalSlotArray[indexOfComp], slot); strcpy(finalCassArray[indexOfComp], carrierId); finalFlag = TRUE; } } else { /* Original position */ strcpy(origSlotArray[indexOfComp], slot); strcpy(origCassArray[indexOfComp], carrierId); /* If final position value is NULL, it is assumed that * the slot position does not change, same as original one */ if (strlen(finalSlotArray[indexOfComp]) == 0) { strcpy(finalSlotArray[indexOfComp], slot); strcpy(finalCassArray[indexOfComp], carrierId); } break; } } } } /* Assign value to 'action', 'operation', 'suboperation' */ if (strstr(recipe, "random")) { strcpy(action, OPERATION_RANDOMIZE); strcpy(operation, stepId); /* Strip out XX stage stuff/sortorder in stage name */ pTmp = strchr(stage, ':'); if (pTmp != NULL) strcpy(subOperation, Trim_End(++pTmp)); else strcpy(subOperation, stage); } else if (strstr(recipe, "reorder")) { strcpy(action, OPERATION_REORDER); strcpy(operation, "reorder"); strcpy(subOperation, "reorder"); } else if (strstr(recipe, "verify")) { /* if (strstr(stepId, "SorterAction")) { strcpy(action, OPERATION_VERIFY); } else { strcpy(action, OPERATION_INLINEVERIFY); } */ strcpy(action, OPERATION_VERIFY); strcpy(operation, "verify"); strcpy(subOperation, "verify"); } else { strcpy(action, recipe); strcpy(operation, recipe); strcpy(subOperation, recipe); } i[I][COLOR="Red"]if (strlen(POSITIONArray[indexOfComp]) !=0) { Write_SA_DataFile(startDate, endDate, action, lot, operation, subOperation, actualQty, eqpId, device, tech, toTime, employee, origSlotArray, origCassArray, inHouseScribeArray, vendorScribeArray, finalSlotArray, finalCassArray, parms); } else { Write_PR_DataFile(startDate, endDate, action, lot, operation, subOperation, actualQty, eqpId, device, tech, toTime, employee, origSlotArray, origCassArray, inHouseScribeArray, vendorScribeArray, finalSlotArray, finalCassArray, parms); } [/COLOR][/I] numOfFiles++; #ifdef DEBUG printf(" #%d lot data is extracted\n", numOfFiles); #endif continue; NOTFOUND: skipLotCntr++; #ifdef DEBUG printf(" #%d lot is skipped\n", skipLotCntr); #endif ; } /* Close cursor */ EXEC SQL CLOSE wsSaCursor; #ifdef DEBUG printf(" %d 'Sorter Action' data files are created successfully\n", numOfFiles); printf("%s: Complete retrieving 'Sorter Action' Information\n", GetCurrDateTime(currDateTime)); #endif return(numOfFiles); } /* Generate_SA_Report */ Kindly comment
If the problem is "some bug", then the solution is "change some code". If you want a more helpful answer, give a more helpful problem description. Read the link in my sig.
Code: int Generate_SA_Report( char* startDate, char* endDate, struct parameters* parms) { /*************************************************** * Preparation ***************************************************/ /* Variable declaration */ int skipLotCntr = 0; int numOfFiles = 0; int compQty = 0; int indexOfComp = 0; int indexOfCarHistRecord = 0; vc2_LotSK lot_sk; vc2_TxnSK txn_sk; vc2_Operation action; vc2_LotId lot; vc2_StepId stepId; vc2_StepId sorterAction; vc2_Stage stage; vc2_Recipe recipe; vc2_Operation operation; vc2_Operation subOperation; vc2_WaferQty qtyIn; vc2_WaferQty qtyOut; vc2_WaferQty actualQty; vc2_EqpId eqpId; vc2_Device device; vc2_Technology tech; vc2_DateTime toTime; vc2_DateTime tiTime; vc2_DateTime createTime; vc2_UserId employee; vc2_CarrierId carrierId; vc2_LotId finalLotId; vc2_GroupHistKey groupHistKey; vc2_PlanId planId; vc2_SlotPosition slot; vc2_CarrierId origCass; vc2_VScriberId inHouseScribe; vc2_VScriberId vendorScribe; vc2_VScriberId POSITION; vc2_CarrierId finalCass; vc2_SlotPosition origSlotArray[MAX_WAFERQTY_PER_LOT]; vc2_CarrierId origCassArray[MAX_WAFERQTY_PER_LOT]; vc2_VScriberId inHouseScribeArray[MAX_WAFERQTY_PER_LOT]; vc2_VScriberId vendorScribeArray[MAX_WAFERQTY_PER_LOT]; vc2_VScriberId POSITIONArray[MAX_WAFERQTY_PER_LOT]; vc2_SlotPosition finalSlotArray[MAX_WAFERQTY_PER_LOT]; vc2_CarrierId finalCassArray[MAX_WAFERQTY_PER_LOT]; vc2_VScriberId scribeId; vc2_SysId carHistSysId; vc2_SysId carHistTxnTime; vc2_SysId carHistSysIdArray[MAX_CARHISTRECORD_NUM]; vc2_SysId carHistTxnTimeArray[MAX_CARHISTRECORD_NUM]; int finalFlag = FALSE; char currDateTime[20]; char* pTmp = NULL; /* Reset memory */ memset(scribeId, 0, sizeof(scribeId)); memset(currDateTime, 0, sizeof(currDateTime)); memset(carHistSysId, 0, sizeof(carHistSysId)); memset(carHistTxnTime, 0, sizeof(carHistTxnTime)); memset(carHistSysIdArray, 0, sizeof(carHistSysIdArray)); memset(carHistTxnTimeArray, 0, sizeof(carHistTxnTimeArray)); #ifdef DEBUG printf("%s: Start to retrieve Sorter Action Information\n", GetCurrDateTime(currDateTime)); printf(" Start Date [%s] ~ End Date [%s]\n", startDate, endDate); #endif /*************************************************** * Query data ***************************************************/ /* Get 'Sorter Action' lot (lot_sk, txn_sk) list */ EXEC SQL DECLARE wsSaCursor CURSOR FOR SELECT wip.lot_sk, wip.txn_sk FROM hdbxuser.fwhdbwipstephistory@hdbsil sh, hdbxuser.fwhdbwiptransaction@hdbsil wip WHERE wip.wipstep_sk = sh.wipstep_sk AND wip.activity = 'TrackIn' AND wip.txntime = sh.trackintime AND sh.trackouttime BETWEEN :startDate AND :endDate; /* Open cursor */ EXEC SQL OPEN wsSaCursor; /* Loop, fetching all salesperson's statistics. * Cause the program to break the loop when no more * data can be retrieved on the cursor. */ EXEC SQL WHENEVER NOT FOUND DO break; for( ; ;) { /* Reset memory */ memset(lot_sk, NULL, sizeof(lot_sk)); memset(txn_sk, NULL, sizeof(txn_sk)); memset(action, NULL, sizeof(action)); memset(lot, NULL, sizeof(lot)); memset(stepId, NULL, sizeof(stepId)); memset(sorterAction, NULL, sizeof(sorterAction)); memset(stage, NULL, sizeof(stage)); memset(recipe, NULL, sizeof(recipe)); memset(operation, NULL, sizeof(operation)); memset(subOperation, NULL, sizeof(subOperation)); memset(qtyIn, NULL, sizeof(qtyIn)); memset(qtyOut, NULL, sizeof(qtyOut)); memset(actualQty, NULL, sizeof(actualQty)); memset(eqpId, NULL, sizeof(eqpId)); memset(device, NULL, sizeof(device)); memset(tech, NULL, sizeof(tech)); memset(toTime, NULL, sizeof(toTime)); memset(tiTime, NULL, sizeof(tiTime)); memset(createTime, NULL, sizeof(createTime)); memset(employee, NULL, sizeof(employee)); memset(carrierId, NULL, sizeof(carrierId)); memset(finalLotId, NULL, sizeof(finalLotId)); memset(groupHistKey, NULL, sizeof(groupHistKey)); memset(planId, NULL, sizeof(planId)); memset(origSlotArray, NULL, sizeof(origSlotArray)); memset(origCassArray, NULL, sizeof(origCassArray)); memset(inHouseScribeArray, NULL, sizeof(inHouseScribeArray)); memset(POSITIONArray,NULL,sizeof(POSITIONArray)); memset(vendorScribeArray, NULL, sizeof(vendorScribeArray)); memset(finalSlotArray, NULL, sizeof(finalSlotArray)); memset(finalCassArray, NULL, sizeof(finalCassArray)); /* Get txn_sk */ EXEC SQL FETCH wsSaCursor INTO :lot_sk, :txn_sk; /* Skip it if no data found */ EXEC SQL WHENEVER NOT FOUND GOTO NOTFOUND; /* To check whether the lot perform 'Sorter Action' or not */ EXEC SQL SELECT LOWER (recipe), transportid, stage, device INTO :recipe, :carrierId, :stage, :device FROM (SELECT lotrecipe.attrvalue recipe, lottransportid.attrvalue transportid, lotstage.attrvalue stage, lotdevice.attrvalue device FROM hdbxuser.fwhdbwiplotattrinstance@hdbsil lotrecipe, hdbxuser.fwhdbwiplotattrinstance@hdbsil lotstage, hdbxuser.fwhdbwiplotattrinstance@hdbsil lottransportid, hdbxuser.fwhdbwiplotattrinstance@hdbsil lotdevice WHERE lotrecipe.lot_sk = :lot_sk AND :txn_sk BETWEEN lotrecipe.startsequence AND lotrecipe.stopsequence AND lotrecipe.attrname = 'Recipe' AND ( LOWER (lotrecipe.attrvalue) LIKE '%verify%' OR (LOWER (lotrecipe.attrvalue) LIKE '%random%') OR (LOWER (lotrecipe.attrvalue) LIKE '%reorder%') ) AND lotstage.lot_sk = :lot_sk AND :txn_sk BETWEEN lotstage.startsequence AND lotstage.stopsequence AND lotstage.attrname = 'Stage' AND lottransportid.lot_sk = :lot_sk AND :txn_sk BETWEEN lottransportid.startsequence AND lottransportid.stopsequence AND lottransportid.attrname = 'transportId' AND lotdevice.lot_sk = :lot_sk AND :txn_sk BETWEEN lotdevice.startsequence AND lotdevice.stopsequence AND lotdevice.attrname = 'partProgId' UNION ALL SELECT lotsorteraction.attrvalue recipe, lottransportid.attrvalue transportid, lotstage.attrvalue stage, lotdevice.attrvalue device FROM hdbxuser.fwhdbwiplotattrinstance@hdbsil lotsorteraction, hdbxuser.fwhdbwiplotattrinstance@hdbsil lotstage, hdbxuser.fwhdbwiplotattrinstance@hdbsil lottransportid, hdbxuser.fwhdbwiplotattrinstance@hdbsil lotdevice WHERE lotsorteraction.lot_sk = :lot_sk AND :txn_sk BETWEEN lotsorteraction.startsequence AND lotsorteraction.stopsequence AND lotsorteraction.attrname = 'SorterAction' AND lotsorteraction.attrvalue IN ('REORDER', 'VERIFY') AND lotstage.lot_sk = :lot_sk AND :txn_sk BETWEEN lotstage.startsequence AND lotstage.stopsequence AND lotstage.attrname = 'Stage' AND lottransportid.lot_sk = :lot_sk AND :txn_sk BETWEEN lottransportid.startsequence AND lottransportid.stopsequence AND lottransportid.attrname = 'transportId' AND lotdevice.lot_sk = :lot_sk AND :txn_sk BETWEEN lotdevice.startsequence AND lotdevice.stopsequence AND lotdevice.attrname = 'partProgId'); /* Get lot detail information */ EXEC SQL SELECT wipin.lotid, wipout.userid, wipin.txntime, wipin.lotqtyout, wipout.txntime totime, wipout.lotid finallotid, wipin.grouphistkey, sh.LOCATION, sh.stepid, sh.planid, sh.productname tech, lot.createtxntime INTO :lot, :employee, :tiTime, :actualQty, :toTime, :finalLotId, :groupHistKey, :eqpId, :stepId, :planId, :tech, :createTime FROM hdbxuser.fwhdblot@hdbsil lot, hdbxuser.fwhdbwipstephistory@hdbsil sh, hdbxuser.fwhdbwiptransaction@hdbsil wipout, hdbxuser.fwhdbwiptransaction@hdbsil wipin WHERE lot.lot_sk = wipin.lot_sk AND wipout.grouphistkey = wipin.grouphistkey AND wipout.activity = 'TrackOut' AND sh.wipstep_sk = wipout.wipstep_sk AND wipin.txn_sk = :txn_sk; /* Get component Id list */ EXEC SQL DECLARE comp_Cursor CURSOR FOR SELECT lot.lotid || '.' || comp.POSITION inhousescribe, comp.componentid vendorscribe, comp.POSITION FROM hdbxuser.fwhdblot@hdbsil lot, hdbxuser.fwhdbwipcomponent@hdbsil comp WHERE lot.lot_sk = comp.originallot_sk AND comp.lot_sk = :lot_sk AND :txn_sk BETWEEN startsequence AND stopsequence AND comp.status <> 'Scrapped' ORDER BY comp.componentid; EXEC SQL OPEN comp_Cursor; EXEC SQL WHENEVER NOT FOUND DO break; indexOfComp = 0; for(; ;) { memset(inHouseScribe, NULL, sizeof(inHouseScribe)); memset(vendorScribe, NULL, sizeof(vendorScribe)); memset (POSITION,NULL,sizeof (POSITION)); EXEC SQL FETCH comp_Cursor INTO :inHouseScribe, :vendorScribe, :POSITION; strcpy(inHouseScribeArray[indexOfComp], inHouseScribe); strcpy(vendorScribeArray[indexOfComp], vendorScribe); strcpy (POSITIONArray[indexOfComp],POSITION); indexOfComp++; } compQty = indexOfComp; EXEC SQL CLOSE comp_Cursor; /* * The following is to retrieve component Id slot-map * information: orignal -- final position * * 1. Get SysId/TxnTime list from FwCarrierHistory in desc order; * Time range: create time ~ to time * SysId list is stored in an array that size is 10. * 2. Loop: wafer by wafer * 2.1 Get final position (FwCarrierHistory_PN2M) * 2.1.1 Make sure TxnTime is between TiTime and ToTime * 2.1.2 Get final position by using the lastest sysId * 2.2 Get original position by using the latest SysId; * 2.2.1 Make sure TxnTime is earlier TiTime. * If not, skip to previous record (SysId); * 2.2.2 Get original position by using SysId. If not found, * skip to previous record (SysId) */ /* VERY IMPORTANT */ /* Minus 1 min (60 seconds) to create time */ /* We may fail to get data if using create time in some cases * because CARRIER transaction is done eariler than WIP. * For example, one child is created (split) in '20090806 152152000', * but the Assign Component happen in 20090806 152151000 */ AddSeconds( createTime, -60 ); /* Get SysId/TxnTime list from FwCarrierHistory */ EXEC SQL DECLARE carhist_Cursor CURSOR FOR SELECT sysid, txntime FROM caruser.fwcarrierhistory WHERE carrierid = :carrierId AND activity IN ('FwCarrierAssignComponentTxn', 'FwCarrierModifyComponentPositionTxn', 'ReAssociateTo' ) AND txntime BETWEEN :createTime AND :toTime ORDER BY txntime DESC; EXEC SQL OPEN carhist_Cursor; EXEC SQL WHENEVER NOT FOUND DO break; memset(carHistSysIdArray, 0, sizeof(carHistSysIdArray)); memset(carHistTxnTimeArray, 0, sizeof(carHistTxnTimeArray)); for(indexOfCarHistRecord = 0; indexOfCarHistRecord < MAX_CARHISTRECORD_NUM; indexOfCarHistRecord++) { memset(carHistSysId, 0, sizeof(carHistSysId)); memset(carHistTxnTime, 0, sizeof(carHistTxnTime)); EXEC SQL FETCH carhist_Cursor INTO :carHistSysId, :carHistTxnTime; strcpy(carHistSysIdArray[indexOfCarHistRecord], carHistSysId); strcpy(carHistTxnTimeArray[indexOfCarHistRecord], carHistTxnTime); } EXEC SQL CLOSE carhist_Cursor; /* To get final & original position for each wafer */ for (indexOfComp = 0; indexOfComp < compQty; indexOfComp++) { finalFlag = FALSE; memset(scribeId, NULL, sizeof(scribeId)); strcpy(scribeId, vendorScribeArray[indexOfComp]); /* Loop: to find original-final slot position */ for(indexOfCarHistRecord = 0; indexOfCarHistRecord < MAX_CARHISTRECORD_NUM; indexOfCarHistRecord++) { memset(slot, NULL, sizeof(slot)); memset(carHistSysId, 0, sizeof(carHistSysId)); strcpy(carHistSysId, carHistSysIdArray[indexOfCarHistRecord]); EXEC SQL WHENEVER NOT FOUND CONTINUE; EXEC SQL SELECT valdata slot INTO :slot FROM caruser.fwcarrierhistory_pn2m WHERE fromid = :carHistSysId AND linkname = 'components' AND keydata = :scribeId; if (strlen(slot) > 0) { if (strcmp(carHistTxnTimeArray[indexOfCarHistRecord], tiTime) > 0) { /* Finalflag is to make sure to get the correst slot position (latest). * To handle abnormal case: namely that there are multiple slot * mapping changes during the period of Track-In and Track-Out. */ if (finalFlag == FALSE) { /* Final position */ strcpy(finalSlotArray[indexOfComp], slot); strcpy(finalCassArray[indexOfComp], carrierId); finalFlag = TRUE; } } else { /* Original position */ strcpy(origSlotArray[indexOfComp], slot); strcpy(origCassArray[indexOfComp], carrierId); /* If final position value is NULL, it is assumed that * the slot position does not change, same as original one */ if (strlen(finalSlotArray[indexOfComp]) == 0) { strcpy(finalSlotArray[indexOfComp], slot); strcpy(finalCassArray[indexOfComp], carrierId); } break; } } } } /* Assign value to 'action', 'operation', 'suboperation' */ if (strstr(recipe, "random")) { strcpy(action, OPERATION_RANDOMIZE); strcpy(operation, stepId); /* Strip out XX stage stuff/sortorder in stage name */ pTmp = strchr(stage, ':'); if (pTmp != NULL) strcpy(subOperation, Trim_End(++pTmp)); else strcpy(subOperation, stage); } else if (strstr(recipe, "reorder")) { strcpy(action, OPERATION_REORDER); strcpy(operation, "reorder"); strcpy(subOperation, "reorder"); } else if (strstr(recipe, "verify")) { /* if (strstr(stepId, "SorterAction")) { strcpy(action, OPERATION_VERIFY); } else { strcpy(action, OPERATION_INLINEVERIFY); } */ strcpy(action, OPERATION_VERIFY); strcpy(operation, "verify"); strcpy(subOperation, "verify"); } else { strcpy(action, recipe); strcpy(operation, recipe); strcpy(subOperation, recipe); } i[I][COLOR="Red"]f ((strlen(inHouseScribeArray[indexOfComp]) !=0)&& (strlen(origSlotArray[indexOfComp]) !=0) && (strlen(origCassArray[indexOfComp]) !=0)&& (strlen(finalCassArray[indexOfComp]) !=0) && (strlen(vendorScribeArray[indexOfComp])!=0) && (strlen(finalSlotArray[indexOfComp]) !=0)&& (strlen(POSITIONArray [indexOfComp]) !=0)) { Write_SA_DataFile(startDate, endDate, action, lot, operation, subOperation, actualQty, eqpId, device, tech, toTime, employee, origSlotArray, origCassArray, inHouseScribeArray, vendorScribeArray, finalSlotArray, finalCassArray, parms); } else { Write_PR_DataFile(startDate, endDate, action, lot, operation, subOperation, actualQty, eqpId, device, tech, toTime, employee, origSlotArray, origCassArray, inHouseScribeArray, vendorScribeArray, finalSlotArray, finalCassArray, parms); } numOfFiles++; #ifdef DEBUG printf(" #%d lot data is extracted\n", numOfFiles); #endif continue; [/COLOR][/I] NOTFOUND: skipLotCntr++; #ifdef DEBUG printf(" #%d lot is skipped\n", skipLotCntr); #endif ; } /* Close cursor */ EXEC SQL CLOSE wsSaCursor; #ifdef DEBUG printf(" %d 'Sorter Action' data files are created successfully\n", numOfFiles); printf("%s: Complete retrieving 'Sorter Action' Information\n", GetCurrDateTime(currDateTime)); #endif return(numOfFiles); } /* Generate_SA_Report */ The problem here is the data is written to the directory wrongly..The problematic 1 with missing position should written to datafeed.track instead of abnormal data.i put the comp.position as well, if one of the values is NULL it should go to else statement and write the entire result in abnormaldata directory.but it doesnt do that..
Again, you're still relying on strlen()==0 to determine if a value is NULL. This is not valid code. You should use NVL or indicators. For example: Code: exec sql declare zz1 cursor for select nvl(foo,'Its NULL Jim') from yyy; exec sql declare zz2 cursor for select foo from yyy; exec sql fetch zz1 into :hostvar1; if (!strcmp(hostvar1,"Its NULL Jim")) { // it's NULL } else { // it's not NULL } exec sql fetch zz2 into :hostvar2:ind; if (ind==1) // rtfm for the correct value, not sure 1 is correct { // it's NULL and you don't need to look at hostvar2 *at all* } else { // it's not NULL } You could also try writing the data out to the debug log just before the if. Write out the content, maybe enclosed in quotes, and the length, e.g.: Code: #ifdef DEBUG printf("indexOfComp=%d, compQty=%d\n", indexOfComp, compQty); printf("inHouseScribeArray[indexOfComp]='%s' length=%d\n",inHouseScribeArray[indexOfComp],strlen(inHouseScribeArray[indexOfComp])); printforigSlotArray[indexOfComp]='%s' length=%dorigSlotArray[indexOfComp],strlenorigSlotArray[indexOfComp])); ...etc (do each string in the if statement) #endif if ((strlen(inHouseScribeArray[indexOfComp]) !=0)&& (strlen(origSlotArray[indexOfComp]) !=0) && (strlen(origCassArray[indexOfComp]) !=0)&& (strlen(finalCassArray[indexOfComp]) !=0) && (strlen(vendorScribeArray[indexOfComp])!=0) && (strlen(finalSlotArray[indexOfComp]) !=0)&& (strlen(POSITIONArray [indexOfComp]) !=0)) { ...etc I think this might print some interesting results.
Dear expert, I had debug code but where i can find the result since im compiling in the unix environemt. By clicking make build command and unable see the error..im running in putty application.. debug in putty Kindly help.. When i write the debug code unable see the result ..what i can do for this case ..
I was going by the other debug in the program, i.e. Code: #ifdef DEBUG printf(" %d 'Sorter Action' data files are created successfully\n", numOfFiles); printf("%s: Complete retrieving 'Sorter Action' Information\n", GetCurrDateTime(currDateTime)); #endif So you'll find it wherever you find this output. If the process is not running in a terminal and using stdout for the printf statements then try redirecting the output to a file, then you can look in the file. Of course, it may not be displaying the debug if DEBUG is not defined. To check this try Code: #ifdef DEBUG printf("Debug is enabled\n"); #else printf("Debug is not enabled\n"); #endif at the top of the program.
Dear Expert, Code: #ifdef DEBUG printf("%s: Start to retrieve 'Create' Information\n", GetCurrDateTime(currDateTime)); printf(" Start Date [%s] ~ End Date [%s]\n", startDate, endDate); #endif should i create a function that call the printf statement into the logfile. Im really stuck..i have no idea how to do this.. Lets say. Code: #ifdef DEBUG printf(" %d 'Sorter Action' data files are created successfully\n", numOfFiles); printf("%s: Complete retrieving 'Sorter Action' Information\n", GetCurrDateTime(currDateTime)); #endif should i put fprintf statement so that ,it goes into the logfile?
Code: #ifdef DEBUG printf("%s: Start to retrieve Sorter Action Information\n", GetCurrDateTime(currDateTime)); fprintf(stdout,"%s: Start to retrieve Sorter Action Information\n", GetCurrDateTime(currDateTime ); printf(" Start Date [%s] ~ End Date [%s]\n", startDate, endDate); fprintf (stdout," Start Date [%s] ~ End Date [%s]\n", startDate, endDate ); #endif I dont knoe im rite or not
Code: I had change the code and and put fprintf as below [CODE] printf("indexOfComp=%d, compQty=%d\n", indexOfComp, compQty); fprintf(fp,"indexOfComp=%d, compQty=%d\n", indexOfComp, compQty); printf("inHouseScribeArray[indexOfComp]='%s' length=%d\n",inHouseScribeArray[indexOfComp],strlen(inHouseScribeArray[indexOfComp])); fprintf(fp,"inHouseScribeArray[indexOfComp]='%s' length=%d\n",inHouseScribeArray[indexOfComp],strlen(inHouseScribeArray[indexOfComp])); fclose(fp); inHouseScribeArray[indexOfComp]='' length=0 indexOfComp=25, compQty=25 inHouseScribeArray[indexOfComp]='' length=0 indexOfComp=25, compQty=25 inHouseScribeArray[indexOfComp]='' length=0[/CODE] its become blank...im not sure why its become blank ...Anything wrong ...
The output when i check back in log file,the length is 0 ,no wonder it jump to the second function... Why that so?any idea
Code: indexOfComp=25, compQty=25 inHouseScribeArray[indexOfComp]='' length=0 origSlotArray[indexOfComp]='ú' length=1 origCassArray[indexOfComp]='ÿó°ï@ÂÈ20' length=9 finalCassArray[indexOfComp]='' length=0 vendorScribeArray[indexOfComp]='7Ò' length=3 finalSlotArray[indexOfComp]='' length=0 I had fprint all the values and the result as above.. Why some of the values is like above.. Kindly help..cuz im passing down the array