DBA Data[Home] [Help]

PACKAGE BODY: APPS.EAM_WO_QUA_UTILITY_PVT

Source


1 PACKAGE BODY EAM_WO_QUA_UTILITY_PVT AS
2 /* $Header: EAMVWQUB.pls 120.1 2006/06/17 02:25:46 baroy noship $ */
3 /***************************************************************************
4 --
5 --  Copyright (c) 2002 Oracle Corporation, Redwood Shores, CA, USA
6 --  All rights reserved.
7 --
8 --  FILENAME
9 --
10 --      EAMVWQUB.pls
11 --
12 --  DESCRIPTION
13 --
14 --      Body of package EAM_WO_QUA_UTILITY_PVT
15 --
16 --  NOTES
17 --
18 --  HISTORY
19 --
20 --  14-FEB-2005    mmaduska     Initial Creation
21 ***************************************************************************/
22 
23 G_PKG_NAME      CONSTANT VARCHAR2(30) := 'EAM_WO_QUA_UTILITY_PVT';
24 
25 PROCEDURE Perform_Writes
26 (
27 	p_eam_request_rec         IN  EAM_PROCESS_WO_PUB.eam_wo_quality_tbl_type,
28 	x_return_status           OUT NOCOPY  VARCHAR2,
29 	x_mesg_token_tbl          OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
30 )IS
31 BEGIN
32 	null;
33 END Perform_Writes;
34 
35   FUNCTION get_error_code(code IN NUMBER) RETURN VARCHAR2 IS
36     BEGIN
37 
38 
39 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Inside EAM_WO_QUA_UTILITY_PVT get_error_code'); END IF;
40 
41         --
42         -- Should figure out the error message from dictionary.
43         --
44         RETURN qa_validation_api.get_error_message (code);
45     END get_error_code;
46 
47 PROCEDURE get_error_messages(
48         errors IN qa_validation_api.ErrorArray,
49         plan_id IN NUMBER,
50         messages OUT NOCOPY VARCHAR2) IS
51 
52         separator CONSTANT VARCHAR2(1) := '@';
53         name qa_chars.prompt%TYPE;
54         code VARCHAR2(2000);
55     BEGIN
56         messages := '';
57 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Inside EAM_WO_QUA_UTILITY_PVT get_error_message'); END IF;
58 
59         --
60         -- This bug is discovered during bug fix for 3402251.
61         -- In some rare situation, this proc can be called when
62         -- error stack is actually empty.  Should return
63         -- immediately.
64         -- bso Mon Feb  9 22:06:09 PST 2004
65         --
66         IF errors.count = 0 then
67             RETURN;
68         END IF;
69 
70         FOR i IN errors.FIRST .. errors.LAST LOOP
71             name := qa_plan_element_api.get_prompt(plan_id,
72                 errors(i).element_id);
73             --
74             -- Just in case the prompt contains @
75             --
76             name := replace(name, separator, separator||separator);
77             code := get_error_code(errors(i).error_code);
78             messages := messages || name || ': ' || code;
79             IF i < errors.LAST THEN
80                 messages := messages || separator;
81             END IF;
82         END LOOP;
83 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Inside EAM_WO_QUA_UTILITY_PVT get_error_message completed ...'); END IF;
84     END get_error_messages;
85 
86 PROCEDURE insert_row
87 (
88 	  p_collection_id	   IN NUMBER
89 	, p_eam_wo_quality_tbl     IN  EAM_PROCESS_WO_PUB.eam_wo_quality_tbl_type
90 	, x_eam_wo_quality_tbl     OUT NOCOPY  EAM_PROCESS_WO_PUB.eam_wo_quality_tbl_type
91 	, x_return_status          OUT NOCOPY  VARCHAR2
92 	, x_mesg_token_tbl         OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
93  )IS
94 
95 	Type header_plan_id_tbl_type is table of NUMBER  INDEX BY BINARY_INTEGER;
96 	header_plan_id_tbl	header_plan_id_tbl_type;
97 	flag			boolean;
98 	header_counter NUMBER   :=0;
99 	l_eam_wo_quality_rec	EAM_PROCESS_WO_PUB.eam_wo_quality_rec_type;
100 	elements		qa_validation_api.ElementsArray;
101 	l_org_id		NUMBER;
102 	l_collection_id  	        NUMBER;
103 	temp_occurence		NUMBER;
104 	msg_count		NUMBER;
105 	msg_data		VARCHAR2(2000);
106 	error_array		qa_validation_api.ErrorArray;
107 	message_array		qa_validation_api.MessageArray;
108 	return_status		VARCHAR2(1);
109 	action_result		VARCHAR2(1);
110 	x_messages		varchar2(2000);
111         l_Mesg_Token_Tbl        EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
112 	l_txn_number		NUMBER;
113 
114 BEGIN
115 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Inside EAM_WO_QUA_UTILITY_PVT insert_row ...'); END IF;
116 
117 	IF  (p_eam_wo_quality_tbl.count >0) THEN
118 		l_org_id	:= p_eam_wo_quality_tbl(p_eam_wo_quality_tbl.FIRST).organization_id;
119 		IF p_eam_wo_quality_tbl(p_eam_wo_quality_tbl.FIRST).OPERATION_SEQ_NUMBER IS NOT NULL THEN
120 			l_txn_number := 33;
121 		ELSE
122 			l_txn_number := 31;
123 		END IF;
124 
125 	END IF;
126 
127 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Get the plan ids ...'); END IF;
128 
129 	l_collection_id := p_collection_id;
130 	-- following loops gets the different plan ids that are in the data
131 	-- for 3 collection plans there will be 3 differnet plan ids
132 	-- after this loop header_id_tbl table will contain the list of plan ids
133 	IF (p_eam_wo_quality_tbl.count >0) THEN
134 		  FOR i_counter in p_eam_wo_quality_tbl.first..p_eam_wo_quality_tbl.last LOOP
135 			  flag:=TRUE;
136 			  l_eam_wo_quality_rec := p_eam_wo_quality_tbl(i_counter);
137 
138 			  IF header_plan_id_tbl.COUNT  > 0 THEN
139 				  FOR J in header_plan_id_tbl.FIRST..header_plan_id_tbl.LAST LOOP
140 					IF l_eam_wo_quality_rec.plan_id = header_plan_id_tbl(j) THEN
141 						flag := FALSE;
142 					END IF;
143 				  END LOOP;
144 			  END IF;
145 
146 			  IF flag = TRUE THEN
147 				IF header_plan_id_tbl.COUNT > 0 THEN
148 				   header_plan_id_tbl(header_plan_id_tbl.COUNT + 1) := l_eam_wo_quality_rec.plan_id;
149 				ELSE
150 				   header_plan_id_tbl(1) := l_eam_wo_quality_rec.plan_id;
151 				END IF;
152 			  END IF;
153 		  END LOOP;
154 	END IF;
155 
156 	FOR xx IN header_plan_id_tbl.FIRST..header_plan_id_tbl.LAST loop
157 		elements.delete;
158 		FOR YY in p_eam_wo_quality_tbl.first..p_eam_wo_quality_tbl.last LOOP
159 			if p_eam_wo_quality_tbl(YY).PLAN_ID = header_plan_id_tbl(xx) then
160 				elements(p_eam_wo_quality_tbl(YY).ELEMENT_ID).id := p_eam_wo_quality_tbl(YY).ELEMENT_ID;
161 				elements(p_eam_wo_quality_tbl(YY).ELEMENT_ID).value := p_eam_wo_quality_tbl(YY).ELEMENT_VALUE;
162 			end if;
163 		END LOOP;
164 
165 --		set_validation_flag (elements, 31);
166 
167 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Calling qa_results_pub.insert_row ...'); END IF;
168 		qa_results_pub.insert_row(
169 			p_api_version => 1.0,
170 			p_init_msg_list => fnd_api.g_true,
171 			p_org_id => l_org_id,
172 			p_plan_id => header_plan_id_tbl(xx),
173 			p_spec_id => null,
174 			p_transaction_number => l_txn_number,
175 			p_transaction_id => null,
176 			p_enabled_flag => 1,
177 			p_commit =>  fnd_api.g_false,
178 			x_collection_id => l_collection_id,
179 			x_occurrence => temp_occurence,
180 			x_row_elements => elements,
181 			x_msg_count => msg_count,
182 			x_msg_data  => msg_data,
183 			x_error_array => error_array,
184 			x_message_array => message_array,
185 			x_return_status => return_status,
186 			x_action_result => action_result);
187 
188 			x_return_status := return_status;
189 
190 		IF error_array.count  <>0 THEN
191 			get_error_messages(error_array, header_plan_id_tbl(xx), x_messages);
192 
193 	                 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
194 				(  p_message_name       => NULL
195 				 , p_message_text       => x_messages
196 				 , x_mesg_token_Tbl     => x_mesg_token_tbl
197 				);
198 
199 		         return_status := EAM_ERROR_MESSAGE_PVT.G_STATUS_ERROR;
200 		END IF;
201 
202 		IF return_status <> 'S' THEN
203 			x_return_status := EAM_ERROR_MESSAGE_PVT.G_STATUS_ERROR;
204 			EAM_ERROR_MESSAGE_PVT.Add_Error_Token
205                         (  p_message_name       => NULL
206                          , p_message_text       => G_PKG_NAME ||' :Inserting Record ' || SQLERRM
207                          , x_mesg_token_Tbl     => x_mesg_token_tbl
208 			);
209 			return;
210 		END IF;
211 
212 	END LOOP;
213 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('completed the insert_row procedure  ...'); END IF;
214 
215      EXCEPTION WHEN OTHERS THEN
216 	return_status := EAM_ERROR_MESSAGE_PVT.G_STATUS_ERROR;
217 	EAM_ERROR_MESSAGE_PVT.Add_Error_Token
218                         (  p_message_name       => NULL
219                          , p_message_text       => G_PKG_NAME ||' :Inserting Record ' || SQLERRM
220                          , x_mesg_token_Tbl     => x_mesg_token_tbl
221           );
222 
223 END insert_row;
224 
225 END EAM_WO_QUA_UTILITY_PVT;