InsertPastProduction(Int32,String,String,String,DateTime,Double,Nullable<Int32>,String,String,String,String,String,String,String,Nullable<Boolean>,Nullable<Boolean>,String,Nullable<Int32>,Nullable<Boolean>,String,String,String,String,DBString,DBString,DBString,DBString,DBString,DBString,DBString,DBString,DBString,DBString,DBString,DBString,DBString,DBString) Method
- Last UpdatedNov 06, 2025
- 7 minute read
The InsertPastProduction() method adds a past production data record to the Item_Prod table.
This overload of the method uses the entity name and site name to specify entities.
'Declaration
Public Overloads Shared Sub InsertPastProduction( _
ByVal sessionId As Integer, _
ByVal userId As String, _
ByVal entName As String, _
ByVal siteName As String, _
ByVal eventTime As Date, _
ByVal qtyProd As Double, _
ByVal reasCd As Nullable(Of Integer), _
ByVal lotNo As String, _
ByVal rmLotNo As String, _
ByVal subLotNo As String, _
ByVal rmSubLotNo As String, _
ByVal toEntName As String, _
ByVal toSiteName As String, _
ByVal itemId As String, _
ByVal processed As Nullable(Of Boolean), _
ByVal byproduct As Nullable(Of Boolean), _
ByVal extRef As String, _
ByVal moveStatus As Nullable(Of Integer), _
ByVal scalingFactor As Nullable(Of Boolean), _
ByVal genealogyId As String, _
ByVal eventId As String, _
ByVal segmentRequirementId As String, _
ByVal segmentResponseId As String, _
ByVal spare1 As DBString, _
ByVal spare2 As DBString, _
ByVal spare3 As DBString, _
ByVal spare4 As DBString, _
ByVal value1 As DBString, _
ByVal value2 As DBString, _
ByVal value3 As DBString, _
ByVal value4 As DBString, _
ByVal value5 As DBString, _
ByVal value6 As DBString, _
ByVal value7 As DBString, _
ByVal value8 As DBString, _
ByVal value9 As DBString, _
ByVal value10 As DBString _
)
'Usage
Dim sessionId As Integer
Dim userId As String
Dim entName As String
Dim siteName As String
Dim eventTime As Date
Dim qtyProd As Double
Dim reasCd As Nullable(Of Integer)
Dim lotNo As String
Dim rmLotNo As String
Dim subLotNo As String
Dim rmSubLotNo As String
Dim toEntName As String
Dim toSiteName As String
Dim itemId As String
Dim processed As Nullable(Of Boolean)
Dim byproduct As Nullable(Of Boolean)
Dim extRef As String
Dim moveStatus As Nullable(Of Integer)
Dim scalingFactor As Nullable(Of Boolean)
Dim genealogyId As String
Dim eventId As String
Dim segmentRequirementId As String
Dim segmentResponseId As String
Dim spare1 As DBString
Dim spare2 As DBString
Dim spare3 As DBString
Dim spare4 As DBString
Dim value1 As DBString
Dim value2 As DBString
Dim value3 As DBString
Dim value4 As DBString
Dim value5 As DBString
Dim value6 As DBString
Dim value7 As DBString
Dim value8 As DBString
Dim value9 As DBString
Dim value10 As DBString
JobExec.InsertPastProduction(sessionId, userId, entName, siteName, eventTime, qtyProd, reasCd, lotNo, rmLotNo, subLotNo, rmSubLotNo, toEntName, toSiteName, itemId, processed, byproduct, extRef, moveStatus, scalingFactor, genealogyId, eventId, segmentRequirementId, segmentResponseId, spare1, spare2, spare3, spare4, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10)
public static void InsertPastProduction(
int sessionId,
string userId,
string entName,
string siteName,
DateTime eventTime,
double qtyProd,
Nullable<int> reasCd,
string lotNo,
string rmLotNo,
string subLotNo,
string rmSubLotNo,
string toEntName,
string toSiteName,
string itemId,
Nullable<bool> processed,
Nullable<bool> byproduct,
string extRef,
Nullable<int> moveStatus,
Nullable<bool> scalingFactor,
string genealogyId,
string eventId,
string segmentRequirementId,
string segmentResponseId,
DBString spare1,
DBString spare2,
DBString spare3,
DBString spare4,
DBString value1,
DBString value2,
DBString value3,
DBString value4,
DBString value5,
DBString value6,
DBString value7,
DBString value8,
DBString value9,
DBString value10
)
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 who is adding this production data in the past time.
- entName
- Required. Holds the name of the entity where the job was run.
- siteName
- Optional. Holds the site name for this entity.
- eventTime
- Required. Holds the past date/time for this production event.
- qtyProd
- Required. Holds the production quantity to be added to this job.
- reasCd
- Optional. Holds the item reason code for this quantity produced (production code or reject production).
- lotNo
- Optional. Holds the lot number for this quantity produced.
- rmLotNo
- Optional. Holds the raw material lot number from which this lot was produced.
- subLotNo
- Optional. Holds the sublot number for this quantity produced.
- rmSubLotNo
- Optional. Holds the raw material sublot number from which this sublot was produced.
- toEntName
- Optional. Holds the name of the storage entity for this quantity produced.
- toSiteName
- Optional. Holds the site name of the storage entity for this quantity produced.
- itemId
- Optional. Holds the ID of the item being produced.
- processed
- Optional. Holds a flag that, if set to true, specifies that the lot is processed.
- byproduct
- Optional. Holds a flag that, if set to true, specifies that this item is a main production item; true if by by-product.
- extRef
- Optional. Holds the reference to the external system to track defects.
- moveStatus
- Optional. Holds a flag that, if set to true, specifies that the lot has been moved to the next operation.
- scalingFactor
- Optional. Holds a flag that, if set to true, specifies that the scaling factor be applied. Default is false.
- genealogyId
- Optional. Holds the genealogy ID (for S95).
- eventId
- Optional. Holds the event ID (for S95).
- segmentRequirementId
- Optional. Holds the segment requirement ID (for S95).
- segmentResponseId
- Optional. Holds the segment response ID (for S95).
- 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.
- value1
- Optional. Holds a value for the value1 column in the Job_Event table.
- value2
- Optional. Holds a value for the value2 column in the Job_Event table.
- value3
- Optional. Holds a value for the value3 column in the Job_Event table.
- value4
- Optional. Holds a value for the value4 column in the Job_Event table.
- value5
- Optional. Holds a value for the value5 column in the Job_Event table.
- value6
- Optional. Holds a value for the value6 column in the Job_Event table.
- value7
- Optional. Holds a value for the value7 column in the Job_Event table.
- value8
- Optional. Holds a value for the value8 column in the Job_Event table.
- value9
- Optional. Holds a value for the value9 column in the Job_Event table.
- value10
- Optional. Holds a value for the value10 column in the Job_Event table.
The purpose of this method is to insert a past production data record into the Item_Prod table attributing the quantities to a job that was running at the supplied event time.
The supplied entity must capture utilization to retrieve the job that was running at that time. Thus, the job details of the job whose start time is immediately prior to the event UTC time (converted from the supplied local event time) are extracted from the Job_History table.
The item, default lot number, default sublot number, default production reason, and default storage entity are extracted from the configured defaults for the job that produces the item at BOM position 0 for any of the supplied parameters that contain a null value.
If the supplied scaling factor is turned on, then the scaling factor is applied by multiplying the supplied quantity with the default scaling factor configured for the job (job_bom.default_scaling_factor for bom_pos is 0).
The supplied quantity is added to an existing production data if and only if the existing row contains the supplied work order, operation, job sequence number, shift (retrieved from the Shift_History table), item, lot number, sublot number, production reason code, supplied user, and storage entity, unless the “maintain distinct reject production” system attribute (attr_id = 309) or the “maintain distinct good production” system attribute (attr_id = 362) are set to true. If no such row is found or the appropriate system attribute (attr_id =309 or attr_id = 362) is turned on, then a new production data is created.
If the supplied item is a serialized item, then the status in the Assigned_Lot table for this work order whose operation is null is set to Done, if the supplied job is the final job and a quantity of 1 is produced to this lot. The status in the Assigned_Lot table for this work order whose operation is null is set to Unstarted if the quantity for the supplied job is 0, if the work order in the assigned lot table is the supplied work order and whose operation is null in the Assigned_Lot table. The status in the Assigned_Lot table for this work order whose operation is null is set to In Process if the quantity for the supplied job totals 1, if the work order in the assigned lot table is the supplied work order and whose operation is null in the Assigned_Lot table. However, if the serial number is assigned for an item to be produced in a specific job, then the status is set to Unstarted if the total quantity produced for that job is 0; set to In Process if the total quantity produced is greater than 0, but less than 1; or set to Done if the total quantity produced is totals 1.
A new job event identifying this production event is recorded with the supplied values. The corresponding Job_Hour_History records for OEE and the quantities for this job are automatically updated. The item produced is always added to the inventory for non-serialized items and added if and only if the quantity has a next whole unit of production and the fractional pieces are not added to the inventory for serialized items. If backflush is turned on for this job (job.backflush is true), then the items that are configured to be consumed for this job are automatically consumed.
For the method to succeed, the following must be true:
- Multiple jobs were not run at the identified time, otherwise it would become ambiguous to attribute the quantity to a single job.
- There were jobs running at the identified time.
- There must be a default production reason code configured for the identified job or for the corresponding entity (in job_exec), and the default production reason code is found.
- The supplied reason code exists in the database.
- This job requires there must be enough quantities to be consumed before the production is added (job_bom.must_consume_before_prod is set to true), and there are.
- If the minimum quantity per parent item for the job (job_bom.min_qty_parent_item) contains a non-null value and the must_consume_before_prod for the job is turned on, the quantity consumed for this job is greater than or equal to this value.
- If the maximum quantity per parent item for the job (job_bom.max_qty_parent_item) contains a non-null value and the must_consume_before_prod for the job is turned on, the quantity consumed for this job is less than or equal to this value.