Breakout to create a Manufacturing Requisition from an order

Discussions relating to breakout scripting, .NET and COM programming with Jiwa objects.

Breakout to create a Manufacturing Requisition from an order

Postby Mike.Sheen » Tue Nov 11, 2008 11:55 am

This breakout will create a MR for a BOM item when the quantity on the order causes a backorder.

The user gets asked if they want to create an MR, and if so, it creates the MR, activates it and then refreshes the sales order quantity to grab the newly created stock.

If there isn't enough components to build the MR, it changes the Bill Production to "Allocate to BO", and informs the user it could not build everything.

Just copy and paste the code below into the Sales Order Line Changed breakout.

Code: Select all
' Sales Order Line Changed Breakout
' =================================
Dim hwndRead
Dim sSQL
Dim Quantity
Dim oBoM
Dim RecID

If InHere = True Then
   Exit Sub
End If

InHere = True

If UCase(FieldName) = "QUANTITYTHISDELIVERY" Then

   If SalesOrderLineObject.QuantityBackOrdered > 0 Then
      RecID = ""
      With SalesOrderObject.Database
         sSQL = "SELECT RecID FROM BO_Main Where InventoryID = " & .FormatChar(SalesOrderLineObject.InventoryID)
         hwndRead = .StatementOpen(CInt(.ConnectionJiwaRead2), False, "", 1)
      
         If .ExecuteSelect(CInt(hwndRead), sSQL, True) = True Then
             If .FetchRow(CInt(hwndRead)) = True Then
                RecID = .GetData(CInt(hwndRead), 1)
             End If
         End If
         .StatementClose(CInt(hwndRead))
      End With

      If Trim(RecID) <> "" Then
         If MsgBox("Do you wish to create a manufacturing requisition for this product?",vbQuestion + vbYesNo) = vbYes Then
             CreateManufacturingRequistion SalesOrderObject.Database, SalesOrderLineObject.InventoryID, SalesOrderLineObject.QuantityBackOrdered
             SalesOrderLineObject.QuantityOrdered = SalesOrderLineObject.QuantityOrdered
          End If
      End If
   End If
End If

InHere = False

End Sub

Dim InHere
InHere = False

Public Sub CreateManufacturingRequistion(DatabaseObject, BillInventoryID, QuantityRequired)
Dim MRObject
Dim FinishedGoodItem
Dim BOMainObject
Dim MRHasBackOrders
   
    Set MRObject = CreateObject("JiwaBOM.clsBoBuild")
    Set MRObject.Database = DatabaseObject
   
    Set FinishedGoodItem = CreateObject("JiwaBOM.clsBoBuildLine")
       
    Set FinishedGoodItem = MRObject.m_Lines(MRObject.AddItemNoObject(BillInventoryID))
   
    FinishedGoodItem.QtyToBuild = QuantityRequired
   
    Set BOMainObject = FinishedGoodItem.m_oBoMs(1)
   
    If BOMainObject.QtyBackOrdered > 0 Then
        Rem There is stuff on backorder
        MRHasBackOrders = True
        MRObject.BillProduction = 3 Rem eumBoMBuildBillProductionOption_AllocBO
    Else
        MRHasBackOrders = False
        MRObject.BillProduction = 0 Rem eumBoMBuildBillProductionOption_BuildBill
    End If
   
    MRObject.Status = 1 Rem eumBoMBuildActivated
   
    If MRObject.SaveRecord = False Then
        MsgBox "An error occured creating the requisition : " & MRObject.errormessage
    Else
        If MRHasBackOrders = True Then
            MsgBox "Requisition No. " & MRObject.BatchNo & " created, but with backorders - not all required items could be built, as components are on backorder."
        Else
            MsgBox "Requisition No. " & MRObject.BatchNo & " created."
        End If
    End If
   
    MRObject.CleanUp
    Set MRObject = Nothing
       
End Sub
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Return to Technical / Programming

Who is online

Users browsing this forum: No registered users and 7 guests

cron