You are on page 1of 5

5/13/12 1.1.

Modeling the Enterprise

Oracle EBS - Supply Chain Management


Sample Code for OM APIs

Prev ConfluentMinds Solutions Next

OM APIs:

Create Order API


Create Delivery API
Update Shipping Attribute API
Pick Release Delivery API

Create Order API:


Declare
l_header_rec OE_ORDER_PUB.Header_Rec_Type;
l_line_tbl OE_ORDER_PUB.Line_Tbl_Type;
l_line_adj_tbl OE_ORDER_PUB.Line_Adj_Tbl_Type;
l_return_status varchar2(200);
l_msg_count number;
l_msg_data varchar2(20000);
l_header_val_rec OE_ORDER_PUB.Header_Val_Rec_Type;
l_Header_Adj_tbl OE_ORDER_PUB.Header_Adj_Tbl_Type;
l_Header_Adj_val_tbl OE_ORDER_PUB.Header_Adj_Val_Tbl_Type;
l_Header_price_Att_tbl OE_ORDER_PUB.Header_Price_Att_Tbl_Type;
l_Header_Adj_Att_tbl OE_ORDER_PUB.Header_Adj_Att_Tbl_Type;
l_Header_Adj_Assoc_tbl OE_ORDER_PUB.Header_Adj_Assoc_Tbl_Type;
l_Header_Scredit_tbl OE_ORDER_PUB.Header_Scredit_Tbl_Type;
l_Header_Scredit_val_tbl OE_ORDER_PUB.Header_Scredit_Val_Tbl_Type;
l_line_val_tbl OE_ORDER_PUB.Line_Val_Tbl_Type;

l_Line_Adj_val_tbl OE_ORDER_PUB.Line_Adj_Val_Tbl_Type;
l_Line_price_Att_tbl OE_ORDER_PUB.Line_Price_Att_Tbl_Type;
l_Line_Adj_Att_tbl OE_ORDER_PUB.Line_Adj_Att_Tbl_Type;
l_Line_Adj_Assoc_tbl OE_ORDER_PUB.Line_Adj_Assoc_Tbl_Type;
l_Line_Scredit_tbl OE_ORDER_PUB.Line_Scredit_Tbl_Type;
l_Line_Scredit_val_tbl OE_ORDER_PUB.Line_Scredit_Val_Tbl_Type;
l_Lot_Serial_tbl OE_ORDER_PUB.Lot_Serial_Tbl_Type;
l_Lot_Serial_val_tbl OE_ORDER_PUB.Lot_Serial_Val_Tbl_Type;
l_action_request_tbl OE_ORDER_PUB.Request_Tbl_Type;

Begin
fnd_global.apps_initialize(1318, 56229, 724);
l_header_rec := OE_ORDER_PUB.G_MISS_HEADER_REC; -- Required attributes (e.g. Order Type and Customer)
l_header_rec.order_type_id := 1437;
l_header_rec.sold_to_org_id := 1005;
l_header_rec.price_list_id := 1000;
l_header_rec.cust_po_number := 'me';
-- l_header_rec.freight_term_code = NULL;
l_header_rec.operation := OE_GLOBALS.G_OPR_CREATE;
-- FIRST LINE RECORD. Initialize record to missing
l_line_tbl(1) := OE_ORDER_PUB.G_MISS_LINE_REC;

l_line_tbl(1).inventory_item_id :=195 ;
l_line_tbl(1).ordered_quantity := 2;
l_line_tbl(1).operation := OE_GLOBALS.G_OPR_CREATE;
-- SECOND LINE RECORD
-- l_line_tbl(2) := OE_ORDER_PUB.G_MISS_LINE_REC;
-- l_line_tbl(2).inventory_item_id := 436;
-- l_line_tbl(2).ordered_quantity := 2;
-- -l_line_tbl(2).operation := OE_GLOBALS.G_OPR_CREATE;
/*
-- LINE ADJUSTMENT RECORD
www.confluentminds.com/Trainings/SCM/CodeSampleOMAPI.html 1/5
5/13/12 1.1. Modeling the Enterprise
-- LINE ADJUSTMENT RECORD
l_line_adj_tbl(1) := OE_ORDER_PUB.G_MISS_LINE_ADJ_REC;
l_line_adj_tbl(1).discount_id := 1;
l_line_adj_tbl(1).percent := 5;
l_line_adj_tbl(1).operation := OE_GLOBALS.G_OPR_CREATE;
-- Indicator that this adjustment belongs to the second line
l_line_adj_tbl(1).line_index := 2;
mun

-- LINE ADJUSTMENT RECORD


l_line_adj_tbl(1) := OE_ORDER_PUB.G_MISS_LINE_ADJ_REC;
l_line_adj_tbl(1).PRICE_ADJUSTMENT_ID := 196494;

l_line_adj_tbl(1).automatic_flag := 'N';
l_line_adj_tbl(1).operation := OE_GLOBALS.G_OPR_CREATE;
-- Indicator that this adjustment belongs to the second line
l_line_adj_tbl(1).line_index := 2;
*/

