Showing posts with label Order Management. Show all posts
Showing posts with label Order Management. Show all posts

Friday, October 16, 2009

Order to Cash

This cycle starts with the order management module where the customer places their order. In this module, we check for the availability of items in the inventory module and if there are enough stock in inventory then the items are shipped to the customer along with the invoice which is processed in account receivables module. Later on, this information goes into cash management for reconciliation purpose and in order to complete the business cycle, these invoices are moved to the GL module. Finally after a review of these journey entries in GL module, they are auto posted in the respective accounts, thus ending the cycle.

Tuesday, July 28, 2009

Cancel lines in an Oracle Order

DECLARE
-- Cursor to get records which needs to be cancelled
CURSOR get_records
IS
SELECT ooha.order_number,ooha.header_id,ooha.org_id,
ooha.open_flag
FROM apps.oe_order_headers_all ooha,
apps.oe_transaction_types_all otta
WHERE 1=1
AND ooha.order_type_id = otta.transaction_type_id
AND ooha.OPEN_FLAG = 'Y'
AND OOHA.ORIG_SYS_DOCUMENT_REF IN ( '2Z24084147','2Z24061178','2Z24061722',
'2Z24062173','2Z24066635','2Z24069163',
'2Z24061213','2Z24166851')
-- Local Variables
l_num_user_id fnd_user.user_id%TYPE; l_chr_msg VARCHAR2(3000); f_log UTL_FILE.file_type; l_num_us_resp_id fnd_responsibility_vl.responsibility_id%TYPE; l_num_ca_resp_id fnd_responsibility_vl.responsibility_id%TYPE; l_num_resp_id fnd_responsibility_vl.responsibility_id%TYPE; l_num_resp_appl_id fnd_application.application_id%TYPE; apps_init_exp EXCEPTION; l_chr_msg_data VARCHAR2(2000) := NULL; l_num_msg_count NUMBER:=0; l_num_iMsgCntr NUMBER; l_chr_errdata VARCHAR2(2000) := NULL; l_num_msg_index_out NUMBER;
l_chr_errcode VARCHAR2(20) ; l_chr_errbuf VARCHAR2(4000);

-- Process Order API variables
l_api_version_number NUMBER := 1.0; l_init_msg_list VARCHAR2(240) := FND_API.G_FALSE; l_chr_return_values VARCHAR2(240) := FND_API.G_FALSE; x_return_status VARCHAR2(240); x_msg_count NUMBER;
x_msg_data VARCHAR2(240); l_header_rec OE_ORDER_PUB.Header_Rec_Type; x_header_rec OE_ORDER_PUB.Header_Rec_Type; x_header_val_rec OE_ORDER_PUB.Header_Val_Rec_Type; x_Header_Adj_tbl OE_ORDER_PUB.Header_Adj_Tbl_Type; x_Header_Adj_val_tbl OE_ORDER_PUB.Header_Adj_Val_Tbl_Type; x_Header_price_Att_tbl OE_ORDER_PUB.Header_Price_Att_Tbl_Type; x_Header_Adj_Att_tbl OE_ORDER_PUB.Header_Adj_Att_Tbl_Type; x_Header_Adj_Assoc_tbl OE_ORDER_PUB.Header_Adj_Assoc_Tbl_Type; x_Header_Scredit_tbl OE_ORDER_PUB.Header_Scredit_Tbl_Type; x_Header_Scredit_val_tbl OE_ORDER_PUB.Header_Scredit_Val_Tbl_Type; x_line_tbl OE_ORDER_PUB.Line_Tbl_Type; x_line_val_tbl OE_ORDER_PUB.Line_Val_Tbl_Type; x_Line_Adj_tbl OE_ORDER_PUB.Line_Adj_Tbl_Type; x_Line_Adj_val_tbl OE_ORDER_PUB.Line_Adj_Val_Tbl_Type; x_Line_price_Att_tbl OE_ORDER_PUB.Line_Price_Att_Tbl_Type; x_Line_Adj_Att_tbl OE_ORDER_PUB.Line_Adj_Att_Tbl_Type; x_Line_Adj_Assoc_tbl OE_ORDER_PUB.Line_Adj_Assoc_Tbl_Type; x_Line_Scredit_tbl OE_ORDER_PUB.Line_Scredit_Tbl_Type; x_Line_Scredit_val_tbl OE_ORDER_PUB.Line_Scredit_Val_Tbl_Type; x_Lot_Serial_tbl OE_ORDER_PUB.Lot_Serial_Tbl_Type; x_Lot_Serial_val_tbl OE_ORDER_PUB.Lot_Serial_Val_Tbl_Type; x_action_request_tbl OE_ORDER_PUB.Request_Tbl_Type;

