Need Sales Order API
Hiii
I need Sales Order ApI For all Level (Entered,Shipped.....)
Plz send me asap
I will be highly oblige to u
Thanks u
Use below url to download MFG API...
http://download.oracle.com/docs/cd/A99488_01/acrobat/115mfgapi.pdf
1) Now go to : 7 Oracle Inventory Open Interfaces & APIs
2) Look for Sales Order Application Program Interface on page 7-113
Hope this will help
Regards,
S.P DASH
Similar Messages
-
Hiiii
When i am running the Sales Order API (Order Mgt) Script, getting error
Plz reply me . where is the problem
Below Mentioned error
failure
process ORDER ret status IS: U
process ORDER msg data IS: FND
process ORDER msg COUNT IS: 1
header.order_number IS:
header.return_status IS:
header.booked_flag IS:
header.header_id IS:
header.order_source_id IS:
header.flow_status_code IS:
message is: ORA-20001: SQL_PLSQL_ERROR: N, ROUTINE, MO_GLOBAL.VALIDATE_ORGID_PUB_API, N, ERRNO, -20001, N, REASON, ORA-20001: in Package OE_Order_PUB Procedure Process_Order
message index is: 1
Debug = F
Debug Level = 1
Debug File = /sqlcom/outbound/l0001064.dbg
******************************************************HI
I have the same problem and I need help form you
po_header_id=31969
so_ou=82
po_header_id=41771
so_ou=82
so_customer_id=6734
so_ORDER_TYPE_ID=1021
so_site_use_id=51769
so_bill_to_site_use_id=12894
before=
after1
depug=
after2
so_bill_to_site_use_id=12894
so_bill_to_site_use_id=12894
Return status failure
failure
process ORDER ret status IS: U
process ORDER msg data IS: FND
process ORDER msg COUNT IS: 1
header.order_number IS:
header.return_status IS:
header.booked_flag IS:
header.header_id IS:
header.order_source_id IS:
header.flow_status_code IS:
message is: ORA-20001: SQL_PLSQL_ERROR: N, ROUTINE, MO_GLOBAL.VALIDATE_ORGID_PUB_API, N, ERRNO, -20001, N, REASON, ORA-20001: في الحزمة OE_Order_PUB، الإجراء Process_Order
message index is: 1
Debug = T
Debug Level = 1
Debug File = /usr/tmp/l2226798.dbg
what I should do to solve problem
Many thanks,,,
Mostafa Buddar -
Hiiii
When i am running the Sales Order API Script, getting error
Plz reply me . where is the problem
Below Mentioned error
failure
process ORDER ret status IS: U
process ORDER msg data IS: FND
process ORDER msg COUNT IS: 1
header.order_number IS:
header.return_status IS:
header.booked_flag IS:
header.header_id IS:
header.order_source_id IS:
header.flow_status_code IS:
message is: ORA-20001: SQL_PLSQL_ERROR: N, ROUTINE, MO_GLOBAL.VALIDATE_ORGID_PUB_API, N, ERRNO, -20001, N, REASON, ORA-20001: in Package OE_Order_PUB Procedure Process_Order
message index is: 1
Debug = F
Debug Level = 1
Debug File = /sqlcom/outbound/l0001064.dbg
****************************************************Application is Order management
This is Sales Order API Code .
DECLARE
l_api_version_number NUMBER := 1;
l_return_status VARCHAR2(2000);
l_msg_count NUMBER;
l_msg_data VARCHAR2(2000);
/*****************PARAMETERS****************************************************/
l_debug_level number := 1; -- OM DEBUG LEVEL (MAX 5)
l_org number := 89; -- OPERATING UNIT
l_no_orders number :=1; --NO OF ORDERS
l_user number := 1110; -- USER
l_resp number := 50769; -- RESPONSIBLILTY
l_appl number := 523; -- ORDER MANAGEMENT
/*****************INPUT VARIABLES FOR PROCESS_ORDER API*************************/
l_header_rec oe_order_pub.header_rec_type;
l_line_tbl oe_order_pub.line_tbl_type;
l_action_request_tbl oe_order_pub.Request_Tbl_Type;
/*****************OUT VARIABLES FOR PROCESS_ORDER API***************************/
l_header_rec_out oe_order_pub.header_rec_type;
l_header_val_rec_out oe_order_pub.header_val_rec_type;
l_header_adj_tbl_out oe_order_pub.header_adj_tbl_type;
l_header_adj_val_tbl_out oe_order_pub.header_adj_val_tbl_type;
l_header_price_att_tbl_out oe_order_pub.header_price_att_tbl_type;
l_header_adj_att_tbl_out oe_order_pub.header_adj_att_tbl_type;
l_header_adj_assoc_tbl_out oe_order_pub.header_adj_assoc_tbl_type;
l_header_scredit_tbl_out oe_order_pub.header_scredit_tbl_type;
l_header_scredit_val_tbl_out oe_order_pub.header_scredit_val_tbl_type;
l_line_tbl_out oe_order_pub.line_tbl_type;
l_line_val_tbl_out oe_order_pub.line_val_tbl_type;
l_line_adj_tbl_out oe_order_pub.line_adj_tbl_type;
l_line_adj_val_tbl_out oe_order_pub.line_adj_val_tbl_type;
l_line_price_att_tbl_out oe_order_pub.line_price_att_tbl_type;
l_line_adj_att_tbl_out oe_order_pub.line_adj_att_tbl_type;
l_line_adj_assoc_tbl_out oe_order_pub.line_adj_assoc_tbl_type;
l_line_scredit_tbl_out oe_order_pub.line_scredit_tbl_type;
l_line_scredit_val_tbl_out oe_order_pub.line_scredit_val_tbl_type;
l_lot_serial_tbl_out oe_order_pub.lot_serial_tbl_type;
l_lot_serial_val_tbl_out oe_order_pub.lot_serial_val_tbl_type;
l_action_request_tbl_out oe_order_pub.request_tbl_type;
l_msg_index NUMBER;
l_data VARCHAR2(2000);
l_loop_count NUMBER;
l_debug_file VARCHAR2(200);
-- book API vars
b_return_status VARCHAR2(200);
b_msg_count NUMBER;
b_msg_data VARCHAR2(2000);
BEGIN
dbms_application_info.set_client_info(89);
/*****************INITIALIZE DEBUG INFO*************************************/
if (l_debug_level > 0) then
l_debug_file := OE_DEBUG_PUB.Set_Debug_Mode('FILE');
oe_debug_pub.initialize;
oe_debug_pub.setdebuglevel(l_debug_level);
Oe_Msg_Pub.initialize;
end if;
/*****************INITIALIZE ENVIRONMENT*************************************/
fnd_global.apps_initialize(1110, 50769, 523); --pass in user_id, responsibility_id, and application_id
/*****************INITIALIZE HEADER RECORD******************************/
l_header_rec := OE_ORDER_PUB.G_MISS_HEADER_REC;
/*****************POPULATE REQUIRED ATTRIBUTES **********************************/
l_header_rec.operation := OE_GLOBALS.G_OPR_CREATE;
l_header_rec.order_type_id := 1055;
l_header_rec.sold_to_org_id := 4253;
l_header_rec.price_list_id := 9032;
l_header_rec.pricing_date := SYSDATE;
l_header_rec.transactional_curr_code := 'SAR';
l_header_rec.flow_status_code:='ENTERED';
l_header_rec.cust_po_number := '2001';
--l_header_rec.attribute1 := 'ABC';
/*****************INITIALIZE ACTION REQUEST RECORD*************************************/
l_action_request_tbl(1) := OE_ORDER_PUB.G_MISS_REQUEST_REC;
/*****************INITIALIZE LINE RECORD********************************/
l_line_tbl(1) := OE_ORDER_PUB.G_MISS_LINE_REC;
l_line_tbl(1).operation := OE_GLOBALS.G_OPR_CREATE;
l_line_tbl(1).inventory_item_id := 1522;
l_line_tbl(1).ordered_quantity := 1;
for i in 1..l_no_orders
loop -- BEGIN LOOP
/*****************CALLTO PROCESS ORDER API*********************************/
OE_Order_PUB.Process_Order( p_api_version_number => l_api_version_number,
p_header_rec => l_header_rec,
p_line_tbl => l_line_tbl,
p_action_request_tbl => l_action_request_tbl,
--OUT variables
x_header_rec => l_header_rec_out,
x_header_val_rec => l_header_val_rec_out,
x_header_adj_tbl => l_header_adj_tbl_out,
x_header_adj_val_tbl => l_header_adj_val_tbl_out,
x_header_price_att_tbl => l_header_price_att_tbl_out,
x_header_adj_att_tbl => l_header_adj_att_tbl_out,
x_header_adj_assoc_tbl => l_header_adj_assoc_tbl_out,
x_header_scredit_tbl => l_header_scredit_tbl_out,
x_header_scredit_val_tbl => l_header_scredit_val_tbl_out,
x_line_tbl => l_line_tbl_out,
x_line_val_tbl => l_line_val_tbl_out,
x_line_adj_tbl => l_line_adj_tbl_out,
x_line_adj_val_tbl => l_line_adj_val_tbl_out,
x_line_price_att_tbl => l_line_price_att_tbl_out,
x_line_adj_att_tbl => l_line_adj_att_tbl_out,
x_line_adj_assoc_tbl => l_line_adj_assoc_tbl_out,
x_line_scredit_tbl => l_line_scredit_tbl_out,
x_line_scredit_val_tbl => l_line_scredit_val_tbl_out,
x_lot_serial_tbl => l_lot_serial_tbl_out,
x_lot_serial_val_tbl => l_lot_serial_val_tbl_out,
x_action_request_tbl => l_action_request_tbl_out,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data);
/*****************CHECK RETURN STATUS***********************************/
if l_return_status = FND_API.G_RET_STS_SUCCESS then
if (l_debug_level > 0) then
dbms_output.put_line('success');
end if;
commit;
OE_ORDER_BOOK_UTIL.COMPLETE_BOOK_ELIGIBLE(1.0,FND_API.G_FALSE,
l_header_rec_out.header_id,
b_return_status,
b_msg_count,
b_msg_data
commit;
else
if (l_debug_level > 0) then
dbms_output.put_line('failure');
end if;
rollback;
end if;
end loop; -- END LOOP
/*****************DISPLAY RETURN STATUS FLAGS******************************/
if (l_debug_level > 0) then
DBMS_OUTPUT.PUT_LINE('process ORDER ret status IS: '|| l_return_status);
DBMS_OUTPUT.PUT_LINE('process ORDER msg data IS: '|| l_msg_data);
DBMS_OUTPUT.PUT_LINE('process ORDER msg COUNT IS: ' || l_msg_count);
DBMS_OUTPUT.PUT_LINE('header.order_number IS: '|| to_char(l_header_rec_out.order_number));
DBMS_OUTPUT.PUT_LINE('header.return_status IS: ' || l_header_rec_out.return_status);
DBMS_OUTPUT.PUT_LINE('header.booked_flag IS: ' || l_header_rec_out.booked_flag);
DBMS_OUTPUT.PUT_LINE('header.header_id IS: ' || l_header_rec_out.header_id);
DBMS_OUTPUT.PUT_LINE('header.order_source_id IS: ' || l_header_rec_out.order_source_id);
DBMS_OUTPUT.PUT_LINE('header.flow_status_code IS: ' || l_header_rec_out.flow_status_code);
end if;
/*****************DISPLAY ERROR MSGS*************************************/
if (l_debug_level > 0) then
FOR i IN 1 .. l_msg_count LOOP
Oe_Msg_Pub.get(
p_msg_index => i
,p_encoded => Fnd_Api.G_FALSE
,p_data => l_data
,p_msg_index_out => l_msg_index);
DBMS_OUTPUT.PUT_LINE('message is: ' || l_data);
DBMS_OUTPUT.PUT_LINE('message index is: ' || l_msg_index);
END LOOP;
end if;
if (l_debug_level > 0) then
DBMS_OUTPUT.PUT_LINE('Debug = ' || OE_DEBUG_PUB.G_DEBUG);
DBMS_OUTPUT.PUT_LINE('Debug Level = ' || to_char(OE_DEBUG_PUB.G_DEBUG_LEVEL));
DBMS_OUTPUT.PUT_LINE('Debug File = ' || OE_DEBUG_PUB.G_DIR||'/'||OE_DEBUG_PUB.G_FILE);
DBMS_OUTPUT.PUT_LINE('****************************************************');
OE_DEBUG_PUB.DEBUG_OFF;
end if;
END;
Edited by: 811288 on Dec 7, 2010 1:16 AM -
I Need Sales Order Status Reports using ALV
Hi I Need Sales Order Status Reports using ALV.
HI!
For alv use REUSE_ALV_GRID_DSPLAY function module.
For the given report fetch data from the tables:
VBAK - sales order header
VBAP - sales order details
VBUK - sales order header status
VBUP - sales order items status
Regards
Tamá -
COPA - Need Sales order no in Reference field through derivation
Hi Friends,
I have stucked with one derivation of CO-PA
Requirement
We need sales order no (KAUFN) in new characteristics(Reference field WWVBE) only in case of sales order document type like "DR"
It is our reporting requirement. I tried this through derivation but it was working for all sales document type like 'RE' , 'ZORF' - I used condition clause in (KEDR) but i didn't get any success.
Please suggest how i can get the sales order no for one document type in new characteristics.
Regards,
KailashAtul,
MRP does not create recommendation based on one Sales Order but looks at the overall requirement for an Item and if a particular item is required to produced then it will create a Production for the same. Since the relation of a Production order is not tied to a particular Sales Order...getting the Sales Order number on Prod Order would not be possible
Suda -
Price is not calculated by process sales order API
All, I am trying to create sales order using process order API.
For some reason, its not populating price in line as a result I am not able to book it.
I am setting the calculate price flag to 'Y'. Still the price is not being populated.
Below is the code for line:
l_in_line_tbl (1) := oe_order_pub.g_miss_line_rec;
l_in_line_tbl (1).inventory_item_id := '162744';
l_in_line_tbl (1).ordered_quantity := 1;
l_in_line_tbl (1).ship_from_org_id := 207;
l_in_line_tbl (1).orig_sys_document_ref := 'NB_HEADER_2';
l_in_line_tbl (1).orig_sys_line_ref := 'NB_LINE_2';
l_in_line_tbl (1).operation := oe_globals.g_opr_create;
l_in_line_tbl (1).calculate_price_flag := 'Y';
It works fine when I create SO manually!
Can anyone please tell me what I am doing wrong?
Edited by: 918553 on Oct 23, 2012 2:18 PMCheck:
(1)If there's already a price list for defaulting in the Customer Setup of transaction Type setup. Else, you might need to pass a price list/list_header_id.
(2)If the UOM on the price list is different that the UOM in the Item Master Set up
Dip -
Hi experts ,
I am trying to load the data via api , Its not getting load , can u help me pls ,
DECLARE
l_line_id NUMBER;
l_item_id NUMBER;
l_order_qty NUMBER;
l_msg_index number;
L_data VARCHAR2 (2000);
l_debug_file VARCHAR2 (200);
resultout VARCHAR2 (100);
l_order_uom VARCHAR2 (10);
l_reship_order NUMBER;
itemkey number := 215600;
l_negative_prorate NUMBER;
l_prorate_qty NUMBER;
l_sch_ship_date DATE;
l_debug_level NUMBER := 3;
l_ship_to_org_id NUMBER;
l_attribute1 VARCHAR2 (150);
l_attribute2 VARCHAR2 (150);
l_line_num NUMBER;
l_agreement_id NUMBER;
l_organization_id NUMBER;
l_segment VARCHAR2 (120);
l_child_onhand NUMBER := 0;
l_qty_temp NUMBER := 0;
l_excl_temp NUMBER := 0;
l_prorate_percent NUMBER;
l_onhand NUMBER;
l_error VARCHAR2 (240);
l_error_message VARCHAR2 (240);
l_line_tbl oe_order_pub.line_tbl_type;
l_line_tbl_count NUMBER := 0;
l_temp_count NUMBER := 0;
p_line_tbl_rec oe_order_pub.line_tbl_type;
p_line_id NUMBER;
p_error_flag VARCHAR2 (1000);
p_error_message VARCHAR2 (1000);
l_api_version_number NUMBER := 1;
l_return_status VARCHAR2 (2000);
l_return_status1 VARCHAR2 (2000);
l_msg_count NUMBER;
l_msg_data VARCHAR2 (2000);
-- l_msg_index VARCHAR2 (1000);
l_line_out_tbl oe_order_pub.line_tbl_type;
p_parent_item VARCHAR2 (100) := 'PROPANE';
p_organization_id NUMBER := 321;
l_header_id NUMBER := 152066;
--- Child Cursor Without Exclusion of Soldado
CURSOR c_child_items (
p_parent_item VARCHAR2,
p_organization_id NUMBER
IS
CURSOR c_positive_items (
p_parent_item VARCHAR2,
p_organization_id NUMBER
IS
SELECT inventory_item_id,
segment1,
organization_id,
SUM (onhand - order_qty) onhand,
COUNT ( * ) OVER () total_rows
FROM ( SELECT msi.inventory_item_id,
msi.segment1,
msi.organization_id,
NVL (
SUM(inv_convert.inv_um_convert_new (
moq.inventory_item_id,
5,
moq.transaction_quantity,
moq.transaction_uom_code,
l_order_uom,
NULL,
NULL,
'U'
0
onhand,
(SELECT NVL (SUM (ordered_quantity), 0)
FROM oe_order_lines_all
WHERE header_id = l_header_id
AND flow_status_code NOT IN
('CLOSED', 'SHIPPED')
AND inventory_item_id =
msi.inventory_item_id)
order_qty
FROM mtl_system_items_b msi,
oe_lookups ol,
mtl_onhand_quantities_detail moq
WHERE msi.segment1 = ol.meaning
AND TRIM (SYSDATE) BETWEEN ol.start_date_active
AND NVL (ol.end_date_active,
TRIM (SYSDATE))
AND ol.enabled_flag = 'Y'
AND ol.lookup_type = p_parent_item
AND msi.organization_id = p_organization_id
AND msi.inventory_item_id = moq.inventory_item_id(+)
AND msi.organization_id = moq.organization_id(+)
AND (msi.segment1 LIKE '%SOLDADO%'
OR msi.segment1 LIKE '%T4%')
GROUP BY msi.inventory_item_id,
msi.segment1,
msi.organization_id)
GROUP BY inventory_item_id, segment1, organization_id
HAVING SUM (onhand - order_qty) > 0
ORDER BY segment1;
--- Child Cursor With only Positive Buckets
CURSOR c_positive_onhand (
p_parent_item IN VARCHAR2,
p_organization_id IN NUMBER
IS
BEGIN
IF (l_debug_level > 0)
THEN
l_debug_file := oe_debug_pub.set_debug_mode ('FILE');
oe_debug_pub.initialize;
oe_debug_pub.setdebuglevel (l_debug_level);
oe_msg_pub.initialize;
END IF;
--- Initialization Block
DBMS_OUTPUT.put_line ('Initialization Block');
fnd_global.apps_initialize (fnd_global.user_id,
fnd_global.resp_id,
fnd_global.resp_appl_id);
-- BEGIN
-- MO_GLOBAL.SET_POLICY_CONTEXT ('S', 321);
-- END;
-- fnd_global.apps_initialize (-1, 21623, 660);
--- Get Line ID from workflow
l_line_id := TO_NUMBER (itemkey);
--- To get the line details
BEGIN
SELECT header_id,
ordered_item,
inventory_item_id,
line_number,
order_quantity_uom,
ordered_quantity,
ship_from_org_id,
ship_to_org_id,
schedule_ship_date,
attribute1,
attribute2,
agreement_id
INTO l_header_id,
l_segment,
l_item_id,
l_line_num,
l_order_uom,
l_order_qty,
l_organization_id,
l_ship_to_org_id,
l_sch_ship_date,
l_attribute1,
l_attribute2,
l_agreement_id
FROM oe_order_lines_all
WHERE line_id = l_line_id;
DBMS_OUTPUT.put_line ('To get the line details');
EXCEPTION
WHEN OTHERS
THEN
l_header_id := NULL;
l_segment := NULL;
l_item_id := NULL;
l_order_qty := NULL;
l_organization_id := NULL;
DBMS_OUTPUT.put_line ('Not Avilable for To get the line details');
END;
-- To get the Original sales order Number
BEGIN
SELECT attribute10
INTO l_reship_order
FROM oe_order_headers_all
WHERE header_id = l_header_id;
EXCEPTION
WHEN OTHERS
THEN
l_reship_order := NULL;
END;
--- Check for the Top Level Item Name
IF l_segment IN ('PROPANE', 'BUTANE', 'ISO BUTANE', 'GASOLINE')
THEN
--- To get the total positive onhand quantity for all the child items
BEGIN
SELECT NVL (SUM (trx_qty), 0)
INTO l_onhand
FROM ( SELECT moq.inventory_item_id,
NVL (
SUM(NVL (
inv_convert.inv_um_convert_new (
msi.inventory_item_id,
5,
moq.transaction_quantity,
moq.transaction_uom_code,
l_order_uom,
NULL,
NULL,
'U'
0
- (SELECT NVL (SUM (ordered_quantity), 0)
FROM oe_order_lines_all
WHERE header_id = l_header_id
AND flow_status_code NOT IN
('CLOSED', 'SHIPPED')
AND inventory_item_id =
msi.inventory_item_id),
0
trx_qty
FROM mtl_onhand_quantities_detail moq,
mtl_system_items msi,
oe_lookups ol
WHERE msi.segment1 = ol.meaning
AND TRIM (SYSDATE) BETWEEN ol.start_date_active
AND NVL (
ol.end_date_active,
TRIM (SYSDATE)
AND ol.enabled_flag = 'Y'
AND ol.lookup_type = l_segment
AND msi.organization_id = l_organization_id
AND moq.inventory_item_id = msi.inventory_item_id
AND moq.organization_id = msi.organization_id
AND (msi.segment1 NOT LIKE '%SOLDADO%'
AND msi.segment1 NOT LIKE '%T4%')
GROUP BY msi.inventory_item_id, moq.inventory_item_id)
WHERE trx_qty > 0;
DBMS_OUTPUT.put_line ('l_onhand' || l_onhand);
EXCEPTION
WHEN OTHERS
THEN
l_onhand := 0;
DBMS_OUTPUT.put_line ('Not Avilable for on hand');
END;
-- To check whether this order is a reshipment order
DBMS_OUTPUT.put_line (
'To check whether this order is a reshipment order'
IF l_reship_order IS NOT NULL
THEN
DBMS_OUTPUT.put_line ('1st Else Case reship');
ELSE
DBMS_OUTPUT.put_line ('1st Else Case no reship');
FOR l_positive_items
IN c_positive_items (l_segment, l_organization_id)
LOOP
DBMS_OUTPUT.put_line( 'l_positive_items.onhand'
|| l_positive_items.onhand
|| 'l_excl_temp'
|| l_excl_temp
|| ' l_order_qty'
|| l_order_qty);
IF l_positive_items.onhand > 0 AND l_excl_temp < l_order_qty
THEN
l_line_tbl_count := l_line_tbl_count + 1;
IF (l_order_qty - l_excl_temp) < l_positive_items.onhand
THEN
l_prorate_qty := l_order_qty - l_excl_temp;
ELSE
l_prorate_qty := l_positive_items.onhand;
END IF;
-- Initializing the Sales order Lines Record type
DBMS_OUTPUT.put_line (
'Initializing the Sales order Lines Record type'
l_line_tbl (l_line_tbl_count) := oe_order_pub.g_miss_line_rec;
l_line_tbl (l_line_tbl_count).operation :=
oe_globals.g_opr_create;
l_line_tbl (l_line_tbl_count).header_id := l_header_id;
l_line_tbl (l_line_tbl_count).inventory_item_id :=
l_positive_items.inventory_item_id;
l_line_tbl (l_line_tbl_count).ship_to_org_id :=
l_ship_to_org_id;
l_line_tbl (l_line_tbl_count).ordered_quantity := l_prorate_qty;
l_line_tbl (l_line_tbl_count).schedule_ship_date :=
l_sch_ship_date;
l_line_tbl (l_line_tbl_count).attribute1 := l_attribute1;
l_line_tbl (l_line_tbl_count).attribute2 := l_attribute2;
l_line_tbl (l_line_tbl_count).attribute9 := l_line_id;
l_line_tbl (l_line_tbl_count).attribute10 :=
ROUND (l_prorate_qty / l_order_qty * 100, 5);
l_line_tbl (l_line_tbl_count).agreement_id := l_agreement_id;
l_line_tbl (l_line_tbl_count).calculate_price_flag := 'Y';
l_excl_temp := l_excl_temp + l_prorate_qty;
END IF;
END LOOP;
-- To check if the total onhand is greater than zero
DBMS_OUTPUT.put_line (
'To check if the total onhand is greater than zero'
IF l_onhand > 0
THEN
IF l_order_qty > l_excl_temp
THEN
-- To check whether the onhand is lesser than order qty
DBMS_OUTPUT.put_line (
'To check whether the onhand is lesser than order qty'
IF (l_onhand < (l_order_qty - l_excl_temp))
THEN
-- Loop the cursor with exclusion of soldado logic
DBMS_OUTPUT.put_line (
'Loop the cursor with exclusion of soldado logic'
FOR l_child_item
IN c_child_items (l_segment, l_organization_id)
LOOP
l_prorate_percent := NULL;
l_negative_prorate := 0;
l_temp_count := 0;
l_prorate_qty := 0;
-- Initializing the Sales order Lines Record type
DBMS_OUTPUT.put_line (
'Initializing the Sales order Lines Record type2'
l_line_tbl (l_line_tbl_count) :=
oe_order_pub.g_miss_line_rec;
l_line_tbl (l_line_tbl_count).operation :=
oe_globals.g_opr_create;
l_line_tbl (l_line_tbl_count).header_id := l_header_id;
l_line_tbl (l_line_tbl_count).inventory_item_id :=
l_child_item.inventory_item_id;
l_line_tbl (l_line_tbl_count).ship_to_org_id :=
l_ship_to_org_id;
l_line_tbl (l_line_tbl_count).ordered_quantity :=
l_prorate_qty;
l_line_tbl (l_line_tbl_count).schedule_ship_date :=
l_sch_ship_date;
l_line_tbl (l_line_tbl_count).attribute1 := l_attribute1;
l_line_tbl (l_line_tbl_count).attribute2 := l_attribute2;
l_line_tbl (l_line_tbl_count).attribute9 := l_line_id;
l_line_tbl (l_line_tbl_count).attribute10 :=
ROUND (l_prorate_qty / l_order_qty * 100, 5);
l_line_tbl (l_line_tbl_count).agreement_id :=
l_agreement_id;
l_line_tbl (l_line_tbl_count).calculate_price_flag := 'Y';
END LOOP;
ELSE
-- Loop the cursor of all the positive buckets
FOR l_child_items
IN c_positive_onhand (l_segment, l_organization_id)
LOOP
l_prorate_percent := NULL;
l_child_onhand := 0;
l_prorate_qty := 0;
-- To get the split percentage of the child items
l_prorate_percent :=
ROUND ( (l_child_items.trx_qty / l_onhand) * 100, 5);
-- To check whether the prorate percentage exits
IF l_prorate_percent IS NOT NULL
AND l_prorate_percent > 0
THEN
-- To calculate the prorate quantity
l_line_tbl_count := l_line_tbl_count + 1;
l_prorate_qty :=
ROUND (
(l_order_qty - l_excl_temp)
* (l_prorate_percent / 100),
5
l_qty_temp := l_qty_temp + l_prorate_qty;
-- To calculate the prorate quantity for the last line
IF c_positive_onhand%ROWCOUNT =
l_child_items.total_rows
THEN
l_prorate_qty :=
l_prorate_qty
+ (l_order_qty - (l_qty_temp + l_excl_temp));
END IF;
-- Initializing the line record type to process
DBMS_OUTPUT.put_line (
'Initializing the Sales order Lines Record type3'
l_line_tbl (l_line_tbl_count) :=
oe_order_pub.g_miss_line_rec;
l_line_tbl (l_line_tbl_count).operation :=
oe_globals.g_opr_create;
l_line_tbl (l_line_tbl_count).header_id := l_header_id;
l_line_tbl (l_line_tbl_count).inventory_item_id :=
l_child_items.inventory_item_id;
l_line_tbl (l_line_tbl_count).ship_to_org_id :=
l_ship_to_org_id;
l_line_tbl (l_line_tbl_count).ordered_quantity :=
l_prorate_qty;
l_line_tbl (l_line_tbl_count).schedule_ship_date :=
l_sch_ship_date;
l_line_tbl (l_line_tbl_count).attribute1 :=
l_attribute1;
l_line_tbl (l_line_tbl_count).attribute2 :=
l_attribute2;
l_line_tbl (l_line_tbl_count).attribute9 := l_line_id;
l_line_tbl (l_line_tbl_count).attribute10 :=
ROUND (l_prorate_qty / l_order_qty * 100, 5);
l_line_tbl (l_line_tbl_count).agreement_id :=
l_agreement_id;
l_line_tbl (l_line_tbl_count).calculate_price_flag :=
'Y';
DBMS_OUTPUT.put_line( '3rd insert'
|| 'l_prorate_qty'
|| l_prorate_qty
|| 'l_ship_to_org_id'
|| l_ship_to_org_id
|| 'l_sch_ship_date'
|| l_sch_ship_date
|| 'l_child_items.inventory_item_id'
|| l_child_items.inventory_item_id
|| 'l_agreement_id'
|| l_agreement_id);
END IF;
COMMIT;
END LOOP;
END IF;
END IF;
ELSIF l_order_qty > l_excl_temp
THEN
-- Loop the cursor with exclusion of soldado logic
FOR l_child_item IN c_child_items (l_segment, l_organization_id)
LOOP
l_prorate_percent := 0;
l_prorate_qty := 0;
l_prorate_percent := ROUND (100 / l_child_item.total_rows, 5);
l_prorate_qty :=
ROUND (
( (l_order_qty - l_excl_temp) / l_child_item.total_rows),
5
l_line_tbl_count := l_line_tbl_count + 1;
l_qty_temp := l_qty_temp + l_prorate_qty;
-- To calculate the prorate quantity for the last line
IF c_child_items%ROWCOUNT = l_child_item.total_rows
THEN
l_prorate_qty :=
l_prorate_qty
+ (l_order_qty - (l_qty_temp + l_excl_temp));
END IF;
-- Initializing the line record type to process
DBMS_OUTPUT.put_line (
'Initializing the Sales order Lines Record type4'
l_line_tbl (l_line_tbl_count) := oe_order_pub.g_miss_line_rec;
l_line_tbl (l_line_tbl_count).operation :=
oe_globals.g_opr_create;
l_line_tbl (l_line_tbl_count).header_id := l_header_id;
l_line_tbl (l_line_tbl_count).inventory_item_id :=
l_child_item.inventory_item_id;
l_line_tbl (l_line_tbl_count).ship_to_org_id :=
l_ship_to_org_id;
l_line_tbl (l_line_tbl_count).ordered_quantity := l_prorate_qty;
l_line_tbl (l_line_tbl_count).schedule_ship_date :=
l_sch_ship_date;
l_line_tbl (l_line_tbl_count).attribute1 := l_attribute1;
l_line_tbl (l_line_tbl_count).attribute2 := l_attribute2;
l_line_tbl (l_line_tbl_count).attribute9 := l_line_id;
l_line_tbl (l_line_tbl_count).attribute10 :=
ROUND (l_prorate_qty / l_order_qty * 100, 5);
l_line_tbl (l_line_tbl_count).agreement_id := l_agreement_id;
l_line_tbl (l_line_tbl_count).calculate_price_flag := 'Y';
END LOOP;
END IF;
END IF; -- to check whether any records are initialized
IF l_line_tbl_count > 0
THEN
-- Cancel the Parent Item
DBMS_OUTPUT.put_line ('Cancel the Parent Item');
l_line_tbl (l_line_tbl_count + 1) := oe_order_pub.g_miss_line_rec;
l_line_tbl (l_line_tbl_count + 1).operation :=
oe_globals.g_opr_update;
l_line_tbl (l_line_tbl_count + 1).header_id := l_header_id;
l_line_tbl (l_line_tbl_count + 1).line_id := l_line_id;
l_line_tbl (l_line_tbl_count + 1).ordered_quantity := 0;
l_line_tbl (l_line_tbl_count + 1).attribute10 := l_order_qty;
l_line_tbl (l_line_tbl_count + 1).cancelled_flag := 'Y';
l_line_tbl (l_line_tbl_count + 1).change_reason := 'Not Provided';
DBMS_OUTPUT.put_line( 'Cancellation Process fileds'
|| 'HDR_ID'
|| l_header_id
|| 'LINE'
|| l_line_id
|| 'l_order_qty'
|| l_order_qty);
-- Call the procedure to process the sales order lines
-- process_order_line_api (p_line_tbl_rec => l_line_tbl,
-- p_line_id => l_line_id,
-- p_error_flag => l_error,
-- p_error_message => l_error_message);
IF l_error = 'Y'
THEN
resultout := 'COMPLETE:Y';
ELSE
resultout := 'COMPLETE:N';
END IF;
ELSE
resultout := 'COMPLETE:N';
END IF;
END IF;
BEGIN
fnd_global.apps_initialize (fnd_global.user_id,
fnd_global.resp_id,
fnd_global.resp_appl_id);
-- BEGIN
-- MO_GLOBAL.SET_POLICY_CONTEXT ('S', 321);
-- END;
-- fnd_global.apps_initialize (-1, 21623, 660);
-- Call Process Line API to process sales order lines
DBMS_OUTPUT.put_line ('fianl line to be processd');
BEGIN
oe_order_pub.process_line (p_line_tbl => p_line_tbl_rec,
x_line_out_tbl => l_line_out_tbl,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data);
COMMIT;
DBMS_OUTPUT.put_line ('API Processed' || l_msg_data);
fnd_file.put_line (fnd_file.LOG, 'Processed - ' || l_msg_data);
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Failed With1' || SQLERRM);
END;
-- display error msgs
IF (l_debug_level > 0)
THEN
FOR i IN 1 .. l_msg_count
LOOP
oe_msg_pub.get (p_msg_index => i,
p_encoded => fnd_api.g_false,
p_data => l_data,
p_msg_index_out => l_msg_index);
fnd_file.put_line (fnd_file.LOG, 'message is:' || l_data);
fnd_file.put_line (fnd_file.LOG,
'message index is:' || l_msg_index);
DBMS_OUTPUT.put_line (
'l_data' || l_data || 'l_debug_level' || l_debug_level
END LOOP;
END IF;
IF p_error_flag = 'N'
THEN
FOR i IN 1 .. l_msg_count
LOOP
oe_msg_pub.get (p_msg_index => i,
p_encoded => fnd_api.g_false,
p_data => p_error_message,
p_msg_index_out => l_msg_index);
END LOOP;
ELSE
DBMS_OUTPUT.put_line ('Out Of loop Exit');
END IF;
fnd_file.put_line (fnd_file.LOG, 'p_error_message - ' || SQLERRM);
DBMS_OUTPUT.put_line ('p_error_message' || p_error_message || SQLERRM);
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Failed With' || SQLERRM);
fnd_file.put_line (fnd_file.LOG,
'Unexpected Errors Found4 - ' || SQLERRM);
END;
END;
Thanks
ShagulHi experts ,
I am trying to load the data via api , Its not getting load , can u help me pls ,
DECLARE
l_line_id NUMBER;
l_item_id NUMBER;
l_order_qty NUMBER;
l_msg_index number;
L_data VARCHAR2 (2000);
l_debug_file VARCHAR2 (200);
resultout VARCHAR2 (100);
l_order_uom VARCHAR2 (10);
l_reship_order NUMBER;
itemkey number := 215600;
l_negative_prorate NUMBER;
l_prorate_qty NUMBER;
l_sch_ship_date DATE;
l_debug_level NUMBER := 3;
l_ship_to_org_id NUMBER;
l_attribute1 VARCHAR2 (150);
l_attribute2 VARCHAR2 (150);
l_line_num NUMBER;
l_agreement_id NUMBER;
l_organization_id NUMBER;
l_segment VARCHAR2 (120);
l_child_onhand NUMBER := 0;
l_qty_temp NUMBER := 0;
l_excl_temp NUMBER := 0;
l_prorate_percent NUMBER;
l_onhand NUMBER;
l_error VARCHAR2 (240);
l_error_message VARCHAR2 (240);
l_line_tbl oe_order_pub.line_tbl_type;
l_line_tbl_count NUMBER := 0;
l_temp_count NUMBER := 0;
p_line_tbl_rec oe_order_pub.line_tbl_type;
p_line_id NUMBER;
p_error_flag VARCHAR2 (1000);
p_error_message VARCHAR2 (1000);
l_api_version_number NUMBER := 1;
l_return_status VARCHAR2 (2000);
l_return_status1 VARCHAR2 (2000);
l_msg_count NUMBER;
l_msg_data VARCHAR2 (2000);
-- l_msg_index VARCHAR2 (1000);
l_line_out_tbl oe_order_pub.line_tbl_type;
p_parent_item VARCHAR2 (100) := 'PROPANE';
p_organization_id NUMBER := 321;
l_header_id NUMBER := 152066;
--- Child Cursor Without Exclusion of Soldado
CURSOR c_child_items (
p_parent_item VARCHAR2,
p_organization_id NUMBER
IS
CURSOR c_positive_items (
p_parent_item VARCHAR2,
p_organization_id NUMBER
IS
SELECT inventory_item_id,
segment1,
organization_id,
SUM (onhand - order_qty) onhand,
COUNT ( * ) OVER () total_rows
FROM ( SELECT msi.inventory_item_id,
msi.segment1,
msi.organization_id,
NVL (
SUM(inv_convert.inv_um_convert_new (
moq.inventory_item_id,
5,
moq.transaction_quantity,
moq.transaction_uom_code,
l_order_uom,
NULL,
NULL,
'U'
0
onhand,
(SELECT NVL (SUM (ordered_quantity), 0)
FROM oe_order_lines_all
WHERE header_id = l_header_id
AND flow_status_code NOT IN
('CLOSED', 'SHIPPED')
AND inventory_item_id =
msi.inventory_item_id)
order_qty
FROM mtl_system_items_b msi,
oe_lookups ol,
mtl_onhand_quantities_detail moq
WHERE msi.segment1 = ol.meaning
AND TRIM (SYSDATE) BETWEEN ol.start_date_active
AND NVL (ol.end_date_active,
TRIM (SYSDATE))
AND ol.enabled_flag = 'Y'
AND ol.lookup_type = p_parent_item
AND msi.organization_id = p_organization_id
AND msi.inventory_item_id = moq.inventory_item_id(+)
AND msi.organization_id = moq.organization_id(+)
AND (msi.segment1 LIKE '%SOLDADO%'
OR msi.segment1 LIKE '%T4%')
GROUP BY msi.inventory_item_id,
msi.segment1,
msi.organization_id)
GROUP BY inventory_item_id, segment1, organization_id
HAVING SUM (onhand - order_qty) > 0
ORDER BY segment1;
--- Child Cursor With only Positive Buckets
CURSOR c_positive_onhand (
p_parent_item IN VARCHAR2,
p_organization_id IN NUMBER
IS
BEGIN
IF (l_debug_level > 0)
THEN
l_debug_file := oe_debug_pub.set_debug_mode ('FILE');
oe_debug_pub.initialize;
oe_debug_pub.setdebuglevel (l_debug_level);
oe_msg_pub.initialize;
END IF;
--- Initialization Block
DBMS_OUTPUT.put_line ('Initialization Block');
fnd_global.apps_initialize (fnd_global.user_id,
fnd_global.resp_id,
fnd_global.resp_appl_id);
-- BEGIN
-- MO_GLOBAL.SET_POLICY_CONTEXT ('S', 321);
-- END;
-- fnd_global.apps_initialize (-1, 21623, 660);
--- Get Line ID from workflow
l_line_id := TO_NUMBER (itemkey);
--- To get the line details
BEGIN
SELECT header_id,
ordered_item,
inventory_item_id,
line_number,
order_quantity_uom,
ordered_quantity,
ship_from_org_id,
ship_to_org_id,
schedule_ship_date,
attribute1,
attribute2,
agreement_id
INTO l_header_id,
l_segment,
l_item_id,
l_line_num,
l_order_uom,
l_order_qty,
l_organization_id,
l_ship_to_org_id,
l_sch_ship_date,
l_attribute1,
l_attribute2,
l_agreement_id
FROM oe_order_lines_all
WHERE line_id = l_line_id;
DBMS_OUTPUT.put_line ('To get the line details');
EXCEPTION
WHEN OTHERS
THEN
l_header_id := NULL;
l_segment := NULL;
l_item_id := NULL;
l_order_qty := NULL;
l_organization_id := NULL;
DBMS_OUTPUT.put_line ('Not Avilable for To get the line details');
END;
-- To get the Original sales order Number
BEGIN
SELECT attribute10
INTO l_reship_order
FROM oe_order_headers_all
WHERE header_id = l_header_id;
EXCEPTION
WHEN OTHERS
THEN
l_reship_order := NULL;
END;
--- Check for the Top Level Item Name
IF l_segment IN ('PROPANE', 'BUTANE', 'ISO BUTANE', 'GASOLINE')
THEN
--- To get the total positive onhand quantity for all the child items
BEGIN
SELECT NVL (SUM (trx_qty), 0)
INTO l_onhand
FROM ( SELECT moq.inventory_item_id,
NVL (
SUM(NVL (
inv_convert.inv_um_convert_new (
msi.inventory_item_id,
5,
moq.transaction_quantity,
moq.transaction_uom_code,
l_order_uom,
NULL,
NULL,
'U'
0
- (SELECT NVL (SUM (ordered_quantity), 0)
FROM oe_order_lines_all
WHERE header_id = l_header_id
AND flow_status_code NOT IN
('CLOSED', 'SHIPPED')
AND inventory_item_id =
msi.inventory_item_id),
0
trx_qty
FROM mtl_onhand_quantities_detail moq,
mtl_system_items msi,
oe_lookups ol
WHERE msi.segment1 = ol.meaning
AND TRIM (SYSDATE) BETWEEN ol.start_date_active
AND NVL (
ol.end_date_active,
TRIM (SYSDATE)
AND ol.enabled_flag = 'Y'
AND ol.lookup_type = l_segment
AND msi.organization_id = l_organization_id
AND moq.inventory_item_id = msi.inventory_item_id
AND moq.organization_id = msi.organization_id
AND (msi.segment1 NOT LIKE '%SOLDADO%'
AND msi.segment1 NOT LIKE '%T4%')
GROUP BY msi.inventory_item_id, moq.inventory_item_id)
WHERE trx_qty > 0;
DBMS_OUTPUT.put_line ('l_onhand' || l_onhand);
EXCEPTION
WHEN OTHERS
THEN
l_onhand := 0;
DBMS_OUTPUT.put_line ('Not Avilable for on hand');
END;
-- To check whether this order is a reshipment order
DBMS_OUTPUT.put_line (
'To check whether this order is a reshipment order'
IF l_reship_order IS NOT NULL
THEN
DBMS_OUTPUT.put_line ('1st Else Case reship');
ELSE
DBMS_OUTPUT.put_line ('1st Else Case no reship');
FOR l_positive_items
IN c_positive_items (l_segment, l_organization_id)
LOOP
DBMS_OUTPUT.put_line( 'l_positive_items.onhand'
|| l_positive_items.onhand
|| 'l_excl_temp'
|| l_excl_temp
|| ' l_order_qty'
|| l_order_qty);
IF l_positive_items.onhand > 0 AND l_excl_temp < l_order_qty
THEN
l_line_tbl_count := l_line_tbl_count + 1;
IF (l_order_qty - l_excl_temp) < l_positive_items.onhand
THEN
l_prorate_qty := l_order_qty - l_excl_temp;
ELSE
l_prorate_qty := l_positive_items.onhand;
END IF;
-- Initializing the Sales order Lines Record type
DBMS_OUTPUT.put_line (
'Initializing the Sales order Lines Record type'
l_line_tbl (l_line_tbl_count) := oe_order_pub.g_miss_line_rec;
l_line_tbl (l_line_tbl_count).operation :=
oe_globals.g_opr_create;
l_line_tbl (l_line_tbl_count).header_id := l_header_id;
l_line_tbl (l_line_tbl_count).inventory_item_id :=
l_positive_items.inventory_item_id;
l_line_tbl (l_line_tbl_count).ship_to_org_id :=
l_ship_to_org_id;
l_line_tbl (l_line_tbl_count).ordered_quantity := l_prorate_qty;
l_line_tbl (l_line_tbl_count).schedule_ship_date :=
l_sch_ship_date;
l_line_tbl (l_line_tbl_count).attribute1 := l_attribute1;
l_line_tbl (l_line_tbl_count).attribute2 := l_attribute2;
l_line_tbl (l_line_tbl_count).attribute9 := l_line_id;
l_line_tbl (l_line_tbl_count).attribute10 :=
ROUND (l_prorate_qty / l_order_qty * 100, 5);
l_line_tbl (l_line_tbl_count).agreement_id := l_agreement_id;
l_line_tbl (l_line_tbl_count).calculate_price_flag := 'Y';
l_excl_temp := l_excl_temp + l_prorate_qty;
END IF;
END LOOP;
-- To check if the total onhand is greater than zero
DBMS_OUTPUT.put_line (
'To check if the total onhand is greater than zero'
IF l_onhand > 0
THEN
IF l_order_qty > l_excl_temp
THEN
-- To check whether the onhand is lesser than order qty
DBMS_OUTPUT.put_line (
'To check whether the onhand is lesser than order qty'
IF (l_onhand < (l_order_qty - l_excl_temp))
THEN
-- Loop the cursor with exclusion of soldado logic
DBMS_OUTPUT.put_line (
'Loop the cursor with exclusion of soldado logic'
FOR l_child_item
IN c_child_items (l_segment, l_organization_id)
LOOP
l_prorate_percent := NULL;
l_negative_prorate := 0;
l_temp_count := 0;
l_prorate_qty := 0;
-- Initializing the Sales order Lines Record type
DBMS_OUTPUT.put_line (
'Initializing the Sales order Lines Record type2'
l_line_tbl (l_line_tbl_count) :=
oe_order_pub.g_miss_line_rec;
l_line_tbl (l_line_tbl_count).operation :=
oe_globals.g_opr_create;
l_line_tbl (l_line_tbl_count).header_id := l_header_id;
l_line_tbl (l_line_tbl_count).inventory_item_id :=
l_child_item.inventory_item_id;
l_line_tbl (l_line_tbl_count).ship_to_org_id :=
l_ship_to_org_id;
l_line_tbl (l_line_tbl_count).ordered_quantity :=
l_prorate_qty;
l_line_tbl (l_line_tbl_count).schedule_ship_date :=
l_sch_ship_date;
l_line_tbl (l_line_tbl_count).attribute1 := l_attribute1;
l_line_tbl (l_line_tbl_count).attribute2 := l_attribute2;
l_line_tbl (l_line_tbl_count).attribute9 := l_line_id;
l_line_tbl (l_line_tbl_count).attribute10 :=
ROUND (l_prorate_qty / l_order_qty * 100, 5);
l_line_tbl (l_line_tbl_count).agreement_id :=
l_agreement_id;
l_line_tbl (l_line_tbl_count).calculate_price_flag := 'Y';
END LOOP;
ELSE
-- Loop the cursor of all the positive buckets
FOR l_child_items
IN c_positive_onhand (l_segment, l_organization_id)
LOOP
l_prorate_percent := NULL;
l_child_onhand := 0;
l_prorate_qty := 0;
-- To get the split percentage of the child items
l_prorate_percent :=
ROUND ( (l_child_items.trx_qty / l_onhand) * 100, 5);
-- To check whether the prorate percentage exits
IF l_prorate_percent IS NOT NULL
AND l_prorate_percent > 0
THEN
-- To calculate the prorate quantity
l_line_tbl_count := l_line_tbl_count + 1;
l_prorate_qty :=
ROUND (
(l_order_qty - l_excl_temp)
* (l_prorate_percent / 100),
5
l_qty_temp := l_qty_temp + l_prorate_qty;
-- To calculate the prorate quantity for the last line
IF c_positive_onhand%ROWCOUNT =
l_child_items.total_rows
THEN
l_prorate_qty :=
l_prorate_qty
+ (l_order_qty - (l_qty_temp + l_excl_temp));
END IF;
-- Initializing the line record type to process
DBMS_OUTPUT.put_line (
'Initializing the Sales order Lines Record type3'
l_line_tbl (l_line_tbl_count) :=
oe_order_pub.g_miss_line_rec;
l_line_tbl (l_line_tbl_count).operation :=
oe_globals.g_opr_create;
l_line_tbl (l_line_tbl_count).header_id := l_header_id;
l_line_tbl (l_line_tbl_count).inventory_item_id :=
l_child_items.inventory_item_id;
l_line_tbl (l_line_tbl_count).ship_to_org_id :=
l_ship_to_org_id;
l_line_tbl (l_line_tbl_count).ordered_quantity :=
l_prorate_qty;
l_line_tbl (l_line_tbl_count).schedule_ship_date :=
l_sch_ship_date;
l_line_tbl (l_line_tbl_count).attribute1 :=
l_attribute1;
l_line_tbl (l_line_tbl_count).attribute2 :=
l_attribute2;
l_line_tbl (l_line_tbl_count).attribute9 := l_line_id;
l_line_tbl (l_line_tbl_count).attribute10 :=
ROUND (l_prorate_qty / l_order_qty * 100, 5);
l_line_tbl (l_line_tbl_count).agreement_id :=
l_agreement_id;
l_line_tbl (l_line_tbl_count).calculate_price_flag :=
'Y';
DBMS_OUTPUT.put_line( '3rd insert'
|| 'l_prorate_qty'
|| l_prorate_qty
|| 'l_ship_to_org_id'
|| l_ship_to_org_id
|| 'l_sch_ship_date'
|| l_sch_ship_date
|| 'l_child_items.inventory_item_id'
|| l_child_items.inventory_item_id
|| 'l_agreement_id'
|| l_agreement_id);
END IF;
COMMIT;
END LOOP;
END IF;
END IF;
ELSIF l_order_qty > l_excl_temp
THEN
-- Loop the cursor with exclusion of soldado logic
FOR l_child_item IN c_child_items (l_segment, l_organization_id)
LOOP
l_prorate_percent := 0;
l_prorate_qty := 0;
l_prorate_percent := ROUND (100 / l_child_item.total_rows, 5);
l_prorate_qty :=
ROUND (
( (l_order_qty - l_excl_temp) / l_child_item.total_rows),
5
l_line_tbl_count := l_line_tbl_count + 1;
l_qty_temp := l_qty_temp + l_prorate_qty;
-- To calculate the prorate quantity for the last line
IF c_child_items%ROWCOUNT = l_child_item.total_rows
THEN
l_prorate_qty :=
l_prorate_qty
+ (l_order_qty - (l_qty_temp + l_excl_temp));
END IF;
-- Initializing the line record type to process
DBMS_OUTPUT.put_line (
'Initializing the Sales order Lines Record type4'
l_line_tbl (l_line_tbl_count) := oe_order_pub.g_miss_line_rec;
l_line_tbl (l_line_tbl_count).operation :=
oe_globals.g_opr_create;
l_line_tbl (l_line_tbl_count).header_id := l_header_id;
l_line_tbl (l_line_tbl_count).inventory_item_id :=
l_child_item.inventory_item_id;
l_line_tbl (l_line_tbl_count).ship_to_org_id :=
l_ship_to_org_id;
l_line_tbl (l_line_tbl_count).ordered_quantity := l_prorate_qty;
l_line_tbl (l_line_tbl_count).schedule_ship_date :=
l_sch_ship_date;
l_line_tbl (l_line_tbl_count).attribute1 := l_attribute1;
l_line_tbl (l_line_tbl_count).attribute2 := l_attribute2;
l_line_tbl (l_line_tbl_count).attribute9 := l_line_id;
l_line_tbl (l_line_tbl_count).attribute10 :=
ROUND (l_prorate_qty / l_order_qty * 100, 5);
l_line_tbl (l_line_tbl_count).agreement_id := l_agreement_id;
l_line_tbl (l_line_tbl_count).calculate_price_flag := 'Y';
END LOOP;
END IF;
END IF; -- to check whether any records are initialized
IF l_line_tbl_count > 0
THEN
-- Cancel the Parent Item
DBMS_OUTPUT.put_line ('Cancel the Parent Item');
l_line_tbl (l_line_tbl_count + 1) := oe_order_pub.g_miss_line_rec;
l_line_tbl (l_line_tbl_count + 1).operation :=
oe_globals.g_opr_update;
l_line_tbl (l_line_tbl_count + 1).header_id := l_header_id;
l_line_tbl (l_line_tbl_count + 1).line_id := l_line_id;
l_line_tbl (l_line_tbl_count + 1).ordered_quantity := 0;
l_line_tbl (l_line_tbl_count + 1).attribute10 := l_order_qty;
l_line_tbl (l_line_tbl_count + 1).cancelled_flag := 'Y';
l_line_tbl (l_line_tbl_count + 1).change_reason := 'Not Provided';
DBMS_OUTPUT.put_line( 'Cancellation Process fileds'
|| 'HDR_ID'
|| l_header_id
|| 'LINE'
|| l_line_id
|| 'l_order_qty'
|| l_order_qty);
-- Call the procedure to process the sales order lines
-- process_order_line_api (p_line_tbl_rec => l_line_tbl,
-- p_line_id => l_line_id,
-- p_error_flag => l_error,
-- p_error_message => l_error_message);
IF l_error = 'Y'
THEN
resultout := 'COMPLETE:Y';
ELSE
resultout := 'COMPLETE:N';
END IF;
ELSE
resultout := 'COMPLETE:N';
END IF;
END IF;
BEGIN
fnd_global.apps_initialize (fnd_global.user_id,
fnd_global.resp_id,
fnd_global.resp_appl_id);
-- BEGIN
-- MO_GLOBAL.SET_POLICY_CONTEXT ('S', 321);
-- END;
-- fnd_global.apps_initialize (-1, 21623, 660);
-- Call Process Line API to process sales order lines
DBMS_OUTPUT.put_line ('fianl line to be processd');
BEGIN
oe_order_pub.process_line (p_line_tbl => p_line_tbl_rec,
x_line_out_tbl => l_line_out_tbl,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data);
COMMIT;
DBMS_OUTPUT.put_line ('API Processed' || l_msg_data);
fnd_file.put_line (fnd_file.LOG, 'Processed - ' || l_msg_data);
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Failed With1' || SQLERRM);
END;
-- display error msgs
IF (l_debug_level > 0)
THEN
FOR i IN 1 .. l_msg_count
LOOP
oe_msg_pub.get (p_msg_index => i,
p_encoded => fnd_api.g_false,
p_data => l_data,
p_msg_index_out => l_msg_index);
fnd_file.put_line (fnd_file.LOG, 'message is:' || l_data);
fnd_file.put_line (fnd_file.LOG,
'message index is:' || l_msg_index);
DBMS_OUTPUT.put_line (
'l_data' || l_data || 'l_debug_level' || l_debug_level
END LOOP;
END IF;
IF p_error_flag = 'N'
THEN
FOR i IN 1 .. l_msg_count
LOOP
oe_msg_pub.get (p_msg_index => i,
p_encoded => fnd_api.g_false,
p_data => p_error_message,
p_msg_index_out => l_msg_index);
END LOOP;
ELSE
DBMS_OUTPUT.put_line ('Out Of loop Exit');
END IF;
fnd_file.put_line (fnd_file.LOG, 'p_error_message - ' || SQLERRM);
DBMS_OUTPUT.put_line ('p_error_message' || p_error_message || SQLERRM);
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Failed With' || SQLERRM);
fnd_file.put_line (fnd_file.LOG,
'Unexpected Errors Found4 - ' || SQLERRM);
END;
END;
Thanks
Shagul -
Need sales order creation using bapi in oops
need code for sales order creation using bapi in oops
hi rocky,
could you pls give a bit explanation on what you are expecting.
regards,
Pavan -
Need Sales Order Approval Workflow upto two level
Hi All,
I am new user of sdn and also in workflow.I want to create a workflow to approve a sales order upto two level of approval.
Is there any standard workflow available for this?or any standard task to approve sales order.Please help.Hi Abhijit,
Thanks for your assistance.
Actually what I need is to build a workflow which will be triggered whenever a Sales Order is created by some user.First the workflow will check if the sales order value is greater than Rs.10,000 or not.If yes it will go for the first level of approval to authority1 if not it simply complete the workflow.If authority1 approve the workflow it will go to authority2 for second level of approval.If authority1 reject that it will go back to the sales order creater to change it or he simply complete the workflow.If he choose change then it will again go for the first level of approval to authority1.If authority1 approve the sales order then it will go to the authority2 for second level of approval.If authority 2 approves it the sales order will be finally approved else it will return back to the creater to change or withdraw.
I think you have understood what I want.Waiting for your reply. -
Urgent help needed - Process order api error
Hi All,
I am having a problem with implementing process order api. I have all the necessary details, but i couldn't get working. I think the problem might be with global initialization or with api parameter declaration. I am posting the code so any help might be helpful.
Any help is urgently required and greatly appreciated.
Thanks
srinivas
Edited by: user2138419 on Feb 6, 2010 4:21 PMHi,
I solved the above issue and I thought may be this would be helpful to others. I solved the process order issues through assisgming proper responsibility and proper org_id under which you are booking orders. If we have these tow correct, then most of the issues will be rectified.. -
To update the status of the Sale Order through Pl/sql(backend)
Hi folks.
May I how to alter the status of Sale Order from 'Entered' to 'Awaiting for Approval' when the sale order was booked.After approval only it needs to change into 'BOOKED'.
Requirement Scenaria as follows:
Activity Status
1) Sale Order Creation Entered
2) Booking the Sale Order Awaiting For Approval
3) After Approved 'Booked'
or
4) After Rejected Rejected --- should not be available for pick and ship.
Please tell me the solution to alter the status and I had already tried both normal update statement and update through sale order API.Both didnt work.
kindly find me an appropriate solution
Note:I had already altered the OE order header workflow to go for approval when Sale order booked
Thanks in advanceApparently, your Sales Order Type has Approval Workflow associated. Have the approver approve it from the Notifications window. Alternatively have a script to approve the workflow with userid as the approver's, in order for approval and booking.
In case of forced Booking, use OE_ORDER_PUB.PROCESS_ORDER API to pass the Order Details along with BOOKED_FLAG='Y' and FLOW_STATUS_CODE='BOOKED'.
let me know,
Dip -
Sales Order Drafts Deleteing unexpectedly
I have an issue with Sales Order Document Drafts deleting.
Here is my scenario
My customer uses the Sales Order Document Draft to generate for a better name, Recurring Sales Orders. We run a process using the SDK to take these Drafts and on a weekly basis update them into Sales Orders.
The problem arises when we use the Documents Drafts Report to maintain and delete no longer needed Sales Order Drafts.
The process to delete is
1) Run Documents Drafts Report for Sales Orders Only, with the Open Only check box Un checked.
2) Highlight the Sales Order draft to delete, right click and select Remove from the drop down menu.
USUALLY this works well, but every so often, when we go back into the Documents Drafts Report for Sales Orders,
anywhere for 20 to 90 of the Sales Orders Drafts are deleted.
We notice that the Sales Orders that were deleted without being selected are missing with in a few minutes of selecting the
ONE Draft to delete.
Also, the person maintaining the Sales Drafts is an experienced user.
The Customer is running SAP B1 SP00 PL47. SQL Server 2005 Database.
Any ideas or similar experiences or suggestions?
Thanks in advance!!
DanaWe are able to determine which Draft we want to delete.
The problem we are experiencing is that we delete 5 drafts
when we rereunthe report, MANY more than the few selected to be deleted were delete.
Basically if the Draft Report displays 100 Drafts and I select 5 drafts, one by one and delete them.
I would expect that when I re reun the Draft report that the report would display 95 Drafts
NOT 50!!!!
The actual numers on my Customer's system were BEFORE we deleted ANY Drafts there
were 442 Drafts.
We Deleted 7 Drfats by selecting a line, Right clicking and then selecting Remove from the Drop
Down menu. Then clicking Update.
We did this seven times.
The we entered a Sales Order saving is as a Draft
We then ran the Daft Document Report for Sales Orders EXPECTING 436 Drafts
BUT There were ONLY 353 Drafts
89 Additional Drafts were deleted.
This makes NO Sense!!!!
I appreciate your input!!!! -
Report of sales orders with several schedules lines
Hi all,
I try to develop a report for sales orders and delivery info. I need sales order quantity, delivery quantity and the quantity in the scheduled line. But I faced with the problem of several scheduled lines.
I could not find the relation between delivery information and the scheduled lines of sales order.
Any function module or other way to find out a delivery belongs to which cheduled line of the sales order ?
Thanks,
UtkuSolved problem
-
Report of sales orders with several scheduled lines
Hi all,
I try to develop a report for sales orders and delivery info. I need sales order quantity, delivery quantity and the quantity in the scheduled line. But I faced with the problem of several scheduled lines.
I could not find the relation between delivery information and the scheduled lines of sales order.
Any function module or other way to find out a delivery belongs to which scheduled line of the sales order ?
Thanks,
Utkupost this in ABAP forum for quicker response.
Regards
Raja -
0DOC_NUMBER - Sales Order No - Attributes
Hi Guys,
Here is my requirement. I need sales order related characteristics like soldto, shipto, endcustomer,purchase order date and some line item level fields like few dates and status flags.
I am planning to add all the above as the attributes of 0DOC_NUMBER.
I plan to use the following DS
2LIS_11_VAHDR u2013 MC11VA0HDR u2013 Sales Document Header
2LIS_11_VAITM u2013 MC11VA0ITM - Sales Document Item
For the fields which are not available in the DS I will derive it from the user exit.
I don't need any Key figures from the above DS just characteristics.
We are not using the above 2 DS for any reporting. What is the best way to enhance the attributes of 0doc_number. Do I have to use the above 2 DS or write a custom DS to populate the required fields.
If I have to use the above 2 DS,will the delta get triggered if there is any change in the date fields like some Z field which is derived in the user exit.
For example if a z date field changed from 08/01/2009 to 08/30/2009. Does this record gets captured in the next delta run. if not then we have to do a full update each time. i don't think it is possible.
Please advise what is the best way to enhance the attributes of 0doc_number .
Thanks for your help.
SenthilHi,
It dont think its advisable to load soldto, shipto, endcustomer,purchase order date and some line item level fields like few dates and status flags to attrbutes. These are transactional data and would not work as you would have simply too many combinations. My suggestion would be to build a cube and use it for reporting.
Also points to be noted are that 2LIS_11_VAHDR u2013 MC11VA0HDR u2013 Sales Document Header
2LIS_11_VAITM u2013 MC11VA0ITM - Sales Document Item, these are transactional datasources.
Regards.
Maybe you are looking for
-
Hi: I created a tutorial project for a customer. The project consist of about 34-40 pieces of voice over to which sprites are animated visualizing what the voice over explains. I converted the voice clips to .wav files because I added cue points for
-
Is there a way to go straight to the detail box when adding an event in month view? When I right click on a date on the calendar then choose "add an event", it just puts it right on the calendar, then I click that so I can put the time down, then onl
-
Using a view to create a theme?
Can a view be used to create a theme? For example, I have several views which are subset of another table which contains my imagery (using GeoRaster). I would like to create a theme for each of these views. I know that a GeoRaster theme has the optio
-
Outlook 2010 "Server is unavailable" error when starting remote app
All, I have recently built and configured a new server to run Remote Desktop Services. It in on Server 2008 R2 Standard 64-bit. I have published numerous applications (e.g. Adobe, Visio, Project, etc. as well as Office 2010) to the host server. Eve
-
Firefox 17.1 hangs up on every use of the flash player
I have activated 'click to play' for plugins at the moment (by about:config). Whenever i click on a flash area in a website, my browser hangs up. My browser is Firefox 17.0.1 (don't know, if the problem existed even with version 17.0). Firefox 16.0.2