How to block Part on The Fly from Sales Order Entry.

Create a BPM on the SalesOrder.ChangePartNumMaster method, this method is called when the user enters/amends a Part Number on a line of the Sales Order.

Pre-Processing as we want to check/block if the Part is not present in the Part Table

Add an action “synchronously execute ABL code … record nothing”

Click on the blue “code” word in the phrase and the ABL action screen appears

Enter the code required to get the current ttOrderDtl record then get the Part record based on the variable “partNum” that is passed into the method call. If the Part record does not exist then show a suitable error message

Here is the code from the BPM:-

find first ttOrderDtl where ttOrderDtl.RowMod = “A” or ttOrderDtl.RowMod = “U” no-lock no-error.

if avail (ttOrderDtl) then do:

   find first Part where Part.Company = ttOrderDtl.Company

                     and Part.PartNum = partNum no-lock no-error.

   if not avail (Part) then do:

      {lib/PublishEx.i

           &ExMethod = ‘ChangePartNumMaster’

           &ExTable  = ‘OrderDtl’

           &ExMsg    = “‘ERROR – Part On The Fly is not allowed, use the Button to search for a Part – BPM'”}

   end.

end.

Click the Validate button and if any errors occur then amend the code and try again. Save the action and the BPM

Then test the change on a new line or amend an existing line, the error should appear