Sales Order API Failure

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

Similar Messages

  • Sales Order API Error

    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

  • 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

  • Sale Order Api Is not working

    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
    Shagul

    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
    Shagul

  • 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 PM

    Check:
    (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

  • 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 advance

    Apparently, 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

  • PL/SQL API for Creating Sales Order

    Hi,
    I am new to Oracle SOA 11g.
    I have done the Deleting Sales Order using PL/SQL API ( Oracle Apps Adapter ) [ API Name: OE_ORDER_PUB.DELETE_ORDER ] in SOA BPEL. While executing the BPEL, it is correctly deleting Sales Order in E Business Suite which is created in EBS User Interface. I don't face any problem while deleting the sales order.
    Now, in same way, I have to create a new Sales Order using PL/SQL API in SOA-BPEL. I don't find any API's related to creating Sales Order in Order Management Suite (OM_PF) -->Order Management (ONT) --> Sales Order (ONT_SALES_ORDER) --> PL/SQL --> Process Order API (OE_ORDER_PUB) in Module Browser.
    Please tell me which PL/SQL API to use to create new Sales Order in BPEL.
    Thanks,
    -- Gowtham
    Edited by: user8223943 on Feb 16, 2012 7:38 AM

    You may be on a different patch level. Can you ensure that you have applied all latest patches for your version?
    See sample code at http://jyotioraapps.blogspot.com/2009/08/use-of-oeorderpubprocessorder-to-create.html
    Hope this helps,
    Sandeep Gandhi

  • PL/SQL API for Creating Sales Order in E Business Suite from BPEL

    Hi,
    I am new to Oracle SOA 11g.
    I have done the Deleting Sales Order using PL/SQL API ( Oracle Apps Adapter ) [ API Name: OE_ORDER_PUB.DELETE_ORDER ]. While executing the BPEL, it is correctly deleting Sales Order in E Business Suite which is created EBS User Interface. I don't face any problem while deleting the sales order.
    Now, in same way, I have to create a new Sales Order using PL/SQL API. I don't find any API's related to creating Sales Order in Order Management Suite (OM_PF) -->Order Management (ONT) --> Sales Order (ONT_SALES_ORDER) --> PL/SQL --> Process Order API (OE_ORDER_PUB) in Module Browser.
    Please tell me which PL/SQL API to use to create new Sales Order in BPEL.
    Thanks,
    -- Gowtham

    You may be on a different patch level. Can you ensure that you have applied all latest patches for your version?
    See sample code at http://jyotioraapps.blogspot.com/2009/08/use-of-oeorderpubprocessorder-to-create.html
    Hope this helps,
    Sandeep Gandhi

  • Issues in creating the sales order with oe_order_pub.process_order api

    Hi All,
    I am trying to create a sales order with BOOKED status using oe_order_pub.process_order api, and I am getting response as
    <X_RETURN_STATUS>E</X_RETURN_STATUS>
              <X_MSG_COUNT>1</X_MSG_COUNT>
              <X_MSG_DATA>ONTOE_LOCK_ROW_DELETED</X_MSG_DATA>
    Can any one help me in fixing this issue ..!
    Thanks,
    Vamsi…
    Edited by: user11147471 on Jul 9, 2009 2:02 AM

    When using the API, are you trying to create the order as booked using the booked flag or the book action?  I would recommend using the action if you are not. To troubleshoot, I would try the API without booking and then use the following article to determine the issue:
    Unable To Setup A Credit Card Bank Account For The Customer. CC Information On The Order Is Not Valid (Doc ID 1450936.1)

  • Issue in creating sales order using process_header API (web service)

    Hi All,
    I am trying to create sales order header using web service call to OE_ORDER_PUB.Process_header API.
    When I pass the inputs and test the service,I get output with return_status='S'. But no record falls at the OE_ORDER_HEADER_ALL table.
    I cant identify where the problem is.Is there any commit missing? Pls help me resolve this issue.
    Thanks,
    Vinoth

    Hi All,
    I am trying to create sales order header using web service call to OE_ORDER_PUB.Process_header API.
    When I pass the inputs and test the service,I get output with return_status='S'. But no record falls at the OE_ORDER_HEADER_ALL table.
    I cant identify where the problem is.Is there any commit missing? Pls help me resolve this issue.
    Thanks,
    Vinoth

  • Issue in creating sales order using process_header API

    Hi all,
    We have a requirement to create sales order using apps adapter in ebiz from SOA suite composite.I used OE_ORDER_PUB.Process_header API to create order header.
    When I pass the inputs and test the service,I get output with return_status='S'. But no record falls at the OE_ORDER_HEADER_ALL table.
    I cant identify where the problem is.Pls suggest me with the things to resolve this issue.
    Thanks,
    goutham

    Hi all,
    We have a requirement to create sales order using apps adapter in ebiz from SOA suite composite.I used OE_ORDER_PUB.Process_header API to create order header.
    When I pass the inputs and test the service,I get output with return_status='S'. But no record falls at the OE_ORDER_HEADER_ALL table.
    I cant identify where the problem is.Pls suggest me with the things to resolve this issue.
    Thanks,
    goutham

  • Problem In Creating Sales Order Through DI API

    Hi
    I am Creating The Sales Order Through DI API.
    the Error Is Coming - " [OACT] , 'No matching records found (ODBC -2028)'"
    anyone  can help me solving it.

    Hi vivek,
    Have you tried adding the same document with the client ?
    OACT is the accounts table and this error message typically indicates that there is an account parameter missing somewhere in the system.
    Possible causes include:
    - you are using a tax group or warehouse which does not have all the required accounts set
    - There is a price rounding and the rounding price account has not been set in the account settings
    - etc.
    The first things I would check include the tax group settings and the G/L Account determination settings.
    Henry

  • How do I get the Sales Orders Statuses? Is there any API for that?

    Hi!
    I'm trying to track all the statuses of a sales order. I want to get the header status, lines status, holds status, shipping status and the invoiced status.
    Does anyone knows if there is an API for that? Or I'll have to make lots of querys for that?
    I found out the following APIs, but it only returned me Y or N:
    -oe_header_status_pub.get_booked_status;
    -oe_header_status_pub.get_cancelled_status;
    -oe_header_status_pub.get_closed_status;
    -oe_holds_pub.check_holds;
    -oe_line_status_pub.get_pick_status;
    -oe_line_status_pub.get_ship_status;
    -oe_line_status_pub.get_invoiced_status;
    Thanks for the help!

    Hi,
    You can find the status of both SO Headers ahd Lines from the FLOW_STATUS_CODE column in oe_order_headers_all and oe_order_lines_all tables.
    Thanks
    Gowrishankar

  • How to use of API for Cancel Sales Orders

    Hi....
    I want to use API for Cancel Sales Orders. Plz give me advice how we can cancel orders. I know that there is procedure provide in ORACLE APPs (i.e. OE_ORDER_PUB.process_order). But in this procedure i know the how to create and update sales order, but how to Cancel order with the use of this API.
    Plz send me soultion as soon as possible. ITS VERY VERY URGENT BASE.
    Thanks in Advance.

    Hi all,
    We are importing Sales Orders on 11.5.9 using OE_Order_PUB.Process_Order API .We have supplied most of the mandatory fields and the same data works from the front end. When we use the API it throws a Ora 20001.
    A snapshot of the error message.
    SQL> exec pk_process_object.process_order('1o');
    Message Count is :2
    Message is RA-20001: User in Package OE_Header_Util Procedure Get_Order_Number
    Message is :User-Defined Exception in Package OE_Header_Util Procedure
    Pre_Write_Process
    Return Status is ErrorU
    PL/SQL procedure successfully completed.
    --------------------------------------------------------------------------------------------

  • Updating a sales order through DI API

    Hi All,
         I have an issue regarding updating a sales order.
    The problem is:
      If there r 2 items(A00001&A00002) existed in the sales order and if I am adding two more items(A00003 & 4)the sales order is updated in a fashion that first item is replaced with third item and forth item is added as last record.The items to that particular sales order after updating will be like this(A00003,A00002,A00004).My doubt is why the 3rd item is replaced with first record.I am sending the code also i have written.
    objRecordSet = SBOCOMUtil.newRecordset(company);
                          IDocuments  oOrder =SBOCOMUtil.newDocuments(company,SBOCOMConstants.BoObjectTypes_Document_oOrders);
                                  objRecordSet.doQuery("select DocEntry from ORDR where DocNum=" + 1111);
                                  DocEntryL =objRecordSet.getFields().item(new String("DocEntry")).getValueInteger().intValue();
                          str += DocEntryL;
                          System.out.println(DocEntryL);
                          if (oOrder.getByKey(new Integer(DocEntryL))) {
                                  //objRecordSet2.doQuery("delete  from rdr1 where DocEntry="+DocEntryL);
                                  str += "2";
                                  System.out.println(str);
                                  //oOrder.remove();
                                  oOrder.setDiscountPercent(new Double(5));
                                  oOrder.setComments("success");
                                  System.out.println(str);
                                  IDocument_Lines oOrderLines = oOrder.getLines();
                                  str += "3";
                                  String[] item={"A00005","A00006"};
                                  for (int counter = 0; counter < item.length; counter++) {
                                       //  oOrderLines.setCurrentLine(new Integer(counter));
                                         if (counter > 0)
                                                 oOrder.getLines().add();
                                         str += "4";
                                  oOrderLines.setItemCode(item[counter]);
                                  System.out.println(item[counter]);
                                     //oOrderLines.setBaseType(new Integer(-1));
                                     //oOrderLines.setBaseEntry(new Integer(0));
                                   //oOrder.getLines().setCurrentLine(new Integer(counter));
                               //oOrderLines.setQuantity(new Double(1));
                                         //oOrderLines.setPrice(new Double(1500));
                                         //oOrderLines.setCurrency(strCurrency[counter]);
                                         //oOrderLines.setLineTotal(new Double(dblLineTotal[counter]));
                                  str += "5";
                                  //oOrder.getLines().getUserFields().getFields().item("Quantity").setValue(new Integer(2));
                                  System.out.println(str);
                                  int result = oOrder.update();
                                  str += "6" + result;
                                  if (result == 0) {
                                         System.out.println("successfully updated");
                                         company.disconnect();
                                  } else {
                                         company.getLastErrorDescription();
                                         System.out.println(
                                                 "Error :" + company.getLastErrorDescription());
                                         company.disconnect();

    If you are using SBP 2004 there are many threads on this forum talking about bugs when updating sales order lines through DI API. This issue was supposed to be fixed with patch level 45 for 2004 which was recently released.
    If u are using 2005 or SP1 I think you may have found a new bug.

Maybe you are looking for

  • Browse and power search crashes itunes

    I do not understand. I am using itunes 5 (I don't want to upgrade to 6) and everytime I click "Browse" or "power search" in the itunes store window, itunes crashes. I tried uninstalling Quicktime, and itunes, then installing quicktime standalone, reb

  • Issues with MSCHAPV2

    Hey Arch forum. I really wanted to avoid having to ask a question on the forum, and try and fix myself, but I'm clueless on how to go about with this one. I've been using Arch for a couple of months now, and this issue has only really started getting

  • Home folder Creation problem solved (for me anyway)

    I have had an issue where when I asked my server to create home folders it was not making them. I also tried all the usual things like removing the share, sudo createhomedir -a and even ran the combo updater on the server again all to no avail. Upon

  • Batch classification in REM

    Hi all I am doing a MFBF for a batch managed material and want the batch classification to pop up when I try to save the transaction. Is there a way I can do it?

  • I know where I can find my podcasts...

    what I would like to do is tell iTunes where I want the podcast stored. Right now it places it in (this is shorthand) Docs\Music\iTunes\iTunesMusic\Podcast\PodcastEpisodeName. I want it to place the podcast in a specific folder that I will create. i.