DBA Data[Home] [Help]
Skip to content

PACKAGE BODY: APPS.WSH_U_CSPV

Source


1 PACKAGE BODY WSH_U_CSPV AS
2 /* $Header: WSHUCSPB.pls 115.12 2002/11/12 01:59:37 nparikh ship $ */
3 
4 	-- standard global constants
5 	G_PKG_NAME CONSTANT VARCHAR2(30) 		:= 'WSH_U_CSPV';
6 	p_message_type	CONSTANT VARCHAR2(1) 	:= 'E';
7 
8 
9 
10 
11 
12 
13 
14 -- -------------------------------------------------------------------
15 -- Start of comments
16 -- API name			: CSP_Validate
17 --	Type				: public
18 --	Function			: compose the input string, call UPS APIs and parse
19 --						  the L_OUTPUT string, place them in the returning
20 --
21 --	Version			: Initial version 1.0
22 -- Notes
23 --
24 -- End of comments
25 -- ---------------------------------------------------------------------
26 PROCEDURE CSP_Validate (
27 								  p_api_version            IN		NUMBER,
28 								  p_init_msg_list          IN		VARCHAR2,
29 								  x_return_status         OUT NOCOPY 		VARCHAR2,
30 								  x_msg_count             OUT NOCOPY 		NUMBER,
31 								  x_msg_data              OUT NOCOPY 		VARCHAR2,
32 								  p_AppVersion					IN		VARCHAR2,
33 								  p_AcceptLicenseAgreement IN		VARCHAR2,
34 	 							  p_ResponseType				IN		VARCHAR2,
35 								  p_request_in					IN		CSPValidateInRec,
36 								  x_CSPValidate_out		  OUT NOCOPY 		CSPValidateOutTblTyp
37 ) IS
38 
39 		-- standard version infermation
40 		l_api_version	CONSTANT	NUMBER		:= 1.0;
41 		l_api_name	CONSTANT	VARCHAR2(30)   := 'CSP_VALIDATE';
42 
43 		-- standard variables
44 		l_return_status	VARCHAR2(1)			:= FND_API.G_RET_STS_SUCCESS;
45 		l_msg_count		NUMBER					:= 0;
46 		l_msg_data		VARCHAR2(2000) 		:= NULL;
47 		l_msg_summary	VARCHAR2(2000);
48 		l_msg_details	VARCHAR2(4000);
49 
50 
51 		-- L_UPS_URL VARCHAR2(200) := 'http://wwwapps.ups.com/using/sevices/cszval/cszval_dss.cgi';
52 		L_UPS_URL VARCHAR2(1000) := NULL;
53 		L_INTERNET_PROXY VARCHAR2(1000) := NULL;
54 
55 		l_boundary_string_start		NUMBER  := 0;
56 		l_boundary_string_end			NUMBER  := 0;
57 		l_boundary_string				VARCHAR2(100)		 := NULL;
58 		L_Content_Str_Len NUMBER					:= 0;
59 
60 		l_request_in CSPValidateInRec;
61 
62 		L_INPUT_STR VARCHAR2(2000);
63 		L_OUTPUT_STR VARCHAR2(10000);
64 		l_output_data  utl_http.html_pieces;
65 
66 		L_CSPV_Message VARCHAR2(500);
67 
68 		L_Content_Type VARCHAR2(200);
69 
70 		L_Locate_boundary NUMBER := 1;
71 		L_Locate_Str_Len  NUMBER := 1;
72 		L_Locate_Str_Len_End NUMBER := 0;
73 		L_Locate_Content  NUMBER :=1;
74 		L_Locate_boundary_End NUMBER := 1;
75 		L_Locate_Begin   NUMBER := 1;
76 		L_Token_Start NUMBER := 1;
77 		L_Token_End NUMBER := 0;
78 		l_find_error NUMBER := 0;
79 
80 		-- this is used to print the debug message only
81 		l_outrec_index BINARY_INTEGER := 0;
82 
83 		WSH_U_INPUT_PARAMETER 		exception;
84 		WSH_U_CAR_URL				exception;
85 		WSH_U_PROXY				exception;
86 		WSH_U_APPVER				exception;
87 		WSH_U_LICAGRE				exception;
88 		WSH_U_RESTYP				exception;
89 		WSH_U_CSP					exception;
90 		WSH_U_CITYORZIP			exception;
91 		WSH_U_NO_HOST            	exception;
92 		REQUEST_FAILED           	exception;
93 		INIT_FAILED              	exception;
94 
95 --
96 l_debug_on BOOLEAN;
97 --
98 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CSP_VALIDATE';
99 --
100 BEGIN
101 
102 		-- Standard call to check for call compatibility.
103 		--
104 		-- Debug Statements
105 		--
106 		--
107 		l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
108 		--
109 		IF l_debug_on IS NULL
110 		THEN
111 		    l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
112 		END IF;
113 		--
114 		IF l_debug_on THEN
115 		    WSH_DEBUG_SV.push(l_module_name);
116 		    --
117 		    WSH_DEBUG_SV.log(l_module_name,'P_API_VERSION',P_API_VERSION);
118 		    WSH_DEBUG_SV.log(l_module_name,'P_INIT_MSG_LIST',P_INIT_MSG_LIST);
119 		    WSH_DEBUG_SV.log(l_module_name,'P_APPVERSION',P_APPVERSION);
120 		    WSH_DEBUG_SV.log(l_module_name,'P_ACCEPTLICENSEAGREEMENT',P_ACCEPTLICENSEAGREEMENT);
121 		    WSH_DEBUG_SV.log(l_module_name,'P_RESPONSETYPE',P_RESPONSETYPE);
122 		END IF;
123 		--
124 		IF NOT FND_API.compatible_api_call(	l_api_version,
125  										p_api_version,
126 										l_api_name,
127 										G_PKG_NAME) THEN
128 	 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
129  		END IF;
130 
131 		-- Check p_init_msg_list
132 		IF FND_API.to_boolean(p_init_msg_list)	THEN
133 			FND_MSG_PUB.initialize;
134 		END IF;
135 
136 		-- initialize API return status to success
137 		x_return_status := FND_API.G_RET_STS_SUCCESS;
138 
139 		x_msg_count 	:= 0;
140 		x_msg_data 	:= NULL;
141 
142 		-- program specific logic begins here
143 
144 		-- initialize global variables
145 
146 
147 
148 
149 		l_request_in := p_request_in;
150 
151 
152 		--
153 		-- Debug Statements
154 		--
155 		IF l_debug_on THEN
156 		    WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_U_UTIL.GET_CARRIER_API_URL',WSH_DEBUG_SV.C_PROC_LEVEL);
157 		END IF;
158 		--
159 		L_UPS_URL := WSH_U_UTIL.Get_Carrier_API_URL(
160 	 						p_api_version		=> 1.0,
161 							p_init_msg_list	=> FND_API.G_TRUE,
162 							x_return_status	=> l_return_status,
163 							x_msg_count       => l_msg_count,
164 							x_msg_data        => l_msg_data,
165 							p_Carrier_Name		=> 'UPS',
166 							p_API_Name		   => 'CSP_VALIDATE');
167 		if l_return_status <> FND_API.G_RET_STS_SUCCESS then
168 				raise WSH_U_CAR_URL;
169 		end if;
170 
171 		L_INPUT_STR := L_UPS_URL || '?';
172 
173 		-- ---------------------------------------------------------------
174 		-- UPS standard parameters: AppVersion
175 		--                          AcceptLicenseAgreement
176 		--	     							 ResponseType
177 		-- ---------------------------------------------------------------
178 
179 		-- AppVersion ---------------------------------------------------------
180       if( p_AppVersion IS NULL) then
181 			raise WSH_U_APPVER;
182 			-- p_AppVersion := '1.0';
183       end if;
184 		L_INPUT_STR := L_INPUT_STR || 'AppVersion' ||'='|| p_AppVersion;
185 
186 		-- AcceptLicenseAgreement ---------------------------------------------
187       if( p_AcceptLicenseAgreement IS NULL) then
188 			raise WSH_U_LICAGRE;
189 			-- p_AcceptLicenseAgreement := 'YES';
190       end if;
191 		L_INPUT_STR := L_INPUT_STR || '&' ||'AcceptUPSLicenseAgreement'||'=' || p_AcceptLicenseAgreement;
192 
193 		-- ResponseType --------------------------------------------------------
194       if( p_ResponseType IS NULL) then
195 			raise WSH_U_RESTYP;
196 			-- p_ResponseType := 'application/x-ups-cszval';
197       end if;
198       L_INPUT_STR := L_INPUT_STR || '&' || 'ResponseType' ||'='|| p_ResponseType;
199 
200 		-- ---------------------------------------------------------------
201 		-- Program specific parameters start here
202 		-- ---------------------------------------------------------------
203 		if (l_request_in.City IS NULL and l_request_in.StateProv IS NULL
204 			and l_request_in.PostalCode IS NULL) then
205 			raise WSH_U_CSP;
206 		end if;
207 
208 		-- --------------------------------------------------------------------
209 		-- City is required if StateProv is NOT NULL and PostalCode is NULL
210 		-- --------------------------------------------------------------------
211 		if (l_request_in.City IS NULL) then
212 			if (l_request_in.StateProv is NOT NULL and l_request_in.PostalCode
213 				is NULL ) then
214 
215 				raise WSH_U_CITYORZIP;
216 			end if;
217 	   else
218 			L_INPUT_STR := L_INPUT_STR || '&' || 'City' ||'='|| l_request_in.City;
219 		end if;
220 
221 		-- ----------------------------------------------------------------
222 		-- StateProv cannot be specified without either City or PostalCode
223 		-- ----------------------------------------------------------------
224 		if(l_request_in.StateProv IS not NULL) then
225 			if (l_request_in.City IS NULL and l_request_in.PostalCode is NULL) then
226 				raise WSH_U_CITYORZIP;
227 			end if;
228 			L_INPUT_STR := L_INPUT_STR || '&' || 'StateProv'||'=' || l_request_in.StateProv;
229 		end if;
230 
231 		-- -------------------------------------------------------------------
232 		-- PostalCode is required when StateProv is populated and City is not
233 		-- provided
234 		-- -------------------------------------------------------------------
235 		if(l_request_in.PostalCode IS NULL) then
236 			if (l_request_in.StateProv is NOT NULL and l_request_in.City is NULL) then
237 					raise WSH_U_CITYORZIP;
238 			end if;
239 		else
240     		L_INPUT_STR := L_INPUT_STR || '&' || 'PostalCode' ||'='|| l_request_in.PostalCode;
241 		end if;
242 
243 		L_INPUT_STR := REPLACE(L_INPUT_STR, ' ', '+');
244 
245 			-- DBMS_OUTPUT.PUT_LINE('========== request begin =========');
246 			-- DBMS_OUTPUT.PUT_LINE(SUBSTR(L_INPUT_STR,0,50));
247 			-- DBMS_OUTPUT.PUT_LINE(SUBSTR(L_INPUT_STR,51,50));
248 			-- DBMS_OUTPUT.PUT_LINE(SUBSTR(L_INPUT_STR,101,50));
249 			-- DBMS_OUTPUT.PUT_LINE(SUBSTR(L_INPUT_STR,151,50));
250 			-- DBMS_OUTPUT.PUT_LINE(SUBSTR(L_INPUT_STR,201,50));
251 			-- DBMS_OUTPUT.PUT_LINE(SUBSTR(L_INPUT_STR,251,50));
252 			-- DBMS_OUTPUT.PUT_LINE('========== request end =========');
253 
254 		-- clear variables before calling subroutine
255 		l_return_status	:= FND_API.G_RET_STS_SUCCESS;
256 		l_msg_count			:= 0;
257 		l_msg_data			:= NULL;
258 
259 
260 	 	-- get proxy server URL
261 		--
262 		-- Debug Statements
263 		--
264 		IF l_debug_on THEN
265 		    WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_U_UTIL.GET_PROXY',WSH_DEBUG_SV.C_PROC_LEVEL);
266 		END IF;
267 		--
268 		L_INTERNET_PROXY := WSH_U_UTIL.Get_PROXY(
269 	 					p_api_version			=> 1.0,
270 						p_init_msg_list		=> FND_API.G_TRUE,
271 						x_return_status		=> l_return_status,
272 						x_msg_count				=> l_msg_count,
273 						x_msg_data				=> l_msg_data);
274 
275 		if l_return_status <> FND_API.G_RET_STS_SUCCESS then
276 				raise WSH_U_PROXY;
277 		end if;
278 		if L_INTERNET_PROXY is not NULL then
279 			l_output_data := utl_http.request_pieces(L_INPUT_STR,100,L_INTERNET_PROXY);
280 		else
281 			l_output_data := utl_http.request_pieces(L_INPUT_STR,100);
282 		end if;
283 
284           -- when no response is received from a request to a given URL
285 		-- then a formatted HTML error message may be returned, it contains the
286 		-- following error message
287 			l_find_error := INSTR(l_output_data(1), 'Can''t locate remote host');
288 			if l_find_error <> 0 then
289 				   raise WSH_U_NO_HOST;
290 		   	end if;
291 
292 
293 		-- It is only good for up to 100 iteration else it will fail.
294 		-- DBMS_OUTPUT.PUT_LINE('======= result begin =============');
295 		FOR i in 1 .. l_output_data.count LOOP
296 				L_OUTPUT_STR := L_OUTPUT_STR || l_output_data(i);
297 					-- DBMS_OUTPUT.PUT_LINE(SUBSTR(l_output_data(i), 1, 250));
298 					-- DBMS_OUTPUT.PUT_LINE(SUBSTR(l_output_data(i), 251, 250));
299 					-- DBMS_OUTPUT.PUT_LINE(SUBSTR(l_output_data(i), 501, 250));
300 					-- DBMS_OUTPUT.PUT_LINE(SUBSTR(l_output_data(i), 751, 250));
301 					-- DBMS_OUTPUT.PUT_LINE(SUBSTR(l_output_data(i), 1001, 250));
302 					-- DBMS_OUTPUT.PUT_LINE(SUBSTR(l_output_data(i), 1251, 250));
303 					-- DBMS_OUTPUT.PUT_LINE(SUBSTR(l_output_data(i), 1501, 250));
304 					-- DBMS_OUTPUT.PUT_LINE(SUBSTR(l_output_data(i), 1751, 250));
305 		END LOOP;
306 
307 		-- DBMS_OUTPUT.PUT_LINE('========== result end ===========');
308     	l_boundary_string_start		:= INSTR(L_OUTPUT_STR, 'boundary=', 1 , 1);
309 		if l_boundary_string_start <> 0 then
310     		l_boundary_string_start		:= l_boundary_string_start + 9;
311 			-- l_boundary_string_end	:= INSTR(L_OUTPUT_STR, '--', l_boundary_string_start,1);
312 			l_boundary_string_end		:= INSTR(L_OUTPUT_STR, FND_GLOBAL.LOCAL_CHR(13), l_boundary_string_start,1);
313 			l_boundary_string				:= SUBSTR(L_OUTPUT_STR,
314 													l_boundary_string_start ,
315 	 												l_boundary_string_end - l_boundary_string_start);
316 		else
317 
318 			l_boundary_string		:= 'UPSBOUNDARY';
319 		end if;
320 		l_boundary_string := '--' || l_boundary_string;
321 		-- DBMS_OUTPUT.PUT_LINE('Boundary String:'|| l_boundary_string);
322 
323 
324 
325 		LOOP
326 
327  			L_Locate_boundary :=INSTR(L_OUTPUT_STR, l_boundary_string ,L_Locate_boundary,1);
328 			L_Locate_Content := INSTR(L_OUTPUT_STR,'Content-type',L_Locate_boundary,1);
329 			-- DBMS_OUTPUT.PUT_LINE('LOCATE CONTENT IS************'||to_char(L_Locate_Content));
330 			L_Locate_Str_Len  := INSTR(L_OUTPUT_STR, 'Content-length',L_Locate_boundary,1);
331 			-- DBMS_OUTPUT.PUT_LINE('LOCATE STR IS************'||to_char(L_Locate_Str_Len));
332     		L_Locate_Begin   := INSTR(L_OUTPUT_STR,'UPSOnLine',L_Locate_boundary,1);
333 			-- DBMS_OUTPUT.PUT_LINE('LOCATE BEGIN IS************'||to_char(L_Locate_Begin));
334 			L_Locate_boundary_End := INSTR(L_OUTPUT_STR, l_boundary_string ,L_Locate_boundary,2);
335 			-- DBMS_OUTPUT.PUT_LINE('LOCATE boundary END************'||to_char(L_Locate_boundary_End));
336 
337 			IF(L_Locate_boundary_End > L_Locate_Begin) THEN
338 
339 				-- DBMS_OUTPUT.PUT_LINE('l_outrec_index BEGIN:' || to_char(l_outrec_index));
340   				l_outrec_index := l_outrec_index + 1;
341 				-- DBMS_OUTPUT.PUT_LINE('l_outrec_index END:' || to_char(l_outrec_index));
342 
343 
344 				-- Get Content-length
345 
346 				L_Locate_Str_Len_End := INSTR(L_OUTPUT_STR, FND_GLOBAL.LOCAL_CHR(13), L_Locate_Str_Len, 1);
347 				L_Content_Str_Len := TO_NUMBER(SUBSTR(L_OUTPUT_STR,(L_Locate_Str_Len+16),L_Locate_Str_Len_End - L_Locate_Str_Len - 16));
348 
349 				-- DBMS_OUTPUT.PUT_LINE('CONTENT STR LENGTH IS ***********'||to_char(L_Content_Str_Len));
350 				L_Content_Type := SUBSTR(L_OUTPUT_STR,(L_Locate_Content + LENGTH('Content-type: application/')),(L_Locate_Str_Len -  (L_Locate_Content + LENGTH('Content-type: application/'))));
351 
352 				L_CSPV_Message := SUBSTR(L_OUTPUT_STR, L_Locate_Begin, L_Content_Str_Len);
353 				-- DBMS_OUTPUT.put_line('Message Is:'||L_CSPV_Message);
354 				-- DBMS_OUTPUT.PUT_LINE('CONTENT_TYPE IS ************'||L_Content_Type||'*********');
355 
356 				if(SUBSTR(L_Content_Type,1,LENGTH('x-ups-cszval')) = 'x-ups-cszval' or
357 				 		SUBSTR(L_Content_Type,1,LENGTH('x-ups-error')) = 'x-ups-error')
358 				then
359 					-- DBMS_OUTPUT.PUT_LINE('===<begin> ======');
360 					L_Token_Start := 0;
361 					L_Token_End := 0;
362 
363 
364 					--
365 					-- Debug Statements
366 					--
367 					IF l_debug_on THEN
368 					    WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_U_UTIL.CALCULATE_TOKEN',WSH_DEBUG_SV.C_PROC_LEVEL);
369 					END IF;
370 					--
371 					x_CSPValidate_out(l_outrec_index).UPSOnLine :=
372 							WSH_U_UTIL.Calculate_Token(L_CSPV_Message,L_Token_Start,L_Token_End);
373 
374 					--
375 					-- Debug Statements
376 					--
377 					IF l_debug_on THEN
378 					    WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_U_UTIL.CALCULATE_TOKEN',WSH_DEBUG_SV.C_PROC_LEVEL);
379 					END IF;
380 					--
381 					x_CSPValidate_out(l_outrec_index).AppVersion :=
382 							WSH_U_UTIL.Calculate_Token(L_CSPV_Message, L_Token_Start,L_Token_End);
383 
384 					--
385 					-- Debug Statements
386 					--
387 					IF l_debug_on THEN
388 					    WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_U_UTIL.CALCULATE_TOKEN',WSH_DEBUG_SV.C_PROC_LEVEL);
389 					END IF;
390 					--
391 					x_CSPValidate_out(l_outrec_index).ReturnCode :=
392 							TO_NUMBER(WSH_U_UTIL.Calculate_Token(L_CSPV_Message, L_Token_Start,L_Token_End));
393 					-- DBMS_OUTPUT.PUT_LINE('Return Code: ' || TO_CHAR(x_CSPValidate_out(l_outrec_index).ReturnCode));
394 
395 					--
396 					-- Debug Statements
397 					--
398 					IF l_debug_on THEN
399 					    WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_U_UTIL.CALCULATE_TOKEN',WSH_DEBUG_SV.C_PROC_LEVEL);
400 					END IF;
401 					--
402 					x_CSPValidate_out(l_outrec_index).MessageText :=
403 							WSH_U_UTIL.Calculate_Token(L_CSPV_Message, L_Token_Start,L_Token_End);
404 
405 					x_CSPValidate_out(l_outrec_index).MessageNumber :=
406 							TO_NUMBER(SUBSTR(x_CSPValidate_out(l_outrec_index).MessageText,1,4));
407 					-- DBMS_OUTPUT.PUT_LINE('MessageNumber: ' || TO_CHAR(x_CSPValidate_out(l_outrec_index).MessageNumber));
408 					x_CSPValidate_out(l_outrec_index).MessageText :=
409 							SUBSTR(x_CSPValidate_out(l_outrec_index).MessageText,5,(LENGTH(x_CSPValidate_out(l_outrec_index).MessageText)-4));
410 					-- DBMS_OUTPUT.PUT_LINE('MessageText: ' || x_CSPValidate_out(l_outrec_index).MessageText);
411 
412 					if (x_CSPValidate_out(l_outrec_index).ReturnCode = 0) then
413 
414 						--
415 						-- Debug Statements
416 						--
417 						IF l_debug_on THEN
418 						    WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_U_UTIL.CALCULATE_TOKEN',WSH_DEBUG_SV.C_PROC_LEVEL);
419 						END IF;
420 						--
421 						x_CSPValidate_out(l_outrec_index).Rank :=
422 								TO_NUMBER(WSH_U_UTIL.Calculate_Token(L_CSPV_Message, L_Token_Start,L_Token_End));
423 
424 						--
425 						-- Debug Statements
426 						--
427 						IF l_debug_on THEN
428 						    WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_U_UTIL.CALCULATE_TOKEN',WSH_DEBUG_SV.C_PROC_LEVEL);
429 						END IF;
430 						--
431 						x_CSPValidate_out(l_outrec_index).Quality :=
432 								TO_NUMBER(WSH_U_UTIL.Calculate_Token(L_CSPV_Message, L_Token_Start,L_Token_End));
433 
434 						--
435 						-- Debug Statements
436 						--
437 						IF l_debug_on THEN
438 						    WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_U_UTIL.CALCULATE_TOKEN',WSH_DEBUG_SV.C_PROC_LEVEL);
439 						END IF;
440 						--
441 						x_CSPValidate_out(l_outrec_index).City :=
442 								WSH_U_UTIL.Calculate_Token(L_CSPV_Message, L_Token_Start,L_Token_End);
443 
444 						--
445 						-- Debug Statements
446 						--
447 						IF l_debug_on THEN
448 						    WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_U_UTIL.CALCULATE_TOKEN',WSH_DEBUG_SV.C_PROC_LEVEL);
449 						END IF;
450 						--
451 						x_CSPValidate_out(l_outrec_index).StateProv :=
452 								WSH_U_UTIL.Calculate_Token(L_CSPV_Message, L_Token_Start,L_Token_End);
453 
454 						--
455 						-- Debug Statements
456 						--
457 						IF l_debug_on THEN
458 						    WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_U_UTIL.CALCULATE_TOKEN',WSH_DEBUG_SV.C_PROC_LEVEL);
459 						END IF;
460 						--
461 						x_CSPValidate_out(l_outrec_index).PostalCodeLow :=
462 								WSH_U_UTIL.Calculate_Token(L_CSPV_Message, L_Token_Start,L_Token_End);
463 
464 						--
465 						-- Debug Statements
466 						--
467 						IF l_debug_on THEN
468 						    WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_U_UTIL.CALCULATE_TOKEN',WSH_DEBUG_SV.C_PROC_LEVEL);
469 						END IF;
470 						--
471 						x_CSPValidate_out(l_outrec_index).PostalCodeHigh :=
472 								WSH_U_UTIL.Calculate_Token(L_CSPV_Message, L_Token_Start,L_Token_End);
473 
474 					else
475 						x_CSPValidate_out(l_outrec_index).Rank := NULL;
476 
477 						x_CSPValidate_out(l_outrec_index).Quality := NULL;
478 
479 						x_CSPValidate_out(l_outrec_index).City := NULL;
480 
481 						x_CSPValidate_out(l_outrec_index).StateProv := NULL;
482 
483 						x_CSPValidate_out(l_outrec_index).PostalCodeLow := NULL;
484 
485 						x_CSPValidate_out(l_outrec_index).PostalCodeHigh := NULL;
486 
487 					end if;
488 					-- DBMS_OUTPUT.PUT_LINE('===<end> === application/x-ups-cszval ===');
489 				end if;
490 
491 
492 		END IF;
493 
494 		-- advance to next UPSBOUNDARYUPS section
495 		L_Locate_boundary := L_Locate_boundary_End;
496 
497  		EXIT WHEN L_Locate_Begin = 0;
498 
499     END LOOP;
500 
501 
502 
503 
504 --
505 -- Debug Statements
506 --
507 IF l_debug_on THEN
508     WSH_DEBUG_SV.pop(l_module_name);
509 END IF;
510 --
511 EXCEPTION
512 
513 		WHEN WSH_U_CAR_URL THEN
514 		   FND_MESSAGE.SET_NAME('WSH', 'WSH_U_CAR_URL');
515 			WSH_UTIL_CORE.ADD_MESSAGE(p_message_type);
516 			x_return_status := FND_API.G_RET_STS_ERROR;
517 			WSH_UTIL_CORE.get_messages( 'Y', l_msg_summary, l_msg_details, x_msg_count);
518 			if x_msg_count > 1 then
519 				x_msg_data := l_msg_summary || l_msg_details;
520 			else
521 				x_msg_data := l_msg_summary;
522 		   end if;
523 
524 			--
525 			-- Debug Statements
526 			--
527 			IF l_debug_on THEN
528 			    WSH_DEBUG_SV.logmsg(l_module_name,'WSH_U_CAR_URL exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
529 			    WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_U_CAR_URL');
530 			END IF;
531 			--
532 		WHEN WSH_U_NO_HOST THEN
533 		   FND_MESSAGE.SET_NAME('WSH', 'WSH_U_NO_HOST');
534 			WSH_UTIL_CORE.ADD_MESSAGE(p_message_type);
535 			x_return_status := FND_API.G_RET_STS_ERROR;
536 			WSH_UTIL_CORE.get_messages( 'Y', l_msg_summary, l_msg_details, x_msg_count);
537 			if x_msg_count > 1 then
538 				x_msg_data := l_msg_summary || l_msg_details;
539 			else
540 				x_msg_data := l_msg_summary;
541 		   end if;
542 
543 			--
544 			-- Debug Statements
545 			--
546 			IF l_debug_on THEN
547 			    WSH_DEBUG_SV.logmsg(l_module_name,'WSH_U_NO_HOST exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
548 			    WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_U_NO_HOST');
549 			END IF;
550 			--
551 		WHEN REQUEST_FAILED THEN
552 		   FND_MESSAGE.SET_NAME('WSH', 'WSH_U_REQUEST_FAILED');
553 			WSH_UTIL_CORE.ADD_MESSAGE(p_message_type);
554 			x_return_status := FND_API.G_RET_STS_ERROR;
555 			WSH_UTIL_CORE.get_messages( 'Y', l_msg_summary, l_msg_details, x_msg_count);
556 			if x_msg_count > 1 then
557 				x_msg_data := l_msg_summary || l_msg_details;
558 			else
559 				x_msg_data := l_msg_summary;
560 		   end if;
561 
562 			--
563 			-- Debug Statements
564 			--
565 			IF l_debug_on THEN
566 			    WSH_DEBUG_SV.logmsg(l_module_name,'REQUEST_FAILED exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
567 			    WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:REQUEST_FAILED');
568 			END IF;
569 			--
570 		WHEN INIT_FAILED THEN
571 		   FND_MESSAGE.SET_NAME('WSH', 'WSH_U_INIT_FAILED');
572 			WSH_UTIL_CORE.ADD_MESSAGE(p_message_type);
573 			x_return_status := FND_API.G_RET_STS_ERROR;
574 			WSH_UTIL_CORE.get_messages( 'Y', l_msg_summary, l_msg_details, x_msg_count);
575 			if x_msg_count > 1 then
576 				x_msg_data := l_msg_summary || l_msg_details;
577 			else
578 				x_msg_data := l_msg_summary;
579 		   end if;
580 
581 			--
582 			-- Debug Statements
583 			--
584 			IF l_debug_on THEN
585 			    WSH_DEBUG_SV.logmsg(l_module_name,'INIT_FAILED exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
586 			    WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:INIT_FAILED');
587 			END IF;
588 			--
589 		WHEN WSH_U_PROXY THEN
590 			FND_MESSAGE.SET_NAME('WSH', 'WSH_U_PROXY');
591 			WSH_UTIL_CORE.ADD_MESSAGE(p_message_type);
592 			x_return_status := FND_API.G_RET_STS_ERROR;
593 			WSH_UTIL_CORE.get_messages( 'Y', l_msg_summary, l_msg_details, x_msg_count);
594 			if x_msg_count > 1 then
595 				x_msg_data := l_msg_summary || l_msg_details;
596 			else
597 				x_msg_data := l_msg_summary;
598 		   end if;
599 
600 			--
601 			-- Debug Statements
602 			--
603 			IF l_debug_on THEN
604 			    WSH_DEBUG_SV.logmsg(l_module_name,'WSH_U_PROXY exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
605 			    WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_U_PROXY');
606 			END IF;
607 			--
608 		WHEN  WSH_U_APPVER THEN
609 			FND_MESSAGE.SET_NAME('WSH', 'WSH_U_APPVER');
610 			WSH_UTIL_CORE.ADD_MESSAGE(p_message_type);
611 			x_return_status := FND_API.G_RET_STS_ERROR;
612 			WSH_UTIL_CORE.get_messages( 'Y', l_msg_summary, l_msg_details, x_msg_count);
613 			if x_msg_count > 1 then
614 				x_msg_data := l_msg_summary || l_msg_details;
615 			else
616 				x_msg_data := l_msg_summary;
617 		   end if;
618 
619 			--
620 			-- Debug Statements
621 			--
622 			IF l_debug_on THEN
623 			    WSH_DEBUG_SV.logmsg(l_module_name,'WSH_U_APPVER exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
624 			    WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_U_APPVER');
625 			END IF;
626 			--
627 		WHEN  WSH_U_LICAGRE THEN
628 			FND_MESSAGE.SET_NAME('WSH', 'WSH_U_LICAGRE');
629 			WSH_UTIL_CORE.ADD_MESSAGE(p_message_type);
630 			x_return_status := FND_API.G_RET_STS_ERROR;
631 			WSH_UTIL_CORE.get_messages( 'Y', l_msg_summary, l_msg_details, x_msg_count);
632 			if x_msg_count > 1 then
633 				x_msg_data := l_msg_summary || l_msg_details;
634 			else
635 				x_msg_data := l_msg_summary;
636 		   end if;
637 
638 			--
639 			-- Debug Statements
640 			--
641 			IF l_debug_on THEN
642 			    WSH_DEBUG_SV.logmsg(l_module_name,'WSH_U_LICAGRE exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
643 			    WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_U_LICAGRE');
644 			END IF;
645 			--
646 		WHEN  WSH_U_RESTYP THEN
647 			FND_MESSAGE.SET_NAME('WSH', 'WSH_U_RESTYP');
648 			WSH_UTIL_CORE.ADD_MESSAGE(p_message_type);
649 			x_return_status := FND_API.G_RET_STS_ERROR;
650 			WSH_UTIL_CORE.get_messages( 'Y', l_msg_summary, l_msg_details, x_msg_count);
651 			if x_msg_count > 1 then
652 				x_msg_data := l_msg_summary || l_msg_details;
653 			else
654 				x_msg_data := l_msg_summary;
655 		   end if;
656 
657 		--
658 		-- Debug Statements
659 		--
660 		IF l_debug_on THEN
661 		    WSH_DEBUG_SV.logmsg(l_module_name,'WSH_U_RESTYP exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
662 		    WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_U_RESTYP');
663 		END IF;
664 		--
665 		WHEN WSH_U_CSP THEN
666 			FND_MESSAGE.SET_NAME('WSH', 'WSH_U_CSP');
667 			WSH_UTIL_CORE.ADD_MESSAGE(p_message_type);
668 			x_return_status := FND_API.G_RET_STS_ERROR;
669 			WSH_UTIL_CORE.get_messages( 'Y', l_msg_summary, l_msg_details, x_msg_count);
670 			if x_msg_count > 1 then
671 				x_msg_data := l_msg_summary || l_msg_details;
672 			else
673 				x_msg_data := l_msg_summary;
674 		   end if;
675 
676 			--
677 			-- Debug Statements
678 			--
679 			IF l_debug_on THEN
680 			    WSH_DEBUG_SV.logmsg(l_module_name,'WSH_U_CSP exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
681 			    WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_U_CSP');
682 			END IF;
683 			--
684 		WHEN WSH_U_CITYORZIP	 THEN
685 			FND_MESSAGE.SET_NAME('WSH', 'WSH_U_INQNO	');
686 			WSH_UTIL_CORE.ADD_MESSAGE(p_message_type);
687 			x_return_status := FND_API.G_RET_STS_ERROR;
688 			WSH_UTIL_CORE.get_messages( 'Y', l_msg_summary, l_msg_details, x_msg_count);
689 			if x_msg_count > 1 then
690 				x_msg_data := l_msg_summary || l_msg_details;
691 			else
692 				x_msg_data := l_msg_summary;
693 		   end if;
694 
695 			--
696 			-- Debug Statements
697 			--
698 			IF l_debug_on THEN
699 			    WSH_DEBUG_SV.logmsg(l_module_name,'WSH_U_CITYORZIP exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
700 			    WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_U_CITYORZIP');
701 			END IF;
702 			--
703 		WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
704 			x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
705 			IF	FND_MSG_PUB.check_msg_level
706 		        (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
707 			THEN
708 					FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
709 			END IF;
710 			FND_MSG_PUB.count_and_get ( p_count => x_msg_count, p_data => x_msg_data);
711 
712 --
713 -- Debug Statements
714 --
715 IF l_debug_on THEN
716     WSH_DEBUG_SV.logmsg(l_module_name,'FND_API.G_EXC_UNEXPECTED_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
717     WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:FND_API.G_EXC_UNEXPECTED_ERROR');
718 END IF;
719 --
720 		WHEN OTHERS THEN
721 			x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
722 			IF	FND_MSG_PUB.check_msg_level
723 		        (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
724 			THEN
725 					FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
726 			END IF;
727 			FND_MSG_PUB.count_and_get ( p_count => x_msg_count, p_data => x_msg_data);
728 
729 			--
730 			-- Debug Statements
731 			--
732 			IF l_debug_on THEN
733 			    WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
734 			    WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
735 			END IF;
736 			--
737 END CSP_Validate;
738 
739 
740 END WSH_U_CSPV;