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.6 2011/04/01 06:36:40 nilegupt ship $ */
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
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
313                                 , x_ship_to_address3    => p_line_val_rec.ship_to_address3
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
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
352                                 , x_invoice_to_postal_code => p_line_val_rec.invoice_to_zip
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 
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 '
464                         ||x_return_status);
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;
587          end if;
588 
589          oe_msg_pub.count_and_get
590          (   p_count     => x_msg_count
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);
726 
727          OE_Blanket_Util.Update_Row(p_header_rec,X_RETURN_STATUS);
728 
729          IF x_return_status = FND_API.G_RET_STS_ERROR THEN
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;
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);
873 
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;
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
1014 				,x_return_status => X_RETURN_STATUS);
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
1147              ( p_count => x_msg_count,
1148               p_data  => x_msg_data);
1149 
1150      END Default_Attributes;
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
1275                         then EXIT;
1276                 end if;
1277                 I := oe_delayed_requests_pvt.g_delayed_requests.next(I);
1278                 END LOOP;
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
1384                    End;
1385               */
1386 
1387               ctr := ctr + 1;
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,
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,
1506      x_msg_count             IN OUT NOCOPY NUMBER,
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;
1632            END IF;
1633         END IF;
1634 
1635          oe_msg_pub.count_and_get
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 
1775         END IF;
1776 
1777          oe_msg_pub.count_and_get
1778          (   p_count     => x_msg_count
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        --below if condition added for bug11841209
1835        IF TO_CHAR(p_x_header_rec.end_date_active,'HH24MISS') = '000000' THEN
1836 
1837            oe_debug_pub.add('nilegupt p_x_header_rec.end_date_active'||TO_CHAR(p_x_header_rec.end_date_active,'DD/MON/YYYY::HH24:MI:SS'));
1838            p_x_header_rec.end_date_active :=
1839            trunc(p_x_header_rec.end_date_active,'DD') +
1840                                             ((24*60*60)-1)/(24*60*60);
1841 
1842        END IF;
1843         --end bug11841209
1844 
1845          found_flag := 'N';
1846          ctr := 1;
1847 
1848          if G_Header_Cache_Rec.count = 0 then
1849             oe_debug_pub.add('Update_Header_Cache is Zero ', 1);
1850             if delete_flag <> 'Y' THEN
1851                G_Header_Cache_Rec(ctr) := p_x_header_rec;
1852             end if;
1853          else
1854             oe_debug_pub.add('Update_Header_Cache is greater then Zero ', 2);
1855             while ctr <= G_Header_Cache_Rec.count and found_flag = 'N' loop
1856                   if G_Header_Cache_Rec(ctr).header_id = p_x_header_rec.header_id then
1857                      found_flag := 'Y';
1858                   else
1859                      ctr := ctr + 1;
1860                   end if;
1861             end loop;
1862          end if;
1863 
1864          /* Later change it to update only for changed attributes */
1865 
1866          If delete_flag = 'Y' then
1867             If found_flag = 'Y' then
1868                G_Header_Cache_Rec(ctr) := NULL;
1869                OE_DELAYED_REQUESTS_PVT.Delete_Reqs_for_Deleted_Entity(
1870                          p_entity_code  => OE_BLANKET_PUB.G_ENTITY_BLANKET_HEADER
1871                          ,p_entity_id    => p_x_header_rec.header_id
1872 			 , p_delete_against => FALSE
1873                          ,x_return_status => l_return_status);
1874             End if;
1875          Else
1876             oe_debug_pub.add('Update_Header_Cache is  OE_Blanket_Form_Control.Update_Header_Cache ', 3);
1877             oe_debug_pub.add('Header Operation Code :'||p_x_header_rec.operation);
1878             G_Header_Cache_Rec(ctr) := p_x_header_rec;
1879          End if;
1880          oe_debug_pub.add('Exiting Update_Header_Cache OE_Blanket_Form_Control.Update_Header_Cache ', 4);
1881 
1882      END Update_Header_Cache;
1883 
1884 
1885 ----------------------------------------------------------
1886      PROCEDURE Update_Line_Cache
1887 ----------------------------------------------------------
1888          (p_x_line_rec            IN OUT NOCOPY OE_Blanket_PUB.line_rec_type,
1889           delete_flag             IN            VARCHAR2 := NULL)
1890      IS
1891          ctr                      number;
1892          found_flag               varchar2(1);
1893          l_return_status          varchar2(80);
1894      BEGIN
1895 
1896          oe_debug_pub.add('Entering Update_line_Cache OE_Blanket_Form_Control.Update_line_Cache ', 0);
1897 
1898          found_flag := 'N';
1899          ctr := 1;
1900 
1901          if G_Line_Cache_Rec.count = 0 then
1902             oe_debug_pub.add('Update_line_Cache is Zero ', 1);
1903             if  delete_flag <> 'Y' then
1904                 G_Line_Cache_Rec(ctr) := p_x_Line_rec;
1905             end if;
1906          else
1907             oe_debug_pub.add('Update_line_Cache is greater then Zero ', 2);
1908             while ctr <= G_Line_Cache_Rec.count and found_flag = 'N' loop
1909                   if G_Line_Cache_Rec(ctr).Line_id = p_x_Line_rec.Line_id then
1910                      found_flag := 'Y';
1911                   else
1912                      ctr := ctr + 1;
1913                   end if;
1914             end loop;
1915 
1916          end if;
1917 
1918          /* Later change it to update only changed attributes */
1919 
1920          If delete_flag = 'Y' then
1921 
1922             If found_flag = 'Y' then
1923                OE_DELAYED_REQUESTS_PVT.Delete_Reqs_for_Deleted_Entity(
1924                          p_entity_code  => OE_BLANKET_PUB.G_ENTITY_BLANKET_LINE
1925                          ,p_entity_id    => p_x_Line_rec.Line_id
1926 			, p_delete_against => FALSE
1927                          ,x_return_status => l_return_status);
1928 
1929                G_Line_Cache_Rec(ctr) := NULL;
1930             End if;
1931          Else
1932             oe_debug_pub.add('Line Operation Code :'||p_x_Line_rec.operation);
1933             G_Line_Cache_Rec(ctr) := p_x_Line_rec;
1934          End if;
1935          oe_debug_pub.add('Exiting Update_line_Cache OE_Blanket_Form_Control.Update_line_Cache ', 4);
1936      END Update_Line_Cache;
1937 
1938 
1939 ----------------------------------------------------------
1940      PROCEDURE Lock_Header_Row
1941 ----------------------------------------------------------
1942      (p_row_id IN VARCHAR2)
1943      IS
1944          dummy_id number;
1945      BEGIN
1946 
1947          select order_number into dummy_id from oe_blanket_headers
1948          where rowid = p_row_id for update;
1949 
1950      END Lock_Header_Row;
1951 
1952 
1953 ----------------------------------------------------------
1954      PROCEDURE Lock_Line_Row
1955 ----------------------------------------------------------
1956      (p_row_id IN VARCHAR2)
1957      IS
1958          dummy_id number;
1959      BEGIN
1960 
1961          select line_id into dummy_id from oe_blanket_Lines
1962          where rowid = p_row_id for update;
1963 
1964      END Lock_Line_Row;
1965 
1966 
1967 ----------------------------------------------------------
1968      PROCEDURE Load_Blanket_Line_Number
1969 ----------------------------------------------------------
1970      (l_x_header_id IN Varchar2)
1971      IS
1972          l_blanket_line_number  number;
1973      BEGIN
1974 
1975          select max(line_number) into l_blanket_line_number
1976          from oe_blanket_lines
1977          where header_id = l_x_header_id;
1978 
1979          g_blanket_line_number :=
1980                      greatest(nvl(g_blanket_line_number,0),nvl(l_blanket_line_number,0));
1981 
1982      END Load_Blanket_Line_Number;
1983 
1984 
1985 ----------------------------------------------------------
1986      PROCEDURE Load_Blanket_Header_Rec
1987 ----------------------------------------------------------
1988      (p_x_Header_rec            IN OUT NOCOPY OE_Blanket_PUB.Header_rec_type
1989      ,p_x_old_Header_rec        IN OUT NOCOPY OE_Blanket_PUB.Header_rec_type)
1990      IS
1991          ctr               number      := 1;
1992          found_flag        varchar2(1) := 'N';
1993          l_x_return_status varchar2(30);
1994      BEGIN
1995 		OE_MSG_PUB.initialize;
1996 
1997          while ctr <= G_header_Cache_Rec.count loop
1998 
1999               if g_header_cache_rec(ctr).header_id = p_x_header_rec.header_id then
2000 
2001                    p_x_old_header_rec := g_header_cache_rec(ctr);
2002                    found_flag := 'Y';
2003                    exit;
2004 
2005               else
2006 
2007                    ctr :=  ctr + 1;
2008 
2009               end if;
2010 
2011          end loop;
2012 
2013          if found_flag = 'N' then
2014 
2015              Begin
2016 		OE_MSG_PUB.initialize;
2017 
2018                   OE_Blanket_Util.Query_Header
2019                    (p_header_id     => p_x_header_rec.header_id,
2020                     x_header_rec    => p_x_old_header_rec,
2021                     x_return_status => l_x_return_status);
2022 
2023              Exception
2024 
2025                  When others then
2026                      p_x_old_header_rec := NULL;
2027 
2028              End;
2029 
2030          end if;
2031 
2032      END Load_Blanket_Header_Rec;
2033 
2034 
2035 ----------------------------------------------------------
2036      PROCEDURE Load_Blanket_Line_Rec
2037 ----------------------------------------------------------
2038      (p_x_line_rec            IN  OE_Blanket_PUB.line_rec_type
2039      ,p_x_old_line_rec        IN OUT NOCOPY OE_Blanket_PUB.line_rec_type)
2040      IS
2041          ctr            number      := 1;
2042          found_flag     varchar2(1) := 'N';
2043          l_x_return_status         varchar2(1);
2044          l_line_tbl                oe_blanket_pub.line_tbl_type;
2045      BEGIN
2046 
2047          while ctr <= G_line_Cache_Rec.count loop
2048 
2049               if g_line_cache_rec(ctr).line_id = p_x_line_rec.line_id then
2050 
2051                    p_x_old_line_rec := g_line_cache_rec(ctr);
2052                    found_flag := 'Y';
2053                    exit;
2054 
2055               else
2056 
2057                    ctr :=  ctr + 1;
2058 
2059               end if;
2060 
2061          end loop;
2062 
2063          if found_flag = 'N' then
2064 
2065              -- 11i10 Pricing Changes
2066              -- Comment out the query here and call query_line
2067              -- instead to populate the line record.
2068              begin
2069 
2070              OE_Blanket_Util.Query_Lines
2071                    (p_line_id     => p_x_line_rec.line_id,
2072                     x_line_tbl    => l_line_tbl,
2073                     x_return_status => l_x_return_status);
2074 
2075              p_x_old_line_rec := l_line_tbl(1);
2076 
2077              exception
2078                when others then
2079                   p_x_old_line_rec := null;
2080              end;
2081 
2082 /*
2083              Begin
2084 
2085                   SELECT
2086                           ACCOUNTING_RULE_ID
2087                   ,       AGREEMENT_ID
2088                   ,       ATTRIBUTE1
2089                   ,       ATTRIBUTE10
2090                   ,       ATTRIBUTE11
2091                   ,       ATTRIBUTE12
2092                   ,       ATTRIBUTE13
2093                   ,       ATTRIBUTE14
2094                   ,       ATTRIBUTE15
2095                   ,       ATTRIBUTE2
2096                   ,       ATTRIBUTE3
2097                   ,       ATTRIBUTE4
2098                   ,       ATTRIBUTE5
2099                   ,       ATTRIBUTE6
2100                   ,       ATTRIBUTE7
2101                   ,       ATTRIBUTE8
2102                   ,       ATTRIBUTE9
2103                   ,       CONTEXT
2104                   ,       CREATED_BY
2105                   ,       CREATION_DATE
2106                   ,       CUST_PO_NUMBER
2107                   ,       DELIVER_TO_ORG_ID
2108                   ,       FREIGHT_TERMS_CODE
2109                   ,       header_id
2110                   ,       INVENTORY_ITEM_ID
2111                   ,       INVOICE_TO_ORG_ID
2112                   ,       INVOICING_RULE_ID
2113                   ,       ORDERED_ITEM_ID
2114                   ,       ITEM_IDENTIFIER_TYPE
2115                   ,       ORDERED_ITEM
2116                   ,       ITEM_TYPE_CODE
2117                   ,       LAST_UPDATED_BY
2118                   ,       LAST_UPDATE_DATE
2119                   ,       LAST_UPDATE_LOGIN
2120                   ,       line_id
2121                   ,       line_number
2122                   ,       PAYMENT_TERM_ID
2123                   ,       PREFERRED_GRADE
2124                   ,       PRICE_LIST_ID
2125                   ,       PROGRAM_APPLICATION_ID
2126                   ,       PROGRAM_ID
2127                   ,       PROGRAM_UPDATE_DATE
2128                   ,       REQUEST_ID
2129                   ,       SALESREP_ID
2130                   ,       SHIPPING_METHOD_CODE
2131                   ,       ship_from_org_id
2132                   ,       SHIP_TO_ORG_ID
2133                   ,       SHIPPING_INSTRUCTIONS
2134                   ,       PACKING_INSTRUCTIONS
2135                   ,       START_DATE_ACTIVE
2136                   ,       END_DATE_ACTIVE
2137                   ,       MAX_RELEASE_AMOUNT
2138                   ,       MIN_RELEASE_AMOUNT
2139                   ,       MAX_RELEASE_QUANTITY
2140                   ,       MIN_RELEASE_QUANTITY
2141                   ,       BLANKET_LINE_MAX_AMOUNT
2142                   ,       BLANKET_LINE_MIN_AMOUNT
2143                   ,       BLANKET_MAX_QUANTITY
2144                   ,       BLANKET_MIN_QUANTITY
2145                   ,       OVERRIDE_BLANKET_CONTROLS_FLAG
2146                   ,       ENFORCE_PRICE_LIST_FLAG
2147                   ,       ORDER_QUANTITY_UOM
2148                   ,       RELEASED_QUANTITY
2149                   ,       FULFILLED_QUANTITY
2150                   ,       RETURNED_QUANTITY
2151                   ,       RELEASED_AMOUNT
2152                   ,       LOCK_CONTROL
2153                   ,       fulfilled_amount
2154 		  ,	  transaction_phase_code   -- hashraf ... pack J
2155                   ,       source_document_version_number
2156                   INTO
2157                           p_x_old_line_rec.ACCOUNTING_RULE_ID
2158                   ,       p_x_old_line_rec.AGREEMENT_ID
2159                   ,       p_x_old_line_rec.ATTRIBUTE1
2160                   ,       p_x_old_line_rec.ATTRIBUTE10
2161                   ,       p_x_old_line_rec.ATTRIBUTE11
2162                   ,       p_x_old_line_rec.ATTRIBUTE12
2163                   ,       p_x_old_line_rec.ATTRIBUTE13
2164                   ,       p_x_old_line_rec.ATTRIBUTE14
2165                   ,       p_x_old_line_rec.ATTRIBUTE15
2166                   ,       p_x_old_line_rec.ATTRIBUTE2
2167                   ,       p_x_old_line_rec.ATTRIBUTE3
2168                   ,       p_x_old_line_rec.ATTRIBUTE4
2169                   ,       p_x_old_line_rec.ATTRIBUTE5
2170                   ,       p_x_old_line_rec.ATTRIBUTE6
2171                   ,       p_x_old_line_rec.ATTRIBUTE7
2172                   ,       p_x_old_line_rec.ATTRIBUTE8
2173                   ,       p_x_old_line_rec.ATTRIBUTE9
2174                   ,       p_x_old_line_rec.CONTEXT
2175                   ,       p_x_old_line_rec.CREATED_BY
2176                   ,       p_x_old_line_rec.CREATION_DATE
2177                   ,       p_x_old_line_rec.CUST_PO_NUMBER
2178                   ,       p_x_old_line_rec.DELIVER_TO_ORG_ID
2179                   ,       p_x_old_line_rec.FREIGHT_TERMS_CODE
2180                   ,       p_x_old_line_rec.header_id
2181                   ,       p_x_old_line_rec.INVENTORY_ITEM_ID
2182                   ,       p_x_old_line_rec.INVOICE_TO_ORG_ID
2183                   ,       p_x_old_line_rec.INVOICING_RULE_ID
2184                   ,       p_x_old_line_rec.ORDERED_ITEM_ID
2185                   ,       p_x_old_line_rec.ITEM_IDENTIFIER_TYPE
2186                   ,       p_x_old_line_rec.ORDERED_ITEM
2187                   ,       p_x_old_line_rec.ITEM_TYPE_CODE
2188                   ,       p_x_old_line_rec.LAST_UPDATED_BY
2189                   ,       p_x_old_line_rec.LAST_UPDATE_DATE
2190                   ,       p_x_old_line_rec.LAST_UPDATE_LOGIN
2191                   ,       p_x_old_line_rec.line_id
2192                   ,       p_x_old_line_rec.line_number
2193                   ,       p_x_old_line_rec.PAYMENT_TERM_ID
2194                   ,       p_x_old_line_rec.PREFERRED_GRADE
2195                   ,       p_x_old_line_rec.PRICE_LIST_ID
2196                   ,       p_x_old_line_rec.PROGRAM_APPLICATION_ID
2197                   ,       p_x_old_line_rec.PROGRAM_ID
2198                   ,       p_x_old_line_rec.PROGRAM_UPDATE_DATE
2199                   ,       p_x_old_line_rec.REQUEST_ID
2200                   ,       p_x_old_line_rec.SALESREP_ID
2201                   ,       p_x_old_line_rec.SHIPPING_METHOD_CODE
2202                   ,       p_x_old_line_rec.ship_from_org_id
2203                   ,       p_x_old_line_rec.SHIP_TO_ORG_ID
2204                   ,       p_x_old_line_rec.SHIPPING_INSTRUCTIONS
2205                   ,       p_x_old_line_rec.PACKING_INSTRUCTIONS
2206                   ,       p_x_old_line_rec.START_DATE_ACTIVE
2207                   ,       p_x_old_line_rec.END_DATE_ACTIVE
2208                   ,       p_x_old_line_rec.MAX_RELEASE_AMOUNT
2209                   ,       p_x_old_line_rec.MIN_RELEASE_AMOUNT
2210                   ,       p_x_old_line_rec.MAX_RELEASE_QUANTITY
2211                   ,       p_x_old_line_rec.MIN_RELEASE_QUANTITY
2212                   ,       p_x_old_line_rec.blanket_max_amount
2213                   ,       p_x_old_line_rec.blanket_min_amount
2214                   ,       p_x_old_line_rec.BLANKET_MAX_QUANTITY
2215                   ,       p_x_old_line_rec.BLANKET_MIN_QUANTITY
2216                   ,       p_x_old_line_rec.OVERRIDE_BLANKET_CONTROLS_FLAG
2217                   ,       p_x_old_line_rec.ENFORCE_PRICE_LIST_FLAG
2218                   ,       p_x_old_line_rec.order_quantity_UOM
2219                   ,       p_x_old_line_rec.RELEASED_QUANTITY
2220                   ,       p_x_old_line_rec.FULFILLED_QUANTITY
2221                   ,       p_x_old_line_rec.RETURNED_QUANTITY
2222                   ,       p_x_old_line_rec.RELEASED_AMOUNT
2223                   ,       p_x_old_line_rec.LOCK_CONTROL
2224                   ,       p_x_old_line_rec.fulfilled_amount
2225 		  ,	  p_x_old_line_rec.transaction_phase_code -- hashraf pack J
2226 		  ,	  p_x_old_line_rec.source_document_version_number
2227                   FROM    OE_BLANKET_LINES_V bl
2228                   WHERE   line_id = p_x_line_rec.line_id;
2229 
2230              Exception
2231 
2232                  When others then
2233 
2234                      p_x_old_line_rec := NULL;
2235 
2236              End;
2237 */
2238 
2239          end if;
2240 
2241      END Load_Blanket_Line_Rec;
2242 ----------------------------------------------------------
2243      FUNCTION Line_Number
2244 ----------------------------------------------------------
2245     ( p_header_id          IN  NUMBER
2246     ) RETURN number
2247     IS
2248     l_line_number number;
2249     Begin
2250 
2251         if (p_header_id is null or p_header_id = '')then
2252 
2253            l_line_number := null;
2254            RETURN l_line_number;
2255 
2256         else
2257 
2258            begin
2259                select max(line_number) into l_line_number
2260                from oe_blanket_lines
2261                where header_id = p_header_id;
2262            exception
2263                when no_data_found then
2264                    l_line_number :=0;
2265            end;
2266 
2267            RETURN nvl(l_line_number,0);
2268         end if;
2269 
2270     END Line_Number;
2271 
2272 ----------------------------------------------------------
2273      FUNCTION Line_Number_reset
2274 ----------------------------------------------------------
2275     RETURN varchar2
2276     IS
2277     l_return_status varchar2(10);
2278     Begin
2279       G_Blanket_Line_Number := G_Blanket_Line_Number-1;
2280       l_return_status := 'TRUE';
2281       return l_return_status;
2282     end Line_Number_reset;
2283 
2284 ----------------------------------------------------------
2285      FUNCTION Sales_Order_Type
2286 ----------------------------------------------------------
2287     (p_order_type_id   IN NUMBER)
2288     RETURN varchar2
2289     IS
2290     l_order_type varchar2(240);
2291     l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2292     Begin
2293         IF l_debug_level  > 0 THEN
2294            oe_debug_pub.add('Entering  OE_Blanket_Form_Control.Sales_Order_Type order Type Id : '||p_order_type_id);
2295         END IF;
2296         select
2297 	name into l_order_type
2298         from 	oe_transaction_types_vl
2299         where 	SALES_DOCUMENT_TYPE_CODE = 'B'
2300         AND     transaction_type_id = p_order_type_id;
2301 
2302         return l_order_type;
2303         IF l_debug_level  > 0 THEN
2304            oe_debug_pub.add('Exiting OE_Blanket_Form_Control.Sales_Order_Type order type: '||l_order_type);
2305         END IF;
2306 
2307     EXCEPTION
2308 
2309     WHEN NO_DATA_FOUND THEN
2310         IF l_debug_level  > 0 THEN
2311            oe_debug_pub.add('IN NO_DATA_FOUND OE_Blanket_Form_Control.Sales_Order_Type for order type ID: '||p_order_type_id);
2312         END IF;
2313 
2314         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_SUCCESS)
2315         THEN
2316             fnd_message.set_name('ONT','OE_ID_TO_VALUE_ERROR');
2317             FND_MESSAGE.SET_TOKEN('ATTRIBUTE','Sales_Order_Type');
2318             OE_MSG_PUB.Add;
2319 
2320         END IF;
2321 
2322         RETURN NULL;
2323 
2324     WHEN OTHERS THEN
2325         IF l_debug_level  > 0 THEN
2326            oe_debug_pub.add('IN OTEHRS OE_Blanket_Form_Control.Sales_Order_Type for order type ID: '||p_order_type_id);
2327         END IF;
2328 
2329         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2330         THEN
2331             OE_MSG_PUB.Add_Exc_Msg
2332             (   G_PKG_NAME
2333             ,   'Sales_Order_Type'
2334             );
2335         END IF;
2336 
2337         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2338     end Sales_Order_Type;
2339 ----------------------------------------------------------
2340      FUNCTION item_identifier
2341 ----------------------------------------------------------
2342     (p_item_identifier_type   IN VARCHAR2)
2343     RETURN varchar2
2344     IS
2345     l_item_identifier varchar2(240);
2346     Begin
2347 
2348         SELECT meaning
2349         INTO  l_item_identifier
2350         FROM oe_lookups
2351         WHERE lookup_type = 'ITEM_IDENTIFIER_TYPE'
2352         AND   lookup_code = p_item_identifier_type;
2353 
2354         return l_item_identifier;
2355 
2356     end item_identifier;
2357 ----------------------------------------------------------
2358      FUNCTION Get_Currency_Format
2359 ----------------------------------------------------------
2360     (p_currency_code    IN VARCHAR2,
2361      p_field_length     IN NUMBER,
2362      p_percision        IN NUMBER,
2363      p_min_acct_unit    IN NUMBER)
2364      RETURN VARCHAR2
2365      IS
2366      l_format_mask       VARCHAR2(500);
2367      X_precision         NUMBER := 6;
2368      X_Ext_precision     NUMBER;
2369      X_min_acct_unit     NUMBER;
2370      l_precision_type    VARCHAR2(30);
2371      Begin
2372          -- For the bug #4106882
2373          -- Originally we use to format based on the hardcoded precision
2374          -- , now we have changed to get the precision based on the QP profile
2375          -- else we will hard coded to 6 digits.
2376          -- This new format will affect all the amounts fields on BSA UI.
2377          FND_CURRENCY.Get_Info(p_currency_code, X_precision,
2378                               X_Ext_precision, X_min_acct_unit);
2379          fnd_profile.get('QP_UNIT_PRICE_PRECISION_TYPE', l_precision_type);
2380          IF (l_precision_type = 'EXTENDED') THEN
2381             FND_CURRENCY.Build_Format_Mask(l_format_mask, p_field_length,
2382             X_Ext_precision,X_min_acct_unit, TRUE);
2383          ELSE
2384             FND_CURRENCY.Build_Format_Mask(l_format_mask, p_field_length,
2385             X_precision,X_min_acct_unit, TRUE);
2386          END IF;
2387          RETURN l_format_mask;
2388 
2389      END;
2390 
2391 ----------------------------------------------------------
2392      FUNCTION Get_Opr_Create
2393 ----------------------------------------------------------
2394      RETURN varchar2
2395      IS
2396      BEGIN
2397          RETURN OE_GLOBALS.G_OPR_CREATE;
2398      END;
2399 
2400 ----------------------------------------------------------
2401      FUNCTION Get_Opr_Update
2402 ----------------------------------------------------------
2403      RETURN varchar2
2404      IS
2405      BEGIN
2406          RETURN OE_GLOBALS.G_OPR_UPDATE;
2407      END;
2408 
2409 ----------------------------------------------------------
2410      FUNCTION Get_Opr_Delete
2411 ----------------------------------------------------------
2412      RETURN varchar2
2413      IS
2414      BEGIN
2415          -- hashraf new function for pack J
2416          RETURN OE_GLOBALS.G_OPR_DELETE;
2417      END;
2418 
2419 ----------------------------------------------------------
2420      FUNCTION chk_for_header_release
2421 ----------------------------------------------------------
2422     (p_blanket_number   IN number)
2423     RETURN varchar2
2424     IS
2425     l_return    varchar2(10):= 'FALSE';
2426     l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2427     Begin
2428 
2429         IF l_debug_level  > 0 THEN
2430            oe_debug_pub.add('IN OE_Blanket_Form_Control.chk_for_header_release '||p_blanket_number);
2431         END IF;
2432 
2433         if p_blanket_number is not null then
2434 
2435             begin
2436 
2437                SELECT 'TRUE'
2438                INTO  l_return
2439                FROM oe_order_headers
2440                WHERE blanket_number = p_blanket_number
2441                AND ROWNUM = 1;
2442 
2443             exception
2444 
2445                when no_data_found then
2446 
2447                     SELECT 'TRUE'
2448                     INTO  l_return
2449                     FROM oe_order_lines
2450                     WHERE blanket_number = p_blanket_number
2451                     AND ROWNUM = 1;
2452             end;
2453 
2454         end if;
2455 
2456         IF l_debug_level  > 0 THEN
2457            oe_debug_pub.add('IN OE_Blanket_Form_Control.chk_for_header_release ');
2458         END IF;
2459 
2460         return l_return;
2461 
2462     EXCEPTION
2463 
2464         WHEN NO_DATA_FOUND THEN
2465 
2466             oe_debug_pub.add('IN OE_Blanket_Form_Control.chk_for_header_release WHEN no_data_found');
2467             RETURN l_return;
2468 
2469         WHEN OTHERS THEN
2470 
2471             oe_debug_pub.add('IN OE_Blanket_Form_Control.chk_for_header_release WHEN OTEHRS');
2472             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2473             THEN
2474                 OE_MSG_PUB.Add_Exc_Msg
2475                 (   G_PKG_NAME
2476                 ,   'chk_for_header_release'
2477                 );
2478             END IF;
2479             RETURN l_return;
2480 
2481     end chk_for_header_release;
2482 
2483 ----------------------------------------------------------
2484      FUNCTION chk_for_line_release
2485 ----------------------------------------------------------
2486     (p_blanket_number   IN number,
2487      p_blanket_line_number in number)
2488     RETURN varchar2
2489     IS
2490     l_return    varchar2(10):= 'FLASE';
2491     l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2492     Begin
2493 
2494         IF l_debug_level  > 0 THEN
2495            oe_debug_pub.add(  'IN OE_Blanket_Form_Control.chk_for_line_release '||p_blanket_number);
2496         END IF;
2497 
2498         if p_blanket_number is not null then
2499 
2500                SELECT 'TRUE'
2501                INTO  l_return
2502                FROM oe_order_lines
2503                WHERE blanket_number = p_blanket_number
2504                AND BLANKET_LINE_NUMBER = p_blanket_line_number
2505                AND rownum = 1;
2506 
2507          end if;
2508 
2509         IF l_debug_level  > 0 THEN
2510            oe_debug_pub.add(  'IN OE_Blanket_Form_Control.chk_for_line_release ');
2511         END IF;
2512 
2513         return l_return;
2514 
2515     EXCEPTION
2516 
2517         WHEN NO_DATA_FOUND THEN
2518 
2519             oe_debug_pub.add(  'IN OE_Blanket_Form_Control.chk_for_line_release WHEN no_data_found');
2520             RETURN l_return;
2521 
2522         WHEN OTHERS THEN
2523 
2524             oe_debug_pub.add(  'IN OE_Blanket_Form_Control.chk_for_line_release WHEN OTEHRS');
2525             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2526             THEN
2527                 OE_MSG_PUB.Add_Exc_Msg
2528                 (   G_PKG_NAME
2529                 ,   'chk_for_header_release'
2530                 );
2531             END IF;
2532             RETURN l_return;
2533 
2534     end chk_for_line_release;
2535 
2536 ----------------------------------------------------------
2537     PROCEDURE Set_Include_All_Revisions(p_value IN VARCHAR2)
2538 ----------------------------------------------------------
2539     IS
2540     BEGIN
2541 
2542       G_INCLUDE_ALL_REVISIONS := p_value;
2543 
2544     END Set_Include_All_Revisions;
2545 
2546 ----------------------------------------------------------
2547     FUNCTION INCLUDE_ALL_REVISIONS
2548 ----------------------------------------------------------
2549     RETURN varchar2
2550     IS
2551     BEGIN
2552 
2553       RETURN G_INCLUDE_ALL_REVISIONS;
2554 
2555     END INCLUDE_ALL_REVISIONS;
2556 
2557 ----------------------------------------------------------
2558      FUNCTION chk_active_revision
2559 ----------------------------------------------------------
2560     (p_blanket_number   IN number,
2561      p_version_number   IN number)
2562     RETURN varchar2
2563     IS
2564     l_return    varchar2(10):= 'FLASE';
2565     l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2566     Begin
2567 
2568         IF l_debug_level  > 0 THEN
2569            oe_debug_pub.add(  'IN OE_Blanket_Form_Control.chk_active_revision '||p_blanket_number);
2570         END IF;
2571 
2572         if p_blanket_number is not null then
2573 
2574                SELECT 'TRUE'
2575                INTO  l_return
2576                FROM  oe_blanket_headers_all
2577                WHERE order_number     = p_blanket_number
2578                AND   version_number   = p_version_number
2579                AND   rownum           = 1;
2580 
2581          end if;
2582 
2583         IF l_debug_level  > 0 THEN
2584            oe_debug_pub.add(  'IN OE_Blanket_Form_Control.chk_active_revision ');
2585         END IF;
2586 
2587         return l_return;
2588 
2589     EXCEPTION
2590 
2591         WHEN NO_DATA_FOUND THEN
2592 
2593             oe_debug_pub.add('IN OE_Blanket_Form_Control.chk_active_revision WHEN no_data_found');
2594             RETURN l_return;
2595 
2596         WHEN OTHERS THEN
2597 
2598             oe_debug_pub.add('IN OE_Blanket_Form_Control.chk_active_revision WHEN OTEHRS');
2599             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2600             THEN
2601                 OE_MSG_PUB.Add_Exc_Msg
2602                 (   G_PKG_NAME
2603                 ,   'chk_active_revision'
2604                 );
2605             END IF;
2606             RETURN l_return;
2607 
2608     end chk_active_revision;
2609 
2610 -- This procedure will be called from the client when the user
2611 -- clears a record
2612 Procedure Clear_Record
2613 ( x_return_status OUT NOCOPY VARCHAR2
2614 , x_msg_count OUT NOCOPY NUMBER
2615 , x_msg_data OUT NOCOPY VARCHAR2
2616 ,   block_name                     IN  VARCHAR2
2617 )
2618 IS
2619 l_return_status                     Varchar2(30);
2620 BEGIN
2621 -- hashraf ... start of pack J
2622      OE_MSG_PUB.initialize;
2623  	x_return_status := FND_API.G_RET_STS_SUCCESS;
2624 
2625 -- Clear the controller cache
2626 --	Clear_Header;
2627 
2628      if block_name in ('BLANKET_HEADER') then
2629 
2630        g_header_cache_rec.delete;
2631 
2632      elsif block_name in ('BLANKET_LINE') then
2633        g_line_cache_rec.delete;
2634 
2635      end if;
2636 
2637 EXCEPTION
2638     WHEN OTHERS THEN
2639         IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2640         THEN
2641             OE_MSG_PUB.Add_Exc_Msg
2642             (   G_PKG_NAME
2643             ,   'Clear_Record'
2644             );
2645         END IF;
2646         --  Get message count and data
2647         OE_MSG_PUB.Count_And_Get
2648         (   p_count                       => x_msg_count
2649         ,   p_data                        => x_msg_data
2650         );
2651         x_return_status := FND_API.G_RET_STS_ERROR;
2652 
2653 END Clear_Record;
2654 
2655 ----------------------------------------------------------
2656      FUNCTION get_trxt_phase_from_order_type
2657 ----------------------------------------------------------
2658     (p_order_type_id   IN number)
2659     RETURN varchar2
2660     IS
2661     l_return    varchar2(10);
2662     l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
2663     Begin
2664 
2665         IF l_debug_level  > 0 THEN
2666            oe_debug_pub.add('IN OE_Blanket_Form_Control.get_trxt_phase_from_order_type '||p_order_type_id);
2667         END IF;
2668 
2669         if p_order_type_id is not null then
2670 
2671             begin
2672 
2673                SELECT DEF_TRANSACTION_PHASE_CODE
2674                INTO  l_return
2675                FROM oe_transaction_types_all
2676                WHERE TRANSACTION_TYPE_ID = p_order_type_id;
2677             EXCEPTION
2678 
2679                WHEN NO_DATA_FOUND THEN
2680                     oe_debug_pub.add('IN OE_Blanket_Form_Control.get_trxt_phas WHEN no_data_found');
2681                     RETURN l_return;
2682             end;
2683 
2684         end if;
2685 
2686         IF l_debug_level  > 0 THEN
2687            oe_debug_pub.add('IN OE_Blanket_Form_Control.get_trxt_phase_from_order_type ');
2688         END IF;
2689 
2690         return l_return;
2691 
2692     EXCEPTION
2693 
2694         WHEN NO_DATA_FOUND THEN
2695 
2696             oe_debug_pub.add('IN OE_Blanket_Form_Control.chk_for_Submit_Draft_flag WHEN no_data_found');
2697             RETURN l_return;
2698 
2699         WHEN OTHERS THEN
2700 
2701             oe_debug_pub.add('IN OE_Blanket_Form_Control.chk_for_header_release WHEN OTEHRS');
2702             IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2703             THEN
2704                 OE_MSG_PUB.Add_Exc_Msg
2705                 (   G_PKG_NAME
2706                 ,   'get_trxt_phase_from_order_type'
2707                 );
2708             END IF;
2709             RETURN l_return;
2710 
2711     end get_trxt_phase_from_order_type;
2712 
2713 END OE_Blanket_Form_Control;