DBA Data[Home] [Help]

PACKAGE BODY: APPS.PO_APPROVED_SUPPLIER_LIST_SV

Source


1 PACKAGE BODY PO_APPROVED_SUPPLIER_LIST_SV AS
2 /* $Header: POXVASLB.pls 120.6 2006/01/18 10:42:55 pthapliy noship $ */
3 
4 -- Read the profile option that enables/disables the debug log
5 g_po_pdoi_write_to_file VARCHAR2(1) := NVL(FND_PROFILE.VALUE('PO_PDOI_WRITE_TO_FILE'),'N');
6 
7 -- <INBOUND LOGISTICS FPJ START>
8 g_pkg_name    CONSTANT VARCHAR2(30) := 'PO_APPROVED_SUPPLIER_LIST_SV';
9 c_log_head    CONSTANT VARCHAR2(50) := 'po.plsql.'|| g_pkg_name || '.';
10 g_fnd_debug VARCHAR2(1) := NVL(FND_PROFILE.VALUE('AFLOG_ENABLED'),'N');
11 -- <INBOUND LOGISTICS FPJ END>
12 
13 /*==================================================================
14   PROCEDURE NAME:  create_po_asl_entries()
15 
16   DESCRIPTION:    This API inserts row into po_approved_supplier_list,
17                   po_asl_attributes,po_asl_documents
18 
19   PARAMETERS: X_interface_header_id, X_interface_line_id -
20                 Sequence number generated from po_headers_interface_s
21                 and po_lines_interface_s.
22               X_item_id, X_vendor_id, X_po_header_id,
23               X_po_line_id,X_document_type
24                 Values of the document that is created from
25                 the PDOI interface tables.
26               X_category_id - Creatgory_id for the Category
27               X_header_processable_flag - Value is N if there was any
28                 error encountered. Set in the procedure
29                 PO_INTERFACE_ERRORS_SV1.handle_interface_errors
30             X_po_interface_error_code - This is the code used to populate interface_type
31             field in po_interface_errors table.
32               p_sourcing_level
33                 This parameter specifies if the Sourcing Rule /ASL should be Global/Local
34                 and if the assignment should be Item or Item Organization.
35 
36 =======================================================================*/
37 
38 PROCEDURE create_po_asl_entries
39 (   x_interface_header_id      IN NUMBER,
40     X_interface_line_id        IN NUMBER,
41     X_item_id                  IN NUMBER,
42     X_category_id              IN NUMBER,
43     X_po_header_id             IN NUMBER,
44     X_po_line_id               IN NUMBER,
45     X_document_type            IN VARCHAR2,
46     x_vendor_site_id           IN NUMBER,        --  GA FPI
47     X_rel_gen_method           IN VARCHAR2,
48     x_asl_org_id               IN NUMBER,
49     X_header_processable_flag  OUT NOCOPY VARCHAR2,
50     X_po_interface_error_code  IN VARCHAR2,
51     --<LOCAL SR/ASL PROJECT 11i11 START>
52     p_sourcing_level           IN VARCHAR2  DEFAULT NULL
53     --<LOCAL SR/ASL PROJECT 11i11 END>
54     )
55 --
56 IS
57 --
58     x_last_update_date          date := sysdate;
59     x_last_updated_by           number := fnd_global.user_id ;
60     x_creation_date             date := sysdate;
61     x_effective_date            date ;
62     x_disable_date              date;
63     x_last_update_login         number := fnd_global.user_id;
64     x_created_by                number := fnd_global.user_id;
65 --
66     x_record_unique             BOOLEAN;
67     x_asl_id                    number := null;
68     x_owning_organization_id    number := null;
69     x_vs_org_id                 number := null;
70     x_vendor_product_num        VARCHAR2(30);
71     x_progress                  VARCHAR2(3);
72 --
73     x_asl_status_id             number := null;
74     x_sequence_num              number := 1;
75     x_purch_uom                 varchar2(25) := null;
76     x_att_puom                  varchar2(25) := null;
77     x_dummy_count               number := null;
78     X_process_flag              varchar2(1) := 'Y';
79 --
80     X_vendor_id                 number;
81     x_type_lookup_code          varchar2(20);
82     l_rel_gen_method            varchar2(25);
83 
84     x_purchasing_flag           varchar2(1) := 'Y';
85     x_osp_flag           varchar2(1) := 'Y';
86 --
87     -- <INBOUND LOGISTICS FPJ START>
88     l_api_version      CONSTANT NUMBER := 1.0;
89     l_return_status    VARCHAR2(1);
90     l_msg_count        NUMBER;
91     l_msg_data         FND_NEW_MESSAGES.message_text%TYPE;
92     l_msg_buf          VARCHAR2(2000);
93     l_api_name         CONSTANT VARCHAR2(40) := 'create_po_asl_entries';
94     l_progress         VARCHAR2(3) := '001';
95     -- <INBOUND LOGISTICS FPJ END>
96 
97     --<LOCAL SR/ASL PROJECT 11i11 START>
98     l_using_organization_id HR_ORGANIZATION_UNITS.organization_id%type;
99     --<LOCAL SR/ASL PROJECT 11i11 END>
100 
101 BEGIN
102     x_header_processable_flag := 'Y';  -- Bug 2692597
103 
104     -- <ASL ERECORD FPJ>
105     -- Adding a Save Point here. If this procedure has an exception it
106     -- will be rollbacked to this point. We need to do this because Approval WF
107     -- simply ignores the exception and PDOI will treat an exception here as an
108     -- error, but either way the ASL should not be created.
109     SAVEPOINT create_po_asl_entries_SP;
110 
111   /* GA FPI Start */
112   /* check to see if the item is valid in the OU of the vendor_site_id passed in */
113 
114         SELECT org_id
115           INTO x_vs_org_id
116           FROM po_vendor_sites_all
117          WHERE vendor_site_id = x_vendor_site_id;
118 
119         -- Bug 3795146: Handle null org id for a single org instance
120 
121     --<LOCAL SR/ASL PROJECT 11i11 START>
122     /*
123        The value of using organization id for Global ASL's is -1. Set the value of
124        l_using_organization_id to -1 if the sourcing level is 'ITEM'. Else if the
125        Sourcing level is 'ITEM-ORGANIZATION'we need to set the value to x_asl_org_id
126 
127        We need to select the value of inventory organization id only if the value
128        of sourcing_level is  is 'ITEM'. This would happen if the calling program is Approval
129        Workflow or if POASLGEN AND PDOI call the program with Sourcing Level set to Item
130     */
131 
132        IF(nvl(p_sourcing_level,'ITEM')='ITEM-ORGANIZATION') THEN
133           l_using_organization_id :=x_asl_org_id;
134           x_owning_organization_id:=x_asl_org_id;
135        ELSE
136           SELECT inventory_organization_id
137            INTO x_owning_organization_id
138            FROM financials_system_params_all
139           WHERE nvl(org_id,-99) = nvl(x_vs_org_id,-99);
140           l_using_organization_id :=-1;
141        END IF;
142 
143     --<LOCAL SR/ASL PROJECT 11i11 END>
144 
145     IF (g_po_pdoi_write_to_file = 'Y') THEN
146         PO_DEBUG.put_line('Create PO ASL Entry for item: '||x_item_id||
147                           ' vendor site id: '||x_vendor_site_id||
148                           ' inv org: '||x_owning_organization_id);
149     END IF;
150 
151     BEGIN       --< Bug 3560121 > Moved BEGIN for exception handling purposes.
152 
153     --<LOCAL SR/ASL PROJECT 11i11 START>
154     /*
155       If the value of x_asl_org_id is not null then we need to verify that
156       the item for which ASL needs to be created is enabled in the inventory
157       organization x_asl_org_id
158     */
159      IF (po_ga_pvt.is_global_agreement(X_po_header_id)or (x_asl_org_id is not null)) THEN    -- Bug 2737193
160     --<LOCAL SR/ASL PROJECT 11i11 END>
161 
162         SELECT purchasing_enabled_flag,
163                outside_operation_flag
164           INTO x_purchasing_flag,
165                x_osp_flag
166           FROM mtl_system_items
167          WHERE inventory_item_id = x_item_id
168            AND organization_id = x_owning_organization_id;
169 
170         --<Shared Proc FPJ>
171         --Introducing the NVL around purchasing org
172         IF nvl(x_purchasing_flag, 'N') = 'N' OR x_osp_flag = 'Y'  THEN
173             --< Bug 3560121 Start >
174             IF (g_po_pdoi_write_to_file = 'Y') THEN
175                 PO_DEBUG.put_line('Cannot create ASL entry. Purchasable: '
176                                   ||x_purchasing_flag||' OSP item: '
177                                   ||x_osp_flag||'. Insert warning msg');
178             END IF;
179             PO_INTERFACE_ERRORS_SV1.handle_interface_errors
180                 ( x_interface_type          => 'PO_DOCS_OPEN_INTERFACE'
181                 , x_error_type              => 'WARNING'
182                 , x_batch_id                => NULL
183                 , x_interface_header_id     => x_interface_header_id
184                 , x_interface_line_id       => x_interface_line_id
185                 , x_error_message_name      => 'PO_PDOI_CREATE_ASL_INVAL_ITEM'
186                 , x_table_name              => 'PO_LINES_INTERFACE'
187                 , x_column_name             => 'ITEM_ID'
188                 , x_tokenname1              => 'ORG_NAME'
189                 , x_tokenname2              => NULL
190                 , x_tokenname3              => NULL
191                 , x_tokenname4              => NULL
192                 , x_tokenname5              => NULL
193                 , x_tokenname6              => NULL
194                 , x_tokenvalue1             => PO_GA_PVT.get_org_name(p_org_id => x_owning_organization_id)
195                 , x_tokenvalue2             => NULL
196                 , x_tokenvalue3             => NULL
197                 , x_tokenvalue4             => NULL
198                 , x_tokenvalue5             => NULL
199                 , x_tokenvalue6             => NULL
200                 , x_header_processable_flag => x_header_processable_flag
201                 , x_interface_dist_id       => NULL
202                 );
203             -- This is just a warning. Processing should continue, so reset the
204             -- flag back to 'Y' before returning.
205             x_header_processable_flag := 'Y';
206             --< Bug 3560121 End >
207             return;
208         END IF;
209 
210      END IF;
211 
212     EXCEPTION
213         --< Bug 3560121 Start > Should only catch NO_DATA_FOUND here. Also, need
214         -- to insert a warning message in this case.
215         WHEN NO_DATA_FOUND THEN
216             IF (g_po_pdoi_write_to_file = 'Y') THEN
217                 PO_DEBUG.put_line('Cannot create ASL entry; item not defined in inv org. Insert warning msg');
218             END IF;
219             PO_INTERFACE_ERRORS_SV1.handle_interface_errors
220                 ( x_interface_type          => 'PO_DOCS_OPEN_INTERFACE'
221                 , x_error_type              => 'WARNING'
222                 , x_batch_id                => NULL
223                 , x_interface_header_id     => x_interface_header_id
224                 , x_interface_line_id       => x_interface_line_id
225                 , x_error_message_name      => 'PO_PDOI_CREATE_ASL_NO_ITEM'
226                 , x_table_name              => 'PO_LINES_INTERFACE'
227                 , x_column_name             => 'ITEM_ID'
228                 , x_tokenname1              => 'ORG_NAME'
229                 , x_tokenname2              => NULL
230                 , x_tokenname3              => NULL
231                 , x_tokenname4              => NULL
232                 , x_tokenname5              => NULL
233                 , x_tokenname6              => NULL
234                 , x_tokenvalue1             => PO_GA_PVT.get_org_name(p_org_id => x_owning_organization_id)
235                 , x_tokenvalue2             => NULL
236                 , x_tokenvalue3             => NULL
237                 , x_tokenvalue4             => NULL
238                 , x_tokenvalue5             => NULL
239                 , x_tokenvalue6             => NULL
240                 , x_header_processable_flag => x_header_processable_flag
241                 , x_interface_dist_id       => NULL
242                 );
243             -- This is just a warning. Processing should continue, so reset the
244             -- flag back to 'Y' before returning.
245             x_header_processable_flag := 'Y';
246             return;
247         --< Bug 3560121 End >
248     END;
249  /* GA FPI End */
250 
251   -- check to see if default asl status is available
252   -- Get the default status from po_asl_statuses.  If no default status has
253   -- been selected, insert error message and terminate transaction.
254   BEGIN
255   --
256     SELECT status_id
257       INTO x_asl_status_id
258       FROM po_asl_statuses
259      WHERE asl_default_flag = 'Y';
260   --
261     EXCEPTION
262     WHEN NO_DATA_FOUND THEN
263       IF (g_po_pdoi_write_to_file = 'Y') THEN
264          PO_DEBUG.put_line('** ERROR: Please specify a default status in the ASL');
265          PO_DEBUG.put_line('** Statuses form before proceeding with this.');
266       END IF;
267       X_process_flag := 'N';
268       po_interface_errors_sv1.handle_interface_errors(
269                                  X_po_interface_error_code,
270                                  'FATAL',
271                                  null,
272                                  X_interface_header_id,
273                                  X_interface_line_id,
274                                  'PO_PDOI_NO_ASL_STATUS',
275                                  'PO_HEADERS_INTERFACE',
276                                  'APPROVAL_STATUS',
277                                  null, null,null,null,null,null,
278                                  null, null,null, null,null,null,
279                                  X_header_processable_flag);
280 
281   END;
282   --
283   -- Get Vendor_id and Vendor_site_id from Blanket
284   --
285 
286   /*
287       We would have to replace the views po_headers with table
288       po_headers_all because the concurrent program POASLGEN can
289       access global agreements from OU's which are merely Purchasing Org's
290       for the GA and not necessarily Owning Orgs
291   */
292 
293   SELECT vendor_id,
294          type_lookup_code
295     INTO x_vendor_id,
296          x_type_lookup_code
297     FROM po_headers_all  --<LOCAL SR/ASL PROJECT 11i11>
298    WHERE po_header_id = X_po_header_id;
299 
300    --
301   -- Get the Purchasing UOM from P.O.
302   --
303 
304   /*
305       We would have to replace the views po_headers with table
306       po_headers_all because the concurrent program POASLGEN can
307       access global agreements from OU's which are merely Purchasing Org's
308       for the GA and not necessarily Owning Orgs
309   */
310 
311      SELECT pol.unit_meas_lookup_code,
312             pol.vendor_product_num
313        INTO x_purch_uom,
314             x_vendor_product_num
315        FROM po_lines_all pol  --<LOCAL SR/ASL PROJECT 11i11>
316       WHERE po_line_id = x_po_line_id;
317   --
318   --
319   -- Check if ASL already exists for this combination.
320   --
321   --<LOCAL SR/ASL PROJECT 11i11 START>
322   /*
323     Depending on the value of sourcing level we would have to pass
324     in the value of inventory_organization_id appropriately to check
325     for uniqueness of asl record
326   */
327 
328   IF nvl(p_sourcing_level,'ITEM')='ITEM' THEN
329   x_record_unique := po_asl_sv.check_record_unique(
330                                NULL,
331                                x_vendor_id,
332                                x_vendor_site_id,
333                                x_item_id,
334                                NULL,
335                                -1);
336   ELSE
337   x_record_unique := po_asl_sv.check_record_unique(
338                                NULL,
339                                x_vendor_id,
340                                x_vendor_site_id,
341                                x_item_id,
342                                NULL,
343                                x_owning_organization_id);
344 
345   END IF;
346   --<LOCAL SR/ASL PROJECT 11i11 END>
347   --
348   IF x_record_unique THEN
349 
350      SELECT PO_APPROVED_SUPPLIER_LIST_S.NEXTVAL
351        INTO x_asl_id
352        FROM SYS.DUAL;
353 
354      IF (g_po_pdoi_write_to_file = 'Y') THEN
355         PO_DEBUG.put_line('Creating Record in Po approved Supplier List');
356      END IF;
357   --
358      INSERT INTO PO_APPROVED_SUPPLIER_LIST (
359          asl_id                  ,
360          using_organization_id   ,
361          owning_organization_id  ,
365          last_updated_by         ,
362          vendor_business_type    ,
363          asl_status_id           ,
364          last_update_date        ,
366          creation_date           ,
367          created_by              ,
368          vendor_id               ,
369          vendor_site_id          ,
370          item_id                 ,
371          primary_vendor_item     ,
372          last_update_login       ,
373          request_id
374      )  VALUES                    (
375          x_asl_id                  ,
376          l_using_organization_id,  --<LOCAL SR/ASL PROJECT 11i11>
377          x_owning_organization_id  ,
378          'DIRECT'                  ,
379          x_asl_status_id           ,
380          x_last_update_date        ,
381          x_last_updated_by         ,
382          x_creation_date           ,
383          x_created_by              ,
384          x_vendor_id               ,
385          x_vendor_site_id          ,
386          x_item_id                 ,
387          x_vendor_product_num      ,
388          x_last_update_login       ,
389          null
390      );
391 
392      -- <INBOUND LOGISTICS FPJ START>
393      l_progress := '020';
394      l_return_status  := FND_API.G_RET_STS_SUCCESS;
395      IF (g_fnd_debug = 'Y') THEN
396          IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_STATEMENT) THEN
397            FND_LOG.string( LOG_LEVEL => FND_LOG.LEVEL_STATEMENT,
398                          MODULE    => c_log_head || '.'||l_api_name||'.' || l_progress,
399                          MESSAGE   => 'Call PO_BUSINESSEVENT_PVT.raise_event'
400                        );
401          END IF;
402      END IF;
403 
404      PO_BUSINESSEVENT_PVT.raise_event
405      (
406          p_api_version      =>    l_api_version,
407          x_return_status    =>    l_return_status,
408          x_msg_count        =>    l_msg_count,
409          x_msg_data         =>    l_msg_data,
410          p_event_name       =>    'oracle.apps.po.event.create_asl',
411          p_entity_name      =>    'ASL',
412          p_entity_id        =>    x_asl_id
413      );
414 
415      IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
416          IF (g_fnd_debug = 'Y') THEN
417              l_msg_buf := NULL;
418              l_msg_buf := FND_MSG_PUB.Get( p_msg_index => 1,
419                                            p_encoded   => 'F');
420              l_msg_buf := SUBSTR('ASL' || x_asl_id || 'errors out at' || l_progress || l_msg_buf, 1, 2000);
421              IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_UNEXPECTED) THEN
422                FND_LOG.string( LOG_LEVEL => FND_LOG.level_unexpected,
423                              MODULE    => c_log_head || '.'||l_api_name||'.error_exception',
424                              MESSAGE   => l_msg_buf
425                            );
426              END IF;
427          END IF;
428      ELSE
429          IF (g_fnd_debug = 'Y') THEN
430              l_msg_buf := NULL;
431              l_msg_buf := SUBSTR('ASL' || x_asl_id||'raised business event successfully', 1, 2000);
432              IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_STATEMENT) THEN
433                FND_LOG.string( LOG_LEVEL => FND_LOG.level_statement,
434                              MODULE    => c_log_head || '.'||l_api_name,
435                              MESSAGE   => l_msg_buf
436                            );
437              END IF;
438          END IF;
439      END IF;  -- IF (l_return_status <> FND_API.G_RET_STS_SUCCESS)
440 
441      -- <INBOUND LOGISTICS FPJ END>
442 
443      IF (g_po_pdoi_write_to_file = 'Y') THEN
444         PO_DEBUG.put_line('Creating Record in Po Asl Attribbutes ');
445      END IF;
446 
447      -- create global ASL in po_asl_documents
448 
449 
450      INSERT INTO po_asl_attributes(
451          asl_id,
452          using_organization_id,
453          last_update_date,
454          last_updated_by,
455          creation_date,
456          created_by,
457          last_update_login,
458          document_sourcing_method,
459          release_generation_method,
460          enable_plan_schedule_flag,
461          enable_ship_schedule_flag,
462          enable_autoschedule_flag,
463          enable_authorizations_flag,
464          vendor_id,
465          vendor_site_id,
466          purchasing_unit_of_measure,
467          item_id
468      ) VALUES (
469          x_asl_id,
470          l_using_organization_id,  --<LOCAL SR/ASL PROJECT 11i11>
471          x_last_update_date,
472          x_last_updated_by,
473          x_creation_date,
474          x_created_by,
475          x_last_update_login,
476          'ASL',
477          DECODE(X_type_lookup_code, 'BLANKET', X_rel_gen_method, NULL),
478          'N',
479          'N',
480          'N',
481          'N',
482          x_vendor_id,
483          x_vendor_site_id,
484          x_purch_uom,
485          x_item_id);
486     --
487 
488      -- <ASL ERECORD FPJ START>
489      -- bug3236816: Move the code that raises eres event after
490      --             PO ASL Attribute is created
491 
492      PO_ASL_SV.raise_asl_eres_event
493      ( x_return_status => l_return_status,
494        p_asl_id        => x_asl_id,
495        p_action        => PO_ASL_SV.G_EVENT_INSERT,
496        p_calling_from  => 'PO_APPROVED_SUPPLIER_LIST_SV.create_po_asl_entries',
497        p_ackn_note     => NULL,
498        p_autonomous_commit => FND_API.G_FALSE
499      );
500 
501      IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
502          RAISE G_EXC_ERES_ERROR;
503      END IF;
504 
505      -- <ASL ERECORD FPJ END>
506 
507     ELSE  --Record Not Unique
508     -- If supplier-item relation exists, return asl_id for this asl entry.
509     --
510       IF (g_po_pdoi_write_to_file = 'Y') THEN
511          PO_DEBUG.put_line('ASL exists for Vndr' || to_char(x_vendor_id));
512          PO_DEBUG.put_line('ASL exists for VndrSite' || to_char(x_vendor_site_id));
513          PO_DEBUG.put_line('ASL already exists for Item' || to_char(x_item_id));
514       END IF;
515     --
516       /* BUG No.1541387:For the case when the sourcing rule is purged and the
517                         corresponding ASL consists of no supplier_site_code -
518                         making the provision for vendor_site_id and
519                         x_vendor_site_id to be null without an error.
520        */
521 
522       x_progress := '050';
523 
524 
525       SELECT asl_id
526         INTO x_asl_id
527         FROM po_approved_supplier_list pasl
528        WHERE pasl.vendor_id = x_vendor_id
529          AND (    pasl.vendor_site_id = x_vendor_site_id
530                OR (    pasl.vendor_site_id is NULL
531                    AND x_vendor_site_id is NULL))
532          AND pasl.item_id = x_item_id
533          AND using_organization_id = l_using_organization_id;  --<LOCAL SR/ASL PROJECT 11i11>
534 
535 
536    /*
537       Bug 2361161 If the ASL entry exists then we update the attributes with the release generation method
538       passed from the approval window. if the Purchasing UOM has not been entered update that with the value
539       from the po line
540    */
541 
542        select purchasing_unit_of_measure,
543               release_generation_method
544        into x_att_puom,
545             l_rel_gen_method
546        from po_asl_attributes
547        where asl_id = x_asl_id
548        and using_organization_id =l_using_organization_id --<LOCAL SR/ASL PROJECT 11i11>
549        and vendor_id = x_vendor_id
550        and vendor_site_id = x_vendor_site_id
551        and item_id = x_item_id;
552 
553       if x_att_puom is null then
554          x_att_puom := x_purch_uom;
555       end if;
556 
557       /* Bug 2438375 fix by davidng. Added the constraint "l_rel_gen_method is null"
558          Hence we are only updating the Release Generation Method if it is originally null */
559       if (X_type_lookup_code = 'BLANKET' and X_rel_gen_method is not null and l_rel_gen_method is null) then
560          l_rel_gen_method := X_rel_gen_method;
561       end if;
562 
563 
564       UPDATE po_asl_attributes
565       set release_generation_method =  l_rel_gen_method,
566           purchasing_unit_of_measure = x_att_puom,
567           last_update_date = x_last_update_date,
568           last_updated_by = x_last_updated_by,
569           last_update_login = last_update_login
570       where asl_id = x_asl_id
571        and using_organization_id =l_using_organization_id --<LOCAL SR/ASL PROJECT 11i11>
572        and vendor_id = x_vendor_id
573        and vendor_site_id = x_vendor_site_id
574        and item_id = x_item_id;
575 
576    END IF;
577 
578    -- Make sure that this source document does not already exist for
579    -- this ASL entry.
580    x_progress := '020';
581    SELECT count(*)
582      INTO x_dummy_count
583      FROM po_asl_documents
584     WHERE asl_id = x_asl_id
585       AND using_organization_id = l_using_organization_id --<LOCAL SR/ASL PROJECT 11i11>
586       AND document_header_id = x_po_header_id
587       AND document_type_code = x_type_lookup_code;
588 
589    IF x_dummy_count > 0 THEN
590       IF (g_po_pdoi_write_to_file = 'Y') THEN
591          PO_DEBUG.put_line('Doc already exists for this ASL');
592       END IF;
593       null;
594    ELSE
595    --
596       SELECT nvl(max(sequence_num)+1, 1)
597         INTO x_sequence_num
598         FROM po_asl_documents
599        WHERE asl_id = x_asl_id
600          AND using_organization_id = l_using_organization_id;  --<LOCAL SR/ASL PROJECT 11i11>
601       --
602       IF (g_po_pdoi_write_to_file = 'Y') THEN
603          PO_DEBUG.put_line('Creating record in Po Asl Docs');
604       END IF;
605       --
606       -- Insert doc into po_asl_documents
607       --
608 
609       INSERT INTO PO_ASL_DOCUMENTS(
610           asl_id,
611           using_organization_id,
612           sequence_num,
613           document_type_code,
614           document_header_id,
615           document_line_id,
616           last_update_date,
617           last_updated_by,
618           last_update_login,
619           creation_date,
620           created_by
621       ) VALUES (
622           x_asl_id,
623           l_using_organization_id,  --<LOCAL SR/ASL PROJECT 11i11>
624           x_sequence_num,
625           x_type_lookup_code,
626           x_po_header_id,
627           x_po_line_id,
628           x_last_update_date,
629           x_last_updated_by,
630           x_last_update_login,
631           x_creation_date,
632           x_created_by
633       );
634 
635     END IF;
636 
637 --  END IF;
638 
639   EXCEPTION
640   WHEN others THEN
641       ROLLBACK TO create_po_asl_entries_SP;  -- <ASL ERECORD FPJ>
642       x_header_processable_flag := 'N';  -- Bug 2692597
643       --< Bug 3560121 Start >
644       IF (g_po_pdoi_write_to_file = 'Y') THEN
645           PO_DEBUG.put_line('Exception caught while creating ASL entries.');
646       END IF;
647       --< Bug 3560121 End >
648       po_message_s.sql_error('create_po_asl_entries', x_progress, sqlcode);
649       raise;
650 END create_po_asl_entries;
651 
652 END PO_APPROVED_SUPPLIER_LIST_SV;