9 Future Cost

The Future Cost Engine calculates the expected cost of an item/supplier/origin country/location at a given point into the future. These values are used to help in many scenarios (for example, when trying to determine what a margin will be at a point in the future, or when doing investment buying).

The future cost engine can execute as either a synchronous, asynchronous or batch process. The focus of this chapter is the batch processes. To support the discussion of the batch processes, there is general discussion of the engine that is also applicable to the synchronous and asynchronous execution of the engine.

There are also two other programs that are referenced in this chapter related to cost - Pricing Cost Refresh and WAC Refresh. These are both used to refresh materialized views that are used by the WAC Variance report that is displayed by default on the Finance Analyst dashboard.

Future Cost Events

There are three basic events that drive recalculation of FUTURE_COST. They are supplier cost changes, deals, and estimated landed cost components. When these events are added or removed from Merchandising, they impact the calculated values on future cost. These transactions are known as primary events.

There are other events that determine if primary events still apply to a given item/supplier/origin country/location combination. They are reclassifications, merchandise hierarchy changes, organization hierarchy changes, cost zone location moves, item/cost zone changes, and supplier hierarchy changes. These are secondary events.

There are also two special events that cause new time lines to be created in FUTURE_COST. They are new item loc (when item/locations are ranged) and new item/supplier/country/location relationships (add and remove). These are initialization events.

The ITEM_LOC.PRIMARY_COST_PACK column plays a special roll in costing. When a primary costing pack is defined for an item, that item's costing values are based on the primary_costing_pack not the item itself. When a primary costing pack is added, changed, or removed, this is a primary pack event.

Table 9-1 Cost Events and Cost Event Types

Cost Event Cost Event Type

Supplier Cost Change

Primary

Deal

Primary

ELC Component

Primary

Reclassification

Secondary

Merchandise hierarchy

Secondary

Organization hierarchy

Secondary

Cost zone location moves

Secondary

Item/cost zone changes

Secondary

Supplier hierarchy

Secondary

New Item Location

Initialization

Item/supplier/country/location relationships

Initialization

Primary cost pack

Primary Pack

WF Cost Template

N/A

WF Cost Template Relationship

N/A

Deal Pass through

N/A

Future Cost Engine Run Type Configuration

The Future Cost Engine can be configured by cost event type in one of three ways:

  • Synchronous

  • Asynchronous

  • Batch

The method to be used by each cost event type is controlled by the configuration defined in the COST_EVENT_RUN_TYPE_CONFIG table.

Synchronous

When running in synchronous mode, the Future Cost Engine is run in the same transaction as the client that calls it. For example if the cost change event is configured to run in synchronous mode, the work done in the Future Cost Engine for the approval of a cost change runs in the same transaction as the flipping of the status of the cost change to ‘A' status. That means the user in the screen will have a busy cursor until the Future Cost Engine completes.

Cost event types with an EVENT_RUN_TYPE set to ‘SYNC' on COST_EVENT_RUN_TYPE_CONFIG will run in synchronous mode.

Figure 9-1 Future Cost Engine - SYNC Mode

Future Cost Engine Sync

Asynchronous

When running in asynchronous mode, the Future Cost Engine is run in a separate transaction than the client that calls it. For example if the cost change event is configured to run in asynchronous mode, the work done in the Future Cost Engine for the approval of a cost change runs in a different transaction as the flipping of the status of the cost change to ‘A' status. This means that control returns to the user in the screen while the Future Cost Engine runs in the background.

Cost event types with an EVENT_RUN_TYPE set to ‘ASYNC' on COST_EVENT_RUN_TYPE_CONFIG runs in asynchronous mode.

Figure 9-2 Future Cost Engine - ASYNC Mode

Future Cost Engine Async

Batch

When running in batch mode, the Future Cost Engine is run during the nightly batch run. For example if the cost change event is configured to run in batch mode, the work done in the Future Cost Engine for the approval of a cost change runs during the next batch run after the approval of the cost change.

Cost event types with an EVENT_RUN_TYPE set to ‘BATCH' on COST_EVENT_RUN_TYPE_CONFIG runs in batch mode.

The fcexec.pc batch program and its associated prepost pre job contain logic to run the Future Cost Engine in batch mode.

Figure 9-3 Future Cost Engine - Batch Mode

Future Cost Engine Batch

Future Cost Engine Concurrency Control

Concurrency control is handled in the Future Cost Engine by locking the FUTURE_COST table. The sole job of the Future Cost Engine is maintaining the FUTURE_COST table and its helper DEAL_ITEM_LOC_EXPLODE. The first step in processing is to lock the item/supplier/origin country/location combinations that the cost event covers (after the identification of item/supplier/origin country/location combinations and chunking has been done). If a lock cannot be obtained, another cost event is already processing some of the data that is required. When this occurs the Future Cost Engine stops processing and records the results accordingly and the cost event can be retried at a later time.

Future Cost Engine Error Handling

The COST_EVENT_RESULT table is used to track all runs of the Future Cost Engine whether or not they succeeded. The table records a cost event ID and thread ID, the result code, and any error message that may exist. A special screen is used to search/access the results

Future Cost Engine Threading/Chunking

The Future Cost Engine deals with large amounts of data. Its inputs can vary greatly in size. Its inputs can be one large driver or a group of smaller drivers.

In order to deal with this volume and variation in input a configurable threading/chunking mechanism is built into the Future Cost Engine.

When the transaction control is set to BATCH, the chunks are run in a threaded manner using the Pro*C batch program to coordinate execution.

Future Cost Process

Note:

This process focuses on batch runs of the future cost engine.

Figure 9-4 Future Cost Process

Future Cost Process
  • Administrators configure the system (COST_EVENT_RUN_TYPE) to define which cost events types will be processed synchronously, asynchronously or in batch. Configuration by cost event type also determines some threading and chunking parameters.

  • Merchandising transactions that should drive future cost recalculation write Cost Events (COST_EVENT and cost event type specific tables).

  • Future Cost Engine recalculates future cost

    Note:

    This process flow focuses on batch recalculations, but synchronous or asynchronous processes could easily be substituted in this step.

  • fcthreadexec.pc prepares threads for processing

  • fcexec.pc recalculates future cost and writes it the future cost table (FUTURE_COST)

  • Merchandising processes use future cost information to determine investment buy, margin, and so on.

  • fc_pricechg.pc performs special calculation of pricing cost for franchise locations

  • costeventprg.pc purges aged cost events from the working cost event tables.