Expand|Select|Wrap|Line Numbers
- *
- *
- * Function Name : int Generate_PR_Report
- * Program:
- * Purpose: -Gather data on problematic lot and put into the log file for user
- reference.
- ********************************************************************************/
- 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);
- }
- if (strlen (inHouseScribeArray[indexOfComp]) == 0)
- {
- return ;
- }
- 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;
- NOTFOUND:
- skipLotCntr++;
- #ifdef DEBUG
- printf(" #%d lot is skipped\n", skipLotCntr);
- #endif
- ;
- }
- }
- /* Close cursor */
- EXEC SQL CLOSE wsSaCursor1;
- return(numOfFiles);
- } /* Generate_PR_Report */
Need help ...
Expand|Select|Wrap|Line Numbers
- if (strlen (inHouseScribeArray[indexOfComp]) == 0)
- {
- return ;
- }
- else
- {
- Write_PR_DataFile(startDate, endDate, action, lot, operation, subOperation,
- actualQty, eqpId, device, tech, toTime, employee, origSlotArray,
- origCassArray, inHouseScribeArray, vendorScribeArray, finalSlotArray,
- finalCassArray, parms);