AddConsPostExec(Int32,String,Double,Nullable<Int32>,String,String,Nullable<Int32>,Nullable<DateTime>,Nullable<Int32>,Nullable<Int32>,String,Nullable<Int32>,String,String,String,String,Nullable<Int32>,String,String,String,String,String,String,DBString,DBString,DBString,DBString,Nullable<Int32>) Method
- Last UpdatedNov 06, 2025
- 6 minute read
The AddConsPostExec() method enters consumption data for a given job, shift, production code, lot, and container in the consumption transaction table (Item_Cons) after the job has run on an entity. This method can add a new Item_Cons record or update an existing record.
This overload of the method uses the entity ID to identify entities specified for the method.
'Declaration
Public Overloads Shared Sub AddConsPostExec( _
ByVal sessionId As Integer, _
ByVal userId As String, _
ByVal qtyCons As Double, _
ByVal entId As Nullable(Of Integer), _
ByVal woId As String, _
ByVal operId As String, _
ByVal seqNo As Nullable(Of Integer), _
ByVal shiftStart As Nullable(Of Date), _
ByVal shiftId As Nullable(Of Integer), _
ByVal bomPos As Nullable(Of Integer), _
ByVal itemId As String, _
ByVal reasCd As Nullable(Of Integer), _
ByVal lotNo As String, _
ByVal fgLotNo As String, _
ByVal subLotNo As String, _
ByVal fgSubLotNo As String, _
ByVal fromEntId As Nullable(Of Integer), _
ByVal extRef As String, _
ByVal genealogyId As String, _
ByVal upstreamEventId As String, _
ByVal segmentRequirementId As String, _
ByVal segmentResponseId As String, _
ByVal comments As String, _
ByVal spare1 As DBString, _
ByVal spare2 As DBString, _
ByVal spare3 As DBString, _
ByVal spare4 As DBString, _
ByVal rowId As Nullable(Of Integer) _
)
'Usage
Dim sessionId As Integer
Dim userId As String
Dim qtyCons As Double
Dim entId As Nullable(Of Integer)
Dim woId As String
Dim operId As String
Dim seqNo As Nullable(Of Integer)
Dim shiftStart As Nullable(Of Date)
Dim shiftId As Nullable(Of Integer)
Dim bomPos As Nullable(Of Integer)
Dim itemId As String
Dim reasCd As Nullable(Of Integer)
Dim lotNo As String
Dim fgLotNo As String
Dim subLotNo As String
Dim fgSubLotNo As String
Dim fromEntId As Nullable(Of Integer)
Dim extRef As String
Dim genealogyId As String
Dim upstreamEventId As String
Dim segmentRequirementId As String
Dim segmentResponseId As String
Dim comments As String
Dim spare1 As DBString
Dim spare2 As DBString
Dim spare3 As DBString
Dim spare4 As DBString
Dim rowId As Nullable(Of Integer)
JobExec.AddConsPostExec(sessionId, userId, qtyCons, entId, woId, operId, seqNo, shiftStart, shiftId, bomPos, itemId, reasCd, lotNo, fgLotNo, subLotNo, fgSubLotNo, fromEntId, extRef, genealogyId, upstreamEventId, segmentRequirementId, segmentResponseId, comments, spare1, spare2, spare3, spare4, rowId)
public static void AddConsPostExec(
int sessionId,
string userId,
double qtyCons,
Nullable<int> entId,
string woId,
string operId,
Nullable<int> seqNo,
Nullable<DateTime> shiftStart,
Nullable<int> shiftId,
Nullable<int> bomPos,
string itemId,
Nullable<int> reasCd,
string lotNo,
string fgLotNo,
string subLotNo,
string fgSubLotNo,
Nullable<int> fromEntId,
string extRef,
string genealogyId,
string upstreamEventId,
string segmentRequirementId,
string segmentResponseId,
string comments,
DBString spare1,
DBString spare2,
DBString spare3,
DBString spare4,
Nullable<int> rowId
)
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 to whom to attribute consumption.
- qtyCons
- Required. Holds the quantity being consumed.
- entId
- Optional. Holds the ID of the entity.
- woId
- Optional. Holds the ID of the work order.
- operId
- Optional. Holds the ID of the operation.
- seqNo
- Optional. Holds the job sequence number.
- shiftStart
- Optional. Holds the shift start.
- shiftId
- Optional. Holds the ID of the shift on the entity.
- bomPos
- Optional. Holds the BOM position of the item being consumed.
- itemId
- Optional. Holds the ID of the item being consumed.
- reasCd
- Optional. Holds the reason code for item being consumed.
- lotNo
- Optional. Holds the lot number of the item being consumed.
- fgLotNo
- Optional. Holds the finished goods lot number of the item being consumed.
- subLotNo
- Optional. Holds the sublot number of the item being consumed.
- fgSubLotNo
- Optional. Holds the finished goods sublot number of the item being consumed.
- fromEntId
- Optional. Holds the ID of the storage entity.
- extRef
- Optional. Holds the external reference of the item being consumed.
- genealogyId
- Optional. Holds the genealogy ID (for S95).
- upstreamEventId
- Optional. Holds the upstream event ID (for S95).
- segmentRequirementId
- Optional. Holds the segment requirement ID (for S95).
- segmentResponseId
- Optional. Holds the segment response ID (for S95).
- comments
- Optional. Holds comments about the consumption that is being added.
- spare1
- Optional. Holds the contents of the user-defined spare1 field.
- spare2
- Optional. Holds the contents of the user-defined spare2 field.
- spare3
- Optional. Holds the contents of the user-defined spare3 field.
- spare4
- Optional. Holds the contents of the user-defined spare4 field.
- rowId
Optional. Holds the row ID of the record in the Item_Cons table to be updated. See Remarks below.
The low number of required parameters for this method are designed to facilitate capturing consumption data from the I/O system via tags as simply as possible.
Determining the Shift Start Time
To determine the shift_start_utc time for the new or updated record, the system first uses the supplied shiftStart value, converting the local time to UTC. If a shiftStart value is not supplied, then it uses the current shift's start time.
Determining Whether an Item_Cons Record Is Updated or Added
- If a matching Item_Cons record is found, that record is updated with the values supplied in the call.
- If a matching Item_Cons record is not found or the Maintain distinct consumption records system attribute is True, then a new record is created with the values supplied in the call.
A matching record is found based on either of the following conditions:
- The rowId is the actual primary key for the Item_Cons table. If a value for it is supplied and a matching record is found, then that record is updated with the other input parameter values supplied in the call.
- A rowId is not supplied or found but all of the supplied values for the following effective primary key fields match those of an existing Item_Cons record:
- shift_start_utc (determined as described above)
- wo_id (cannot be null)
- oper_id (cannot be null)
- seq_no (cannot be null)
- item_id (cannot be null)
- lot_no (can be null, but the existing record’s value must also be null)
- fg_lot_no (can be null, but the existing record’s value must also be null)
- sublot_no (can be null, but the existing record’s value must also be null)
- reas_cd (cannot be null)
- user_id (cannot be null)
- genealogy_id (can be null, but the existing record’s value must also be null)
- upstream_event_id (can be null, but the existing record’s value must also be null)
- segment_requirement_id (can be null, but the existing record’s value must also be null)
- segment_response_id (can be null, but the existing record’s value must also be null)
Other Behaviors of This Method
- If the work order details are not provided, they default to the current job running on the entity.
- If any of the lot, container, reason code, or entity values change, then these changes are written to the Job_Bom table and used as the defaults for future transactions where the defaults are to be applied.
- If the fg_lot_no column changes, then this change is remembered for the item being produced. This is as if the lot number was changed using the AddProd() or SetCurProdData() methods.
- If the update_inv flag is set for this BOM position, then the qty_left column in the Item_Inv record will be reduced by the consumed qty_cons.
Input Parameter Rules
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.