We’re attempting to automate some of our Customer Service ( repair/upgrade ) functions. One of these is the Start Job Production Activity in MES.
I’ve got a Customization which calls the attached code, but always runs into the same error :
Error Detail
============
Description: Labor cannot be reported to a non-location resource.
The error is from adapterLabor.Update(). I commented out that line to be certain, and when that line is commented out, the error does not occur ( also, of course, the database is not updated ).
I checked Resource Groups, and the ResourceGrpID “Depot” is a Location ResourceGrpID. Which it would have to be, as that is what is used to process repairs/upgrades via MES.
The calls to set fields in the block ending with RowMod = “U” are there for testing. The JobNum is correct; this is Active for my employee ID in MES. These lines are set with specific values for testing; if/when the data can be updated for this record, I’ll test some others and then go to work on setting those values automatically.
I’ve done some debugging, and found that the calls to set fields in the block ending with RowMod = “U” do run; I checked several of those fields before and after those calls and the values do change to those set in the calls. I initially had only the first of those calls ( JobNum), then added the rest one at a time to see if I could get past the error. No luck; the error still occurs.
The lack of documentation of the Adapter Methods is the reason for the guesswork in trying to use the adapter.
The LaborDtlSeq value does correctly increment for the new LaborDtl row, but since the new row doesn’t get written, it keeps incrementing to the same value. I tried adding a new LaborDtl row to this Job via MES; that new row used the LaborDtlSeq that was coming up from the procedure, and the procedure then incremented to the next value on the next run.
Not sure where to look from here. I haven’t been able to find anything useful in the Trace logs, even when the MES Trace log has more than just Trace Log packets.
Any ideas, or experiences similar to this ?
Thanks,
Ken Brunelli
private void StartJobProductionActivityMES()
{
try
{
// Declare and Initialize EpiDataView Variables
EpiDataView edv_WIP_Status = ((EpiDataView)(this.oTrans.EpiDataViews["edv_WIP_Status"]));
EpiDataView edv_WIP_ActiveTrans = ((EpiDataView)(this.oTrans.EpiDataViews["edv_WIP_ActiveTrans"]));
// Check if valid EpiDataView Row(s) are selected
if ((edv_WIP_Status.Row < 0)) { return; }
if ((edv_WIP_ActiveTrans.Row < 0)) { return; }
// Declare and create an instance of the Adapter.
LaborAdapter adapterLabor = new LaborAdapter(this.oTrans);
adapterLabor.BOConnect();
// Declare and Initialize Variables
string stringId = ((string)(edv_WIP_Status.dataView[edv_WIP_Status.Row]["UD07_ShortChar02"]));
string stringEmployeeNum = ((string)(edv_WIP_ActiveTrans.dataView[edv_WIP_ActiveTrans.Row]["LaborHed_EmployeeNum"]));
Int32 integerLaborHedSeq = ((Int32)(edv_WIP_ActiveTrans.dataView[edv_WIP_ActiveTrans.Row]["LaborHed_LaborHedSeq"]));
// Call Adapter methods - Labor
adapterLabor.GetByID(integerLaborHedSeq);
bool resultGetNewLaborDtl = adapterLabor.GetNewLaborDtl(integerLaborHedSeq);
adapterLabor.LaborData.LaborDtl[ ( adapterLabor.LaborData.LaborDtl.Count - 1 ) ].JobNum = "4652";
adapterLabor.LaborData.LaborDtl[ ( adapterLabor.LaborData.LaborDtl.Count - 1 ) ].OprSeq = 10;
adapterLabor.LaborData.LaborDtl[ ( adapterLabor.LaborData.LaborDtl.Count - 1 ) ].OpCode = "DptRepar";
adapterLabor.LaborData.LaborDtl[ ( adapterLabor.LaborData.LaborDtl.Count - 1 ) ].ResourceID = "Depot";
adapterLabor.LaborData.LaborDtl[ ( adapterLabor.LaborData.LaborDtl.Count - 1 ) ].ResourceGrpID = "Depot";
adapterLabor.LaborData.LaborDtl[ ( adapterLabor.LaborData.LaborDtl.Count - 1 ) ].TimeStatus = "A";
adapterLabor.LaborData.LaborDtl[ ( adapterLabor.LaborData.LaborDtl.Count - 1 ) ].EmployeeNum = "kb01";
adapterLabor.LaborData.LaborDtl[ ( adapterLabor.LaborData.LaborDtl.Count - 1 ) ].LaborType = "P";
adapterLabor.LaborData.LaborDtl[ ( adapterLabor.LaborData.LaborDtl.Count - 1 ) ].LaborTypePseudo = "P";
adapterLabor.LaborData.LaborDtl[ ( adapterLabor.LaborData.LaborDtl.Count - 1 ) ].Shift = 1;
adapterLabor.LaborData.LaborHed[ 0 ].RowMod = "U";
bool resultLaborUpdate = adapterLabor.Update();
// Cleanup Adapter Reference
adapterLabor.Dispose();
} catch (System.Exception ex)
{
ExceptionBox.Show(ex);
}
}