-- CALL TO PROCESS ORDER


OE_Order_PUB.Process_Order(
p_api_version_number=>1.0,
p_header_rec => l_header_rec,
p_line_tbl=> l_line_tbl,
p_line_adj_tbl=> l_line_adj_tbl,

-- OUT variables,
x_header_rec =>l_header_rec
, x_header_val_rec =>l_header_val_rec
, x_Header_Adj_tbl =>l_Header_Adj_tbl
, x_Header_Adj_val_tbl =>l_Header_Adj_val_tbl
, x_Header_price_Att_tbl =>l_Header_price_Att_tbl
, x_Header_Adj_Att_tbl =>l_Header_Adj_Att_tbl
, x_Header_Adj_Assoc_tbl =>l_Header_Adj_Assoc_tbl
, x_Header_Scredit_tbl =>l_Header_Scredit_tbl
, x_Header_Scredit_val_tbl=>l_Header_Scredit_val_tbl
, x_line_tbl =>l_line_tbl
, x_line_val_tbl =>l_line_val_tbl
, x_Line_Adj_tbl =>l_Line_Adj_tbl
, x_Line_Adj_val_tbl =>l_Line_Adj_val_tbl
, x_Line_price_Att_tbl =>l_Line_price_Att_tbl
, x_Line_Adj_Att_tbl =>l_Line_Adj_Att_tbl
, x_Line_Adj_Assoc_tbl =>l_Line_Adj_Assoc_tbl
, x_Line_Scredit_tbl =>l_Line_Scredit_tbl
, x_Line_Scredit_val_tbl =>l_Line_Scredit_val_tbl
, x_Lot_Serial_tbl =>l_Lot_Serial_tbl
, x_Lot_Serial_val_tbl =>l_Lot_Serial_val_tbl
, x_action_request_tbl =>l_action_request_tbl,
x_return_status=> l_return_status,
x_msg_count=> l_msg_count,
x_msg_data=> l_msg_data);
if l_msg_count > 0 then
for l_index in 1..l_msg_count loop
l_msg_data := oe_msg_pub.get(p_msg_index => l_index, p_encoded => 'F');
dbms_output.put_line('Order Failed.'||l_msg_data);
end loop;
end if;
-- Check the return status
if l_return_status = FND_API.G_RET_STS_SUCCESS then
dbms_output.put_line('Order..'||l_header_rec.order_number);
Else
dbms_output.put_line('Order Failed.');
end if;
www.confluentminds.com/Trainings/SCM/CodeSampleOMAPI.html 2/5
5/13/12 1.1. Modeling the Enterprise
end if;
End;
/

Create Delivery API :

declare
v_del_tab wsh_util_core.id_tab_type;
v_out_del_tab wsh_util_core.id_tab_type;

l_return_status varchar2(10);
l_msg_count NUMBER;
l_msg_data Varchar2(2000);
Begin
-- Initializing the application
FND_GLOBAL.APPS_INITIALIZE(user_id => 1318
,resp_id =>56229
,resp_appl_id =>724);

v_del_tab(1) := 214173;
--v_del_tab(2) := 225509;

wsh_delivery_details_pub.Autocreate_Deliveries( p_api_version_number => 1.0


, p_init_msg_list => FND_API.G_TRUE
, p_commit => FND_API.G_TRUE
, x_return_status => l_return_status
, x_msg_count => l_msg_count
, x_msg_data => l_msg_data
, p_line_rows => v_del_tab
, x_del_rows => v_out_del_tab
);

if l_msg_count > 0 then


for l_index in 1..l_msg_count loop
l_msg_data := oe_msg_pub.get(p_msg_index => l_index, p_encoded => 'F');
dbms_output.put_line('My msg.'||l_msg_data);
end loop;
end if;

dbms_output.put_line('Status : '||l_return_status);

