Document 135331.1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Copyright (c) 2024, Oracle. All rights reserved. Oracle Confidential.

MRP Forecast API - An Example (Doc ID 135331.1)

Open Forecast Entries Application Program Interface


OCT-2014 - New Example tested in EBS 12.1.3 is uploaded in file -
135331.1_forecast_api_REV1.xlsx. Go to the bottom of the Note to find link and
download the XLS

API description is valid for all releases 11.5.x - 12.2.x

The Open Forecast Entries Application Program Interface(API) allows you to create, replace, or delete forecast entries for
existing forecasts and forecast sets in Oracle Master Scheduling/MRP Note that you cannot update, only replace, so if
reloading a forecast with updates - such as adding more entries for the future - then all previous rows for that same
forecast name must also be uploaded again.

The purpose of this essay is to explain how to use the Open Forecast Entries API so that you can integrate other
applications with Oracle Master Scheduling/MRP. TheOpen Forecast Entries API differs from the Open Forecast Interface in
two ways:

There is tighter coupling between the calling interface and the MRP system.

It is used for synchronous actions on the forecasting data, and you can manipulate data within a commit cycle
controlled by the calling module.

This is achieved by the use of a PL/SQL table instead of a database table.

Functional Overview
You can process MRP Forecast Entries directly from within your calling module without running a concurrent process, it is
PL/SQL based. This program allows you to create new forecasts, replace existing forecasts, and delete forecast entries
within a defined forecast name or designator. The forecast data that needs to be imported is loaded from a table and
inserted into the MRP_FORECAST_DATES parameter.

Setting Up the Open Forecast Entries API


The Open Forecast Entries API is a stored PL/SQL function,
MRP_FORECAST_INTERFACE_PK.MRP_FORECAST_INTERFACE,with two parameters. One parameter is a PL/SQL
table structured the same as MRP_FORECAST_INTERFACE. The second parameter is a table defining the forecast and
organization.

Inserting into the Open Forecast Entries API Tables


You must load your forecast data into the T_FORECAST_INTERFACE PL/SQL table, and the FORECAST_DESIGNATOR
PL/SQL table.

Open Forecast Entries Application Program Interface PL/SQL Table Description

The Open Forecast Entries Application Program Interface PL/SQL table is described in the following table:

Table 7–3 Oracle Master Scheduling/MRP Open Forecast Entries API

T_FORECAST_INTERFACE Column Type Required Derived Optional


Name
INVENTORY_ITEM_ID Number X

FORECAST_DESIGNATOR Varchar2(10) X

ORGANIZATION_ID Number X

FORECAST_DATE Date X

LAST_UPDATE_DATE Number x

CREATION_DATE Date x

CREATED_BY Number x

LAST_UPDATE_LOGIN Number x x

QUANTITY Number x

PROCESS_STATUS Number x

CONFIDENCE_PRECENTAGE Number x

COMMENTS Varchar2(240) x

ERROR_MESSAGE Varchar2(240) X

REQUEST_ID Number X

PROGRAM_APPLICATION_ID Number X

PROGRAM_ID Number X

PROGRAM_UPDATE_DATE Date X
WORKDAY_CONTROL Number x

BUCKET_TYPE Number x

FORECAST_END_DATE Date x

TRANSACTION_ID Number x

SOURCE_CODE Varchar2(10) x

SOURCE_LINE_ID Number x

ATTRIBUTE1 - ATTRIBUTE15 Varchar2(150) x

PROJECT ID Number(15) x

TASK ID Number(15) x

LINE_ID Number(15) x

Open Forecast Interface Designator Table Description


The Open Forecast Interface Designator Table is described in the following table:
Table 7–4 Oracle Master Scheduling/MRP Open Forecast Interface Designator

T_FORECAST_DESIGNATOR Type Required Derived Optional


Column Name

ORGANIZATION_ID Number x

FORECAST_DESIGNATOR Varchar2(10) x

Legend

1: Multiple Period Forecast Entries only

Returns
True if successful.

False if failure.

Parameters

Name Type In/Out

T_FORECAST_INTERFACE Table of MRP_FORECAST_INTERFACE ROWTYPE In and Out

T_FORECAST_DESIGNATOR Table of User-defined record In