BEGIN
fnd_global.apps.initialize (51690, 59145, 20044);

FOR rec_get IN cur_get LOOP
BEGIN
l_chr_msg:=NULL;
l_chr_errcode:=NULL;
l_chr_errbuf:=NULL;

-- Initialising the local variables to be passed to Process Order API l_header_rec:= OE_ORDER_PUB.G_MISS_HEADER_REC; l_header_rec.operation := OE_GLOBALS.G_OPR_UPDATE; l_header_rec.header_id := rec_get.header_id; l_header_rec.org_id := rec_get.org_id; l_header_rec.cancelled_flag := 'Y';

-- Call to Process Order API for cancelling the orders OE_ORDER_PUB.Process_Order
( p_api_version_number => version_number ,p_init_msg_list =>l_init_msg_list ,p_return_values => l_chr_return_values ,x_return_status => x_return_status ,x_msg_count => x_msg_count ,x_msg_data => x_msg_data ,p_header_rec => l_header_rec ,x_header_rec => x_header_rec ,x_header_val_rec => x_header_val_rec ,x_Header_Adj_tbl => x_Header_Adj_tbl ,x_Header_Adj_val_tbl => x_Header_Adj_val_tbl ,x_Header_price_Att_tbl => x_Header_price_Att_tbl ,x_Header_Adj_Att_tbl => x_Header_Adj_Att_tbl ,x_Header_Adj_Assoc_tbl => x_Header_Adj_Assoc_tbl ,x_Header_Scredit_tbl => x_Header_Scredit_tbl ,x_Header_Scredit_val_tbl => x_Header_Scredit_val_tbl ,x_line_tbl => x_line_tbl ,x_line_val_tbl => x_line_val_tbl ,x_Line_Adj_tbl => x_Line_Adj_tbl ,x_Line_Adj_val_tbl => x_Line_Adj_val_tbl ,x_Line_price_Att_tbl => x_Line_price_Att_tbl ,x_Line_Adj_Att_tbl => x_Line_Adj_Att_tbl ,x_Line_Adj_Assoc_tbl => x_Line_Adj_Assoc_tbl ,x_Line_Scredit_tbl => x_Line_Scredit_tbl ,x_Line_Scredit_val_tbl => x_Line_Scredit_val_tbl ,x_Lot_Serial_tbl => x_Lot_Serial_tbl ,x_Lot_Serial_val_tbl => x_Lot_Serial_val_tbl ,x_action_request_tbl => x_action_request_tbl );

l_chr_msg:=l_chr_msg'The cancellation return status is 'x_return_status;

DBMS_OUTPUT.PUT_LINE('l_chr_msg : 'l_chr_msg);

IF x_return_status <> FND_API.G_RET_STS_SUCCESS
THEN
IF x_msg_count > 0
THEN l_num_iMsgCntr := 1;

WHILE l_num_iMsgCntr <= x_msg_count LOOP OE_MSG_PUB.GET ( p_msg_index => l_num_iMsgCntr ,p_encoded => 'F' ,p_data => x_msg_data ,p_msg_index_out => l_num_msg_index_out );
l_chr_errdata:= l_chr_errdatax_msg_data;
l_num_iMsgCntr := l_num_iMsgCntr + 1;
END LOOP;
l_chr_msg:=l_chr_msg' NOT CANCELLED'l_chr_errdata;
END IF;
END IF;
EXCEPTION
WHEN OTHERS
THEN
l_chr_msg:=l_chr_msg' Unknown execption while cancellation of this order 'SQLERRM; DBMS_OUTPUT.PUT_LINE('l_chr_msg'l_chr_msg);
END;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE('Error: program unsuccessfully terminated 'SQLERRM);
END;
/