The following lines contain the word 'select', 'insert', 'update' or 'delete':
| central API to update status
|
=============================================================================*/
/*****************************************************************************
Function: link_config
Parameters: p_model_line_id - line id of the top model in
oe_order_lines_all
p_config_item_id - config id of the selected configuration
item to which the model line will be linked.
x_error_message - error message if match function fails
x_message_name - name of error message if match
function fails
Description: This function is called from the Sales Order Pad to manually
link a selected configuration item to an ATO model order
line.
After linking a configuration item to the model line,
this link_config function updates the ATO model workflow
to complete the 'CREATE CONFIG ITEM ELIGIBLE' block
activity.
A manual link can only be done if the ATO model order line
is not linked to a configuration item.
*****************************************************************************/
PG_DEBUG Number := NVL(FND_PROFILE.value('ONT_DEBUG_LEVEL'), 0);
select oel.inventory_item_id, oel.ship_from_org_id
into l_model_id, l_org_id
from oe_order_lines_all oel
where oel.line_id = p_model_line_id;
Update Model Line's workflow.
+-------------------------------*/
IF (CTO_WORKFLOW_API_PK.start_model_workflow(p_model_line_id) = FALSE)
THEN
IF PG_DEBUG <> 0 THEN
oe_debug_pub.add('link_config: ' || 'Failed in call to start_model_workflow',1);
select line_id, header_id
into l_config_line_id, l_header_id
from oe_order_lines_all
where ato_line_id = p_model_line_id
and item_type_code = 'CONFIG';
SELECT config_item_id,
inventory_item_id,
ship_from_org_id
BULK COLLECT INTO old_config_dtls.config_item_id,
old_config_dtls.base_item_id,
old_config_dtls.ship_from_org_id
FROM bom_cto_order_lines
WHERE top_model_line_id = p_model_line_id
AND config_item_id IS NOT NULL
AND line_id <> top_model_line_id;
UPDATE bom_cto_order_lines
SET config_item_id = p_config_item_id
WHERE line_id = p_model_line_id;
SELECT 1
INTO l_bom_exists
FROM bom_bill_of_materials bom
WHERE bom.assembly_item_id = p_config_item_id
AND bom.organization_id = old_config_dtls.ship_from_org_id(1)
AND bom.alternate_bom_designator IS NULL;
SELECT 1
INTO flag
FROM bom_bill_of_materials bom
WHERE bom.assembly_item_id = p_config_item_id
AND bom.organization_id = l_org
AND bom.alternate_bom_designator IS NULL;
UPDATE bom_cto_order_lines
SET config_item_id = p_config_item_id
WHERE line_id = p_model_line_id;
UPDATE bom_cto_order_lines --Updating the lower level configs to NULL
SET config_item_id = NULL
WHERE top_model_line_id = p_model_line_id
AND config_item_id IS NOT NULL
AND line_id <> top_model_line_id;
UPDATE bom_cto_order_lines
SET config_item_id = p_config_item_id
WHERE line_id = p_model_line_id;
UPDATE bom_cto_order_lines
SET config_item_id = NULL
WHERE top_model_line_id = p_model_line_id
AND config_item_id IS NOT NULL
AND line_id <> top_model_line_id;
UPDATE bom_cto_order_lines
SET config_item_id = new_config_dtls.config_item_id(j)
WHERE ato_line_id = p_model_line_id
AND inventory_item_id = new_config_dtls.base_item_id(j);
UPDATE bom_cto_order_lines
SET config_item_id = NULL
WHERE ato_line_id = p_model_line_id
AND inventory_item_id = old_config_dtls.base_item_id(i);
UPDATE bom_cto_order_lines
SET config_item_id = p_config_item_id
WHERE line_id = p_model_line_id;
select distinct 1
into l_valid
from oe_order_lines_all oel, --model line
mtl_system_items msi --config item
where oel.line_id = p_model_line_id
and oel.inventory_item_id = msi.base_item_id
and msi.inventory_item_id = p_config_item_id;
SELECT inventory_item_id, base_item_id
FROM mtl_system_items msi
WHERE inventory_item_id IN
( SELECT component_item_id
FROM bom_inventory_components bic, bom_bill_of_materials bom
WHERE bom.assembly_item_id = pconfigId --p_config_id
AND bom.common_bill_sequence_id = bic.bill_sequence_id
AND bom.alternate_bom_designator IS NULL
AND bom.organization_id = pshipOrg
)
AND auto_created_config_flag = 'Y'
AND organization_id = pshipOrg;