DBA Data[Home] [Help]

PACKAGE BODY: APPS.EAM_OP_NETWORK_VALIDATE_PVT

Source


1 PACKAGE BODY EAM_OP_NETWORK_VALIDATE_PVT AS
2 /* $Header: EAMVONVB.pls 115.4 2003/06/18 00:16:48 baroy ship $ */
3 /***************************************************************************
4 --
5 --  Copyright (c) 2002 Oracle Corporation, Redwood Shores, CA, USA
6 --  All rights reserved.
7 --
8 --  FILENAME
9 --
10 --      EAMVONVB.pls
11 --
12 --  DESCRIPTION
13 --
14 --      Body of package EAM_OP_NETWORK_VALIDATE_PVT
15 --
16 --  NOTES
17 --
18 --  HISTORY
19 --
20 --  30-JUN-2002    Kenichi Nagumo     Initial Creation
21 ***************************************************************************/
22 
23 G_Pkg_Name      VARCHAR2(30) := 'EAM_OP_NETWORK_VALIDATE_PVT';
24 
25 g_token_tbl     EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
26 g_dummy         NUMBER;
27 
28     /*******************************************************************
29     * Procedure	: Check_Existence
30     * Returns	: None
31     * Parameters IN : Material Requirements Record
32     * Parameters OUT NOCOPY: Old Material Requirements Record
33     *                 Mesg Token Table
34     *                 Return Status
35     * Purpose	: Procedure will query the old EAM work order
36     *             record and return it in old record variables. If the
37     *             Transaction Type is Create and the record already
38     *             exists the return status would be error or if the
39     *             transaction type is Update and the record
40     *             does not exist then the return status would be an
41     *             error as well. Mesg_Token_Table will carry the
42     *             error messsage and the tokens associated with the
43     *             message.
44     *********************************************************************/
45 
46      PROCEDURE Check_Existence
47      ( p_eam_op_network_rec     IN  EAM_PROCESS_WO_PUB.eam_op_network_rec_type
48      , x_old_eam_op_network_rec OUT NOCOPY EAM_PROCESS_WO_PUB.eam_op_network_rec_type
49      , x_Mesg_Token_Tbl	        OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
50      , x_return_status	        OUT NOCOPY VARCHAR2
51         )
52      IS
53             l_token_tbl      EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
54             l_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
55             l_out_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
56             l_return_status  VARCHAR2(1);
57      BEGIN
58 
59 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Quering Operation Network'); END IF;
60 
61         EAM_OP_NETWORK_UTILITY_PVT.Query_Row
62         ( p_wip_entity_id       => p_eam_op_network_rec.wip_entity_id
63         , p_organization_id     => p_eam_op_network_rec.organization_id
64         , p_prior_operation     => p_eam_op_network_rec.prior_operation
65         , p_next_operation      => p_eam_op_network_rec.next_operation
66         , x_eam_op_network_rec  => x_old_eam_op_network_rec
67         , x_Return_status       => l_return_status
68         );
69 
70 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Query Row Returned with : ' || l_return_status); END IF;
71 
72         IF l_return_status = EAM_PROCESS_WO_PVT.G_RECORD_FOUND AND
73             p_eam_op_network_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE
74         THEN
75             l_token_tbl(1).token_name  := 'PRIOR_OPERATION';
76             l_token_tbl(1).token_value := p_eam_op_network_rec.prior_operation;
77 
78             l_out_mesg_token_tbl  := l_mesg_token_tbl;
79             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
80             (  x_Mesg_token_tbl => l_out_Mesg_Token_Tbl
81              , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
82              , p_message_name   => 'EAM_OPN_ALREADY_EXISTS'
83              , p_token_tbl      => l_token_tbl
84              );
85             l_mesg_token_tbl      := l_out_mesg_token_tbl;
86 
87             l_return_status := FND_API.G_RET_STS_ERROR;
88 
89         ELSIF l_return_status = EAM_PROCESS_WO_PVT.G_RECORD_NOT_FOUND AND
90              p_eam_op_network_rec.transaction_type IN
91              (EAM_PROCESS_WO_PVT.G_OPR_UPDATE, EAM_PROCESS_WO_PVT.G_OPR_DELETE)
92         THEN
93             l_token_tbl(1).token_name  := 'PRIOR_OPERATION';
94             l_token_tbl(1).token_value :=  p_eam_op_network_rec.prior_operation;
95 
96             l_out_mesg_token_tbl  := l_mesg_token_tbl;
97             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
98                         (  x_Mesg_token_tbl => l_out_Mesg_Token_Tbl
99                          , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
100                          , p_message_name   => 'EAM_OPN_DOESNOT_EXISTS'
101                          , p_token_tbl      => l_token_tbl
102                          );
103             l_mesg_token_tbl      := l_out_mesg_token_tbl;
104 
105             l_return_status := FND_API.G_RET_STS_ERROR;
106 
107         ELSIF l_Return_status = FND_API.G_RET_STS_UNEXP_ERROR
108         THEN
109             l_out_mesg_token_tbl  := l_mesg_token_tbl;
110             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
111             (  x_Mesg_token_tbl     => l_out_Mesg_Token_Tbl
112              , p_Mesg_Token_Tbl     => l_Mesg_Token_Tbl
113              , p_message_name       => NULL
114              , p_message_text       => 'Unexpected error while existence verification of ' || 'Operation Network '|| p_eam_op_network_rec.prior_operation , p_token_tbl => l_token_tbl
115              );
116             l_mesg_token_tbl      := l_out_mesg_token_tbl;
117             l_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
118 
119         ELSE /* Assign the relevant transaction type for SYNC operations */
120             IF p_eam_op_network_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_SYNC THEN
121                IF l_return_status = EAM_PROCESS_WO_PVT.G_RECORD_FOUND THEN
122                    x_old_eam_op_network_rec.transaction_type := EAM_PROCESS_WO_PVT.G_OPR_UPDATE;
123                ELSE
124                    x_old_eam_op_network_rec.transaction_type := EAM_PROCESS_WO_PVT.G_OPR_CREATE;
125                END IF;
126             END IF;
127             l_return_status := FND_API.G_RET_STS_SUCCESS;
128 
129         END IF;
130 
131         x_return_status := l_return_status;
132         x_mesg_token_tbl := l_mesg_token_tbl;
133     END Check_Existence;
134 
135 
136 
137     /********************************************************************
138     * Procedure     : Check_Attributes
139     * Parameters IN : Material Requirements Column record
140     *                 Old Material Requirements Column record
141     * Parameters OUT NOCOPY: Return Status
142     *                 Mesg Token Table
143     * Purpose       : Check_Attrbibutes procedure will validate every
144     *                 revised item attrbiute in its entirety.
145     **********************************************************************/
146 
147     PROCEDURE Check_Attributes
148         (  p_eam_op_network_rec      IN EAM_PROCESS_WO_PUB.eam_op_network_rec_type
149          , p_old_eam_op_network_rec  IN EAM_PROCESS_WO_PUB.eam_op_network_rec_type
150          , x_return_status           OUT NOCOPY VARCHAR2
151          , x_Mesg_Token_Tbl          OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
152     )
153     IS
154     l_err_text              VARCHAR2(2000) := NULL;
155     l_Mesg_Token_Tbl        EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
156     l_out_Mesg_Token_Tbl        EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
157     l_Token_Tbl             EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
158 
159     BEGIN
160 
161 
162 
163 --  prior_operation
164 
165 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating prior_operation . . . '); END IF;
166 
167    begin
168 
169    if (p_eam_op_network_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE) then
170 
171     select 1
172       into g_dummy
173       from wip_operations wo
174      where wo.organization_id = p_eam_op_network_rec.organization_id
175        and wo.wip_entity_id = p_eam_op_network_rec.wip_entity_id
176        and wo.operation_seq_num = p_eam_op_network_rec.prior_operation
177        and nvl(wo.operation_completed,'N') = 'N';
178 
179    end if;
180 
181     x_return_status := FND_API.G_RET_STS_SUCCESS;
182 
183   exception
184     when others then
185 
186       l_token_tbl(1).token_name  := 'PRIOR_OPERATION';
187       l_token_tbl(1).token_value :=  p_eam_op_network_rec.prior_operation;
188 
189             l_out_mesg_token_tbl  := l_mesg_token_tbl;
190       EAM_ERROR_MESSAGE_PVT.Add_Error_Token
191       (  p_message_name  => 'EAM_OPN_PRIOR_OP_INVALID'
192        , p_token_tbl     => l_token_tbl
193        , p_mesg_token_tbl     => l_mesg_token_tbl
194        , x_mesg_token_tbl     => l_out_mesg_token_tbl
195       );
196       l_mesg_token_tbl      := l_out_mesg_token_tbl;
197 
198       x_return_status := FND_API.G_RET_STS_ERROR;
199       x_mesg_token_tbl := l_mesg_token_tbl ;
200       return;
201 
202   end;
203 
204 
205 --  next_operation
206 
207 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating next_operation . . . '); END IF;
208 
209    begin
210 
211    if (p_eam_op_network_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE) then
212 
213     select 1
214       into g_dummy
215       from wip_operations wo
216      where wo.organization_id = p_eam_op_network_rec.organization_id
217        and wo.wip_entity_id = p_eam_op_network_rec.wip_entity_id
218        and wo.operation_seq_num = p_eam_op_network_rec.next_operation
219        and nvl(wo.operation_completed,'N') = 'N';
220 
221    end if;
222 
223     x_return_status := FND_API.G_RET_STS_SUCCESS;
224 
225   exception
226     when others then
227 
228       l_token_tbl(1).token_name  := 'NEXT_OPERATION';
229       l_token_tbl(1).token_value :=  p_eam_op_network_rec.next_operation;
230 
231       l_out_mesg_token_tbl  := l_mesg_token_tbl;
232       EAM_ERROR_MESSAGE_PVT.Add_Error_Token
233       (  p_message_name  => 'EAM_OPN_NEXT_OP_INVALID'
234        , p_token_tbl     => l_token_tbl
235        , p_mesg_token_tbl     => l_mesg_token_tbl
236        , x_mesg_token_tbl     => l_out_mesg_token_tbl
237       );
238       l_mesg_token_tbl      := l_out_mesg_token_tbl;
239 
240       x_return_status := FND_API.G_RET_STS_ERROR;
241       x_mesg_token_tbl := l_mesg_token_tbl ;
242       return;
243 
244   end;
245 
246         x_return_status := FND_API.G_RET_STS_SUCCESS;
247 
248         IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Within Operation Network Check Attributes . . . '); END IF;
249 
250 
251     END Check_Attributes;
252 
253     /*********************************************************************
254     * Procedure     : Check_Required
255     * Parameters IN : Material Requirements column record
256     * Parameters OUT NOCOPY: Mesg Token Table
257     *                 Return_Status
258     * Purpose       :
259     **********************************************************************/
260 
261     PROCEDURE Check_Required
262         (  p_eam_op_network_rec     IN EAM_PROCESS_WO_PUB.eam_op_network_rec_type
263          , x_return_status          OUT NOCOPY VARCHAR2
264          , x_Mesg_Token_Tbl         OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
265          )
266     IS
267             l_Mesg_Token_Tbl        EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
268             l_out_Mesg_Token_Tbl        EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
269             l_Token_Tbl             EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
270     BEGIN
271 
272         x_return_status := FND_API.G_RET_STS_SUCCESS;
273 
274 
275         IF p_eam_op_network_rec.wip_entity_id IS NULL
276         THEN
277             l_token_tbl(1).token_name  := 'PRIOR_OPERATION';
278             l_token_tbl(1).token_value :=  p_eam_op_network_rec.prior_operation;
279 
280             l_out_mesg_token_tbl  := l_mesg_token_tbl;
281             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
282             (  p_message_name	=> 'EAM_OPN_ENTITY_ID_REQUIRED'
283              , p_token_tbl		=> l_Token_tbl
284              , p_Mesg_Token_Tbl	=> l_Mesg_Token_Tbl
285              , x_Mesg_Token_Tbl	=> l_out_Mesg_Token_Tbl
286              );
287             l_mesg_token_tbl      := l_out_mesg_token_tbl;
288 
289             x_return_status := FND_API.G_RET_STS_ERROR;
290 
291         END IF;
292 
293 
294         IF p_eam_op_network_rec.organization_id IS NULL
295         THEN
296             l_token_tbl(1).token_name  := 'PRIOR_OPERATION';
297             l_token_tbl(1).token_value :=  p_eam_op_network_rec.prior_operation;
298 
299             l_out_mesg_token_tbl  := l_mesg_token_tbl;
300             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
301             (  p_message_name	=> 'EAM_OPN_ORG_REQUIRED'
302              , p_token_tbl		=> l_Token_tbl
303              , p_Mesg_Token_Tbl	=> l_Mesg_Token_Tbl
304              , x_Mesg_Token_Tbl	=> l_out_Mesg_Token_Tbl
305              );
306             l_mesg_token_tbl      := l_out_mesg_token_tbl;
307 
308             x_return_status := FND_API.G_RET_STS_ERROR;
309 
310         END IF;
311 
312 
313         IF p_eam_op_network_rec.prior_operation IS NULL
314         THEN
315             l_token_tbl(1).token_name  := 'PRIOR_OPERATION';
316             l_token_tbl(1).token_value :=  p_eam_op_network_rec.prior_operation;
317 
318             l_out_mesg_token_tbl  := l_mesg_token_tbl;
319             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
320             (  p_message_name	=> 'EAM_OPN_PRIOR_OP_REQUIRED'
321              , p_token_tbl		=> l_Token_tbl
322              , p_Mesg_Token_Tbl	=> l_Mesg_Token_Tbl
323              , x_Mesg_Token_Tbl	=> l_out_Mesg_Token_Tbl
324              );
325             l_mesg_token_tbl      := l_out_mesg_token_tbl;
326 
327             x_return_status := FND_API.G_RET_STS_ERROR;
328 
329         END IF;
330 
331 
332         IF p_eam_op_network_rec.next_operation IS NULL
333         THEN
334             l_token_tbl(1).token_name  := 'PRIOR_OPERATION';
335             l_token_tbl(1).token_value :=  p_eam_op_network_rec.prior_operation;
336 
337             l_out_mesg_token_tbl  := l_mesg_token_tbl;
338             EAM_ERROR_MESSAGE_PVT.Add_Error_Token
339             (  p_message_name	=> 'EAM_OPN_NEXT_OP_REQUIRED'
340              , p_token_tbl		=> l_Token_tbl
341              , p_Mesg_Token_Tbl	=> l_Mesg_Token_Tbl
342              , x_Mesg_Token_Tbl	=> l_out_Mesg_Token_Tbl
343              );
344             l_mesg_token_tbl      := l_out_mesg_token_tbl;
345 
346             x_return_status := FND_API.G_RET_STS_ERROR;
347 
348         END IF;
349 
350 
351 
352         x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
353 
354     END Check_Required;
355 
356 END EAM_OP_NETWORK_VALIDATE_PVT;