AddLabor Method
- Last UpdatedNov 06, 2025
- 4 minute read
'Declaration
Public Shared Sub AddLabor( _
ByVal sessionId As Integer, _
ByVal userId As String, _
ByVal entId As Integer, _
ByVal duration As Integer, _
ByVal laborStart As Nullable(Of Date), _
ByVal woId As DBString, _
ByVal operId As DBString, _
ByVal seqNo As DBInt, _
ByVal stepNo As DBInt, _
ByVal itemId As DBString, _
ByVal lotNo As DBString, _
ByVal subLotNo As DBString, _
ByVal labCd As String, _
ByVal deptId As String, _
ByVal shiftId As Nullable(Of Integer), _
ByVal shiftStart As Nullable(Of Date), _
ByVal pctToApply As Nullable(Of Double), _
ByVal active As Nullable(Of Boolean), _
ByVal comments As DBString, _
ByVal rawReasCd As DBString, _
ByVal lastEditComment As DBString _
)
'Usage
Dim sessionId As Integer
Dim userId As String
Dim entId As Integer
Dim duration As Integer
Dim laborStart As Nullable(Of Date)
Dim woId As DBString
Dim operId As DBString
Dim seqNo As DBInt
Dim stepNo As DBInt
Dim itemId As DBString
Dim lotNo As DBString
Dim subLotNo As DBString
Dim labCd As String
Dim deptId As String
Dim shiftId As Nullable(Of Integer)
Dim shiftStart As Nullable(Of Date)
Dim pctToApply As Nullable(Of Double)
Dim active As Nullable(Of Boolean)
Dim comments As DBString
Dim rawReasCd As DBString
Dim lastEditComment As DBString
LaborExec.AddLabor(sessionId, userId, entId, duration, laborStart, woId, operId, seqNo, stepNo, itemId, lotNo, subLotNo, labCd, deptId, shiftId, shiftStart, pctToApply, active, comments, rawReasCd, lastEditComment)
public static void AddLabor(
int sessionId,
string userId,
int entId,
int duration,
Nullable<DateTime> laborStart,
DBString woId,
DBString operId,
DBInt seqNo,
DBInt stepNo,
DBString itemId,
DBString lotNo,
DBString subLotNo,
string labCd,
string deptId,
Nullable<int> shiftId,
Nullable<DateTime> shiftStart,
Nullable<double> pctToApply,
Nullable<bool> active,
DBString comments,
DBString rawReasCd,
DBString lastEditComment
)
Parameters
- sessionId
- Required. Holds the session ID and thus the user who is making this method call.
- userId
- Required. Holds the ID of the user whose labor time is being accounted for.
- entId
- Required. Holds the ID of the entity for which the labor time is being added.
- duration
- Required. Holds the duration of labor, in seconds.
- laborStart
- Optional. Holds the labor start time for the shift during which the labor was performed.
- woId
- Optional. Holds the ID of the work order on which the labor was performed.
- operId
- Optional. Holds the ID of the operation on which the labor was performed.
- seqNo
- Optional. Holds the sequence number of the the operation on which the labor was performed.
- stepNo
- Optional. Holds the step number of the job on which the labor was performed.
- itemId
- Optional. Holds the ID of the item on which the labor was performed.
- lotNo
- Optional. Holds the number of the lot on which the labor was performed.
- subLotNo
- Optional. Holds the number of the sublot on which the labor was performed.
- labCd
- Optional. Holds the code of the labor category to be applied for this duration.
- deptId
- Optional. Holds the ID of the department to be applied for this duration.
- shiftId
- Optional. Holds the ID of the shift during which the labor was performed. Defaults to the current shift that is running on this entity.
- shiftStart
- Optional. Holds the shift start time for the shift during which the labor was performed. Defaults to the current shift start time that is running on this entity.
- pctToApply
- Optional. Holds the percentage split of labor for this duration.
- active
- Optional. Holds a flag that, if set to true, specifies that this duration of labor is currently active.
- comments
- Optional. Holds the comments to be added for this labor transaction.
- rawReasCd
- Optional. Holds the raw reason code to be applied for this labor transaction.
- lastEditComment
- Optional. Holds comments for this labor transaction.
Observe the following input parameter rules:
- Required non-DB* parameters: Must pass a value. Cannot be empty or null.
- Optional non-DB* parameters: Either enter a value or pass a null. If passing a null and a default value has been defined, the default value will be used for the parameter.
- Required DB* parameters: Must pass a value. To enter an empty value for the parameter, pass DB*.null (e.g., DBInt.null).
- Optional DB* parameters: To enter no value for the parameter, pass DB*.null (e.g., DBInt.null). To use the default value for the parameter if one has been defined for the object being added, pass a null.
This method first verifies that a non-null value is being passed or a default value exists for the following: ent_id, user_id, duration, ent_id, labor_cd and dept_id. Otherwise, the method will fail.
If the supplied shift ID or the shift start time is null, then the current shift ID and the current shift start time for that entity is used to create a new labor record. Also, if the supplied labor code or the department ID is null, then the Middleware looks at the supplied user’s default labor code and the user’s default department ID from the User_Name table. If such values are not found from the user’s defaults, then the Middleware looks for the default values from the entity. If no such values are found, then the method will fail.
If the supplied work order ID (wo_id) or the operation ID (oper_id) is null, then the current job that is running on the entity at job position 0 is used to create this new labor record. Additionally, if the supplied item_id is null, then the item_id is retrieved from the identified job record if the identified job is a valid job in the database.
If the supplied lot_no or the sublot_no is null, then the Middleware uses the default lot number (def_lot_no) and default sublot number (def_sublot_no) from the Job_Bom table to create a new labor_usage record.
Finally, a new labor_usage record is added to the database.
Note that this method does not adjust the other records to sum up the percentage to 100%.