[Home] [Help]
PACKAGE BODY: APPS.CUG_VALIDATE_ADDRESS_TYPE
Source
1 Package Body CUG_VALIDATE_ADDRESS_TYPE AS
2 --
3 -- To modify this template, edit file PKGBODY.TXT in TEMPLATE
4 -- directory of SQL Navigator
5 --
6 -- Purpose: Briefly explain the functionality of the package body
7 --
8 -- MODIFICATION HISTORY
9 -- Person Date Comments
10 -- --------- ------ ------------------------------------------
11 -- aneemuch 11-Feb-04 To fix bug 2657648 changed hz_location_pub to hz_location_v2_pub
12 --
13 --
14 -- Enter procedure, function bodies as shown below
15 G_PKG_NAME CONSTANT VARCHAR2(25):= 'CUG_VALIDATE_ADDRESS_TYPE';
16
17 PROCEDURE Validate_Incident_Address_Type (
18 p_api_version IN NUMBER,
19 p_init_msg_list IN VARCHAR2 default fnd_api.g_false,
20 p_commit IN VARCHAR2 default fnd_api.g_false,
21 p_incident_type_id IN NUMBER,
22 p_incident_address_rec IN OUT NOCOPY CUG_VALIDATE_ADDRESS_TYPE.INCIDENT_ADDRESS_TBL,
23 x_msg_count OUT NOCOPY NUMBER,
24 x_msg_data OUT NOCOPY VARCHAR2,
25 x_return_status OUT NOCOPY VARCHAR2,
26 p_validation_level IN NUMBER:=FND_API.G_VALID_LEVEL_FULL)
27 IS
28 l_api_name CONSTANT VARCHAR2(30) := 'Validate_Incident_Address_Type';
29 l_api_version CONSTANT NUMBER := 2.0;
30 l_api_name_full CONSTANT VARCHAR2(61) := G_PKG_NAME||'.'||l_api_name;
31
32 -- To fix bug 2657648 changed hz_location_pub to hz_location_v2pub, aneemuch 11-Feb-2004
33 -- l_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
34
35 l_return_status VARCHAR2(1);
36 l_msg_count NUMBER;
37 l_msg_data VARCHAR2(2000);
38 l_location_id NUMBER;
39 l_incident_id NUMBER;
40
41 l_incident_address_rec CUG_VALIDATE_ADDRESS_TYPE.INCIDENT_ADDRESS_TBL;
42 l_incident_address_index BINARY_INTEGER;
43
44 CURSOR l_ValidateAddressFlag_csr IS
45 SELECT validate_address_flag
46 FROM cug_sr_type_dup_chk_info_v
47 WHERE incident_type_id = p_incident_type_id;
48 l_Validate_Address_Flag VARCHAR2(1);
49
50
51 Begin
52
53 l_incident_address_rec := p_incident_address_rec;
54
55 l_incident_address_index := l_incident_address_rec.FIRST;
56
57 l_incident_address_rec(l_incident_address_index).jurisdiction_status := 'S';
58 l_incident_address_rec(l_incident_address_index).validation_status := 'S';
59 l_return_status := FND_API.G_RET_STS_SUCCESS;
60
61 -- Check if the validate_address flag is turned on for the given incident type
62 -- If yes, only then call CUG_VALIDATE_ADDRESS_PKG.Validate_Incident_Address
63 -- Else, do not call anything. Just return success status
64
65 OPEN l_ValidateAddressFlag_csr;
66 FETCH l_ValidateAddressFlag_csr INTO l_Validate_Address_Flag;
67 IF (l_ValidateAddressFlag_csr%NOTFOUND) THEN
68 l_Validate_Address_Flag := 'N';
69 FND_MESSAGE.Set_Name('CUG', 'CUG_ADDRESS_VALIDATION_FAILED');
70 FND_MESSAGE.Set_Token('API_NAME', l_api_name_full);
71 FND_MSG_PUB.Add;
72 END IF;
73 CLOSE l_ValidateAddressFlag_csr;
74
75 IF(l_Validate_Address_Flag = 'Y') THEN
76 CUG_Validate_Address_Pkg.Validate_Incident_Address (
77 p_api_version => l_api_version,
78 p_init_msg_list => p_init_msg_list,
79 p_commit => p_commit,
80 p_incident_type_id => p_incident_type_id,
81 p_incident_address_rec => l_incident_address_rec,
82 x_msg_count => l_msg_count,
83 x_msg_data => l_msg_data,
84 x_return_status => l_return_status,
85 p_validation_level => p_validation_level);
86
87 x_return_status := l_return_status;
88 p_incident_address_rec := l_incident_address_rec;
89 x_msg_count := l_msg_count;
90 x_msg_data := l_msg_data;
91
92 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
93 FND_MESSAGE.Set_Name('CUG', 'CUG_ADDRESS_VALIDATION_FAILED');
94 FND_MESSAGE.Set_Token('API_NAME', l_api_name_full);
95 FND_MSG_PUB.Add;
96 -- RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
97 ELSE
98 l_incident_address_index := l_incident_address_rec.FIRST;
99
100 IF(l_incident_address_rec(l_incident_address_index).jurisdiction_status is NULL) THEN
101 CUG_Validate_Type_Pkg.Validate_Incident_Type (
102 p_api_version => l_api_version,
103 p_init_msg_list => p_init_msg_list,
104 p_commit => p_commit,
105 p_incident_type_id => p_incident_type_id,
106 p_incident_address_rec => l_incident_address_rec,
107 x_msg_count => l_msg_count,
108 x_msg_data => l_msg_data,
109 x_return_status => l_return_status,
110 p_validation_level => p_validation_level);
111
112 x_return_status := l_return_status;
113 p_incident_address_rec := l_incident_address_rec;
114 x_msg_count := l_msg_count;
115 x_msg_data := l_msg_data;
116
117 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
118 FND_MESSAGE.Set_Name('CUG', 'CUG_TYPE_VALIDATION_FAILED');
119 FND_MESSAGE.Set_Token('API_NAME', l_api_name_full);
120 FND_MSG_PUB.Add;
121 -- RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
122 END IF;
123 END IF; -- Jurisdiction check (only of address validation api did not do jurisdiction check)
124 END IF; -- If return status from Address Validation was succesful
125 END IF; -- If validate_address_flag = 'Y'
126
127 x_return_status := l_return_status;
128 p_incident_address_rec := l_incident_address_rec;
129 x_msg_count := l_msg_count;
130 x_msg_data := l_msg_data;
131
132 EXCEPTION
133 WHEN FND_API.G_EXC_ERROR THEN
134 FND_MESSAGE.Set_Name('CUG', 'CUG_ADDRESS_VALIDATION_FAILED');
135 FND_MESSAGE.Set_Token('API_NAME', l_api_name_full);
136 FND_MSG_PUB.Add;
137 x_return_status := 'E';
138 FND_MSG_PUB.Count_And_Get
139 ( p_count => x_msg_count,
140 p_data => x_msg_data
141 );
142 -- raise FND_API.G_EXC_ERROR;
143
144 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
145 FND_MESSAGE.Set_Name('CUG', 'CUG_ADDRESS_VALIDATION_FAILED');
146 FND_MESSAGE.Set_Token('API_NAME', l_api_name_full);
147 FND_MSG_PUB.Add;
148 x_return_status := 'E';
149 FND_MSG_PUB.Count_And_Get
150 ( p_count => x_msg_count,
151 p_data => x_msg_data
152 );
153 -- raise FND_API.G_EXC_UNEXPECTED_ERROR;
154 WHEN OTHERS THEN
155 FND_MESSAGE.Set_Name('CUG', 'CUG_ADDRESS_VALIDATION_FAILED');
156 FND_MESSAGE.Set_Token('API_NAME', l_api_name_full);
157 FND_MSG_PUB.Add;
158 x_return_status := 'U';
159 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
160 FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
161 END IF;
162 FND_MSG_PUB.Count_And_Get
163 ( p_count => x_msg_count,
164 p_data => x_msg_data
165 );
166 -- raise FND_API.G_EXC_ERROR;
167
168 END Validate_Incident_Address_Type;
169 -- Enter further code below as specified in the Package spec.
170 END; -- Package Body CUG_VALIDATE_ADDRESS_TYPE