1 PACKAGE BODY WSH_FACILITIES_INTEGRATION as
2 /* $Header: WSHFACIB.pls 115.1 2003/09/05 01:38:21 arguha noship $ */
3
4 --
5 G_PKG_NAME CONSTANT VARCHAR2(50) := 'WSH_FACILITIES_INTEGRATION';
6 --
7
8 ---------------------------------------------------------
9 -- Start of comments
10 -- API name : Create_Facilities
11 -- Type : Private
12 -- Pre-reqs : None.
13 -- Function : 1. Create a new facility (row in FTE_LOCATION_PARAMETERS) for each
14 -- location id specified in the input table p_location_ids.
15 -- NOTE: It is recommended, but not required to pass in the corresponding
16 -- <p_company_names> and <p_site_names>.
17 -- (a). If both <p_company_names> and <p_site_names> are not null,
18 -- the facility codes are generated from a combination of
19 -- the location's company_name and site_name. (See function
20 -- Create_Description)
21 -- (b). If the <p_company_names> is NOT null but <p_site_names> is
22 -- null, the facility codes are derived from the company names.
23 -- (c). If both <p_company_names> AND <p_site_names> are null,
24 -- a query is used to obtain the company_name and site_name for
25 -- each location_id (See Fetch_Facility_Descriptions). Caching
26 -- is used to make more efficient.
27 --
28 -- PARAMETERS :
29 -- IN Parameters:
30 -- 1. p_location_ids WSH_LOCATIONS_PKG.ID_Tbl_Type (Required)
31 -- The location ids for the facilities.
32 --
33 -- 2. p_company_names WSH_LOCATIONS_PKG.Address_Tbl_Type (Not Required)
34 -- Corresponding company names for each
35 -- location ID.
36 -- 3. p_site_names WSH_LOCATIONS_PKG.LocationCode_Tbl_Type (Not Required)
37 -- Corresponding site names for the
38 -- location ids, if applicable.
39 --
40 -- OUT Parameters : x_return_status VARCHAR2
41 -- The return status is one of the following:
42 -- i. WSH_UTIL_CORE.G_RET_STS_SUCCESS: All facilities created.
43 -- iv. WSH_UTIL_CORE.G_RET_STS_WARNING: If some of the location_ids
44 -- already had facilities created.
45 -- iv. WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR
46 -- Version : 1.0
47 -- Previous version 1.0
48 -- Initial version 1.0
49 -- End of comments
50 -----------------------------------------------------------------------------------
51 PROCEDURE Create_Facilities (p_location_ids IN WSH_LOCATIONS_PKG.ID_Tbl_Type,
52 p_company_names IN WSH_LOCATIONS_PKG.Address_Tbl_Type,
53 p_site_names IN WSH_LOCATIONS_PKG.LocationCode_Tbl_Type,
54 x_return_status OUT NOCOPY VARCHAR2,
55 x_error_msg OUT NOCOPY VARCHAR2) IS
56
57 --
58 -- Variables used for debugging
59 --
60 l_debug_on CONSTANT BOOLEAN := WSH_DEBUG_SV.is_debug_enabled;
61 --
62 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Create_Facilities';
63
64 BEGIN
65 IF l_debug_on THEN
66 WSH_DEBUG_SV.push(l_module_name);
67 END IF;
68
69 IF WSH_UTIL_CORE.FTE_Is_Installed = 'Y' THEN
70 FTE_LOCATION_PARAMETERS_PKG.Create_Facilities( p_location_ids => p_location_ids,
71 p_company_names => p_company_names,
72 p_site_names => p_site_names,
73 x_return_status => x_return_status,
74 x_error_msg => x_error_msg);
75 END IF;
76
77 IF l_debug_on THEN
78 WSH_DEBUG_SV.pop(l_module_name);
79 END IF;
80
81 EXCEPTION
82 WHEN OTHERS THEN
83 x_error_msg := SQLERRM;
84 IF l_debug_on THEN
85 WSH_DEBUG_SV.logmsg(l_module_name,
86 'UNEXP. ERROR IN WSH_FACILITIES_INTEGRATION.Create_Facilities: '|| x_error_msg);
87 WSH_DEBUG_SV.logmsg(l_module_name,
88 'Error message is '|| SQLERRM, WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
89 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
90 END IF;
91 --
92 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
93
94 IF l_debug_on THEN
95 WSH_DEBUG_SV.pop(l_module_name);
96 END IF;
97 END Create_Facilities;
98 ------------------------------------------------------------------
99
100 END WSH_FACILITIES_INTEGRATION;