425: l_count NUMBER;
426:
427: BEGIN
428: -- initializing
429: --apps.FND_MSG_PUB.initialize;
430: l_return_status := Fnd_Api.g_ret_sts_success;
431:
432: -- territory rec
433: l_trans_rec.trans_object_id := JTF_TERR_NUMBER_LIST(null);
783: l_msg_count NUMBER;
784: l_count NUMBER;
785: BEGIN
786: -- initializing
787: --apps.FND_MSG_PUB.initialize;
788: l_return_status := Fnd_Api.g_ret_sts_success;
789:
790: -- territory rec
791: l_trx_rec.trans_object_id := JTF_TERR_NUMBER_LIST(null);
1131: l_count NUMBER;
1132:
1133: BEGIN
1134: -- initializing
1135: --apps.FND_MSG_PUB.initialize;
1136: l_return_status := Fnd_Api.g_ret_sts_success;
1137:
1138: -- territory rec
1139: l_trans_rec.trans_object_id := JTF_TERR_NUMBER_LIST(null);
1469: l_count NUMBER;
1470:
1471: BEGIN
1472: -- initializing
1473: --apps.FND_MSG_PUB.initialize;
1474: l_return_status := Fnd_Api.g_ret_sts_success;
1475:
1476: -- territory rec
1477: l_trans_rec.trans_object_id := JTF_TERR_NUMBER_LIST(null);
1978: IF p_resale_line_tbl.COUNT > 0 THEN
1979: l_resale_table_type := p_resale_line_tbl(1).resale_table_type;
1980: END IF;
1981:
1982: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
1983: Fnd_Msg_Pub.Add_Exc_Msg( 'l_resale_table_type', l_resale_table_type);
1984: Fnd_Msg_Pub.Add_Exc_Msg( 'p_line_id', p_line_id);
1985: END IF;
1986:
1979: l_resale_table_type := p_resale_line_tbl(1).resale_table_type;
1980: END IF;
1981:
1982: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
1983: Fnd_Msg_Pub.Add_Exc_Msg( 'l_resale_table_type', l_resale_table_type);
1984: Fnd_Msg_Pub.Add_Exc_Msg( 'p_line_id', p_line_id);
1985: END IF;
1986:
1987: CASE
1980: END IF;
1981:
1982: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
1983: Fnd_Msg_Pub.Add_Exc_Msg( 'l_resale_table_type', l_resale_table_type);
1984: Fnd_Msg_Pub.Add_Exc_Msg( 'p_line_id', p_line_id);
1985: END IF;
1986:
1987: CASE
1988: WHEN l_resale_table_type = 'RESALE' THEN
1996: CLOSE c_resale_line_info;
1997:
1998: --Based on the resale batch's OU derive exchange_rate_type from System Parameter's page.
1999:
2000: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2001: Fnd_Msg_Pub.Add_Exc_Msg( 'l_organization_id', l_organization_id);
2002: Fnd_Msg_Pub.Add_Exc_Msg( 'l_supplier_item_cost', l_supplier_item_cost);
2003: END IF;
2004:
1997:
1998: --Based on the resale batch's OU derive exchange_rate_type from System Parameter's page.
1999:
2000: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2001: Fnd_Msg_Pub.Add_Exc_Msg( 'l_organization_id', l_organization_id);
2002: Fnd_Msg_Pub.Add_Exc_Msg( 'l_supplier_item_cost', l_supplier_item_cost);
2003: END IF;
2004:
2005: OPEN c_exchange_rate_type_csr(l_organization_id);
1998: --Based on the resale batch's OU derive exchange_rate_type from System Parameter's page.
1999:
2000: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2001: Fnd_Msg_Pub.Add_Exc_Msg( 'l_organization_id', l_organization_id);
2002: Fnd_Msg_Pub.Add_Exc_Msg( 'l_supplier_item_cost', l_supplier_item_cost);
2003: END IF;
2004:
2005: OPEN c_exchange_rate_type_csr(l_organization_id);
2006: FETCH c_exchange_rate_type_csr INTO l_conversion_type_code;
2036: FETCH c_iface_line_info INTO l_inventory_item_id, l_organization_id, l_supplier_item_cost,
2037: l_uom_code, l_order_currency;
2038: CLOSE c_iface_line_info;
2039:
2040: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2041: Fnd_Msg_Pub.Add_Exc_Msg( 'l_organization_id', l_organization_id);
2042: END IF;
2043:
2044: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2037: l_uom_code, l_order_currency;
2038: CLOSE c_iface_line_info;
2039:
2040: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2041: Fnd_Msg_Pub.Add_Exc_Msg( 'l_organization_id', l_organization_id);
2042: END IF;
2043:
2044: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2045: Fnd_Msg_Pub.Add_Exc_Msg( 'l_organization_id', l_organization_id);
2040: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2041: Fnd_Msg_Pub.Add_Exc_Msg( 'l_organization_id', l_organization_id);
2042: END IF;
2043:
2044: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2045: Fnd_Msg_Pub.Add_Exc_Msg( 'l_organization_id', l_organization_id);
2046: Fnd_Msg_Pub.Add_Exc_Msg( 'l_supplier_item_cost', l_supplier_item_cost);
2047: END IF;
2048:
2041: Fnd_Msg_Pub.Add_Exc_Msg( 'l_organization_id', l_organization_id);
2042: END IF;
2043:
2044: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2045: Fnd_Msg_Pub.Add_Exc_Msg( 'l_organization_id', l_organization_id);
2046: Fnd_Msg_Pub.Add_Exc_Msg( 'l_supplier_item_cost', l_supplier_item_cost);
2047: END IF;
2048:
2049: OPEN c_exchange_rate_type_csr(l_organization_id);
2042: END IF;
2043:
2044: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2045: Fnd_Msg_Pub.Add_Exc_Msg( 'l_organization_id', l_organization_id);
2046: Fnd_Msg_Pub.Add_Exc_Msg( 'l_supplier_item_cost', l_supplier_item_cost);
2047: END IF;
2048:
2049: OPEN c_exchange_rate_type_csr(l_organization_id);
2050: FETCH c_exchange_rate_type_csr INTO l_conversion_type_code;
2069: l_uom_code, l_order_currency,
2070: l_conversion_type_code, l_inv_org_id;
2071: CLOSE c_order_info;
2072:
2073: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2074: Fnd_Msg_Pub.Add_Exc_Msg( 'l_organization_id', l_organization_id);
2075: END IF;
2076:
2077: MO_GLOBAL.set_policy_context('S', l_organization_id);
2070: l_conversion_type_code, l_inv_org_id;
2071: CLOSE c_order_info;
2072:
2073: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2074: Fnd_Msg_Pub.Add_Exc_Msg( 'l_organization_id', l_organization_id);
2075: END IF;
2076:
2077: MO_GLOBAL.set_policy_context('S', l_organization_id);
2078:
2077: MO_GLOBAL.set_policy_context('S', l_organization_id);
2078:
2079: l_column_name := FND_PROFILE.value('OZF_ITEM_COST_COLUMN');
2080:
2081: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2082: Fnd_Msg_Pub.Add_Exc_Msg( 'l_column_name', l_column_name);
2083: END IF;
2084:
2085: /*FOR OM orders we have a new seeded profile at site and org level
2078:
2079: l_column_name := FND_PROFILE.value('OZF_ITEM_COST_COLUMN');
2080:
2081: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2082: Fnd_Msg_Pub.Add_Exc_Msg( 'l_column_name', l_column_name);
2083: END IF;
2084:
2085: /*FOR OM orders we have a new seeded profile at site and org level
2086: OZF: Store Item Cost. This profile will store the name of DFF column from
2090: IF l_column_name IS NOT NULL THEN
2091: l_qry_str := 'UPDATE oe_order_lines_all SET '|| l_column_name ||' = :1 WHERE line_id = :2 AND ' || l_column_name ||' IS NULL';
2092: l_call_costing_api := true;
2093: ELSE
2094: IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_debug_low) THEN
2095: FND_MESSAGE.set_name('OZF', 'OZF_PROFILE_MISS_WRG');
2096: FND_MESSAGE.Set_Token('TEXT','Profile OZF: Store Item Cost is NULL.');
2097: FND_MSG_PUB.add;
2098: END IF;
2093: ELSE
2094: IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_debug_low) THEN
2095: FND_MESSAGE.set_name('OZF', 'OZF_PROFILE_MISS_WRG');
2096: FND_MESSAGE.Set_Token('TEXT','Profile OZF: Store Item Cost is NULL.');
2097: FND_MSG_PUB.add;
2098: END IF;
2099: END IF;
2100:
2101: END CASE;
2103: /*If the processing is happening for resale/iface batch which is either indirect
2104: OR it is a direct batch but supplier_item_cost was not provided during POS data upload
2105: OR it is an EBS OM order then call costing API.*/
2106:
2107: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2108: Fnd_Msg_Pub.Add_Exc_Msg( 'l_inv_org_id', l_inv_org_id);
2109: END IF;
2110:
2111: IF ((l_call_costing_api OR l_cost_price IS NULL OR l_cost_price = FND_API.G_MISS_NUM)
2104: OR it is a direct batch but supplier_item_cost was not provided during POS data upload
2105: OR it is an EBS OM order then call costing API.*/
2106:
2107: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2108: Fnd_Msg_Pub.Add_Exc_Msg( 'l_inv_org_id', l_inv_org_id);
2109: END IF;
2110:
2111: IF ((l_call_costing_api OR l_cost_price IS NULL OR l_cost_price = FND_API.G_MISS_NUM)
2112: AND (l_inv_org_id IS NOT NULL AND l_inv_org_id <> FND_API.G_MISS_NUM )) THEN
2115: ,p_inventory_item_id => l_inventory_item_id
2116: ,p_organization_id => l_inv_org_id
2117: );
2118:
2119: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2120: Fnd_Msg_Pub.Add_Exc_Msg( 'l_cost_price', l_cost_price);
2121: END IF;
2122:
2123: OPEN c_primary_uom_csr(l_inventory_item_id,l_inv_org_id);
2116: ,p_organization_id => l_inv_org_id
2117: );
2118:
2119: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2120: Fnd_Msg_Pub.Add_Exc_Msg( 'l_cost_price', l_cost_price);
2121: END IF;
2122:
2123: OPEN c_primary_uom_csr(l_inventory_item_id,l_inv_org_id);
2124: FETCH c_primary_uom_csr INTO l_primary_uom_code;
2124: FETCH c_primary_uom_csr INTO l_primary_uom_code;
2125: CLOSE c_primary_uom_csr;
2126:
2127:
2128: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2129: Fnd_Msg_Pub.Add_Exc_Msg( 'l_order_uom_code', l_order_uom_code);
2130: Fnd_Msg_Pub.Add_Exc_Msg( 'l_primary_uom_code', l_primary_uom_code);
2131: END IF;
2132:
2125: CLOSE c_primary_uom_csr;
2126:
2127:
2128: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2129: Fnd_Msg_Pub.Add_Exc_Msg( 'l_order_uom_code', l_order_uom_code);
2130: Fnd_Msg_Pub.Add_Exc_Msg( 'l_primary_uom_code', l_primary_uom_code);
2131: END IF;
2132:
2133: l_order_uom_code := l_uom_code;
2126:
2127:
2128: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2129: Fnd_Msg_Pub.Add_Exc_Msg( 'l_order_uom_code', l_order_uom_code);
2130: Fnd_Msg_Pub.Add_Exc_Msg( 'l_primary_uom_code', l_primary_uom_code);
2131: END IF;
2132:
2133: l_order_uom_code := l_uom_code;
2134:
2143: --Cost Price in Order Line UOM & Ledger Currency
2144: l_cost_price := l_cost_price * l_Uom_rate;
2145: END IF;
2146:
2147: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2148: Fnd_Msg_Pub.Add_Exc_Msg( 'l_cost_price', l_cost_price);
2149: END IF;
2150:
2151: OPEN c_cost_price_curr_csr(l_organization_id);
2144: l_cost_price := l_cost_price * l_Uom_rate;
2145: END IF;
2146:
2147: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2148: Fnd_Msg_Pub.Add_Exc_Msg( 'l_cost_price', l_cost_price);
2149: END IF;
2150:
2151: OPEN c_cost_price_curr_csr(l_organization_id);
2152: FETCH c_cost_price_curr_csr INTO l_cost_price_currency;
2152: FETCH c_cost_price_curr_csr INTO l_cost_price_currency;
2153: CLOSE c_cost_price_curr_csr;
2154:
2155:
2156: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2157: Fnd_Msg_Pub.Add_Exc_Msg( 'l_cost_price_currency', l_cost_price_currency);
2158: Fnd_Msg_Pub.Add_Exc_Msg( 'l_order_currency', l_order_currency);
2159: END IF;
2160:
2153: CLOSE c_cost_price_curr_csr;
2154:
2155:
2156: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2157: Fnd_Msg_Pub.Add_Exc_Msg( 'l_cost_price_currency', l_cost_price_currency);
2158: Fnd_Msg_Pub.Add_Exc_Msg( 'l_order_currency', l_order_currency);
2159: END IF;
2160:
2161: IF l_cost_price_currency IS NOT NULL AND l_cost_price_currency <> FND_API.G_MISS_CHAR
2154:
2155:
2156: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_DEBUG_LOW ) THEN
2157: Fnd_Msg_Pub.Add_Exc_Msg( 'l_cost_price_currency', l_cost_price_currency);
2158: Fnd_Msg_Pub.Add_Exc_Msg( 'l_order_currency', l_order_currency);
2159: END IF;
2160:
2161: IF l_cost_price_currency IS NOT NULL AND l_cost_price_currency <> FND_API.G_MISS_CHAR
2162: AND l_cost_price_currency <> l_order_currency THEN
2168:
2169:
2170: IF l_conversion_type_code IS NULL OR l_conversion_type_code = FND_API.G_MISS_CHAR THEN
2171: --Conversion type not entered in sales order header, unable to perform cost conversion
2172: IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_debug_low) THEN
2173: FND_MESSAGE.set_name('OZF', 'OZF_INS_RESALE_LOG_WRG');
2174: FND_MESSAGE.Set_Token('TEXT','Conversion rate type is not defined for OU.'|| l_organization_id);
2175: FND_MSG_PUB.add;
2176: END IF;
2171: --Conversion type not entered in sales order header, unable to perform cost conversion
2172: IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_debug_low) THEN
2173: FND_MESSAGE.set_name('OZF', 'OZF_INS_RESALE_LOG_WRG');
2174: FND_MESSAGE.Set_Token('TEXT','Conversion rate type is not defined for OU.'|| l_organization_id);
2175: FND_MSG_PUB.add;
2176: END IF;
2177: RETURN NULL;
2178: END IF;
2179:
2203: RETURN l_sdr_flag;
2204:
2205: EXCEPTION
2206: WHEN Fnd_Api.G_EXC_ERROR THEN
2207: Fnd_Msg_Pub.Count_AND_Get
2208: ( p_count => x_msg_count,
2209: p_data => x_msg_data,
2210: p_encoded => Fnd_Api.G_FALSE
2211: );
2211: );
2212: EXECUTE IMMEDIATE l_qry_str USING -1, p_line_id;
2213: RETURN l_sdr_flag;
2214: WHEN Fnd_Api.G_EXC_UNEXPECTED_ERROR THEN
2215: Fnd_Msg_Pub.Count_AND_Get
2216: ( p_count => x_msg_count,
2217: p_data => x_msg_data,
2218: p_encoded => Fnd_Api.G_FALSE
2219: );
2219: );
2220: EXECUTE IMMEDIATE l_qry_str USING -1, p_line_id;
2221: RETURN l_sdr_flag;
2222: WHEN OTHERS THEN
2223: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_UNEXP_ERROR ) THEN
2224: Fnd_Msg_Pub.Add_Exc_Msg( G_PKG_NAME,l_api_name);
2225: END IF;
2226: Fnd_Msg_Pub.Count_AND_Get
2227: ( p_count => x_msg_count,
2220: EXECUTE IMMEDIATE l_qry_str USING -1, p_line_id;
2221: RETURN l_sdr_flag;
2222: WHEN OTHERS THEN
2223: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_UNEXP_ERROR ) THEN
2224: Fnd_Msg_Pub.Add_Exc_Msg( G_PKG_NAME,l_api_name);
2225: END IF;
2226: Fnd_Msg_Pub.Count_AND_Get
2227: ( p_count => x_msg_count,
2228: p_data => x_msg_data,
2222: WHEN OTHERS THEN
2223: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_UNEXP_ERROR ) THEN
2224: Fnd_Msg_Pub.Add_Exc_Msg( G_PKG_NAME,l_api_name);
2225: END IF;
2226: Fnd_Msg_Pub.Count_AND_Get
2227: ( p_count => x_msg_count,
2228: p_data => x_msg_data,
2229: p_encoded => Fnd_Api.G_FALSE
2230: );
2307: RETURN l_qualified_flag;
2308:
2309: /*EXCEPTION
2310: WHEN Fnd_Api.G_EXC_ERROR THEN
2311: Fnd_Msg_Pub.Count_AND_Get
2312: ( p_count => x_msg_count,
2313: p_data => x_msg_data,
2314: p_encoded => Fnd_Api.G_FALSE
2315: );
2313: p_data => x_msg_data,
2314: p_encoded => Fnd_Api.G_FALSE
2315: );
2316: WHEN Fnd_Api.G_EXC_UNEXPECTED_ERROR THEN
2317: Fnd_Msg_Pub.Count_AND_Get
2318: ( p_count => x_msg_count,
2319: p_data => x_msg_data,
2320: p_encoded => Fnd_Api.G_FALSE
2321: );
2320: p_encoded => Fnd_Api.G_FALSE
2321: );
2322:
2323: WHEN OTHERS THEN
2324: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_UNEXP_ERROR ) THEN
2325: Fnd_Msg_Pub.Add_Exc_Msg( G_PKG_NAME,l_api_name);
2326: END IF;
2327: Fnd_Msg_Pub.Count_AND_Get
2328: ( p_count => x_msg_count,
2321: );
2322:
2323: WHEN OTHERS THEN
2324: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_UNEXP_ERROR ) THEN
2325: Fnd_Msg_Pub.Add_Exc_Msg( G_PKG_NAME,l_api_name);
2326: END IF;
2327: Fnd_Msg_Pub.Count_AND_Get
2328: ( p_count => x_msg_count,
2329: p_data => x_msg_data,
2323: WHEN OTHERS THEN
2324: IF Fnd_Msg_Pub.Check_Msg_Level ( Fnd_Msg_Pub.G_MSG_LVL_UNEXP_ERROR ) THEN
2325: Fnd_Msg_Pub.Add_Exc_Msg( G_PKG_NAME,l_api_name);
2326: END IF;
2327: Fnd_Msg_Pub.Count_AND_Get
2328: ( p_count => x_msg_count,
2329: p_data => x_msg_data,
2330: p_encoded => Fnd_Api.G_FALSE
2331: );