REC_FORECAST_DESG(Organization_id number,
Forecast DesignatorVarchar2( 10)

Required Data

ORGANIZATION_ID, FORECAST_DESIGNATOR, INVENTORY_ITEM_ID, FORECAST_DATE, and QUANTITY are used by the


Forecast Interface Entries program to create, replace, or delete forecast entries in T_FORECAST_INTERFACE. LINE ID
Number(15 x

PROCESS_STATUS indicates the current state of processing of each new forecast entry. Valid values include:

1 - Do not process

2 - Waiting to be processed

When you first load a new forecast entry into the Open Forecast Entries Interface, set PROCESS_STATUS to 2 (Waiting to
be processed). The values 3 (Being processed), 4 (Error), and 5 (Processed) are used to report back to the calling
program.

Derived Data

The concurrent program and WHO columns, along with the error message column, are derived and set by the API
accordingly.

Optional Data

Use WORKDAY_CONTROL to indicate the action that the Forecast Interface Entry should take if it finds a forecast date or
forecast end date that is not a valid workday. Enter one of the following:

1 - Reject

2 - Shift forward

3 - Shift backward

If WORKDAY_CONTROL is set to Null, the Forecast Interface Entry program assumes a value of 1 (Reject).

Use BUCKET_TYPE to indicate the bucket type of each new forecast entry. Enter one of the following:

1 - Days

2 - Weeks

3 - Periods

If BUCKET_TYPE is null, the Forecast Interface Load program assumes a value of 1 (Days).

Use FORECAST_END_DATE for forecast entries that span multiple periods.

Use TRANSACTION_ID if you wish to replace an existing entry in MRP_ FORECAST_DATES with a new forecast entry that
you have loaded into the Open Forecast Interface. The Forecast Interface Load deletes any existing entries in
MRP_FORECAST_DATES with the same TRANSACTION_ID before importing the newforecast entry.
Use SOURCE_CODE and SOURCE_LINE_ID to identify the source of new forecast entries.

See Also

Oracle Master Scheduling/MRP Technical Reference Manual

Validation
Standard Validation

Oracle Master Scheduling/MRP validates all required columns in the interface table. For specific information on the data
implied by these columns, see your Oracle Master Scheduling/MRP Reference Manual for details.

Other Validation

Oracle Open Forecast Entries Interface also performs the following validation:

INVENTORY_ITEM_ID Must be a valid item defined IN MTL_SYSTEM_ITEMS.

FORECAST_DESIGNATOR Must be a valid, non-disabled forecast name defined in MRP_FORECAST_DESIGNATORS.

ORGANIZATION_ID Must be a valid organization defined in ORG_ORGANIZATION_DEFINITIONS.

FORECAST_DATE Must be less than or equal to FORECAST_END_DATE if FORECAST_END_DATE is provided.

PROCESS_STATUS Must be one of:

1 - Do not process

2 - Waiting to be processed

FORECAST_END_DATE Must be greater than or equal to FORECAST_DATE. Must be greater than 0 and less than or
equal to 99999999.9.

FORECAST_QUANTITY Must be greater than 0 and less than or equal to 99999999.9.

WORKDAY_CONTROL Must be one of:

1 - Reject

2 - Shift forward

3 - Shift backward

BUCKET_TYPE Must be one of:

1 - Days

2 - Weeks

3 - Periods

TRANSACTION_ID If provided, TRANSACTION_ID must match an existing TRANSACTION_ID in


MRP_FORECAST_DATES.

Using the Open Forecast Entries API


Creating New Forecast Entries

Populate table T_FORECAST_INTERFACE with all the forecast data that needs to be imported. Set
PROCESS_STATUS to a value of 2 for all rows.

Call MRP_FORECAST_INTERFACE_PK.MRP_FORECAST_INTERFACE using parameter T_FORECAST_INTERFACE and


T_FORECAST_DESIGNATOR.

The Forecast Interface Entry program creates a new row in MRP_FORECAST_ITEMS for each new forecast entry
that refers to an item that has not beenassigned to the forecast referenced in the Open Forecast Interface.
The application program interface will process the rows and set the column PROCESS_STATUS to a value of either 4
or 5:

- 4 an error occurred, the column ERROR_MESSAGE will indicate the error

- 5 the row was inserted into MRP_FORECAST_DATES

Replacing Forecast Entries

Populate table T_FORECAST_INTERFACE with all the forecast data that needs to be imported. Set
PROCESS_STATUS to a value of 2 for all rows.

Populate table T_FORECAST_DESIGNATOR with all the forecast desIgnators for which entries need to be deleted.

Call MRP_FORECAST_INTERFACE_PK.MRP_FORECAST_INTERFACE with the following parameters:

FORECAST_INTERFACE, RECAST_DESIGNATOR.

The application program interface will delete the existing entries for each forecast designator in
T_FORECAST_DESIGNATOR. It will process the rows in T_FORECAST_INTERFACE and set the column
PROCESS_STATUS to a value of either 4 or 5:

- 4 an error occurred, the column ERROR_MESSAGEwill indicate the error

- 5 the row was inserted into MRP_FORECAST_DATES

Deleting All Forecast Entries in Multiple Forecast Designators

Populate table T_FORECAST_DESIGNATOR with all the forecast desIgnators for which entries need to be deleted.

Call MRP_FORECAST_INTERFACE_PK.MRP _FORECAST_INTERFACE

with parameter T_FORECAST_DESIGNATOR.

The application program interface will delete the existing entries for each forecast desIgnator in
T_FORECAST_DESIGNATOR.

Error Handling

The Open Forecast Entries Interface program will process the rows and report the following values for every record in the
FORECAST__INTERFACE entry table.

Condition PROCESS_STATUS ERROR_MESSAGE

Success 5 Null

Failure 4 actual error message

Example
Cut between the two /*=========*/ line and save this script in fcstapi.sql. Then launch the api with the corresponding
inventory_item_id, forecast_designator, quantities, and, forecast_dates.

/*=======================================================================*/

set serveroutput on

/**************************************************************************************************

EXAMPLE - Populating MRP_FORECAST_DATES tables using the MRP FORECAST API

**************************************************************************************************/

Declare
t_forecast_interface_tab MRP_FORECAST_INTERFACE_PK.t_forecast_interface;

t_forecast_designator_tab MRP_FORECAST_INTERFACE_PK.t_forecast_designator;

var_bool BOOLEAN;

begin

t_forecast_interface_tab(1).inventory_item_id := 3921;

t_forecast_interface_tab(1).forecast_designator := 'SK-FORECST';

t_forecast_interface_tab(1).organization_id := 207;

t_forecast_interface_tab(1).forecast_date := TO_DATE('12-FEB-01');

t_forecast_interface_tab(1).bucket_type := 2;

t_forecast_interface_tab(1).quantity := 100;

t_forecast_interface_tab(1).process_status := 2;

t_forecast_interface_tab(1).confidence_percentage := 100;

t_forecast_designator_tab(1).organization_id := 207;

t_forecast_designator_tab(1).forecast_designator := 'SK-FORECST';

t_forecast_interface_tab(2).inventory_item_id := 3921;

t_forecast_interface_tab(2).forecast_designator := 'SK-FORECST';

t_forecast_interface_tab(2).organization_id := 207;

t_forecast_interface_tab(2).forecast_date := TO_DATE('19-FEB-01');

t_forecast_interface_tab(2).bucket_type := 2;

t_forecast_interface_tab(2).quantity := 150;

t_forecast_interface_tab(2).process_status := 2;

t_forecast_interface_tab(2).confidence_percentage := 100;

t_forecast_designator_tab(2).organization_id := 207;

t_forecast_designator_tab(2).forecast_designator := 'SK-FORECST';

t_forecast_interface_tab(3).inventory_item_id := 3921;

t_forecast_interface_tab(3).forecast_designator := 'SK-FORECST';

t_forecast_interface_tab(3).organization_id := 207;

t_forecast_interface_tab(3).forecast_date := TO_DATE('26-FEB-01');

t_forecast_interface_tab(3).bucket_type := 2;

t_forecast_interface_tab(3).quantity := 200;

t_forecast_interface_tab(3).process_status := 2;

t_forecast_interface_tab(3).confidence_percentage := 100;

t_forecast_designator_tab(3).organization_id := 207;

t_forecast_designator_tab(3).forecast_designator := 'SK-FORECST';

var_bool := MRP_FORECAST_INTERFACE_PK.MRP_FORECAST_INTERFACE (t_forecast_interface_tab,

t_forecast_designator_tab);

dbms_output.put_line('Return Status = '||t_forecast_interface_tab(1).process_status);

dbms_output.put_line('Error Message = '||t_forecast_interface_tab(1).error_message);

commit;

end;

/*=======================================================================*/
You can verify the success by running the followin script, or by going to forecast entries screen.

SELECT concatenated_segments ITEM,

fct.inventory_item_id ITEM_ID,

decode(fct.bucket_type,

1,'Days',
2,'Weeks',

3,'Period') BUCKET,

decode(mtl.ato_forecast_control,

1,'Consume',

2,'Consume and Derive',

3,'None') FCST_CONTROL,

forecast_date FCST_DATE,

current_forecast_quantity CURQTY,

original_forecast_quantity ORIGQTY,

transaction_id TRAN_ID

FROM mrp_forecast_dates fct,

mtl_system_items_kfv mtl

WHERE fct.organization_id = &org_id

AND forecast_designator = '&forecast_name'

AND fct.inventory_item_id = mtl.inventory_item_id

AND fct.organization_id = mtl.organization_id

ORDER BY forecast_date;

ITEM ITEM_ID BUCKET FCST_CONTROL FCST_DATE CURQTY ORIGQTY TRAN_ID

-------------- ---------- ------ ------------------ --------- ---------- ---------- ----------

SK-TESTITEM01 3921 Weeks Consume and Derive 12-FEB-01 100 100 85525

SK-TESTITEM01 3921 Weeks Consume and Derive 19-FEB-01 150 150 85526

SK-TESTITEM01 3921 Weeks Consume and Derive 26-FEB-01 200 200 85527

*** *** *** ***


Didn't find what you are looking for?

You might also like