DBA Data[Home] [Help]

PACKAGE BODY: APPS.OE_BLANKET_FORM_CONTROL

Source


1 PACKAGE BODY OE_Blanket_Form_Control AS
2 /* $Header: OEXFBSOB.pls 120.5 2006/02/16 16:36:50 spagadal noship $ */
3 
4 -----------------------------------------------------------
5   -- Package Globals
6 -----------------------------------------------------------
7 
8      TYPE HEADER_CACHE IS TABLE OF oe_blanket_pub.header_rec_type INDEX BY BINARY_INTEGER;
9      TYPE LINE_CACHE   IS TABLE OF oe_blanket_pub.line_rec_type   INDEX BY BINARY_INTEGER;
10 
11      G_Header_Cache_Rec         Header_Cache;
12      G_Line_Cache_Rec           Line_Cache;
13      G_Blanket_Line_Number      Number;
14 
15      G_Header_Security_Cache  oe_blanket_pub.header_rec_type;
16      G_Line_Security_Cache    oe_blanket_pub.line_rec_type;
17 
18 
19 
20 ----------------------------------------------------------
21      PROCEDURE Header_Value_Conversion
22 ----------------------------------------------------------
23     (   p_header_rec         IN  OUT NOCOPY OE_Blanket_PUB.Header_Rec_type
24     ,   p_header_val_rec     IN  OUT NOCOPY OE_Order_PUB.Header_Val_Rec_Type
25     )IS
26        l_header_rec                            OE_Order_PUB.Header_Rec_Type;
27        l_order_type          varchar2(240);
28        l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
29      BEGIN
30 		OE_MSG_PUB.initialize;
31         l_header_rec.accounting_rule_id               := p_header_rec.accounting_rule_id;
32         l_header_rec.agreement_id                     := p_header_rec.agreement_id;
33         l_header_rec.price_list_id                    := p_header_rec.price_list_id;
34         l_header_rec.deliver_to_org_id                := p_header_rec.deliver_to_org_id;
35         l_header_rec.invoice_to_org_id                := p_header_rec.invoice_to_org_id;
36         l_header_rec.ship_to_org_id                   := p_header_rec.ship_to_org_id;
37         l_header_rec.salesrep_id                      := p_header_rec.salesrep_id;
38         l_header_rec.shipping_method_code             := p_header_rec.shipping_method_code;
39         l_header_rec.conversion_type_code             := p_header_rec.conversion_type_code;
40         l_header_rec.order_type_id                    := p_header_rec.order_type_id;
41         l_header_rec.invoicing_rule_id                := p_header_rec.invoicing_rule_id;
42         l_header_rec.freight_terms_code               := p_header_rec.freight_terms_code;
43         l_header_rec.payment_term_id                  := p_header_rec.payment_term_id;
44 -- hashraf pack J
45         l_header_rec.sold_to_site_use_id                   := p_header_rec.sold_to_site_use_id;
46         l_order_type :=  OE_Blanket_Form_Control.sales_order_type(p_header_rec.order_type_id);
47         p_header_val_rec := OE_Header_Util.Get_Values(p_header_rec => l_header_rec);
48         p_header_val_rec.order_type := l_order_type;
49      EXCEPTION
50 
51      WHEN NO_DATA_FOUND THEN
52 
53        /* IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
54         THEN
55 
56             fnd_message.set_name('ONT','OE_ID_TO_VALUE_ERROR');
57             FND_MESSAGE.SET_TOKEN('ATTRIBUTE','Header_Value_Conversion');
58             OE_MSG_PUB.Add;
59 
60         END IF; */
61         null;
62 
63 
64      WHEN OTHERS THEN
65 
66        /* IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
67         THEN
68             OE_MSG_PUB.Add_Exc_Msg
69             (   G_PKG_NAME
70             ,   'Header_Value_Conversion'
71             );
72         END IF;
73 
74         RAISE FND_API.G_EXC_UNEXPECTED_ERROR; */
75         null;
76 
77      END Header_Value_Conversion;
78 
79 
80 
81 ----------------------------------------------------------
82      PROCEDURE Line_Value_Conversion
83 ----------------------------------------------------------
84     (  p_line_rec            IN OUT  NOCOPY  OE_Blanket_PUB.Line_Rec_Type
85     ,  p_line_val_rec        IN OUT  NOCOPY  OE_Order_PUB.Line_Val_Rec_Type
86     )IS
87        l_line_rec                            OE_Order_PUB.Line_Rec_Type;
88        l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
89      BEGIN
90 
91 		OE_MSG_PUB.initialize;
92         l_line_rec.invoice_to_org_id                := p_line_rec.invoice_to_org_id;
93         l_line_rec.ship_to_org_id                   := p_line_rec.ship_to_org_id;
94         l_line_rec.deliver_to_org_id                := p_line_rec.deliver_to_org_id;
95         l_line_rec.accounting_rule_id               := p_line_rec.accounting_rule_id;
96         l_line_rec.invoicing_rule_id                := p_line_rec.invoicing_rule_id;
97         l_line_rec.agreement_id                     := p_line_rec.agreement_id;
98         l_line_rec.price_list_id                    := p_line_rec.price_list_id;
99         l_line_rec.shipping_method_code             := p_line_rec.shipping_method_code;
100         l_line_rec.freight_terms_code               := p_line_rec.freight_terms_code;
101         l_line_rec.ordered_item_id                  := p_line_rec.ordered_item_id;
102         l_line_rec.ship_from_org_id                 := p_line_rec.ship_from_org_id;
103 
104         p_line_val_rec := OE_Line_Util.Get_Values(p_line_rec => l_line_rec);
105 
106         OE_ID_TO_VALUE.Ship_From_Org(
107                     p_ship_from_org_id   => l_line_rec.ship_from_org_id
108                    ,x_ship_from_address1 => p_line_val_rec.ship_from_address1
109                    ,x_ship_from_address2 => p_line_val_rec.ship_from_address2
110                    ,x_ship_from_address3 => p_line_val_rec.ship_from_address3
111                    ,x_ship_from_address4 => p_line_val_rec.ship_from_address4
112                    ,x_ship_from_location => p_line_val_rec.ship_from_location
113                    ,x_ship_from_org      => p_line_val_rec.ship_from_org
114                    );
115      EXCEPTION
116 
117      WHEN NO_DATA_FOUND THEN
118 
119         /* IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
120         THEN
121 
122             fnd_message.set_name('ONT','OE_ID_TO_VALUE_ERROR');
123             FND_MESSAGE.SET_TOKEN('ATTRIBUTE','Line_Value_Conversion');
124             OE_MSG_PUB.Add;
125 
126         END IF; */
127         null;
128 
129 
130      WHEN OTHERS THEN
131 
132         /* IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
133         THEN
134             OE_MSG_PUB.Add_Exc_Msg
135             (   G_PKG_NAME
136             ,   'Line_Value_Conversion'
137             );
138         END IF;
139 
140         RAISE FND_API.G_EXC_UNEXPECTED_ERROR; */
141         null;
142      END Line_Value_Conversion;
143 
144 ----------------------------------------------------------
145      PROCEDURE Populate_Header_Values_ID
146 ----------------------------------------------------------
147     (  p_Header_rec            IN OUT  NOCOPY  OE_Blanket_PUB.Header_Rec_Type
148     ,  p_Header_val_rec        IN OUT  NOCOPY  OE_Order_PUB.Header_Val_Rec_Type
149     )IS
150      l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
151 
152      BEGIN
153 
154         OE_MSG_PUB.initialize;
155 
156         OE_ID_TO_VALUE.Ship_From_Org(
157                     p_ship_from_org_id   => p_header_rec.ship_from_org_id
158                    ,x_ship_from_address1 => p_header_val_rec.ship_from_address1
159                    ,x_ship_from_address2 => p_header_val_rec.ship_from_address2
160                    ,x_ship_from_address3 => p_header_val_rec.ship_from_address3
161                    ,x_ship_from_address4 => p_header_val_rec.ship_from_address4
162                    ,x_ship_from_location => p_header_val_rec.ship_from_location
163                    ,x_ship_from_org      => p_header_val_rec.ship_from_org
164                    );
165 
166 
167 
168        if p_header_rec.ship_to_org_id is not null then
169                      OE_ID_TO_VALUE.Ship_To_Org
170                             (   p_ship_to_org_id        => p_header_rec.ship_To_org_id
171                                 , x_ship_to_address1    => p_header_val_rec.ship_to_address1
172                                 , x_ship_to_address2    => p_header_val_rec.ship_to_address2
173                                 , x_ship_to_address3    => p_header_val_rec.ship_to_address3
174                                 , x_ship_to_address4    => p_header_val_rec.ship_to_address4
175                                 , x_ship_to_location    => p_header_val_rec.ship_to_location
176                                 , x_ship_to_org         => p_header_val_rec.ship_to_org
177                                 , x_ship_to_city        => p_header_val_rec.ship_to_city
178                                 , x_ship_to_state       => p_header_val_rec.ship_to_state
179                                 , x_ship_to_postal_code => p_header_val_rec.ship_to_zip
180                                 , x_ship_to_country     => p_header_val_rec.ship_to_country
181                                 );
182        end if;
183 
184        if p_header_rec.deliver_to_org_id is not null then
185                      OE_ID_TO_VALUE.deliver_To_Org
186                             (   p_deliver_to_org_id        => p_header_rec.deliver_To_org_id
187                                 , x_deliver_to_address1    => p_header_val_rec.deliver_to_address1
188                                 , x_deliver_to_address2    => p_header_val_rec.deliver_to_address2
189                                 , x_deliver_to_address3    => p_header_val_rec.deliver_to_address3
190                                 , x_deliver_to_address4    => p_header_val_rec.deliver_to_address4
191                                 , x_deliver_to_location    => p_header_val_rec.deliver_to_location
192                                 , x_deliver_to_org         => p_header_val_rec.deliver_to_org
193                                 , x_deliver_to_city        => p_header_val_rec.deliver_to_city
194                                 , x_deliver_to_state       => p_header_val_rec.deliver_to_state
195                                 , x_deliver_to_postal_code => p_header_val_rec.deliver_to_zip
196                                 , x_deliver_to_country     => p_header_val_rec.deliver_to_country
197                                 );
198        end if;
199 
200 
201        if p_header_rec.invoice_to_org_id is not null then
202                      OE_ID_TO_VALUE.invoice_To_Org
203                             (   p_invoice_to_org_id        => p_header_rec.invoice_To_org_id
204                                 , x_invoice_to_address1    => p_header_val_rec.invoice_to_address1
205                                 , x_invoice_to_address2    => p_header_val_rec.invoice_to_address2
206                                 , x_invoice_to_address3    => p_header_val_rec.invoice_to_address3
207                                 , x_invoice_to_address4    => p_header_val_rec.invoice_to_address4
208                                 , x_invoice_to_location    => p_header_val_rec.invoice_to_location
209                                 , x_invoice_to_org         => p_header_val_rec.invoice_to_org
210                                 , x_invoice_to_city        => p_header_val_rec.invoice_to_city
211                                 , x_invoice_to_state       => p_header_val_rec.invoice_to_state
212                                 , x_invoice_to_postal_code => p_header_val_rec.invoice_to_zip
213                                 , x_invoice_to_country     => p_header_val_rec.invoice_to_country
214                                 );
215        end if;
216 
217 -- hashraf ... start of pack J
218        if p_header_rec.sold_to_site_use_id is not null then
219 	   OE_ID_TO_VALUE.CUSTOMER_LOCATION
220            (  p_sold_to_site_use_id       => p_header_rec.sold_to_site_use_id,
221  	      x_sold_to_location_address1 => p_header_val_rec.SOLD_TO_LOCATION_ADDRESS1,
222  	      x_sold_to_location_address2 => p_header_val_rec.SOLD_TO_LOCATION_ADDRESS2,
223 	      x_sold_to_location_address3 => p_header_val_rec.SOLD_TO_LOCATION_ADDRESS3,
224 	      x_sold_to_location_address4 => p_header_val_rec.SOLD_TO_LOCATION_ADDRESS4,
225 	      x_sold_to_location     => p_header_val_rec.SOLD_TO_LOCATION,
226 
227 	      x_sold_to_location_city => p_header_val_rec.SOLD_TO_LOCATION_CITY,
228 	      x_sold_to_location_state => p_header_val_rec.SOLD_TO_LOCATION_STATE,
229 	      x_sold_to_location_postal => p_header_val_rec.SOLD_TO_LOCATION_POSTAL,
230  	      x_sold_to_location_country => p_header_val_rec.SOLD_TO_LOCATION_COUNTRY
231 );
232        end if;
233        if p_header_rec.transaction_phase_code is not null then
234           p_header_val_rec.Transaction_Phase  := OE_ID_TO_VALUE.Transaction_Phase(p_header_rec.Transaction_Phase_Code);
235        end if;
236        if p_header_rec.flow_status_code is not null then
237           p_header_val_rec.Status  := OE_ID_TO_VALUE.Flow_Status(p_header_rec.Flow_Status_Code);
238        end if;
239        if p_header_rec.user_status_code is not null then
240           p_header_val_rec.User_Status  := OE_ID_TO_VALUE.User_Status(p_header_rec.User_Status_Code);
241        end if;
242 
243 -- hashraf ... end of pack J
244 
245        if p_header_rec.freight_terms_code is not null then
246           p_header_val_rec.Freight_Terms   := OE_ID_TO_VALUE.Freight_Terms(p_header_rec.freight_terms_code);
247        end if;
248        if p_header_rec.price_list_id is not null then
249           p_header_val_rec.Price_List      := OE_ID_TO_VALUE.Price_List(p_header_rec.price_list_id);
250        end if;
251        if p_header_rec.conversion_type_code is not null then
252           p_header_val_rec.Conversion_Type := OE_ID_TO_VALUE.Conversion_Type(p_header_rec.conversion_type_code);
253        end if;
254        if p_header_rec.payment_term_id is not null then
255           p_header_val_rec.Payment_Term    := OE_ID_TO_VALUE.Payment_Term(p_header_rec.payment_term_id);
256        end if;
257        if p_header_rec.accounting_rule_id is not null then
258           p_header_val_rec.Accounting_Rule := OE_ID_TO_VALUE.Accounting_Rule(p_header_rec.accounting_rule_id);
259        end if;
260        if p_header_rec.invoicing_rule_id is not null then
261           p_header_val_rec.Invoicing_Rule  := OE_ID_TO_VALUE.Invoicing_Rule(p_header_rec.invoicing_rule_id);
262        end if;
263        if p_header_rec.Salesrep_id is not null then
264           p_header_val_rec.salesrep        := OE_ID_TO_VALUE.Salesrep(p_header_rec.Salesrep_id);
265        end if;
266 
267        BEGIN
268            Select meaning
269                   INTO p_header_val_rec.shipping_method
270            FROM   oe_ship_methods_v
271            WHERE  lookup_code=p_header_rec.shipping_method_code;
272        EXCEPTION
273            WHEN NO_DATA_FOUND THEN
274              Null;
275            When too_many_rows then
276              Null;
277            When others then
278              Null;
279        END;
280 
281 
282      Exception
283         when others then
284           null;
285      END;
286 
287 ----------------------------------------------------------
288      PROCEDURE Populate_Line_Values_ID
289 ----------------------------------------------------------
290     (  p_Line_rec            IN OUT  NOCOPY  OE_Blanket_PUB.Line_Rec_Type
291     ,  p_line_val_rec        IN OUT  NOCOPY  OE_Order_PUB.Line_Val_Rec_Type
292     )IS
293      BEGIN
294           oe_debug_pub.add('enter Populate_Line_Values_ID');
295 
296 		OE_MSG_PUB.initialize;
297         OE_ID_TO_VALUE.Ship_From_Org(
298                     p_ship_from_org_id   => p_line_rec.ship_from_org_id
299                    ,x_ship_from_address1 => p_line_val_rec.ship_from_address1
300                    ,x_ship_from_address2 => p_line_val_rec.ship_from_address2
301                    ,x_ship_from_address3 => p_line_val_rec.ship_from_address3
302                    ,x_ship_from_address4 => p_line_val_rec.ship_from_address4
303                    ,x_ship_from_location => p_line_val_rec.ship_from_location
304                    ,x_ship_from_org      => p_line_val_rec.ship_from_org
305                    );
306        oe_debug_pub.add('before Populate_Line_Values_ID ship_to_org_id '||p_line_rec.ship_to_org_id);
307        if p_line_rec.ship_to_org_id is not null then
308           oe_debug_pub.add('ship to : '||p_line_rec.ship_To_org_id);
309                      OE_ID_TO_VALUE.Ship_To_Org
313                                 , x_ship_to_address3    => p_line_val_rec.ship_to_address3
310                             (   p_ship_to_org_id        => p_line_rec.ship_To_org_id
311                                 , x_ship_to_address1    => p_line_val_rec.ship_to_address1
312                                 , x_ship_to_address2    => p_line_val_rec.ship_to_address2
314                                 , x_ship_to_address4    => p_line_val_rec.ship_to_address4
315                                 , x_ship_to_location    => p_line_val_rec.ship_to_location
316                                 , x_ship_to_org         => p_line_val_rec.ship_to_org
317                                 , x_ship_to_city        => p_line_val_rec.ship_to_city
318                                 , x_ship_to_state       => p_line_val_rec.ship_to_state
319                                 , x_ship_to_postal_code => p_line_val_rec.ship_to_zip
320                                 , x_ship_to_country     => p_line_val_rec.ship_to_country
321                                 );
322        end if;
323        oe_debug_pub.add('After Populate_Line_Values_ID ship_to_org_id '||p_line_rec.ship_to_org_id);
324 
325        if p_line_rec.deliver_to_org_id is not null then
326                      OE_ID_TO_VALUE.deliver_To_Org
327                             (   p_deliver_to_org_id        => p_line_rec.deliver_To_org_id
328                                 , x_deliver_to_address1    => p_line_val_rec.deliver_to_address1
329                                 , x_deliver_to_address2    => p_line_val_rec.deliver_to_address2
330                                 , x_deliver_to_address3    => p_line_val_rec.deliver_to_address3
331                                 , x_deliver_to_address4    => p_line_val_rec.deliver_to_address4
332                                 , x_deliver_to_location    => p_line_val_rec.deliver_to_location
333                                 , x_deliver_to_org         => p_line_val_rec.deliver_to_org
334                                 , x_deliver_to_city        => p_line_val_rec.deliver_to_city
335                                 , x_deliver_to_state       => p_line_val_rec.deliver_to_state
336                                 , x_deliver_to_postal_code => p_line_val_rec.deliver_to_zip
337                                 , x_deliver_to_country     => p_line_val_rec.deliver_to_country
338                                 );
339        end if;
340 
341        if p_line_rec.invoice_to_org_id is not null then
342                      OE_ID_TO_VALUE.invoice_To_Org
343                             (   p_invoice_to_org_id        => p_line_rec.invoice_To_org_id
344                                 , x_invoice_to_address1    => p_line_val_rec.invoice_to_address1
345                                 , x_invoice_to_address2    => p_line_val_rec.invoice_to_address2
346                                 , x_invoice_to_address3    => p_line_val_rec.invoice_to_address3
347                                 , x_invoice_to_address4    => p_line_val_rec.invoice_to_address4
348                                 , x_invoice_to_location    => p_line_val_rec.invoice_to_location
352                                 , x_invoice_to_postal_code => p_line_val_rec.invoice_to_zip
349                                 , x_invoice_to_org         => p_line_val_rec.invoice_to_org
350                                 , x_invoice_to_city        => p_line_val_rec.invoice_to_city
351                                 , x_invoice_to_state       => p_line_val_rec.invoice_to_state
353                                 , x_invoice_to_country     => p_line_val_rec.invoice_to_country
354                                 );
355        end if;
356 
357 
358        if p_line_rec.freight_terms_code is not null then
359           p_line_val_rec.Freight_Terms   := OE_ID_TO_VALUE.Freight_Terms(p_line_rec.freight_terms_code);
360        end if;
361        if p_line_rec.agreement_id is not null then
362           p_line_val_rec.Agreement       := OE_ID_TO_VALUE.Agreement(p_line_rec.agreement_id);
363        end if;
364        if p_line_rec.price_list_id is not null then
365           p_line_val_rec.Price_List      := OE_ID_TO_VALUE.Price_List(p_line_rec.price_list_id);
366        end if;
367        if p_line_rec.payment_term_id is not null then
368           p_line_val_rec.Payment_Term    := OE_ID_TO_VALUE.Payment_Term(p_line_rec.payment_term_id);
369        end if;
370        if p_line_rec.accounting_rule_id is not null then
371           p_line_val_rec.Accounting_Rule := OE_ID_TO_VALUE.Accounting_Rule(p_line_rec.accounting_rule_id);
372        end if;
373        if p_line_rec.invoicing_rule_id is not null then
374           p_line_val_rec.Invoicing_Rule  := OE_ID_TO_VALUE.Invoicing_Rule(p_line_rec.invoicing_rule_id);
375        end if;
376 
377 -- hashraf ... start of pack J
378        if p_line_rec.transaction_phase_code is not null then
379           p_line_val_rec.transaction_phase  := OE_ID_TO_VALUE.Transaction_Phase(p_line_rec.transaction_phase_code);
380        end if;
381 -- hashraf ... end of pack J
382 
383        if p_line_rec.Salesrep_id is not null then
384           p_line_val_rec.salesrep        := OE_ID_TO_VALUE.Salesrep(p_line_rec.Salesrep_id);
385        end if;
386 
387        BEGIN
388 
389            Select meaning
390                   INTO p_Line_val_rec.shipping_method
391            FROM   oe_ship_methods_v
392            WHERE  lookup_code=p_line_rec.shipping_method_code;
393 
394        EXCEPTION
395            WHEN NO_DATA_FOUND THEN
396              Null;
397            When too_many_rows then
398              Null;
399            When others then
400              Null;
401        END;
402 
403      Exception
404         when others then
405           null;
406      END;
407 
408 ----------------------------------------------------------
409      PROCEDURE Validate_Entity
410 ----------------------------------------------------------
411      (p_header_rec         IN OUT NOCOPY       OE_Blanket_PUB.Header_rec_type,
412       x_return_status      OUT    NOCOPY       VARCHAR2,
413       x_msg_count          OUT    NOCOPY       NUMBER,
414       x_msg_data           OUT    NOCOPY       VARCHAR2
415      )IS
416           l_old_header_rec      oe_blanket_pub.header_rec_type;
417           l_old_blanket_number  number;
418           l_api_name            CONSTANT VARCHAR2(30)  := 'Validate_Entity';
419           l_debug_level         CONSTANT NUMBER        := oe_debug_pub.g_debug_level;
420      BEGIN
421 		OE_MSG_PUB.initialize;
422 
423 
424          l_old_blanket_number := p_header_rec.order_number;
425 
426          IF p_header_rec.header_id is null THEN
427 
428               l_old_header_rec := NULL;
429 
430          ELSE
431 
432               Load_Blanket_Header_Rec (p_header_rec,l_old_header_rec);
433 
434          END IF;
435 
436          oe_debug_pub.add('Before sending to the API New Blanket MAX number FROM the API '
437                         ||p_header_rec.blanket_max_amount);
438          oe_debug_pub.add('Before sending to the API OLd Blanket MAX number FROM the API '
439                         ||l_old_header_rec.blanket_max_amount);
440          oe_debug_pub.add('Before sending to the API New Blanket MIN number FROM the API '
441                         ||p_header_rec.blanket_min_amount);
442          oe_debug_pub.add('Before sending to the API OLd Blanket MIN number FROM the API '
443                         ||l_old_header_rec.blanket_min_amount);
444 
445          OE_Blanket_Util.Validate_Entity(p_header_rec,
446                                          l_old_header_rec,
447                                          x_return_status);
448 
449          oe_debug_pub.add('After returning from the API New Blanket MAX number FROM the API '
450                         ||p_header_rec.blanket_max_amount);
451          oe_debug_pub.add('After returning from the API OLd Blanket MAX number FROM the API '
452                         ||l_old_header_rec.blanket_max_amount);
453          oe_debug_pub.add('After returning from the API New Blanket MIN number FROM the API '
454                         ||p_header_rec.blanket_min_amount);
455          oe_debug_pub.add('After returning from the API OLd Blanket MIN number FROM the API '
456                         ||l_old_header_rec.blanket_min_amount);
457 
458          oe_debug_pub.add('Return status of validate entity API '
459                         ||x_return_status);
460 
464                         ||x_return_status);
461          IF x_return_status = FND_API.G_RET_STS_ERROR THEN
462 
463            oe_debug_pub.add('Return status int the IF Expected error API '
465            RAISE FND_API.G_EXC_ERROR;
466 
467          ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
468 
469            oe_debug_pub.add('Return status int the ELSE in the unexpected errorAPI '
470                         ||x_return_status);
471            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
472 
473          END IF;
474 
475          oe_debug_pub.add('Before udation of the cache New Blanket MAX number after exp FROM the API '
476                         ||p_header_rec.blanket_max_amount);
477          oe_debug_pub.add('Before udation of the cache OLd Blanket MAX number after exp FROM the API '
478                         ||l_old_header_rec.blanket_max_amount);
479          oe_debug_pub.add('Before udation of the cache New Blanket MIN number after exp FROM the API '
480                         ||p_header_rec.blanket_min_amount);
481          oe_debug_pub.add('Before udation of the cache OLd Blanket MIN number after exp FROM the API '
482                         ||l_old_header_rec.blanket_min_amount);
483 
484          Update_Header_Cache(p_header_rec);
485 
486          oe_debug_pub.add('After udation of the cache New Blanket MAX number after exp FROM the API '
487                         ||p_header_rec.blanket_max_amount);
488          oe_debug_pub.add('After udation of the cache OLd Blanket MAX number after exp FROM the API '
489                         ||l_old_header_rec.blanket_max_amount);
490          oe_debug_pub.add('After udation of the cache New Blanket MIN number after exp FROM the API '
491                         ||p_header_rec.blanket_min_amount);
492          oe_debug_pub.add('After udation of the cache OLd Blanket MIN number after exp FROM the API '
493                         ||l_old_header_rec.blanket_min_amount);
494 
495          oe_msg_pub.count_and_get
496          (   p_count     => x_msg_count
497           ,  p_data      => x_msg_data);
498 
499          oe_debug_pub.add('After Validate Entity of the cache x_msg_count Header' ||x_msg_count);
500          oe_debug_pub.add('After Validate Entity of the cache x_msg_data Header' ||x_msg_data);
501 
502      EXCEPTION
503 
504          WHEN FND_API.G_EXC_ERROR THEN
505 
506              x_return_status := FND_API.G_RET_STS_ERROR;
507              --  Get message count and data
508 
509              oe_msg_pub.count_and_get
510              (   p_count                       => x_msg_count
511               ,  p_data                        => x_msg_data
512               );
513 
514          WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
515 
516              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
517              --  Get message count and data
518              oe_msg_pub.count_and_get
519              (   p_count                       => x_msg_count
520              ,   p_data                        => x_msg_data
521              );
522 
523          WHEN OTHERS THEN
524              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
525 
526          IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
527 
528              OE_MSG_PUB.Add_Exc_Msg
529                     (G_PKG_NAME,
530                      l_api_name);
531 
532          END IF;
533 
534          --  Get message count and data
535 
536          OE_MSG_PUB.Count_And_Get
537          ( p_count => x_msg_count,
538           p_data  => x_msg_data);
539 
540      END Validate_Entity;
541 
542 
543 ----------------------------------------------------------
544      PROCEDURE Validate_Entity
545 ----------------------------------------------------------
546      (p_line_rec           IN OUT NOCOPY   OE_Blanket_PUB.line_rec_type,
547       x_return_status      IN OUT NOCOPY   VARCHAR2,
548       x_msg_count          OUT    NOCOPY   NUMBER,
549       x_msg_data           OUT    NOCOPY   VARCHAR2
550 
551      ) IS
552        l_old_line_rec    oe_blanket_pub.line_rec_type;
553        l_api_name         CONSTANT VARCHAR2(30)         := 'Validate_Entity';
554        l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
555      BEGIN
556 
557          OE_MSG_PUB.initialize;
558 
559          x_return_status := FND_API.G_RET_STS_SUCCESS;
560 
561          if p_line_rec.line_id is null then
562 
563               l_old_line_rec := NULL;
564 
565          else
566 
567             Load_Blanket_line_Rec (p_line_rec,l_old_line_rec);
568 
569          end if;
570 
571          oe_debug_pub.add('Inventory item id - RAJ' || p_line_rec.inventory_item_id);
572 
573          OE_Blanket_Util.Validate_Entity(p_line_rec,
574 				l_old_line_rec,
575 				x_return_status);
576 
577          IF x_return_status = FND_API.G_RET_STS_ERROR THEN
578               RAISE FND_API.G_EXC_ERROR;
579          ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
580               RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
581          END IF;
582 
583          Update_Line_Cache(p_line_rec);
584 
585          if nvl(G_Blanket_Line_Number,0) < nvl(p_line_rec.line_number,0) then
586              G_Blanket_Line_Number := p_line_rec.line_Number;
590          (   p_count     => x_msg_count
587          end if;
588 
589          oe_msg_pub.count_and_get
591           ,  p_data      => x_msg_data);
592 
593          oe_debug_pub.add('After Validate Entity of the cache x_msg_count Line' ||x_msg_count);
594          oe_debug_pub.add('After Validate Entity of the cache x_msg_data Line' ||x_msg_data);
595 
596      EXCEPTION
597 
598          WHEN FND_API.G_EXC_ERROR THEN
599                    oe_debug_pub.add('Return Status is-Exp ' || X_return_status);
600                    x_return_status := FND_API.G_RET_STS_ERROR;
601 
602                    --  Get message count and data
603 
604                    oe_msg_pub.count_and_get
605                        (   p_count                       => x_msg_count
606                         ,  p_data                        => x_msg_data
607                        );
608 
609           WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
610 
611                   x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
612 
613                   --  Get message count and data
614 
615                   oe_msg_pub.count_and_get
616                   (   p_count                       => x_msg_count
617                   ,   p_data                        => x_msg_data
618                   );
619 
620           WHEN OTHERS THEN
621                   x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
622 
623                   IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
624 
625                       OE_MSG_PUB.Add_Exc_Msg
626                              (G_PKG_NAME,
627                               l_api_name);
628 
629                   END IF;
630 
631                  --  Get message count and data
632 
633                   OE_MSG_PUB.Count_And_Get
634                   ( p_count => x_msg_count,
635                    p_data  => x_msg_data);
636 
637      END Validate_Entity;
638 
639 
640 ----------------------------------------------------------
641      PROCEDURE Insert_Row
642 ----------------------------------------------------------
643      (p_header_rec     IN OUT NOCOPY  OE_Blanket_PUB.Header_rec_type,
644       x_return_status  OUT NOCOPY VARCHAR2,
645       x_msg_count      OUT NOCOPY NUMBER,
646       x_msg_data       OUT NOCOPY VARCHAR2
647      )
648      IS
649        l_api_name         CONSTANT VARCHAR2(30)         := 'Insert_Row';
650        l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
651      BEGIN
652 		OE_MSG_PUB.initialize;
653          oe_debug_pub.add('Entering Header OE_Blanket_Form_Control.Insert_row', 1);
654 
655          OE_Blanket_Util.Insert_Row(p_header_rec,X_RETURN_STATUS);
656 
657          IF x_return_status = FND_API.G_RET_STS_ERROR THEN
658              RAISE FND_API.G_EXC_ERROR;
659          ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
660              RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
661          END IF;
662 
663          oe_msg_pub.count_and_get
664          (   p_count     => x_msg_count
665           ,  p_data      => x_msg_data);
666 
667          oe_debug_pub.add('Entering Header OE_Blanket_Form_Control.Insert_row', 1);
668 
669      EXCEPTION
670 
671      WHEN FND_API.G_EXC_ERROR THEN
672              x_return_status := FND_API.G_RET_STS_ERROR;
673 
674              --  Get message count and data
675 
676              oe_msg_pub.count_and_get
677              (   p_count                       => x_msg_count
678               ,  p_data                        => x_msg_data
679               );
680 
681      WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
682 
683              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
684 
685              --  Get message count and data
686 
687              oe_msg_pub.count_and_get
688              (   p_count                       => x_msg_count
689              ,   p_data                        => x_msg_data
690              );
691 
692      WHEN OTHERS THEN
693              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
694 
695              IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
696                  OE_MSG_PUB.Add_Exc_Msg
697                     (G_PKG_NAME,
698                      l_api_name
699                 );
700              END IF;
701 
702              --  Get message count and data
703 
704              OE_MSG_PUB.Count_And_Get
705              ( p_count => x_msg_count,
706               p_data  => x_msg_data);
707 
708      End Insert_Row;
709 
710 
711 ----------------------------------------------------------
712      PROCEDURE Update_Row
713 ----------------------------------------------------------
714      (p_header_rec     IN  OUT NOCOPY OE_Blanket_PUB.Header_rec_type,
715       x_return_status  OUT NOCOPY VARCHAR2,
716       x_msg_count      OUT NOCOPY NUMBER,
717       x_msg_data       OUT NOCOPY VARCHAR2
718      )
719      IS
720        l_api_name         CONSTANT VARCHAR2(30)     := 'Update_Row';
721        l_debug_level      CONSTANT NUMBER           := oe_debug_pub.g_debug_level;
722 
723      BEGIN
724 		OE_MSG_PUB.initialize;
725          oe_debug_pub.add('Entering Header OE_Blanket_Form_Control.Update_row', 1);
729          IF x_return_status = FND_API.G_RET_STS_ERROR THEN
726 
727          OE_Blanket_Util.Update_Row(p_header_rec,X_RETURN_STATUS);
728 
730             RAISE FND_API.G_EXC_ERROR;
731          ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
732             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
733          END IF;
734 
735          oe_msg_pub.count_and_get
736          (   p_count     => x_msg_count
737           ,  p_data      => x_msg_data);
738 
739          oe_debug_pub.add('Existing Header OE_Blanket_Form_Control.Update_row', 1);
740 
741      EXCEPTION
742 
743      WHEN FND_API.G_EXC_ERROR THEN
744 
745              x_return_status := FND_API.G_RET_STS_ERROR;
746 
747              --  Get message count and data
748 
749              oe_msg_pub.count_and_get
750              (   p_count                       => x_msg_count
751               ,  p_data                        => x_msg_data
752               );
753 
754      WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
755 
756              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
757 
758              --  Get message count and data
759 
760              oe_msg_pub.count_and_get
761              (   p_count                       => x_msg_count
762              ,   p_data                        => x_msg_data
763              );
764 
765      WHEN OTHERS THEN
766              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
767 
768              IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
769                  OE_MSG_PUB.Add_Exc_Msg
770                         (G_PKG_NAME,
771                          l_api_name
772                     );
773              END IF;
774 
775              --  Get message count and data
776 
777              OE_MSG_PUB.Count_And_Get
778              ( p_count => x_msg_count,
779               p_data  => x_msg_data);
780 
781      End Update_Row;
782 
783 ----------------------------------------------------------
784      PROCEDURE Delete_Row
785 ----------------------------------------------------------
786      (p_header_id     IN NUMBER,
787       x_return_status  OUT NOCOPY VARCHAR2,
788       x_msg_count      OUT NOCOPY NUMBER,
789       x_msg_data       OUT NOCOPY VARCHAR2
790      )
791      IS
792        l_api_name         CONSTANT VARCHAR2(30)         := 'Delete_Row';
793        l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
794      BEGIN
795 -- hashraf ... start of pack J
796 
797 		OE_MSG_PUB.initialize;
798          oe_debug_pub.add('Entering Header OE_Blanket_Form_Control.Delete_row', 1);
799 
800          OE_Blanket_Util.Delete_Row(p_header_id => p_header_id
801 				,X_RETURN_STATUS => x_return_status);
802 
803          IF x_return_status = FND_API.G_RET_STS_ERROR THEN
804              RAISE FND_API.G_EXC_ERROR;
805          ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
806              RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
807          END IF;
808 
809          oe_msg_pub.count_and_get
810          (   p_count     => x_msg_count
811           ,  p_data      => x_msg_data);
812 
813          oe_debug_pub.add('Exiting Header OE_Blanket_Form_Control.Delete_row', 1);
814 
815      EXCEPTION
816 
817      WHEN FND_API.G_EXC_ERROR THEN
818              x_return_status := FND_API.G_RET_STS_ERROR;
819 
820              --  Get message count and data
821 
822              oe_msg_pub.count_and_get
823              (   p_count                       => x_msg_count
824               ,  p_data                        => x_msg_data
825               );
826 
827      WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
828 
829              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
830 
831              --  Get message count and data
832 
833              oe_msg_pub.count_and_get
834              (   p_count                       => x_msg_count
835              ,   p_data                        => x_msg_data
836              );
837 
838      WHEN OTHERS THEN
839              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
840 
841              IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
842                  OE_MSG_PUB.Add_Exc_Msg
843                     (G_PKG_NAME,
844                      l_api_name
845                 );
846              END IF;
847 
848              --  Get message count and data
849 
850              OE_MSG_PUB.Count_And_Get
851              ( p_count => x_msg_count,
852               p_data  => x_msg_data);
853 
854      End Delete_Row;
855 
856 
857 ----------------------------------------------------------
858      PROCEDURE Insert_Row
859 ----------------------------------------------------------
860      (p_line_rec       IN  OUT NOCOPY OE_Blanket_PUB.line_rec_type,
861       x_return_status  OUT NOCOPY  VARCHAR2,
862       x_msg_count      OUT NOCOPY NUMBER,
863       x_msg_data       OUT NOCOPY VARCHAR2
864      )
865      IS
866        l_api_name         CONSTANT VARCHAR2(30)     := 'Update_Row';
867        l_debug_level      CONSTANT NUMBER           := oe_debug_pub.g_debug_level;
868      BEGIN
869 		OE_MSG_PUB.initialize;
873 
870          oe_debug_pub.add('Entering Lines OE_Blanket_Form_Control.Insert_row', 1);
871 
872          OE_Blanket_Util.Insert_Row(p_line_rec,X_RETURN_STATUS);
874          IF x_return_status = FND_API.G_RET_STS_ERROR THEN
875              RAISE FND_API.G_EXC_ERROR;
876          ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
877              RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
878          END IF;
879 
880          oe_msg_pub.count_and_get
881          (   p_count     => x_msg_count
882           ,  p_data      => x_msg_data);
883 
884          oe_debug_pub.add('Existing Lines OE_Blanket_Form_Control.Insert_row', 1);
885 
886      EXCEPTION
887 
888      WHEN FND_API.G_EXC_ERROR THEN
889              x_return_status := FND_API.G_RET_STS_ERROR;
890 
891              --  Get message count and data
892 
893              oe_msg_pub.count_and_get
894              (   p_count                       => x_msg_count
895               ,  p_data                        => x_msg_data
896               );
897 
898      WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
899 
900              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
901 
902              --  Get message count and data
903 
904              oe_msg_pub.count_and_get
905              (   p_count                       => x_msg_count
906              ,   p_data                        => x_msg_data
907              );
908 
909      WHEN OTHERS THEN
910              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
911 
912              IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
913                  OE_MSG_PUB.Add_Exc_Msg
914                         (G_PKG_NAME,
915                          l_api_name
916                     );
917              END IF;
918 
919              --  Get message count and data
920 
921              OE_MSG_PUB.Count_And_Get
922              ( p_count => x_msg_count,
923               p_data  => x_msg_data);
924 
925      End Insert_Row;
926 
927 
928 ----------------------------------------------------------
929      PROCEDURE Update_Row
930 ----------------------------------------------------------
931      (   p_line_rec       IN  OUT NOCOPY OE_Blanket_PUB.line_rec_type,
932          x_return_status  OUT  NOCOPY  VARCHAR2,
933          x_msg_count      OUT  NOCOPY NUMBER,
934          x_msg_data       OUT  NOCOPY VARCHAR2
935      )
936      IS
937        l_api_name         CONSTANT VARCHAR2(30)     := 'Update_Row';
938        l_debug_level      CONSTANT NUMBER           := oe_debug_pub.g_debug_level;
939      BEGIN
940 		OE_MSG_PUB.initialize;
941          oe_debug_pub.add('Entering Lines OE_Blanket_Form_Control.Update_row', 1);
942          OE_Blanket_Util.Update_Row(p_line_rec,X_RETURN_STATUS);
943 
944          IF x_return_status = FND_API.G_RET_STS_ERROR THEN
945             RAISE FND_API.G_EXC_ERROR;
946          ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
947             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
948          END IF;
949 
950          oe_msg_pub.count_and_get
951          (   p_count     => x_msg_count
952           ,  p_data      => x_msg_data);
953 
954          oe_debug_pub.add('Existing Lines OE_Blanket_Form_Control.Update_row', 1);
955 
956      EXCEPTION
957 
958          WHEN FND_API.G_EXC_ERROR THEN
959              x_return_status := FND_API.G_RET_STS_ERROR;
960 
961              --  Get message count and data
962 
963              oe_msg_pub.count_and_get
964              (   p_count                       => x_msg_count
965               ,  p_data                        => x_msg_data
966               );
967 
968          WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
969 
970              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
971 
972              --  Get message count and data
973 
974              oe_msg_pub.count_and_get
975              (   p_count                       => x_msg_count
976              ,   p_data                        => x_msg_data
977              );
978 
979          WHEN OTHERS THEN
980              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
981 
982              IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
983                  OE_MSG_PUB.Add_Exc_Msg
984                         (G_PKG_NAME,
985                          l_api_name
986                     );
987              END IF;
988 
989              --  Get message count and data
990 
991              OE_MSG_PUB.Count_And_Get
992              ( p_count => x_msg_count,
993               p_data  => x_msg_data);
994 
995      End Update_Row;
996 
997 ----------------------------------------------------------
998      PROCEDURE Delete_Row
999 ----------------------------------------------------------
1000      (p_line_id       IN NUMBER,
1001       x_return_status  OUT NOCOPY  VARCHAR2,
1002       x_msg_count      OUT NOCOPY NUMBER,
1003       x_msg_data       OUT NOCOPY VARCHAR2
1004      )
1005      IS
1006        l_api_name         CONSTANT VARCHAR2(30)     := 'Delete_Row';
1007        l_debug_level      CONSTANT NUMBER           := oe_debug_pub.g_debug_level;
1008      BEGIN
1009 -- hashraf ... start of pack J
1010 		OE_MSG_PUB.initialize;
1014 				,x_return_status => X_RETURN_STATUS);
1011          oe_debug_pub.add('Entering Lines OE_Blanket_Form_Control.Delete_row', 1);
1012 
1013          OE_Blanket_Util.Delete_Row(p_line_id => p_line_id
1015 
1016          IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1017              RAISE FND_API.G_EXC_ERROR;
1018          ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1019              RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1020          END IF;
1021 
1022          oe_msg_pub.count_and_get
1023          (   p_count     => x_msg_count
1024           ,  p_data      => x_msg_data);
1025 
1026          oe_debug_pub.add('Exiting Lines OE_Blanket_Form_Control.Delete_row', 1);
1027 
1028      EXCEPTION
1029 
1030      WHEN FND_API.G_EXC_ERROR THEN
1031              x_return_status := FND_API.G_RET_STS_ERROR;
1032 
1033              --  Get message count and data
1034 
1035              oe_msg_pub.count_and_get
1036              (   p_count                       => x_msg_count
1037               ,  p_data                        => x_msg_data
1038               );
1039 
1040      WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1041 
1042              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1043 
1044              --  Get message count and data
1045 
1046              oe_msg_pub.count_and_get
1047              (   p_count                       => x_msg_count
1048              ,   p_data                        => x_msg_data
1049              );
1050 
1051      WHEN OTHERS THEN
1052              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1053 
1054              IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
1055                  OE_MSG_PUB.Add_Exc_Msg
1056                         (G_PKG_NAME,
1057                          l_api_name
1058                     );
1059              END IF;
1060 
1061              --  Get message count and data
1062 
1063              OE_MSG_PUB.Count_And_Get
1064              ( p_count => x_msg_count,
1065               p_data  => x_msg_data);
1066 
1067      End Delete_Row;
1068 
1069 
1070 ----------------------------------------------------------
1071      PROCEDURE Default_Attributes
1072 ----------------------------------------------------------
1073      (p_x_header_rec          IN OUT NOCOPY OE_Blanket_PUB.Header_rec_type,
1074       x_msg_count             OUT NOCOPY NUMBER,
1075       x_msg_data              OUT NOCOPY VARCHAR2,
1076       x_return_status         OUT NOCOPY VARCHAR2
1077      )
1078      IS
1079      l_error            NUMBER := 0;
1080      l_api_name         CONSTANT VARCHAR2(30)         := 'Default_Attributes';
1081      l_debug_level      CONSTANT NUMBER               := oe_debug_pub.g_debug_level;
1082      BEGIN
1083          IF l_debug_level  > 0 THEN
1084             oe_debug_pub.add('Entering Header OE_Blanket_Form_Control.DEFAULT_ATTRIBUTES', 1);
1085          END IF;
1086          OE_MSG_PUB.initialize;
1087          --Clearing the line cache Bug#4878846.
1088          g_line_cache_rec.delete;
1089          l_error := 1;
1090 
1091          --p_x_header_rec.operation := OE_GLOBALS.G_OPR_CREATE;
1092 
1093          OE_Blanket_Util.Default_Attributes (p_x_header_rec,x_return_status);
1094 
1095          IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1096             RAISE FND_API.G_EXC_ERROR;
1097          ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1098             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1099          END IF;
1100 
1101          oe_msg_pub.count_and_get
1102          (   p_count     => x_msg_count
1103           ,  p_data      => x_msg_data);
1104 
1105          IF l_debug_level  > 0 THEN
1106             oe_debug_pub.add('Exiting Header OE_Blanket_Form_Control.DEFAULT_ATTRIBUTES', 1);
1107          END IF;
1108 
1109      EXCEPTION
1110          WHEN FND_API.G_EXC_ERROR THEN
1111              x_return_status := FND_API.G_RET_STS_ERROR;
1112              --  Get message count and data
1113              oe_msg_pub.count_and_get
1114              (   p_count                       => x_msg_count
1115               ,  p_data                        => x_msg_data
1116               );
1117              IF l_debug_level  > 0 THEN
1118                 oe_debug_pub.add('Exiting Header OE_Blanket_Form_Control.DEFAULT_ATTRIBUTES expected errors', 1);
1119              END IF;
1120 
1121          WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1122 
1123              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1124              --  Get message count and data
1125              oe_msg_pub.count_and_get
1126              (   p_count                       => x_msg_count
1127              ,   p_data                        => x_msg_data
1128              );
1129 
1130          WHEN OTHERS THEN
1131              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1132 
1133              IF OE_MSG_PUB.Check_Msg_Level
1134                 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1135              THEN
1136                  OE_MSG_PUB.Add_Exc_Msg
1137                         (G_PKG_NAME,
1138                          l_api_name
1139                     );
1140              END IF;
1141              IF l_debug_level  > 0 THEN
1142                 oe_debug_pub.add('Exiting Header OE_Blanket_Form_Control.DEFAULT_ATTRIBUTES unexpected errors', 1);
1143              END IF;
1144 
1145              --  Get message count and data
1146              OE_MSG_PUB.Count_And_Get
1150      END Default_Attributes;
1147              ( p_count => x_msg_count,
1148               p_data  => x_msg_data);
1149 
1151 
1152 
1153 ----------------------------------------------------------
1154      PROCEDURE Default_Attributes
1155 ----------------------------------------------------------
1156      (p_x_line_rec            IN OUT NOCOPY OE_Blanket_PUB.line_rec_type,
1157       x_msg_count             OUT NOCOPY NUMBER,
1158       x_msg_data              OUT NOCOPY VARCHAR2,
1159       x_return_status         OUT NOCOPY VARCHAR2
1160      )
1161      IS
1162          l_old_blanket_line_number    number;
1163          l_error                      NUMBER;
1164          p_default_from_header        BOOLEAN := TRUE;
1165      BEGIN
1166          OE_MSG_PUB.initialize;
1167          oe_debug_pub.add('Entering Lines OE_Blanket_Form_Control.DEFAULT_ATTRIBUTES', 1);
1168 
1169          l_error := 1;
1170          l_old_blanket_line_number := p_x_line_rec.line_number;
1171 
1172          --p_x_line_rec.operation := OE_GLOBALS.G_OPR_CREATE;
1173 
1174          OE_Blanket_Util.Default_Attributes (p_x_line_rec,p_default_from_header,x_return_status);
1175 
1176          IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1177             RAISE FND_API.G_EXC_ERROR;
1178          ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1179             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1180          END IF;
1181 
1182          -- Defaulting for Line Number
1183 
1184          if nvl(l_old_blanket_line_number,0) = 0 then
1185                g_blanket_line_number := nvl(g_blanket_line_number,0);
1186                p_x_line_rec.line_number := g_blanket_line_number;
1187          else
1188                p_x_line_rec.line_number := l_old_blanket_line_number;
1189          end if;
1190 
1191          oe_msg_pub.count_and_get
1192          (   p_count     => x_msg_count
1193           ,  p_data      => x_msg_data);
1194 
1195          oe_debug_pub.add('Existing Lines OE_Blanket_Form_Control.DEFAULT_ATTRIBUTES', 1);
1196 
1197      EXCEPTION
1198          WHEN FND_API.G_EXC_ERROR THEN
1199              x_return_status := FND_API.G_RET_STS_ERROR;
1200              --  Get message count and data
1201              oe_msg_pub.count_and_get
1202              (   p_count                       => x_msg_count
1203               ,  p_data                        => x_msg_data
1204               );
1205 
1206          WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1207 
1208              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1209              --  Get message count and data
1210              oe_msg_pub.count_and_get
1211              (   p_count                       => x_msg_count
1212              ,   p_data                        => x_msg_data
1213              );
1214 
1215          WHEN OTHERS THEN
1216 
1217              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1218 
1219              --  Get message count and data
1220              OE_MSG_PUB.Count_And_Get
1221              ( p_count => x_msg_count,
1222                p_data  => x_msg_data);
1223 
1224      END Default_Attributes;
1225 
1226 
1227 ----------------------------------------------------------
1228      PROCEDURE Process_Object
1229 ----------------------------------------------------------
1230      (   x_return_status  IN OUT NOCOPY VARCHAR2,
1231          x_msg_count      IN OUT NOCOPY NUMBER,
1232          x_msg_data       IN OUT NOCOPY VARCHAR2
1233      )
1234      IS
1235      ctr                number := 1;
1236      l_api_name         CONSTANT VARCHAR2(30)         := 'Process_Object';
1237      l_debug_level      CONSTANT NUMBER               := oe_debug_pub.g_debug_level;
1238      --bug#4691643
1239      I                  number := 1;
1240      l_dummy_header_rec oe_blanket_pub.header_rec_type;
1241      l_dummy_line_rec   oe_blanket_pub.line_rec_type;
1242      l_request_rec      OE_Order_PUB.Request_Rec_Type;
1243      l_return_status    varchar2(30);
1244      BEGIN
1245 
1246 
1247          OE_MSG_PUB.initialize;
1248 
1249 
1250          oe_debug_pub.add('Entering OE_Blanket_Form_Control.Process_object', 0);
1251          --bug#4691643
1252          --Log delayed requests again ,if delayed requests for the corresponding
1253          --entity doesn't exist because of exception
1254         While ctr <= G_header_Cache_Rec.count loop
1255         If G_header_cache_rec(ctr).operation IN
1256         (OE_GLOBALS.G_OPR_CREATE,OE_GLOBALS.G_OPR_UPDATE) then
1257 		IF G_header_cache_rec(ctr).operation =OE_GLOBALS.G_OPR_CREATE
1258 		THEN
1259         	l_dummy_header_rec := NULL;
1260 		ELSIF G_header_cache_rec(ctr).operation
1261 				=OE_GLOBALS.G_OPR_UPDATE THEN
1262                 	OE_Blanket_util.Query_Header(
1263               				p_header_id =>G_header_cache_rec(ctr).header_id,
1264               				x_header_rec =>l_dummy_header_Rec,
1265               		 		x_return_status =>l_return_status);
1266 
1267 			IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1268 			RAISE FND_API.G_EXC_ERROR;
1269 			END IF;
1270 		END IF;
1271         	I := oe_delayed_requests_pvt.g_delayed_requests.first;
1272                 WHILE I IS NOT NULL LOOP
1273                 l_request_rec := oe_delayed_requests_pvt.g_delayed_requests(I);
1274                 if l_request_rec.entity_id=G_header_cache_rec(ctr).header_id
1278                 END LOOP;
1275                         then EXIT;
1276                 end if;
1277                 I := oe_delayed_requests_pvt.g_delayed_requests.next(I);
1279                 IF I IS NULL THEN
1280                 OE_Blanket_Util.Validate_Entity(G_header_cache_rec(ctr),
1281                                          l_dummy_header_rec,
1282                                          x_return_status);
1283 
1284                 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1285                 RAISE FND_API.G_EXC_ERROR;
1286                 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1287                 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1288                 END IF;
1289                 END IF;
1290         END IF;
1291         ctr := ctr + 1;
1292         End Loop;
1293 
1294 	ctr := 1;
1295         while ctr <= G_Line_Cache_Rec.count loop
1296         If G_line_cache_rec(ctr).operation IN
1297         (OE_GLOBALS.G_OPR_CREATE,OE_GLOBALS.G_OPR_UPDATE) then
1298 		If G_line_cache_rec(ctr).operation = OE_GLOBALS.G_OPR_CREATE
1299 		THEN
1300         	l_dummy_line_rec := NULL;
1301 		ELSIF G_line_cache_rec(ctr).operation = OE_GLOBALS.G_OPR_UPDATE
1302 		THEN
1303 		l_dummy_line_rec := OE_Blanket_util.Query_Row(p_line_id => 											G_LIne_cache_rec(ctr).line_id);
1304 		END IF;
1305         	I := oe_delayed_requests_pvt.g_delayed_requests.first;
1306                 WHILE I IS NOT NULL LOOP
1307                 l_request_rec := oe_delayed_requests_pvt.g_delayed_requests(I);
1308                 if l_request_rec.entity_id=G_LIne_cache_rec(ctr).line_id
1309                 then EXIT;
1310                 end if;
1311                 I := oe_delayed_requests_pvt.g_delayed_requests.next(I);
1312                 END LOOP;
1313                 IF I IS NULL THEN
1314                 OE_Blanket_Util.Validate_Entity(G_line_cache_rec(ctr),
1315                                          l_dummy_line_rec,
1316                                          x_return_status);
1317 
1318                 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1319                 RAISE FND_API.G_EXC_ERROR;
1320                 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1321                 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1322                 END IF;
1323                 END IF;
1324         END IF;
1325        ctr := ctr + 1;
1326        end loop;
1327 
1328 ctr := 1;
1329     oe_debug_pub.add('Entering OE_Blanket_Form_Control.Process_object', 0);
1330     --bug#4691643 end
1331       ----------------------------------------------------------
1332          -- Insert or Update Header Records into the Database
1333          ----------------------------------------------------------
1334 
1335          --x_return_status := FND_API.G_RET_STS_SUCCESS;
1336 
1337          --For bug 3217764. Altered the Exception Logic.
1338          --1. Moved the savepoint out of the loop
1339          --2. Commented out all the exception block and having a common exception block for the fn.
1340 
1341          SAVEPOINT Save_Blanket_Changes;
1342 
1343          While ctr <= G_header_Cache_Rec.count loop
1344               oe_debug_pub.add('Operation IS: '||G_header_cache_rec(ctr).operation);
1345               x_return_status := FND_API.G_RET_STS_SUCCESS;
1346 
1347               If G_header_cache_rec(ctr).operation = OE_GLOBALS.G_OPR_UPDATE then
1348                  oe_debug_pub.add('Operation in Update Condi: '||G_header_cache_rec(ctr).operation);
1349                  OE_Blanket_Util.Update_Row(G_header_Cache_Rec(ctr),x_return_status);
1350               ElsIf G_header_cache_rec(ctr).operation = OE_GLOBALS.G_OPR_CREATE then
1351                  oe_debug_pub.add('Operation IN Insert Condi: '||G_header_cache_rec(ctr).operation);
1352                  OE_Blanket_Util.Insert_Row(G_header_Cache_Rec(ctr),x_return_status);
1353 
1354                  --Workflow changes for 11i10.
1355                  --For the bug3230820
1356                  -- Move this particular code to Oe_Blanket_Util.Process_object.
1357                  -- Where we are calling directly to accomaidate both for backend creation of BSA and
1358                  -- Through BSA UI.
1359 
1360               -- hashraf ... start of pack J
1361               ElsIf G_header_cache_rec(ctr).operation = OE_GLOBALS.G_OPR_DELETE then
1362                     oe_debug_pub.add('Operation IS Delete Condi: '||G_header_cache_rec(ctr).operation);
1363                     OE_Blanket_Util.Delete_Row(p_header_id     => G_header_Cache_Rec(ctr).header_id,
1364                                                x_return_status => x_return_status);
1365               -- hashraf ... end of pack J
1366               End if;
1367 
1368               IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1369                  ROLLBACK TO SAVEPOINT Save_Blanket_Changes;
1370               END IF;
1371 
1372               IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1373                  RAISE FND_API.G_EXC_ERROR;
1374               ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1375                  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1376               END IF;
1377 
1378               oe_msg_pub.count_and_get
1379                        (   p_count     => x_msg_count
1380                         ,  p_data      => x_msg_data);
1381 
1382               --for bug 3217764, the exception block was removed
1383               /*   Exception
1387               ctr := ctr + 1;
1384                    End;
1385               */
1386 
1388 
1389          End Loop;
1390 
1391          ----------------------------------------------------------
1392          -- Insert or Update Line Records into the Database
1393          ----------------------------------------------------------
1394          ctr := 1;
1395 
1396          while ctr <= G_Line_Cache_Rec.count loop
1397 
1398                If G_line_cache_rec(ctr).operation = OE_GLOBALS.G_OPR_UPDATE then
1399                   oe_debug_pub.add('Process_object for Lines update', 4);
1400                   OE_Blanket_Util.Update_Row(G_line_Cache_Rec(ctr),x_return_status);
1401                ElsIf G_line_cache_rec(ctr).operation = OE_GLOBALS.G_OPR_CREATE then
1402                   oe_debug_pub.add('Process_object for Lines Insert', 5);
1403                   OE_Blanket_Util.Insert_Row(G_line_Cache_Rec(ctr),x_return_status);
1404                -- hashraf ... start of pack J
1405                ElsIf G_line_cache_rec(ctr).operation = OE_GLOBALS.G_OPR_DELETE then
1406                   oe_debug_pub.add('Process_object for Lines Delete', 6);
1407                   OE_Blanket_Util.Delete_Row(p_line_id => G_line_Cache_Rec(ctr).line_id, x_return_status => x_return_status);
1408                -- hashraf ... end of pack J
1409                End if;
1410 
1411                IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1412                   RAISE FND_API.G_EXC_ERROR;
1413                ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1414                   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1415                END IF;
1416 
1417                oe_msg_pub.count_and_get
1418                        (   p_count     => x_msg_count
1419                         ,  p_data      => x_msg_data);
1420 
1421                --for bug 3217764, the exception block code has been removed.
1422                /*  Exception
1423                   End;
1424                */
1425                ctr := ctr + 1;
1426 
1427          end loop;
1428          if x_return_status = FND_API.G_RET_STS_SUCCESS then
1429             OE_Blanket_Util.Process_Object(x_return_status);
1430          end if;
1431 
1432          IF x_return_status = FND_API.G_RET_STS_ERROR THEN
1433             RAISE FND_API.G_EXC_ERROR;
1434          ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1435             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1436          ELSIF x_return_status = FND_API.G_RET_STS_SUCCESS THEN
1437             --only delete cache if successfully processed delayed requests
1438             g_header_cache_rec.delete;
1439             g_line_cache_rec.delete;
1440          END IF;
1441 
1442          oe_msg_pub.count_and_get
1443          (   p_count     => x_msg_count
1444           ,  p_data      => x_msg_data);
1445 
1446          oe_debug_pub.add(' oe_msg_pub.count_and_get x_msg_count'||x_msg_count);
1447          oe_debug_pub.add(' oe_msg_pub.count_and_get x_msg_data'||x_msg_data);
1448          oe_debug_pub.add('Leaving from the Process Object OE_Blanket_Form_Control.Process_object ', 5);
1449 
1450      EXCEPTION
1451         WHEN FND_API.G_EXC_ERROR THEN
1452              x_return_status := FND_API.G_RET_STS_ERROR;
1453 
1454              --  Get message count and data
1455              oe_msg_pub.count_and_get
1456              (   p_count                       => x_msg_count
1457               ,  p_data                        => x_msg_data
1458               );
1459              --for bug 3217764
1460              oe_debug_pub.add('Leaving the Process Object with excepted errors', 5);
1461              ROLLBACK TO SAVEPOINT Save_Blanket_Changes;
1462 
1463          WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1464 
1465              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1466              --  Get message count and data
1467 
1468              oe_msg_pub.count_and_get
1469              (   p_count                       => x_msg_count
1470              ,   p_data                        => x_msg_data
1471              );
1472              --for bug 3217764
1473              oe_debug_pub.add('Leaving the Process Object with unexcepted errors', 5);
1474              ROLLBACK TO SAVEPOINT Save_Blanket_Changes;
1475 
1476          WHEN OTHERS THEN
1477              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1478 
1479              IF OE_MSG_PUB.Check_Msg_Level
1480                 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1481              THEN
1482                  OE_MSG_PUB.Add_Exc_Msg
1483                         (G_PKG_NAME,
1484                          l_api_name
1485                     );
1486              END IF;
1487 
1488              --  Get message count and data
1489              OE_MSG_PUB.Count_And_Get
1490              ( p_count => x_msg_count,
1491               p_data  => x_msg_data);
1492               --for bug 3217764
1493               oe_debug_pub.add('Leaving the Process Object with other errors', 5);
1494               ROLLBACK TO SAVEPOINT Save_Blanket_Changes;
1495      END Process_Object;
1496 
1497 
1498 ----------------------------------------------------------
1499     PROCEDURE Check_Sec_Header_Attr
1500 ----------------------------------------------------------
1501     (x_return_status         IN OUT NOCOPY varchar2,
1502      p_header_rec            IN OUT NOCOPY OE_Blanket_PUB.Header_rec_type,
1506      x_msg_count             IN OUT NOCOPY NUMBER,
1503      p_old_header_rec        IN OUT NOCOPY OE_Blanket_PUB.Header_rec_type,
1504      -- 11i10 Pricing Changes
1505      p_column_name           IN VARCHAR2 DEFAULT NULL,
1507      x_msg_data              IN OUT NOCOPY VARCHAR2)
1508     IS
1509      l_result NUMBER;
1510      -- 11i10 Pricing Changes
1511      l_operation             varchar2(30);
1512      l_action                number;
1513      l_rowtype_rec           oe_ak_blanket_headers_v%rowtype;
1514      l_api_name            CONSTANT VARCHAR2(30)  := 'Check_Sec_Header_Attr';
1515     BEGIN
1516            oe_debug_pub.add('Entering oe_blanket_form_control.check_sec_header_attr');
1517 		OE_MSG_PUB.initialize;
1518 
1519 
1520         IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
1521 
1522            -- 11i10 Pricing Changes
1523            -- Check security for a specific attribute
1524            IF p_column_name IS NOT NULL THEN
1525 
1526               OE_BLANKET_UTIL.API_Rec_To_Rowtype_Rec
1527                                (p_header_rec,l_rowtype_rec);
1528               if p_header_rec.operation = OE_GLOBALS.G_OPR_CREATE then
1529                  l_operation := OE_PC_GLOBALS.CREATE_OP;
1530               elsif p_header_rec.operation = OE_GLOBALS.G_OPR_UPDATE then
1531                  l_operation := OE_PC_GLOBALS.UPDATE_OP;
1532               end if;
1533 
1534               -- Initialize security global record
1535               OE_Blanket_Header_Security.g_record := l_rowtype_rec;
1536 
1537               l_result := OE_Blanket_Header_Security.Is_OP_Constrained
1538                                (p_operation => l_operation
1539                                ,p_column_name => p_column_name
1540                                ,p_record => l_rowtype_rec
1541                                ,x_on_operation_action => l_action
1542                                );
1543               if l_result = OE_PC_GLOBALS.YES then
1544                  raise fnd_api.g_exc_error;
1545               end if;
1546 
1547            -- Check security for all attributes that changed
1548            ELSE
1549 
1550               OE_Blanket_Header_Security.Attributes(p_header_rec => p_header_rec,
1551                       p_old_header_rec => p_old_header_rec,
1552                       x_result => l_result,
1553                       x_return_status => x_return_status);
1554 
1555               IF l_result = OE_PC_GLOBALS.YES THEN
1556                 RAISE FND_API.G_EXC_ERROR;
1557               END IF;
1558 
1559            END IF; -- if column name is not null
1560 
1561          END IF; -- if code release level >= 11i10
1562 
1563          oe_msg_pub.count_and_get
1564          (   p_count     => x_msg_count
1565           ,  p_data      => x_msg_data);
1566 
1567            oe_debug_pub.add('Exiting oe_blanket_form_control.check_sec_header_attr');
1568     EXCEPTION
1569 
1570          WHEN FND_API.G_EXC_ERROR THEN
1571 
1572              x_return_status := FND_API.G_RET_STS_ERROR;
1573              --  Get message count and data
1574 
1575              oe_msg_pub.count_and_get
1576              (   p_count                       => x_msg_count
1577               ,  p_data                        => x_msg_data
1578               );
1579 
1580          WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1581 
1582              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1583              --  Get message count and data
1584              oe_msg_pub.count_and_get
1585              (   p_count                       => x_msg_count
1586              ,   p_data                        => x_msg_data
1587              );
1588 
1589          WHEN OTHERS THEN
1590              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1591 
1592          IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
1593 
1594              OE_MSG_PUB.Add_Exc_Msg
1595                     (G_PKG_NAME,
1596                      l_api_name);
1597 
1598          END IF;
1599 
1600          --  Get message count and data
1601 
1602          OE_MSG_PUB.Count_And_Get
1603          ( p_count => x_msg_count,
1604           p_data  => x_msg_data);
1605 
1606     END Check_Sec_Header_Attr;
1607 
1608 ----------------------------------------------------------
1609     PROCEDURE Check_Sec_Line_Attr
1610 ----------------------------------------------------------
1611     (x_return_status         IN OUT NOCOPY varchar2,
1612      p_line_rec            IN OUT NOCOPY OE_Blanket_PUB.Line_rec_type,
1613      p_old_line_rec        IN OUT NOCOPY OE_Blanket_PUB.Line_rec_type,
1614      x_msg_count             IN OUT NOCOPY NUMBER,
1615      x_msg_data              IN OUT NOCOPY VARCHAR2)
1616     IS
1617      l_result NUMBER;
1618      l_api_name            CONSTANT VARCHAR2(30)  := 'Check_Sec_Line_Attr';
1619 
1620     BEGIN
1621 		OE_MSG_PUB.initialize;
1622 
1623         IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
1624 
1625          OE_Blanket_Line_Security.Attributes(p_line_rec => p_line_rec,
1626                       p_old_line_rec => p_old_line_rec,
1627                       x_result => l_result,
1628                       x_return_status => x_return_status);
1629 
1630            IF l_result = OE_PC_GLOBALS.YES THEN
1631                 RAISE FND_API.G_EXC_ERROR;
1635          oe_msg_pub.count_and_get
1632            END IF;
1633         END IF;
1634 
1636          (   p_count     => x_msg_count
1637           ,  p_data      => x_msg_data);
1638 
1639     EXCEPTION
1640 
1641          WHEN FND_API.G_EXC_ERROR THEN
1642 
1643              x_return_status := FND_API.G_RET_STS_ERROR;
1644              --  Get message count and data
1645 
1646              oe_msg_pub.count_and_get
1647              (   p_count                       => x_msg_count
1648               ,  p_data                        => x_msg_data
1649               );
1650 
1651          WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1652 
1653              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1654              --  Get message count and data
1655              oe_msg_pub.count_and_get
1656              (   p_count                       => x_msg_count
1657              ,   p_data                        => x_msg_data
1658              );
1659 
1660          WHEN OTHERS THEN
1661              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1662 
1663          IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
1664 
1665              OE_MSG_PUB.Add_Exc_Msg
1666                     (G_PKG_NAME,
1667                      l_api_name);
1668 
1669          END IF;
1670 
1671          --  Get message count and data
1672 
1673          OE_MSG_PUB.Count_And_Get
1674          ( p_count => x_msg_count,
1675           p_data  => x_msg_data);
1676 
1677     END Check_Sec_Line_Attr;
1678 
1679 ----------------------------------------------------------
1680     PROCEDURE Check_Sec_Header_Entity
1681 ----------------------------------------------------------
1682     (x_return_status         IN OUT NOCOPY varchar2,
1683      p_header_rec            IN OUT NOCOPY OE_Blanket_PUB.Header_rec_type,
1684      x_msg_count             IN OUT NOCOPY NUMBER,
1685      x_msg_data              IN OUT NOCOPY VARCHAR2)
1686     IS
1687      l_result NUMBER;
1688      l_api_name            CONSTANT VARCHAR2(30)  := 'Check_Sec_Header_Entity';
1689 
1690     BEGIN
1691            oe_debug_pub.add('Entering oe_blanket_form_control.check_sec_header_Entity');
1692 		OE_MSG_PUB.initialize;
1693 
1694         IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
1695 
1696          OE_Blanket_Header_Security.Entity(p_header_rec => p_header_rec,
1697                       x_result => l_result,
1698                       x_return_status => x_return_status);
1699 
1700            IF l_result = OE_PC_GLOBALS.YES THEN
1701                 RAISE FND_API.G_EXC_ERROR;
1702            END IF;
1703 
1704         END IF;
1705 
1706          oe_msg_pub.count_and_get
1707          (   p_count     => x_msg_count
1708           ,  p_data      => x_msg_data);
1709 
1710            oe_debug_pub.add('Exiting oe_blanket_form_control.check_sec_header_Entity');
1711     EXCEPTION
1712 
1713          WHEN FND_API.G_EXC_ERROR THEN
1714 
1715              x_return_status := FND_API.G_RET_STS_ERROR;
1716              --  Get message count and data
1717 
1718              oe_msg_pub.count_and_get
1719              (   p_count                       => x_msg_count
1720               ,  p_data                        => x_msg_data
1721               );
1722 
1723          WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1724 
1725              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1726              --  Get message count and data
1727              oe_msg_pub.count_and_get
1728              (   p_count                       => x_msg_count
1729              ,   p_data                        => x_msg_data
1730              );
1731 
1732          WHEN OTHERS THEN
1733              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1734 
1735          IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
1736 
1737              OE_MSG_PUB.Add_Exc_Msg
1738                     (G_PKG_NAME,
1739                      l_api_name);
1740 
1741          END IF;
1742 
1743          --  Get message count and data
1744 
1745          OE_MSG_PUB.Count_And_Get
1746          ( p_count => x_msg_count,
1747           p_data  => x_msg_data);
1748 
1749     END Check_Sec_Header_Entity;
1750 
1751 ----------------------------------------------------------
1752     PROCEDURE Check_Sec_Line_Entity
1753 ----------------------------------------------------------
1754     (x_return_status         IN OUT NOCOPY varchar2,
1755      p_line_rec            IN OUT NOCOPY OE_Blanket_PUB.Line_rec_type,
1756      x_msg_count             IN OUT NOCOPY NUMBER,
1757      x_msg_data              IN OUT NOCOPY VARCHAR2)
1758     IS
1759      l_result NUMBER;
1760      l_api_name            CONSTANT VARCHAR2(30)  := 'Check_Sec_Line_Entity';
1761 
1762     BEGIN
1763 		OE_MSG_PUB.initialize;
1764 
1765         IF OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
1766 
1767          OE_Blanket_Line_Security.Entity(p_line_rec => p_line_rec,
1768                       x_result => l_result,
1769                       x_return_status => x_return_status);
1770 
1771            IF l_result = OE_PC_GLOBALS.YES THEN
1772                 RAISE FND_API.G_EXC_ERROR;
1773            END IF;
1774 
1778          (   p_count     => x_msg_count
1775         END IF;
1776 
1777          oe_msg_pub.count_and_get
1779           ,  p_data      => x_msg_data);
1780 
1781     EXCEPTION
1782 
1783          WHEN FND_API.G_EXC_ERROR THEN
1784 
1785              x_return_status := FND_API.G_RET_STS_ERROR;
1786              --  Get message count and data
1787 
1788              oe_msg_pub.count_and_get
1789              (   p_count                       => x_msg_count
1790               ,  p_data                        => x_msg_data
1791               );
1792 
1793          WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1794 
1795              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1796              --  Get message count and data
1797              oe_msg_pub.count_and_get
1798              (   p_count                       => x_msg_count
1799              ,   p_data                        => x_msg_data
1800              );
1801 
1802          WHEN OTHERS THEN
1803              x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1804 
1805          IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
1806 
1807              OE_MSG_PUB.Add_Exc_Msg
1808                     (G_PKG_NAME,
1809                      l_api_name);
1810 
1811          END IF;
1812 
1813          --  Get message count and data
1814 
1815          OE_MSG_PUB.Count_And_Get
1816          ( p_count => x_msg_count,
1817           p_data  => x_msg_data);
1818 
1819     END Check_Sec_Line_Entity;
1820 
1821 ----------------------------------------------------------
1822      PROCEDURE Update_Header_Cache
1823 ----------------------------------------------------------
1824      (p_x_header_rec            IN OUT NOCOPY OE_Blanket_PUB.header_rec_type,
1825       delete_flag               IN            Varchar2 )
1826      IS
1827          ctr                    number;
1828          found_flag             varchar2(1);
1829          l_return_status        varchar2(80);
1830      BEGIN
1831 
1832          oe_debug_pub.add('Entering Update_Header_Cache OE_Blanket_Form_Control.Update_Header_Cache ', 0);
1833 
1834          found_flag := 'N';
1835          ctr := 1;
1836 
1837          if G_Header_Cache_Rec.count = 0 then
1838             oe_debug_pub.add('Update_Header_Cache is Zero ', 1);
1839             if delete_flag <> 'Y' THEN
1840                G_Header_Cache_Rec(ctr) := p_x_header_rec;
1841             end if;
1842          else
1843             oe_debug_pub.add('Update_Header_Cache is greater then Zero ', 2);
1844             while ctr <= G_Header_Cache_Rec.count and found_flag = 'N' loop
1845                   if G_Header_Cache_Rec(ctr).header_id = p_x_header_rec.header_id then
1846                      found_flag := 'Y';
1847                   else
1848                      ctr := ctr + 1;
1849                   end if;
1850             end loop;
1851          end if;
1852 
1853          /* Later change it to update only for changed attributes */
1854 
1855          If delete_flag = 'Y' then
1856             If found_flag = 'Y' then
1857                G_Header_Cache_Rec(ctr) := NULL;
1858                OE_DELAYED_REQUESTS_PVT.Delete_Reqs_for_Deleted_Entity(
1859                          p_entity_code  => OE_BLANKET_PUB.G_ENTITY_BLANKET_HEADER
1860                          ,p_entity_id    => p_x_header_rec.header_id
1861 			 , p_delete_against => FALSE
1862                          ,x_return_status => l_return_status);
1863             End if;
1864          Else
1865             oe_debug_pub.add('Update_Header_Cache is  OE_Blanket_Form_Control.Update_Header_Cache ', 3);
1866             oe_debug_pub.add('Header Operation Code :'||p_x_header_rec.operation);
1867             G_Header_Cache_Rec(ctr) := p_x_header_rec;
1868          End if;
1869          oe_debug_pub.add('Exiting Update_Header_Cache OE_Blanket_Form_Control.Update_Header_Cache ', 4);
1870 
1871      END Update_Header_Cache;
1872 
1873 
1874 ----------------------------------------------------------
1875      PROCEDURE Update_Line_Cache
1876 ----------------------------------------------------------
1877          (p_x_line_rec            IN OUT NOCOPY OE_Blanket_PUB.line_rec_type,
1878           delete_flag             IN            VARCHAR2 := NULL)
1879      IS
1880          ctr                      number;
1881          found_flag               varchar2(1);
1882          l_return_status          varchar2(80);
1883      BEGIN
1884 
1885          oe_debug_pub.add('Entering Update_line_Cache OE_Blanket_Form_Control.Update_line_Cache ', 0);
1886 
1887          found_flag := 'N';
1888          ctr := 1;
1889 
1890          if G_Line_Cache_Rec.count = 0 then
1891             oe_debug_pub.add('Update_line_Cache is Zero ', 1);
1892             if  delete_flag <> 'Y' then
1893                 G_Line_Cache_Rec(ctr) := p_x_Line_rec;
1894             end if;
1895          else
1896             oe_debug_pub.add('Update_line_Cache is greater then Zero ', 2);
1897             while ctr <= G_Line_Cache_Rec.count and found_flag = 'N' loop
1898                   if G_Line_Cache_Rec(ctr).Line_id = p_x_Line_rec.Line_id then
1899                      found_flag := 'Y';
1900                   else
1901                      ctr := ctr + 1;
1902                   end if;
1903             end loop;
1904 
1905          end if;
1906 
1907          /* Later change it to update only changed attributes */
1911             If found_flag = 'Y' then
1908 
1909          If delete_flag = 'Y' then
1910 
1912                OE_DELAYED_REQUESTS_PVT.Delete_Reqs_for_Deleted_Entity(
1913                          p_entity_code  => OE_BLANKET_PUB.G_ENTITY_BLANKET_LINE
1914                          ,p_entity_id    => p_x_Line_rec.Line_id
1915 			, p_delete_against => FALSE
1916                          ,x_return_status => l_return_status);
1917 
1918                G_Line_Cache_Rec(ctr) := NULL;
1919             End if;
1920          Else
1921             oe_debug_pub.add('Line Operation Code :'||p_x_Line_rec.operation);
1922             G_Line_Cache_Rec(ctr) := p_x_Line_rec;
1923          End if;
1924          oe_debug_pub.add('Exiting Update_line_Cache OE_Blanket_Form_Control.Update_line_Cache ', 4);
1925      END Update_Line_Cache;
1926 
1927 
1928 ----------------------------------------------------------
1929      PROCEDURE Lock_Header_Row
1930 ----------------------------------------------------------
1931      (p_row_id IN VARCHAR2)
1932      IS
1933          dummy_id number;
1934      BEGIN
1935 
1936          select order_number into dummy_id from oe_blanket_headers
1937          where rowid = p_row_id for update;
1938 
1939      END Lock_Header_Row;
1940 
1941 
1942 ----------------------------------------------------------
1943      PROCEDURE Lock_Line_Row
1944 ----------------------------------------------------------
1945      (p_row_id IN VARCHAR2)
1946      IS
1947          dummy_id number;
1948      BEGIN
1949 
1950          select line_id into dummy_id from oe_blanket_Lines
1951          where rowid = p_row_id for update;
1952 
1953      END Lock_Line_Row;
1954 
1955 
1956 ----------------------------------------------------------
1957      PROCEDURE Load_Blanket_Line_Number
1958 ----------------------------------------------------------
1959      (l_x_header_id IN Varchar2)
1960      IS
1961          l_blanket_line_number  number;
1962      BEGIN
1963 
1964          select max(line_number) into l_blanket_line_number
1965          from oe_blanket_lines
1966          where header_id = l_x_header_id;
1967 
1968          g_blanket_line_number :=
1969                      greatest(nvl(g_blanket_line_number,0),nvl(l_blanket_line_number,0));
1970 
1971      END Load_Blanket_Line_Number;
1972 
1973 
1974 ----------------------------------------------------------
1975      PROCEDURE Load_Blanket_Header_Rec
1976 ----------------------------------------------------------
1977      (p_x_Header_rec            IN OUT NOCOPY OE_Blanket_PUB.Header_rec_type
1978      ,p_x_old_Header_rec        IN OUT NOCOPY OE_Blanket_PUB.Header_rec_type)
1979      IS
1980          ctr               number      := 1;
1981          found_flag        varchar2(1) := 'N';
1982          l_x_return_status varchar2(30);
1983      BEGIN
1984 		OE_MSG_PUB.initialize;
1985 
1986          while ctr <= G_header_Cache_Rec.count loop
1987 
1988               if g_header_cache_rec(ctr).header_id = p_x_header_rec.header_id then
1989 
1990                    p_x_old_header_rec := g_header_cache_rec(ctr);
1991                    found_flag := 'Y';
1992                    exit;
1993 
1994               else
1995 
1996                    ctr :=  ctr + 1;
1997 
1998               end if;
1999 
2000          end loop;
2001 
2002          if found_flag = 'N' then
2003 
2004              Begin
2005 		OE_MSG_PUB.initialize;
2006 
2007                   OE_Blanket_Util.Query_Header
2008                    (p_header_id     => p_x_header_rec.header_id,
2009                     x_header_rec    => p_x_old_header_rec,
2010                     x_return_status => l_x_return_status);
2011 
2012              Exception
2013 
2014                  When others then
2015                      p_x_old_header_rec := NULL;
2016 
2017              End;
2018 
2019          end if;
2020 
2021      END Load_Blanket_Header_Rec;
2022 
2023 
2024 ----------------------------------------------------------
2025      PROCEDURE Load_Blanket_Line_Rec
2026 ----------------------------------------------------------
2027      (p_x_line_rec            IN  OE_Blanket_PUB.line_rec_type
2028      ,p_x_old_line_rec        IN OUT NOCOPY OE_Blanket_PUB.line_rec_type)
2029      IS
2030          ctr            number      := 1;
2031          found_flag     varchar2(1) := 'N';
2032          l_x_return_status         varchar2(1);
2033          l_line_tbl                oe_blanket_pub.line_tbl_type;
2034      BEGIN
2035 
2036          while ctr <= G_line_Cache_Rec.count loop
2037 
2038               if g_line_cache_rec(ctr).line_id = p_x_line_rec.line_id then
2039 
2040                    p_x_old_line_rec := g_line_cache_rec(ctr);
2041                    found_flag := 'Y';
2042                    exit;
2043 
2044               else
2045 
2046                    ctr :=  ctr + 1;
2047 
2048               end if;
2049 
2050          end loop;
2051 
2052          if found_flag = 'N' then
2053 
2054              -- 11i10 Pricing Changes
2055              -- Comment out the query here and call query_line
2056              -- instead to populate the line record.
2057              begin
2058 
2059              OE_Blanket_Util.Query_Lines
2060                    (p_line_id     => p_x_line_rec.line_id,
2061                     x_line_tbl    => l_line_tbl,
2065 
2062                     x_return_status => l_x_return_status);
2063 
2064              p_x_old_line_rec := l_line_tbl(1);
2066              exception
2067                when others then
2068                   p_x_old_line_rec := null;
2069              end;
2070 
2071 /*
2072              Begin
2073 
2074                   SELECT
2075                           ACCOUNTING_RULE_ID
2076                   ,       AGREEMENT_ID
2077                   ,       ATTRIBUTE1
2078                   ,       ATTRIBUTE10
2079                   ,       ATTRIBUTE11
2080                   ,       ATTRIBUTE12
2081                   ,       ATTRIBUTE13
2082                   ,       ATTRIBUTE14
2083                   ,       ATTRIBUTE15
2084                   ,       ATTRIBUTE2
2085                   ,       ATTRIBUTE3
2086                   ,       ATTRIBUTE4
2087                   ,       ATTRIBUTE5
2088                   ,       ATTRIBUTE6
2089                   ,       ATTRIBUTE7
2090                   ,       ATTRIBUTE8
2091                   ,       ATTRIBUTE9
2092                   ,       CONTEXT
2093                   ,       CREATED_BY
2094                   ,       CREATION_DATE
2095                   ,       CUST_PO_NUMBER
2096                   ,       DELIVER_TO_ORG_ID
2097                   ,       FREIGHT_TERMS_CODE
2098                   ,       header_id
2099                   ,       INVENTORY_ITEM_ID
2100                   ,       INVOICE_TO_ORG_ID
2101                   ,       INVOICING_RULE_ID
2102                   ,       ORDERED_ITEM_ID
2103                   ,       ITEM_IDENTIFIER_TYPE
2104                   ,       ORDERED_ITEM
2105                   ,       ITEM_TYPE_CODE
2106                   ,       LAST_UPDATED_BY
2107                   ,       LAST_UPDATE_DATE
2108                   ,       LAST_UPDATE_LOGIN
2109                   ,       line_id
2110                   ,       line_number
2111                   ,       PAYMENT_TERM_ID
2112                   ,       PREFERRED_GRADE
2113                   ,       PRICE_LIST_ID
2114                   ,       PROGRAM_APPLICATION_ID
2115                   ,       PROGRAM_ID
2116                   ,       PROGRAM_UPDATE_DATE
2117                   ,       REQUEST_ID
2118                   ,       SALESREP_ID
2119                   ,       SHIPPING_METHOD_CODE
2120                   ,       ship_from_org_id
2121                   ,       SHIP_TO_ORG_ID
2122                   ,       SHIPPING_INSTRUCTIONS
2123                   ,       PACKING_INSTRUCTIONS
2124                   ,       START_DATE_ACTIVE
2125                   ,       END_DATE_ACTIVE
2126                   ,       MAX_RELEASE_AMOUNT
2127                   ,       MIN_RELEASE_AMOUNT
2128                   ,       MAX_RELEASE_QUANTITY
2129                   ,       MIN_RELEASE_QUANTITY
2130                   ,       BLANKET_LINE_MAX_AMOUNT
2131                   ,       BLANKET_LINE_MIN_AMOUNT
2132                   ,       BLANKET_MAX_QUANTITY
2133                   ,       BLANKET_MIN_QUANTITY
2134                   ,       OVERRIDE_BLANKET_CONTROLS_FLAG
2135                   ,       ENFORCE_PRICE_LIST_FLAG
2136                   ,       ORDER_QUANTITY_UOM
2137                   ,       RELEASED_QUANTITY
2138                   ,       FULFILLED_QUANTITY
2139                   ,       RETURNED_QUANTITY
2140                   ,       RELEASED_AMOUNT
2141                   ,       LOCK_CONTROL
2142                   ,       fulfilled_amount
2143 		  ,	  transaction_phase_code   -- hashraf ... pack J
2144                   ,       source_document_version_number
2145                   INTO
2146                           p_x_old_line_rec.ACCOUNTING_RULE_ID
2147                   ,       p_x_old_line_rec.AGREEMENT_ID
2148                   ,       p_x_old_line_rec.ATTRIBUTE1
2149                   ,       p_x_old_line_rec.ATTRIBUTE10
2150                   ,       p_x_old_line_rec.ATTRIBUTE11
2151                   ,       p_x_old_line_rec.ATTRIBUTE12
2152                   ,       p_x_old_line_rec.ATTRIBUTE13
2153                   ,       p_x_old_line_rec.ATTRIBUTE14
2154                   ,       p_x_old_line_rec.ATTRIBUTE15
2155                   ,       p_x_old_line_rec.ATTRIBUTE2
2156                   ,       p_x_old_line_rec.ATTRIBUTE3
2157                   ,       p_x_old_line_rec.ATTRIBUTE4
2158                   ,       p_x_old_line_rec.ATTRIBUTE5
2159                   ,       p_x_old_line_rec.ATTRIBUTE6
2160                   ,       p_x_old_line_rec.ATTRIBUTE7
2161                   ,       p_x_old_line_rec.ATTRIBUTE8
2162                   ,       p_x_old_line_rec.ATTRIBUTE9
2163                   ,       p_x_old_line_rec.CONTEXT
2164                   ,       p_x_old_line_rec.CREATED_BY
2165                   ,       p_x_old_line_rec.CREATION_DATE
2166                   ,       p_x_old_line_rec.CUST_PO_NUMBER
2167                   ,       p_x_old_line_rec.DELIVER_TO_ORG_ID
2168                   ,       p_x_old_line_rec.FREIGHT_TERMS_CODE
2169                   ,       p_x_old_line_rec.header_id
2170                   ,       p_x_old_line_rec.INVENTORY_ITEM_ID
2171                   ,       p_x_old_line_rec.INVOICE_TO_ORG_ID
2172                   ,       p_x_old_line_rec.INVOICING_RULE_ID
2173                   ,       p_x_old_line_rec.ORDERED_ITEM_ID
2174                   ,       p_x_old_line_rec.ITEM_IDENTIFIER_TYPE
2175                   ,       p_x_old_line_rec.ORDERED_ITEM
2176                   ,       p_x_old_line_rec.ITEM_TYPE_CODE
2180                   ,       p_x_old_line_rec.line_id
2177                   ,       p_x_old_line_rec.LAST_UPDATED_BY
2178                   ,       p_x_old_line_rec.LAST_UPDATE_DATE
2179                   ,       p_x_old_line_rec.LAST_UPDATE_LOGIN
2181                   ,       p_x_old_line_rec.line_number
2182                   ,       p_x_old_line_rec.PAYMENT_TERM_ID
2183                   ,       p_x_old_line_rec.PREFERRED_GRADE
2184                   ,       p_x_old_line_rec.PRICE_LIST_ID
2185                   ,       p_x_old_line_rec.PROGRAM_APPLICATION_ID
2186                   ,       p_x_old_line_rec.PROGRAM_ID
2187                   ,       p_x_old_line_rec.PROGRAM_UPDATE_DATE
2188                   ,       p_x_old_line_rec.REQUEST_ID
2189                   ,       p_x_old_line_rec.SALESREP_ID
2190                   ,       p_x_old_line_rec.SHIPPING_METHOD_CODE
2191                   ,       p_x_old_line_rec.ship_from_org_id
2192                   ,       p_x_old_line_rec.SHIP_TO_ORG_ID
2193                   ,       p_x_old_line_rec.SHIPPING_INSTRUCTIONS
2194                   ,       p_x_old_line_rec.PACKING_INSTRUCTIONS
2195                   ,       p_x_old_line_rec.START_DATE_ACTIVE
2196                   ,       p_x_old_line_rec.END_DATE_ACTIVE
2197                   ,       p_x_old_line_rec.MAX_RELEASE_AMOUNT
2198                   ,       p_x_old_line_rec.MIN_RELEASE_AMOUNT
2199                   ,       p_x_old_line_rec.MAX_RELEASE_QUANTITY
2200                   ,       p_x_old_line_rec.MIN_RELEASE_QUANTITY
2201                   ,       p_x_old_line_rec.blanket_max_amount
2202                   ,       p_x_old_line_rec.blanket_min_amount
2203                   ,       p_x_old_line_rec.BLANKET_MAX_QUANTITY
2204                   ,       p_x_old_line_rec.BLANKET_MIN_QUANTITY
2205                   ,       p_x_old_line_rec.OVERRIDE_BLANKET_CONTROLS_FLAG
2206                   ,       p_x_old_line_rec.ENFORCE_PRICE_LIST_FLAG
2207                   ,       p_x_old_line_rec.order_quantity_UOM
2208                   ,       p_x_old_line_rec.RELEASED_QUANTITY
2209                   ,       p_x_old_line_rec.FULFILLED_QUANTITY
2210                   ,       p_x_old_line_rec.RETURNED_QUANTITY
2211                   ,       p_x_old_line_rec.RELEASED_AMOUNT
2212                   ,       p_x_old_line_rec.LOCK_CONTROL
2213                   ,       p_x_old_line_rec.fulfilled_amount
2214 		  ,	  p_x_old_line_rec.transaction_phase_code -- hashraf pack J
2215 		  ,	  p_x_old_line_rec.source_document_version_number
2216                   FROM    OE_BLANKET_LINES_V bl
2217                   WHERE   line_id = p_x_line_rec.line_id;
2218 
2219              Exception
2220 
2221                  When others then
2222 
2223                      p_x_old_line_rec := NULL;
2224 
2225              End;
2226 */
2227 
2228          end if;
2229 
2230      END Load_Blanket_Line_Rec;
2231 ----------------------------------------------------------
2232      FUNCTION Line_Number
2233 ----------------------------------------------------------
2234     ( p_header_id          IN  NUMBER
2235     ) RETURN number
2236     IS
2237     l_line_number number;
2238     Begin
2239 
2240         if (p_header_id is null or p_header_id = '')then
2241 
2242            l_line_number := null;
2243            RETURN l_line_number;
2244 
2245         else
2246 
2247            begin
2248                select max(line_number) into l_line_number
2249                from oe_blanket_lines
2250                where header_id = p_header_id;
2251            exception
2252                when no_data_found then
2253                    l_line_number :=0;
2254            end;
2255 
2256            RETURN nvl(l_line_number,0);
2257         end if;
2258 
2259     END Line_Number;
2260 
2261 ----------------------------------------------------------
2262      FUNCTION Line_Number_reset
2263 ----------------------------------------------------------
2264     RETURN varchar2
2265     IS
2266     l_return_status varchar2(10);
2267     Begin
2268       G_Blanket_Line_Number := G_Blanket_Line_Number-1;
2269       l_return_status := 'TRUE';
2270       return l_return_status;
2271     end Line_Number_reset;
2272 
2273 ----------------------------------------------------------
2274      FUNCTION Sales_Order_Type
2275 ----------------------------------------------------------
2276     (p_order_type_id   IN NUMBER)
2277     RETURN varchar2
2278     IS
2279     l_order_type varchar2(240);
2280     l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2281     Begin
2282         IF l_debug_level  > 0 THEN
2283            oe_debug_pub.add('Entering  OE_Blanket_Form_Control.Sales_Order_Type order Type Id : '||p_order_type_id);
2284         END IF;
2285         select
2286 	name into l_order_type
2287         from 	oe_transaction_types_vl
2288         where 	SALES_DOCUMENT_TYPE_CODE = 'B'
2289         AND     transaction_type_id = p_order_type_id;
2290 
2291         return l_order_type;
2292         IF l_debug_level  > 0 THEN
2293            oe_debug_pub.add('Exiting OE_Blanket_Form_Control.Sales_Order_Type order type: '||l_order_type);
2294         END IF;
2295 
2296     EXCEPTION
2297 
2298     WHEN NO_DATA_FOUND THEN
2299         IF l_debug_level  > 0 THEN
2300            oe_debug_pub.add('IN NO_DATA_FOUND OE_Blanket_Form_Control.Sales_Order_Type for order type ID: '||p_order_type_id);
2301         END IF;
2302 
2306             FND_MESSAGE.SET_TOKEN('ATTRIBUTE','Sales_Order_Type');
2303         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
2304         THEN
2305             fnd_message.set_name('ONT','OE_ID_TO_VALUE_ERROR');
2307             OE_MSG_PUB.Add;
2308 
2309         END IF;
2310 
2311         RETURN NULL;
2312 
2313     WHEN OTHERS THEN
2314         IF l_debug_level  > 0 THEN
2315            oe_debug_pub.add('IN OTEHRS OE_Blanket_Form_Control.Sales_Order_Type for order type ID: '||p_order_type_id);
2316         END IF;
2317 
2318         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2319         THEN
2320             OE_MSG_PUB.Add_Exc_Msg
2321             (   G_PKG_NAME
2322             ,   'Sales_Order_Type'
2323             );
2324         END IF;
2325 
2326         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2327     end Sales_Order_Type;
2328 ----------------------------------------------------------
2329      FUNCTION item_identifier
2330 ----------------------------------------------------------
2331     (p_item_identifier_type   IN VARCHAR2)
2332     RETURN varchar2
2333     IS
2334     l_item_identifier varchar2(240);
2335     Begin
2336 
2337         SELECT meaning
2338         INTO  l_item_identifier
2339         FROM oe_lookups
2340         WHERE lookup_type = 'ITEM_IDENTIFIER_TYPE'
2341         AND   lookup_code = p_item_identifier_type;
2342 
2343         return l_item_identifier;
2344 
2345     end item_identifier;
2346 ----------------------------------------------------------
2347      FUNCTION Get_Currency_Format
2348 ----------------------------------------------------------
2349     (p_currency_code    IN VARCHAR2,
2350      p_field_length     IN NUMBER,
2351      p_percision        IN NUMBER,
2352      p_min_acct_unit    IN NUMBER)
2353      RETURN VARCHAR2
2354      IS
2355      l_format_mask       VARCHAR2(500);
2356      X_precision         NUMBER := 6;
2357      X_Ext_precision     NUMBER;
2358      X_min_acct_unit     NUMBER;
2359      l_precision_type    VARCHAR2(30);
2360      Begin
2361          -- For the bug #4106882
2362          -- Originally we use to format based on the hardcoded precision
2363          -- , now we have changed to get the precision based on the QP profile
2364          -- else we will hard coded to 6 digits.
2365          -- This new format will affect all the amounts fields on BSA UI.
2366          FND_CURRENCY.Get_Info(p_currency_code, X_precision,
2367                               X_Ext_precision, X_min_acct_unit);
2368          fnd_profile.get('QP_UNIT_PRICE_PRECISION_TYPE', l_precision_type);
2369          IF (l_precision_type = 'EXTENDED') THEN
2370             FND_CURRENCY.Build_Format_Mask(l_format_mask, p_field_length,
2371             X_Ext_precision,X_min_acct_unit, TRUE);
2372          ELSE
2373             FND_CURRENCY.Build_Format_Mask(l_format_mask, p_field_length,
2374             X_precision,X_min_acct_unit, TRUE);
2375          END IF;
2376          RETURN l_format_mask;
2377 
2378      END;
2379 
2380 ----------------------------------------------------------
2381      FUNCTION Get_Opr_Create
2382 ----------------------------------------------------------
2383      RETURN varchar2
2384      IS
2385      BEGIN
2386          RETURN OE_GLOBALS.G_OPR_CREATE;
2387      END;
2388 
2389 ----------------------------------------------------------
2390      FUNCTION Get_Opr_Update
2391 ----------------------------------------------------------
2392      RETURN varchar2
2393      IS
2394      BEGIN
2395          RETURN OE_GLOBALS.G_OPR_UPDATE;
2396      END;
2397 
2398 ----------------------------------------------------------
2399      FUNCTION Get_Opr_Delete
2400 ----------------------------------------------------------
2401      RETURN varchar2
2402      IS
2403      BEGIN
2404          -- hashraf new function for pack J
2405          RETURN OE_GLOBALS.G_OPR_DELETE;
2406      END;
2407 
2408 ----------------------------------------------------------
2409      FUNCTION chk_for_header_release
2410 ----------------------------------------------------------
2411     (p_blanket_number   IN number)
2412     RETURN varchar2
2413     IS
2414     l_return    varchar2(10):= 'FALSE';
2415     l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2416     Begin
2417 
2418         IF l_debug_level  > 0 THEN
2419            oe_debug_pub.add('IN OE_Blanket_Form_Control.chk_for_header_release '||p_blanket_number);
2420         END IF;
2421 
2422         if p_blanket_number is not null then
2423 
2424             begin
2425 
2426                SELECT 'TRUE'
2427                INTO  l_return
2428                FROM oe_order_headers
2429                WHERE blanket_number = p_blanket_number
2430                AND ROWNUM = 1;
2431 
2432             exception
2433 
2434                when no_data_found then
2435 
2436                     SELECT 'TRUE'
2437                     INTO  l_return
2438                     FROM oe_order_lines
2439                     WHERE blanket_number = p_blanket_number
2440                     AND ROWNUM = 1;
2441             end;
2442 
2443         end if;
2444 
2445         IF l_debug_level  > 0 THEN
2446            oe_debug_pub.add('IN OE_Blanket_Form_Control.chk_for_header_release ');
2450 
2447         END IF;
2448 
2449         return l_return;
2451     EXCEPTION
2452 
2453         WHEN NO_DATA_FOUND THEN
2454 
2455             oe_debug_pub.add('IN OE_Blanket_Form_Control.chk_for_header_release WHEN no_data_found');
2456             RETURN l_return;
2457 
2458         WHEN OTHERS THEN
2459 
2460             oe_debug_pub.add('IN OE_Blanket_Form_Control.chk_for_header_release WHEN OTEHRS');
2461             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2462             THEN
2463                 OE_MSG_PUB.Add_Exc_Msg
2464                 (   G_PKG_NAME
2465                 ,   'chk_for_header_release'
2466                 );
2467             END IF;
2468             RETURN l_return;
2469 
2470     end chk_for_header_release;
2471 
2472 ----------------------------------------------------------
2473      FUNCTION chk_for_line_release
2474 ----------------------------------------------------------
2475     (p_blanket_number   IN number,
2476      p_blanket_line_number in number)
2477     RETURN varchar2
2478     IS
2479     l_return    varchar2(10):= 'FLASE';
2480     l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2481     Begin
2482 
2483         IF l_debug_level  > 0 THEN
2484            oe_debug_pub.add(  'IN OE_Blanket_Form_Control.chk_for_line_release '||p_blanket_number);
2485         END IF;
2486 
2487         if p_blanket_number is not null then
2488 
2489                SELECT 'TRUE'
2490                INTO  l_return
2491                FROM oe_order_lines
2492                WHERE blanket_number = p_blanket_number
2493                AND BLANKET_LINE_NUMBER = p_blanket_line_number
2494                AND rownum = 1;
2495 
2496          end if;
2497 
2498         IF l_debug_level  > 0 THEN
2499            oe_debug_pub.add(  'IN OE_Blanket_Form_Control.chk_for_line_release ');
2500         END IF;
2501 
2502         return l_return;
2503 
2504     EXCEPTION
2505 
2506         WHEN NO_DATA_FOUND THEN
2507 
2508             oe_debug_pub.add(  'IN OE_Blanket_Form_Control.chk_for_line_release WHEN no_data_found');
2509             RETURN l_return;
2510 
2511         WHEN OTHERS THEN
2512 
2513             oe_debug_pub.add(  'IN OE_Blanket_Form_Control.chk_for_line_release WHEN OTEHRS');
2514             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2515             THEN
2516                 OE_MSG_PUB.Add_Exc_Msg
2517                 (   G_PKG_NAME
2518                 ,   'chk_for_header_release'
2519                 );
2520             END IF;
2521             RETURN l_return;
2522 
2523     end chk_for_line_release;
2524 
2525 ----------------------------------------------------------
2526     PROCEDURE Set_Include_All_Revisions(p_value IN VARCHAR2)
2527 ----------------------------------------------------------
2528     IS
2529     BEGIN
2530 
2531       G_INCLUDE_ALL_REVISIONS := p_value;
2532 
2533     END Set_Include_All_Revisions;
2534 
2535 ----------------------------------------------------------
2536     FUNCTION INCLUDE_ALL_REVISIONS
2537 ----------------------------------------------------------
2538     RETURN varchar2
2539     IS
2540     BEGIN
2541 
2542       RETURN G_INCLUDE_ALL_REVISIONS;
2543 
2544     END INCLUDE_ALL_REVISIONS;
2545 
2546 ----------------------------------------------------------
2547      FUNCTION chk_active_revision
2548 ----------------------------------------------------------
2549     (p_blanket_number   IN number,
2550      p_version_number   IN number)
2551     RETURN varchar2
2552     IS
2553     l_return    varchar2(10):= 'FLASE';
2554     l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2555     Begin
2556 
2557         IF l_debug_level  > 0 THEN
2561         if p_blanket_number is not null then
2558            oe_debug_pub.add(  'IN OE_Blanket_Form_Control.chk_active_revision '||p_blanket_number);
2559         END IF;
2560 
2562 
2563                SELECT 'TRUE'
2564                INTO  l_return
2565                FROM  oe_blanket_headers_all
2566                WHERE order_number     = p_blanket_number
2567                AND   version_number   = p_version_number
2568                AND   rownum           = 1;
2569 
2570          end if;
2571 
2572         IF l_debug_level  > 0 THEN
2573            oe_debug_pub.add(  'IN OE_Blanket_Form_Control.chk_active_revision ');
2574         END IF;
2575 
2576         return l_return;
2577 
2578     EXCEPTION
2579 
2580         WHEN NO_DATA_FOUND THEN
2581 
2582             oe_debug_pub.add('IN OE_Blanket_Form_Control.chk_active_revision WHEN no_data_found');
2583             RETURN l_return;
2584 
2585         WHEN OTHERS THEN
2586 
2587             oe_debug_pub.add('IN OE_Blanket_Form_Control.chk_active_revision WHEN OTEHRS');
2588             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2589             THEN
2590                 OE_MSG_PUB.Add_Exc_Msg
2591                 (   G_PKG_NAME
2592                 ,   'chk_active_revision'
2593                 );
2594             END IF;
2595             RETURN l_return;
2596 
2597     end chk_active_revision;
2598 
2599 -- This procedure will be called from the client when the user
2600 -- clears a record
2601 Procedure Clear_Record
2602 ( x_return_status OUT NOCOPY VARCHAR2
2603 , x_msg_count OUT NOCOPY NUMBER
2604 , x_msg_data OUT NOCOPY VARCHAR2
2605 ,   block_name                     IN  VARCHAR2
2606 )
2607 IS
2608 l_return_status                     Varchar2(30);
2609 BEGIN
2610 -- hashraf ... start of pack J
2611      OE_MSG_PUB.initialize;
2612  	x_return_status := FND_API.G_RET_STS_SUCCESS;
2613 
2614 -- Clear the controller cache
2615 --	Clear_Header;
2616 
2617      if block_name in ('BLANKET_HEADER') then
2618 
2619        g_header_cache_rec.delete;
2620 
2621      elsif block_name in ('BLANKET_LINE') then
2622        g_line_cache_rec.delete;
2623 
2624      end if;
2625 
2626 EXCEPTION
2627     WHEN OTHERS THEN
2628         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2629         THEN
2630             OE_MSG_PUB.Add_Exc_Msg
2631             (   G_PKG_NAME
2632             ,   'Clear_Record'
2633             );
2634         END IF;
2635         --  Get message count and data
2636         OE_MSG_PUB.Count_And_Get
2637         (   p_count                       => x_msg_count
2638         ,   p_data                        => x_msg_data
2639         );
2640         x_return_status := FND_API.G_RET_STS_ERROR;
2641 
2642 END Clear_Record;
2643 
2644 ----------------------------------------------------------
2645      FUNCTION get_trxt_phase_from_order_type
2646 ----------------------------------------------------------
2647     (p_order_type_id   IN number)
2648     RETURN varchar2
2649     IS
2650     l_return    varchar2(10);
2651     l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2652     Begin
2653 
2654         IF l_debug_level  > 0 THEN
2655            oe_debug_pub.add('IN OE_Blanket_Form_Control.get_trxt_phase_from_order_type '||p_order_type_id);
2656         END IF;
2657 
2658         if p_order_type_id is not null then
2659 
2660             begin
2661 
2662                SELECT DEF_TRANSACTION_PHASE_CODE
2663                INTO  l_return
2664                FROM oe_transaction_types_all
2665                WHERE TRANSACTION_TYPE_ID = p_order_type_id;
2666             EXCEPTION
2667 
2668                WHEN NO_DATA_FOUND THEN
2669                     oe_debug_pub.add('IN OE_Blanket_Form_Control.get_trxt_phas WHEN no_data_found');
2670                     RETURN l_return;
2671             end;
2672 
2673         end if;
2674 
2675         IF l_debug_level  > 0 THEN
2676            oe_debug_pub.add('IN OE_Blanket_Form_Control.get_trxt_phase_from_order_type ');
2677         END IF;
2678 
2679         return l_return;
2680 
2681     EXCEPTION
2682 
2683         WHEN NO_DATA_FOUND THEN
2684 
2685             oe_debug_pub.add('IN OE_Blanket_Form_Control.chk_for_Submit_Draft_flag WHEN no_data_found');
2686             RETURN l_return;
2687 
2688         WHEN OTHERS THEN
2689 
2690             oe_debug_pub.add('IN OE_Blanket_Form_Control.chk_for_header_release WHEN OTEHRS');
2691             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2692             THEN
2693                 OE_MSG_PUB.Add_Exc_Msg
2694                 (   G_PKG_NAME
2695                 ,   'get_trxt_phase_from_order_type'
2696                 );
2697             END IF;
2698             RETURN l_return;
2699 
2700     end get_trxt_phase_from_order_type;
2701 
2702 END OE_Blanket_Form_Control;