Examples: Setting up a ProductionOrder BOD generation to run in the background

The Replication Document Outbound Cross References form includes three provided definitions for generating ProductionOrder BODs from the application. The definitions have different methods and filters. The methods are:

  • TriggerProductionOrderSyncSp - include all production orders
  • TriggerProductionOrderBGSyncSp - include all production orders just scheduled
  • TriggerProductionOrderBGSchSyncSp - include all production orders that have changed.

The definitions with "BG" in the method name can be run as background tasks. These sample definitions do not include filtering criteria for the date range; you can add date filters after the first time the background task is run, when a date appears in the Last Manual Publish Date.

Example 1

Using the definition containing the method TriggerProductionOrderBGSyncSp and the filters below, all newly created jobs are updated after planning or schedule run. The filter obtains the ProductionOrder after the first schedule update. The job was entered with dates. The planner runs for the first time and updates start and end dates.

Use this combination of filters to limit the Production Order records:

  • Filter for firm jobs only; this picks up schedule changes:

    Status = 'Firm'

    You could also filter for released jobs only to pick up material and labor changes for actual reporting.

  • Filter for any records that have changed since the last time the background task was run:

    RecordDate > dbo.GetReplDocLastManualPublishDate('SP!', 'Invoke', 'TriggerProductionOrderBGSyncSp')

  • Filter for jobs that have been created (jobs in firm status) that have not previously been scheduled:

    CreateDate > dbo.GetReplDocLastManualPublishDate('SP!', 'Invoke', 'TriggerProductionOrderBGSyncSp')

  • You can add a filter for certain items:

    Item BETWEEN 'item number' AND 'item number' AND NOT Item = 'item number'

  • You can add a filter for certain product codes:

    Product_code IN ('Product_code1','Product_code2')

Example 2

The definition containing the TriggerProductionOrderBGSchSyncSp method can use the filters below, which are specific to a scheduled change within a time fence determined by the user (a planning window of one month in the past and one month in the future).

  • Filter for firm jobs only; this picks up schedule changes:

    Status = 'Firm'

  • Filter for any records changed since the last time the background task was run:

    RecordDate > dbo.GetReplDocLastManualPublishDate('SP!', 'Invoke', 'TriggerProductionOrderBGSchSyncSp')

  • You also filter for jobs that have been changed since the last ProductionOrder scheduled start date or since the current scheduled start date within the time fence:

    MONTH(StartDate) BETWEEN MONTH(GETDATE() - 1) AND (MONTH(GETDATE())+ 1) OR MONTH(LastStartDate) BETWEEN MONTH(GETDATE() - 1) AND (MONTH(GETDATE()) + 1)

  • You can add a filter for certain items:

    Item BETWEEN 'item number' AND 'item number' AND NOT Item = 'item number'

  • You can also add a filter for certain product codes:

    ProductCode IN ('Product_code1','Product_code2')

  • You can add a filter to not create BODs that were created in the first scheduled run:

    CreateDate < dbo.GetReplDocLastManualPublishDate('SP!', 'Invoke', 'TriggerProductionOrderBGSyncSp')