if (l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) then


dbms_output.put_line(substr(l_msg_data,1,250));
else
dbms_output.put_line(v_out_del_tab(1));
end if;
commit;
END;
/

Update Shipping Attribute API:

DECLARE
l_return_status varchar2(10);

l_msg_count NUMBER;
l_msg_data Varchar2(2000);
l_trip_id varchar2(20);
l_trip_name varchar2(40);
source_code varchar2(40);

changed_attributes WSH_DELIVERY_DETAILS_PUB.ChangedAttributeTabType;
l_serialRangeTab WSH_DELIVERY_DETAILS_GRP.serialRangeTabType;
BEGIN
www.confluentminds.com/Trainings/SCM/CodeSampleOMAPI.html 3/5
5/13/12 1.1. Modeling the Enterprise
BEGIN
-- Initializing the application
FND_GLOBAL.APPS_INITIALIZE(user_id => 1318
,resp_id =>50578
,resp_appl_id =>201);

/* Values for updating delivery details to ship all quantities in the first line,
stage everything in the second line, and back order all in the third.
It is assumed that the user knows the quantities in each line. */

source_code := 'OE'; -- The only source code that should be used by the API
changed_attributes(1).delivery_detail_id := 225508;
changed_attributes(1).shipped_quantity := 1;
changed_attributes(2).delivery_detail_id := 225509;
changed_attributes(2).shipped_quantity := 2;

l_serialRangeTab(1).delivery_detail_id :=225508;
l_serialRangeTab(1).from_serial_number :='Dev10';
l_serialRangeTab(1).to_serial_number :='Dev10';
l_serialRangeTab(1).quantity :=1;

WSH_DELIVERY_DETAILS_PUB.Update_Shipping_Attributes( p_api_version_number => 1.0


, p_init_msg_list => FND_API.G_TRUE
, p_commit => FND_API.G_TRUE
, x_return_status => l_return_status
, x_msg_count => l_msg_count
, x_msg_data => l_msg_data
,p_changed_attributes => changed_attributes
,p_source_code => source_code
,p_serial_range_tab=>l_serialRangeTab);

dbms_output.put_line('Just to Check '||l_return_status);

if l_msg_count > 0 then


for l_index in 1..l_msg_count loop
l_msg_data := oe_msg_pub.get(p_msg_index => l_index, p_encoded => 'F');
dbms_output.put_line('My msg.'||l_msg_data);

end loop;
end if;

end;
/
Pick Release Delivery API:

DECLARE
l_return_status varchar2(10);
l_msg_count NUMBER;
l_msg_data Varchar2(2000);
l_trip_id varchar2(20);
l_trip_name varchar2(40);
v_status_msg_count NUMBER;
begin
-- Initializing the application
FND_GLOBAL.APPS_INITIALIZE(user_id => 1318
,resp_id =>56229
,resp_appl_id =>724);

WSH_DELIVERIES_PUB.Delivery_Action(
p_api_version_number => 1.0
, p_init_msg_list => FND_API.G_TRUE
, x_return_status => l_return_status
, x_msg_count => l_msg_count
, x_msg_data => l_msg_data
,p_action_code => 'PICK-RELEASE'
www.confluentminds.com/Trainings/SCM/CodeSampleOMAPI.html 4/5
5/13/12 1.1. Modeling the Enterprise
,p_action_code => 'PICK-RELEASE'
,p_delivery_id => 62892
,x_trip_id=>l_trip_id
,x_trip_name=>l_trip_name
);

dbms_output.put_line('Just to Check '||l_return_status);

v_status_msg_count := apps.fnd_msg_pub.count_msg;

FOR v_status_msg_num in 1..v_status_msg_count LOOP


apps.fnd_msg_pub.get(v_status_msg_num,apps.fnd_api.g_false,l_msg_data,v_status_msg_count);
dbms_output.put_line(l_msg_data);
END LOOP;

commit;

dbms_output.put_line('Trip Id '||l_trip_id);

end;
/

Copyright © 2000-2005 ConfluentMinds Pvt Ltd. All Rights Reserved. Unauthorized use, duplication or distribution is strictly prohibited. This is the
proprietary information of ConfluentMinds Pvt Ltd. Use is subject to license terms.

Prev Home Next


A Techno-functional Guide to Oracle Applications - Supply Chain Management.Your feedback please.

www.confluentminds.com/Trainings/SCM/CodeSampleOMAPI.html 5/5

You might also like