DBA Data[Home] [Help]

PACKAGE BODY: APPS.IBY_BUILD_INSTRUCTIONS_PUB_PKG

Source


1 PACKAGE BODY IBY_BUILD_INSTRUCTIONS_PUB_PKG AS
2 /*$Header: ibypayib.pls 120.49.12010000.1 2008/07/28 05:41:31 appldev ship $*/
3 
4  --
5  -- Declare global variables
6  --
7  G_PKG_NAME CONSTANT VARCHAR2(30) := 'IBY_BUILD_INSTRUCTIONS_PUB_PKG';
8 
9  --
10  -- List of instruction statuses that are used / set in this
11  -- module (payment instruction creation flow).
12  --
13  INS_STATUS_CREATED         CONSTANT VARCHAR2(100) := 'CREATED';
14  INS_STATUS_PRINT_DEFERRED  CONSTANT VARCHAR2(100) := 'PRINTING_DEFERRED';
15  INSTR_STATUS_RETRY_CREAT   CONSTANT VARCHAR2(100) := 'RETRY_CREATION';
16  INSTR_STATUS_CREAT_ERROR   CONSTANT VARCHAR2(100) := 'CREATION_ERROR';
17  INS_STATUS_READY_TO_PRINT  CONSTANT VARCHAR2(100) :=
18                                          'CREATED_READY_FOR_PRINTING';
19  INS_STATUS_READY_TO_FORMAT CONSTANT VARCHAR2(100) :=
20                                          'CREATED_READY_FOR_FORMATTING';
21 
22 /*--------------------------------------------------------------------
23  | NAME:
24  |     build_pmt_instructions
25  |
26  | PURPOSE:
27  |     This is the top level procedure of the payment instruction
28  |     creation program; This procedure will run as a concurrent program.
29  |
30  | PARAMETERS:
31  |     IN
32  |
33  |     p_calling_app_id
34  |         The 3-character product code of the calling application
35  |
36  |     p_calling_app_payreq_cd
37  |         Id of the payment service request from the calling app's
38  |         point of view. For a given calling app, this id should be
39  |         unique; the build program will communicate back to the calling
40  |         app using this payment request id.
41  |
42  |     p_internal_bank_account_id
43  |         The internal bank account to pay from.
44  |
45  |     p_payment_profile_id
46  |         Payment profile
47  |
48  |     p_allow_zero_payments_flag
49  |         'Y' / 'N' flag indicating whether zero value payments are allowed.
50  |         If not set, this value will be defaulted to 'Y'.
51  |
52  |     p_payment_date
53  |         The payment date.
54  |
55  |     p_anticipated_value_date
56  |         The anticipated value date.
57  |
58  |     p_args10 - p_args100
59  |         These 91 parameters are mandatory for any stored procedure
60  |         that is submitted from Oracle Forms as a concurrent request
61  |         (to get the total number of args to the concurrent procedure
62  |         to 100).
63  |
64  |     OUT
65  |
66  |     x_errbuf
67  |     x_retcode
68  |
69  |         These two are mandatory output paramaters for a concurrent
70  |         program. They will store the error message and error code
71  |         to indicate a successful/failed run of the concurrent request.
72  |
73  | RETURNS:
74  |
75  | NOTES:
76  |
77  *---------------------------------------------------------------------*/
78  PROCEDURE build_pmt_instructions(
79      x_errbuf                     OUT NOCOPY VARCHAR2,
80      x_retcode                    OUT NOCOPY VARCHAR2,
81 
82      /*-- processing criteria --*/
83      p_processing_type            IN         VARCHAR2,
84      p_payment_profile_id         IN         VARCHAR2 DEFAULT NULL,
85      p_pmt_document_id            IN         VARCHAR2 DEFAULT NULL,
86      p_internal_bank_account_id   IN         VARCHAR2 DEFAULT NULL,
87      p_print_now_flag             IN         VARCHAR2 DEFAULT NULL,
88      p_printer_name               IN         VARCHAR2 DEFAULT NULL,
89      p_payment_currency           IN         VARCHAR2 DEFAULT NULL,
90      p_transmit_now_flag          IN         VARCHAR2 DEFAULT NULL,
91 
92      /*-- user/admin assigned criteria --*/
93      p_admin_assigned_ref         IN         VARCHAR2 DEFAULT NULL,
94      p_comments                   IN         VARCHAR2 DEFAULT NULL,
95 
96      /*-- selection criteria --*/
97      p_calling_app_id             IN         VARCHAR2 DEFAULT NULL,
98      p_calling_app_payreq_cd      IN         VARCHAR2 DEFAULT NULL,
99      p_le_id                      IN         VARCHAR2 DEFAULT NULL,
100      p_org_id                     IN         VARCHAR2 DEFAULT NULL,
101      p_org_type                   IN         VARCHAR2 DEFAULT NULL,
102      p_payment_from_date          IN         VARCHAR2 DEFAULT NULL,
103      p_payment_to_date            IN         VARCHAR2 DEFAULT NULL,
104 
105      p_arg19  IN VARCHAR2 DEFAULT NULL,
106      p_arg20  IN VARCHAR2 DEFAULT NULL, p_arg21  IN VARCHAR2 DEFAULT NULL,
107      p_arg22  IN VARCHAR2 DEFAULT NULL, p_arg23  IN VARCHAR2 DEFAULT NULL,
108      p_arg24  IN VARCHAR2 DEFAULT NULL, p_arg25  IN VARCHAR2 DEFAULT NULL,
109      p_arg26  IN VARCHAR2 DEFAULT NULL, p_arg27  IN VARCHAR2 DEFAULT NULL,
110      p_arg28  IN VARCHAR2 DEFAULT NULL, p_arg29  IN VARCHAR2 DEFAULT NULL,
111      p_arg30  IN VARCHAR2 DEFAULT NULL, p_arg31  IN VARCHAR2 DEFAULT NULL,
112      p_arg32  IN VARCHAR2 DEFAULT NULL, p_arg33  IN VARCHAR2 DEFAULT NULL,
113      p_arg34  IN VARCHAR2 DEFAULT NULL, p_arg35  IN VARCHAR2 DEFAULT NULL,
114      p_arg36  IN VARCHAR2 DEFAULT NULL, p_arg37  IN VARCHAR2 DEFAULT NULL,
115      p_arg38  IN VARCHAR2 DEFAULT NULL, p_arg39  IN VARCHAR2 DEFAULT NULL,
116      p_arg40  IN VARCHAR2 DEFAULT NULL, p_arg41  IN VARCHAR2 DEFAULT NULL,
117      p_arg42  IN VARCHAR2 DEFAULT NULL, p_arg43  IN VARCHAR2 DEFAULT NULL,
118      p_arg44  IN VARCHAR2 DEFAULT NULL, p_arg45  IN VARCHAR2 DEFAULT NULL,
119      p_arg46  IN VARCHAR2 DEFAULT NULL, p_arg47  IN VARCHAR2 DEFAULT NULL,
120      p_arg48  IN VARCHAR2 DEFAULT NULL, p_arg49  IN VARCHAR2 DEFAULT NULL,
121      p_arg50  IN VARCHAR2 DEFAULT NULL, p_arg51  IN VARCHAR2 DEFAULT NULL,
122      p_arg52  IN VARCHAR2 DEFAULT NULL, p_arg53  IN VARCHAR2 DEFAULT NULL,
123      p_arg54  IN VARCHAR2 DEFAULT NULL, p_arg55  IN VARCHAR2 DEFAULT NULL,
124      p_arg56  IN VARCHAR2 DEFAULT NULL, p_arg57  IN VARCHAR2 DEFAULT NULL,
125      p_arg58  IN VARCHAR2 DEFAULT NULL, p_arg59  IN VARCHAR2 DEFAULT NULL,
126      p_arg60  IN VARCHAR2 DEFAULT NULL, p_arg61  IN VARCHAR2 DEFAULT NULL,
127      p_arg62  IN VARCHAR2 DEFAULT NULL, p_arg63  IN VARCHAR2 DEFAULT NULL,
128      p_arg64  IN VARCHAR2 DEFAULT NULL, p_arg65  IN VARCHAR2 DEFAULT NULL,
129      p_arg66  IN VARCHAR2 DEFAULT NULL, p_arg67  IN VARCHAR2 DEFAULT NULL,
130      p_arg68  IN VARCHAR2 DEFAULT NULL, p_arg69  IN VARCHAR2 DEFAULT NULL,
131      p_arg70  IN VARCHAR2 DEFAULT NULL, p_arg71  IN VARCHAR2 DEFAULT NULL,
132      p_arg72  IN VARCHAR2 DEFAULT NULL, p_arg73  IN VARCHAR2 DEFAULT NULL,
133      p_arg74  IN VARCHAR2 DEFAULT NULL, p_arg75  IN VARCHAR2 DEFAULT NULL,
134      p_arg76  IN VARCHAR2 DEFAULT NULL, p_arg77  IN VARCHAR2 DEFAULT NULL,
135      p_arg78  IN VARCHAR2 DEFAULT NULL, p_arg79  IN VARCHAR2 DEFAULT NULL,
136      p_arg80  IN VARCHAR2 DEFAULT NULL, p_arg81  IN VARCHAR2 DEFAULT NULL,
137      p_arg82  IN VARCHAR2 DEFAULT NULL, p_arg83  IN VARCHAR2 DEFAULT NULL,
138      p_arg84  IN VARCHAR2 DEFAULT NULL, p_arg85  IN VARCHAR2 DEFAULT NULL,
139      p_arg86  IN VARCHAR2 DEFAULT NULL, p_arg87  IN VARCHAR2 DEFAULT NULL,
140      p_arg88  IN VARCHAR2 DEFAULT NULL, p_arg89  IN VARCHAR2 DEFAULT NULL,
141      p_arg90  IN VARCHAR2 DEFAULT NULL, p_arg91  IN VARCHAR2 DEFAULT NULL,
142      p_arg92  IN VARCHAR2 DEFAULT NULL, p_arg93  IN VARCHAR2 DEFAULT NULL,
143      p_arg94  IN VARCHAR2 DEFAULT NULL, p_arg95  IN VARCHAR2 DEFAULT NULL,
144      p_arg96  IN VARCHAR2 DEFAULT NULL, p_arg97  IN VARCHAR2 DEFAULT NULL,
145      p_arg98  IN VARCHAR2 DEFAULT NULL, p_arg99  IN VARCHAR2 DEFAULT NULL,
146      p_arg100 IN VARCHAR2 DEFAULT NULL
147      )
148  IS
149 
150  l_return_status  VARCHAR2 (100);
151  l_return_message VARCHAR2 (3000);
152 
153  l_msg_count      NUMBER;
154  l_msg_data       VARCHAR2(4000);
155 
156  /* hook related params */
157  l_pkg_name       VARCHAR2(200);
158  l_callout_name   VARCHAR2(500);
159  l_stmt           VARCHAR2(1000);
160  l_ret_status     VARCHAR2(300);
161  l_error_code     VARCHAR2(3000);
162  l_api_version    CONSTANT NUMBER := 1.0;
163 
164  l_payreq_id      IBY_PAY_SERVICE_REQUESTS.payment_service_request_id%TYPE;
165  l_module_name    VARCHAR2(200) := G_PKG_NAME || '.build_payment_instructions';
166  l_not_provided   CONSTANT VARCHAR2(100) := '<not provided>';
167 
168  l_pmtInstrTab    IBY_PAYINSTR_PUB.pmtInstrTabType;
169 
170  /*
171   * Implementing the callout is optional for the calling app.
172   * If the calling app does not implement the hook, then
173   * the call to the hook will result in ORA-06576 error.
174   *
175   * There is no exception name associated with this code, so
176   * we create one called 'PROCEDURE_NOT_IMPLEMENTED'. If this
177   * exception occurs, it is not fatal: we log the error and
178   * proceed.
179   *
180   * If, on the other hand, the calling app implements the
181   * callout, but the callout throws an exception, it is fatal
182   * and we must abort the program (this will be caught
183   * in WHEN OTHERS block).
184   */
185  PROCEDURE_NOT_IMPLEMENTED EXCEPTION;
186  PRAGMA EXCEPTION_INIT(PROCEDURE_NOT_IMPLEMENTED, -6576);
187 
188  BEGIN
189 
190      print_debuginfo(l_module_name, 'ENTER');
191 
192      SAVEPOINT BEGIN_PMT_INST_PROCESSING;
193 
194      print_debuginfo(l_module_name, '+--------------------------------------+');
195      print_debuginfo(l_module_name, '|STEP 1: Create Payment Instructions   |');
196      print_debuginfo(l_module_name, '+--------------------------------------+');
197 
198      /*
199       * F8 - Payment Instruction Creation Flow (Part I)
200       *
201       * Find all payments that are in 'created' status
202       * and create payment instructions from such payments.
203       */
204 
205      BEGIN
206 
207          print_debuginfo(l_module_name, 'Provided selection criteria - ');
208 
209          print_debuginfo(l_module_name, 'p_processing_type: '
210              || NVL(p_processing_type,           l_not_provided));
211          print_debuginfo(l_module_name, 'p_payment_profile_id: '
212              || NVL(p_payment_profile_id,        l_not_provided));
213          print_debuginfo(l_module_name, 'p_pmt_document_id: '
214              || NVL(p_pmt_document_id,           l_not_provided));
215          print_debuginfo(l_module_name, 'p_internal_bank_account_id: '
216              || NVL(p_internal_bank_account_id,  l_not_provided));
217          print_debuginfo(l_module_name, 'p_print_now_flag: '
218              || NVL(p_print_now_flag,            l_not_provided));
219          print_debuginfo(l_module_name, 'p_printer_name: '
220              || NVL(p_printer_name,              l_not_provided));
221          print_debuginfo(l_module_name, 'p_payment_currency: '
222              || NVL(p_payment_currency,          l_not_provided));
223          print_debuginfo(l_module_name, 'p_transmit_now_flag: '
224              || NVL(p_transmit_now_flag,         l_not_provided));
225          print_debuginfo(l_module_name, 'p_admin_assigned_ref: '
226              || NVL(p_admin_assigned_ref,        l_not_provided));
227          print_debuginfo(l_module_name, 'p_comments: '
228              || NVL(p_comments,                  l_not_provided));
229          print_debuginfo(l_module_name, 'p_calling_app_id: '
230              || NVL(p_calling_app_id,            l_not_provided));
231          print_debuginfo(l_module_name, 'p_calling_app_payreq_cd: '
232              || NVL(p_calling_app_payreq_cd,     l_not_provided));
233          print_debuginfo(l_module_name, 'p_le_id: '
234              || NVL(p_le_id,                     l_not_provided));
235          print_debuginfo(l_module_name, 'p_org_id: '
236              || NVL(p_org_id,                    l_not_provided));
237          print_debuginfo(l_module_name, 'p_org_type: '
238              || NVL(p_org_type,                  l_not_provided));
239          print_debuginfo(l_module_name, 'p_payment_from_date: '
240              || NVL(p_payment_from_date,         l_not_provided));
241          print_debuginfo(l_module_name, 'p_payment_to_date: '
242              || NVL(p_payment_to_date,           l_not_provided));
243 
244          IF (p_calling_app_payreq_cd IS NOT NULL) THEN
245 
246              IF (p_calling_app_id IS NULL) THEN
247 
248                  print_debuginfo(l_module_name, 'Invalid selection '
249                      || 'criteria provided; calling app payment '
250                      || 'service request id has been provided but '
251                      || 'calling app id has not been provided.'
252                      || 'For selection by payment service request, '
253                      || 'the calling app id needs to be provided.'
254                      );
255 
256                  print_debuginfo(l_module_name, 'Payment instruction '
257                      || 'creation will not proceed.'
258                      );
259 
260                  x_errbuf := 'PAY INSTRUCTION PROGRAM ERROR - INVALID '
261                       || 'SELECTION CRITERIA PROVIDED';
262                  x_retcode := '-1';
263 
264                  print_debuginfo(l_module_name, 'EXIT');
265 
266                  RETURN;
267 
268              END IF;
269 
270              l_payreq_id := get_payreq_id(p_calling_app_id,
271                                 p_calling_app_payreq_cd);
272 
273          END IF;
274 
275          print_debuginfo(l_module_name, 'Invoking createPaymentInstructions()');
276 
277          /*
278           * Invoke payment instruction creation logic.
279           */
280          IBY_PAYINSTR_PUB.createPaymentInstructions(
281              p_processing_type,
282              p_pmt_document_id,
283              p_printer_name,
284              p_print_now_flag,
285              p_transmit_now_flag,
286              p_admin_assigned_ref,
287              p_comments,
288              p_payment_profile_id,
289              TO_NUMBER(p_calling_app_id),
290              p_calling_app_payreq_cd,
291              l_payreq_id,
292              TO_NUMBER(p_internal_bank_account_id),
293              p_payment_currency,
294              TO_NUMBER(p_le_id),
295              TO_NUMBER(p_org_id),
296              p_org_type,
297 
298              /*
299               * Fix for bug 5129717:
300               *
301               * Provide the appropriate date pattern to
302               * convert date filter criteria into DATE
303               * datetypes.
304               */
305              TO_DATE(p_payment_from_date, 'YYYY/MM/DD HH24:MI:SS'),
306              TO_DATE(p_payment_to_date,   'YYYY/MM/DD HH24:MI:SS'),
307              'N',                 -- single payments flow flag
308              l_pmtInstrTab,
309              l_return_status,
310              l_msg_count,
311              l_msg_data
312              );
313 
314          print_debuginfo(l_module_name, 'Status after payment '
315              || 'instruction creation: '
316              || l_return_status);
317 
318          /*
319           * If payment instruction creation was completed, then commit.
320           */
321          print_debuginfo(l_module_name, 'Payment instruction '
322              || 'creation completed successfully.');
323 
324          print_debuginfo(l_module_name, 'Performing commit ..');
325          COMMIT;
326 
327      EXCEPTION
328 
329          WHEN OTHERS THEN
330          print_debuginfo(l_module_name, 'Exception occured when '
331              || 'creating payment instructions. Payment instruction '
332              || 'creation will be aborted.'
333              );
334          print_debuginfo(l_module_name, 'SQLCODE: ' || SQLCODE);
335          print_debuginfo(l_module_name, 'SQLERRM: ' || SQLERRM);
336 
337          ROLLBACK TO SAVEPOINT BEGIN_PMT_INST_PROCESSING;
338 
339          x_errbuf := 'PROGRAM ERROR - CANNOT CREATE PAYMENT INSTRUCTIONS';
340          x_retcode := '-1';
341          print_debuginfo(l_module_name, 'EXIT');
342 
343          RETURN;
344 
345      END;
346 
347 
348      /*
349       * If we reached here, it means that the payment instruction
350       * creation program finished successfully. Invoke
351       * check numbering if we are building payment instructions
352       * of processing type 'printed'.
353       */
354      BEGIN
355 
356          IF (p_processing_type = 'PRINTED') THEN
357 
358              IF (l_pmtInstrTab.COUNT > 0) THEN
359 
360                  /*
361                   * Perform check numbering (paper document numbering)
362                   * for the first successful payment instruction. All
363                   * other payment instructions are to be moved to a
364                   * deferred status for later numbering.
365                   *
366                   * This is because the payment document (check stock)
367                   * is locked once it is used to number a payment
368                   * instruction. This lock will only be released after
369                   * the user has confirmed that the checks printed
370                   * correctly. So, there is no point in proceeding
371                   * with other payment instructions until the numbered
372                   * instruction has been confirmed by the user.
373                   */
374                  FOR i IN l_pmtInstrTab.FIRST .. l_pmtInstrTab.LAST LOOP
375 
376                      /*
377                       * Number only successful payment
378                       * instructions.
379                       */
380                      IF (l_pmtInstrTab(i).payment_instruction_status =
381                              INS_STATUS_CREATED) THEN
382 
383                          print_debuginfo(l_module_name, 'Invoking '
384                              || 'numbering for payment '
385                              || 'instruction '
386                              || l_pmtInstrTab(i).payment_instruction_id
387                              || ' with instruction status: '
388                              || l_pmtInstrTab(i).payment_instruction_status
389                              );
390 
391                          /*
392                           * Invoke check numbering for this payment
393                           * instruction.
394                           */
395                          IBY_CHECKNUMBER_PUB.performCheckNumbering(
396                              l_pmtInstrTab(i).payment_instruction_id,
397                              p_pmt_document_id,
398                              NULL,
399                              l_return_status,
400                              l_return_message,
401                              l_msg_count,
402                              l_msg_data
403                              );
404 
405                          print_debuginfo(l_module_name, 'After numbering, '
406                              || 'return status: '
407                              || l_return_status
408                              || ', and return message: '
409                              || l_return_message
410                              );
411 
412                          IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
413 
414                              print_debuginfo(l_module_name, 'Check '
415                                  || 'numbering module returned failure '
416                                  || 'response. Aborting.. ',
417                                  FND_LOG.LEVEL_UNEXPECTED
418                                  );
419 
420                              APP_EXCEPTION.RAISE_EXCEPTION;
421 
422                          END IF;
423 
424                          /*
425                           * The first successful payment instruction has now
426                           * been numbered.
427                           *
428                           * Invoke the set of post-payment instruction
429                           * creation programs that are responsible for
430                           * extracting, formatting and printing the
431                           * payment instruction data.
432                           */
433                          BEGIN
434 
435                              print_debuginfo(l_module_name, 'Invoking '
436                                  || 'extract and format programs for '
437                                  || 'instruction '
438                                  || l_pmtInstrTab(i).payment_instruction_id
439                                  );
440 
441                              IBY_FD_POST_PICP_PROGS_PVT.
442                                  Run_Post_PI_Programs(
443                                      l_pmtInstrTab(i).payment_instruction_id,
444                                      'N'
445                                      );
446 
447                              print_debuginfo(l_module_name, 'Extract '
448                                  || 'and format operation completed.'
449                                  );
450 
451                          EXCEPTION
452                              WHEN OTHERS THEN
453 
454                              print_debuginfo(l_module_name, 'Extract and '
455                                  || 'format operation generated '
456                                  || 'exception for payment instruction '
457                                  || l_pmtInstrTab(i).payment_instruction_id,
458                                  FND_LOG.LEVEL_UNEXPECTED
459                                  );
460 
461                              print_debuginfo(l_module_name, 'SQL code: '
462                                  || SQLCODE, FND_LOG.LEVEL_UNEXPECTED);
463                              print_debuginfo(l_module_name, 'SQL err msg: '
464                                  || SQLERRM, FND_LOG.LEVEL_UNEXPECTED);
465 
466                              /*
467                               * Propogate exception.
468                               */
469                              RAISE;
470 
471                          END;
472 
473                          /*
474                           * Move all other successful payment instructions
475                           * to deferred status (for later numbering).
476                           */
477                          moveInstrToDeferredStatus(l_pmtInstrTab,
478                              l_pmtInstrTab(i).payment_instruction_id);
479 
480                          /*
481                           * Once we have numbered and formatted the first
482                           * successful payment instruction, exit.
483                           */
484                          EXIT;
485 
486                      ELSE
487 
488                          print_debuginfo(l_module_name, 'Not invoking '
489                              || 'paper document numbering for payment '
490                              || 'instruction '
491                              || l_pmtInstrTab(i).payment_instruction_id
492                              || ', as it is in status '
493                              || l_pmtInstrTab(i).payment_instruction_status
494                              );
495 
496                      END IF;
497 
498                  END LOOP;
499 
500              ELSE
501 
502                  print_debuginfo(l_module_name, 'Instruction count is '
503                      || 'zero. Skipping paper document numbering ..'
504                      );
505 
506              END IF; -- if instruction count > 0
507 
508          ELSE
509 
510              print_debuginfo(l_module_name, 'Processing type is '
511                  || p_processing_type
512                  || '. Numbering of paper documents skipped ..'
513                  );
514 
515              /*
516               * If we reached here, it means the processing type
517               * is electronic.
518               *
519               * For electronic payment instructions, check numbering
520               * not required. Instead, directly call the extracting
521               * and formatting programs.
522               */
523 
524              IF (l_pmtInstrTab.COUNT > 0) THEN
525 
526                  /*
527                   * Loop through all the payment instructions one-by-one.
528                   *
529                   * Invoke extract and format for each successful payment
530                   * instruction.
531                   */
532                  FOR i IN l_pmtInstrTab.FIRST .. l_pmtInstrTab.LAST LOOP
533 
534                      /*
535                       * Call post-PICP programs only for successful
536                       * payment instructions.
537                       */
538                      IF (l_pmtInstrTab(i).payment_instruction_status =
539                              INS_STATUS_CREATED) THEN
540 
541 
542                          /*
543                           * WITHHOLDING CERTIFICATES HOOK:
544                           *
545                           * Fix for bug 6706749:
546                           *
547                           * We need to invoke withholding certificates hook for
548                           * electronic payments. This is already being done
549                           * from printed payments since base R12. Invoking
550                           * withholding certificates for electronic payments
551                           * is new functionality that is addressed in this
552                           * fix.
553                           */
554 
555                          l_pkg_name     := 'AP_AWT_CALLOUT_PKG';
556                          l_callout_name := l_pkg_name
557                                            || '.'
558                                            || 'zx_witholdingCertificatesHook';
559 
560                          print_debuginfo(l_module_name,
561                              'Attempting to call hook: '
562                              || l_callout_name, FND_LOG.LEVEL_UNEXPECTED);
563 
564                          l_stmt := 'CALL '|| l_callout_name
565                                           || '(:1, :2, :3, :4, :5, :6, :7, :8)';
566 
567                          BEGIN
568 
569                              EXECUTE IMMEDIATE
570                                  (l_stmt)
571                              USING
572                                  IN  l_pmtInstrTab(i).payment_instruction_id,
573                                  IN  'GENERATE',
574                                  IN  l_api_version,
575                                  IN  FND_API.G_FALSE,
576                                  IN  FND_API.G_FALSE,
577                                  OUT l_ret_status,
578                                  OUT l_msg_count,
579                                  OUT l_msg_data
580                              ;
581 
582                              print_debuginfo(l_module_name,
583                                  'Finished invoking hook: '
584                                  || l_callout_name
585                                  || ', return status: '
586                                  || l_ret_status, FND_LOG.LEVEL_UNEXPECTED);
587 
588                              /*
589                               * If the called procedure did not return success,
590                               * raise an exception.
591                               */
592                              IF (l_ret_status IS NULL OR
593                                  l_ret_status <> FND_API.G_RET_STS_SUCCESS)
594                                  THEN
595 
596                                  print_debuginfo(l_module_name,
597                                      'Fatal: External app callout '''
598                                      || l_callout_name
599                                      || ''', returned failure status - '
600                                      || l_ret_status
601                                      || '. Raising exception.',
602                                      FND_LOG.LEVEL_UNEXPECTED);
603 
604                                  APP_EXCEPTION.RAISE_EXCEPTION;
605 
606                              END IF;
607 
608                          EXCEPTION
609 
610                              WHEN PROCEDURE_NOT_IMPLEMENTED THEN
611                                  print_debuginfo(l_module_name,
612                                      'Callout "'
613                                      || l_callout_name
614                                      || '" not implemented by application - AP',
615                                      FND_LOG.LEVEL_UNEXPECTED);
616 
617                                  print_debuginfo(l_module_name,
618                                      'Skipping hook call.');
619 
620                              WHEN OTHERS THEN
621 
622                                  print_debuginfo(l_module_name,
623                                      'Fatal: External app '
624                                      || 'callout '''
625                                      || l_callout_name
626                                      || ''', generated exception.',
627                                      FND_LOG.LEVEL_UNEXPECTED
628                                      );
629 
630                                  l_error_code := 'IBY_INS_AWT_CERT_HOOK_FAILED';
631                                  FND_MESSAGE.set_name('IBY', l_error_code);
632 
633                                  FND_MESSAGE.SET_TOKEN('CALLOUT',
634                                      l_callout_name,
635                                      FALSE);
636                                  /*
637                                   * Set the error message on the concurrent
638                                   * program output file (to warn user that
639                                   * the hook failed).
640                                   */
641                                  FND_FILE.PUT_LINE(FND_FILE.OUTPUT,
642                                      FND_MESSAGE.GET);
643 
644                                  /*
645                                   * Set the message on the error stack
646                                   * to display in UI (in case of direct
647                                   * API call from UI).
648                                   */
649                                  FND_MSG_PUB.ADD;
650 
651                                  /*
652                                   * Propogate exception to caller.
653                                   */
654                                  RAISE;
655 
656                          END;
657 
658 
659                          BEGIN
660 
661                              print_debuginfo(l_module_name, 'Invoking '
662                                  || 'extract and format for payment '
663                                  || 'instruction '
664                                  || l_pmtInstrTab(i).payment_instruction_id
665                                  || ' with instruction status: '
666                                  || l_pmtInstrTab(i).payment_instruction_status
667                                  );
668 
669                              IBY_FD_POST_PICP_PROGS_PVT.
670                                  Run_Post_PI_Programs(
671                                      l_pmtInstrTab(i).payment_instruction_id,
672                                      'N'
673                                      );
674 
675                              print_debuginfo(l_module_name, 'Extract '
676                                  || 'and format operation completed.'
677                                  );
678 
679                          EXCEPTION
680                              WHEN OTHERS THEN
681 
682                              print_debuginfo(l_module_name, 'Extract and '
683                                  || 'format operation generated '
684                                  || 'exception for payment instruction '
685                                  || l_pmtInstrTab(i).payment_instruction_id,
686                                  FND_LOG.LEVEL_UNEXPECTED
687                                  );
688 
689                              print_debuginfo(l_module_name, 'SQL code: '
690                                  || SQLCODE, FND_LOG.LEVEL_UNEXPECTED);
691                              print_debuginfo(l_module_name, 'SQL err msg: '
692                                  || SQLERRM, FND_LOG.LEVEL_UNEXPECTED);
693 
694                              /*
695                               * Propogate exception.
696                               */
697                              RAISE;
698 
699                          END;
700 
701                      ELSE
702 
703                          print_debuginfo(l_module_name, 'Not invoking '
704                              || 'extract and format for payment '
705                              || 'instruction '
706                              || l_pmtInstrTab(i).payment_instruction_id
707                              || ' because it is in status: '
708                              || l_pmtInstrTab(i).payment_instruction_status
709                              );
710 
711                      END IF;
712 
713                  END LOOP;
714 
715              END IF; -- if count of instructions > 0
716 
717          END IF; -- processing type = 'printed'
718 
719          /*
720           * In case check numbering completes, perform a commit.
721           */
722          print_debuginfo(l_module_name, 'Performing commit ..');
723          COMMIT;
724 
725      EXCEPTION
726 
727          WHEN OTHERS THEN
728 
729          print_debuginfo(l_module_name, 'Exception occured when performing '
730              || 'check numbering / invoking extract and format. '
731              || 'Processing aborted ..'
732              );
733          print_debuginfo(l_module_name, 'SQLCODE: ' || SQLCODE);
734          print_debuginfo(l_module_name, 'SQLERRM: ' || SQLERRM);
735 
736          x_errbuf := 'PROGRAM ERROR - CANNOT PERFORM '
737              || 'CHECK NUMBERING';
738          x_retcode := '-1';
739          print_debuginfo(l_module_name, 'EXIT');
740 
741          RETURN;
742 
743      END;
744 
745      /*
746       * If we reached here, it means that the payment instruction
747       * creation program finished successfully. Set the response
748       * message to 'success'.
749       */
750      x_errbuf := 'PAYMENT INSTRUCTION CREATION PROGRAM COMPLETED SUCCESSFULLY';
751      x_retcode := '0';
752 
753      print_debuginfo(l_module_name, 'EXIT');
754 
755  END build_pmt_instructions;
756 
757 /*--------------------------------------------------------------------
758  | NAME:
759  |     rebuild_pmt_instruction
760  |
761  |
762  | PURPOSE:
763  |
764  |
765  | PARAMETERS:
766  |     IN
767  |
768  |
769  |     OUT
770  |
771  |
772  | RETURNS:
773  |
774  | NOTES:
775  |
776  *---------------------------------------------------------------------*/
777  PROCEDURE rebuild_pmt_instruction(
778      x_errbuf         OUT NOCOPY VARCHAR2,
779      x_retcode        OUT NOCOPY VARCHAR2,
780      p_pmt_instr_id   IN         VARCHAR2,
781      p_arg4   IN VARCHAR2 DEFAULT NULL, p_arg5   IN VARCHAR2 DEFAULT NULL,
782      p_arg6   IN VARCHAR2 DEFAULT NULL, p_arg7   IN VARCHAR2 DEFAULT NULL,
783      p_arg8   IN VARCHAR2 DEFAULT NULL, p_arg9   IN VARCHAR2 DEFAULT NULL,
784      p_arg10  IN VARCHAR2 DEFAULT NULL, p_arg11  IN VARCHAR2 DEFAULT NULL,
785      p_arg12  IN VARCHAR2 DEFAULT NULL, p_arg13  IN VARCHAR2 DEFAULT NULL,
786      p_arg14  IN VARCHAR2 DEFAULT NULL, p_arg15  IN VARCHAR2 DEFAULT NULL,
787      p_arg16  IN VARCHAR2 DEFAULT NULL, p_arg17  IN VARCHAR2 DEFAULT NULL,
788      p_arg18  IN VARCHAR2 DEFAULT NULL, p_arg19  IN VARCHAR2 DEFAULT NULL,
789      p_arg20  IN VARCHAR2 DEFAULT NULL, p_arg21  IN VARCHAR2 DEFAULT NULL,
790      p_arg22  IN VARCHAR2 DEFAULT NULL, p_arg23  IN VARCHAR2 DEFAULT NULL,
791      p_arg24  IN VARCHAR2 DEFAULT NULL, p_arg25  IN VARCHAR2 DEFAULT NULL,
792      p_arg26  IN VARCHAR2 DEFAULT NULL, p_arg27  IN VARCHAR2 DEFAULT NULL,
793      p_arg28  IN VARCHAR2 DEFAULT NULL, p_arg29  IN VARCHAR2 DEFAULT NULL,
794      p_arg30  IN VARCHAR2 DEFAULT NULL, p_arg31  IN VARCHAR2 DEFAULT NULL,
795      p_arg32  IN VARCHAR2 DEFAULT NULL, p_arg33  IN VARCHAR2 DEFAULT NULL,
796      p_arg34  IN VARCHAR2 DEFAULT NULL, p_arg35  IN VARCHAR2 DEFAULT NULL,
797      p_arg36  IN VARCHAR2 DEFAULT NULL, p_arg37  IN VARCHAR2 DEFAULT NULL,
798      p_arg38  IN VARCHAR2 DEFAULT NULL, p_arg39  IN VARCHAR2 DEFAULT NULL,
799      p_arg40  IN VARCHAR2 DEFAULT NULL, p_arg41  IN VARCHAR2 DEFAULT NULL,
800      p_arg42  IN VARCHAR2 DEFAULT NULL, p_arg43  IN VARCHAR2 DEFAULT NULL,
801      p_arg44  IN VARCHAR2 DEFAULT NULL, p_arg45  IN VARCHAR2 DEFAULT NULL,
802      p_arg46  IN VARCHAR2 DEFAULT NULL, p_arg47  IN VARCHAR2 DEFAULT NULL,
803      p_arg48  IN VARCHAR2 DEFAULT NULL, p_arg49  IN VARCHAR2 DEFAULT NULL,
804      p_arg50  IN VARCHAR2 DEFAULT NULL, p_arg51  IN VARCHAR2 DEFAULT NULL,
805      p_arg52  IN VARCHAR2 DEFAULT NULL, p_arg53  IN VARCHAR2 DEFAULT NULL,
806      p_arg54  IN VARCHAR2 DEFAULT NULL, p_arg55  IN VARCHAR2 DEFAULT NULL,
807      p_arg56  IN VARCHAR2 DEFAULT NULL, p_arg57  IN VARCHAR2 DEFAULT NULL,
808      p_arg58  IN VARCHAR2 DEFAULT NULL, p_arg59  IN VARCHAR2 DEFAULT NULL,
809      p_arg60  IN VARCHAR2 DEFAULT NULL, p_arg61  IN VARCHAR2 DEFAULT NULL,
810      p_arg62  IN VARCHAR2 DEFAULT NULL, p_arg63  IN VARCHAR2 DEFAULT NULL,
811      p_arg64  IN VARCHAR2 DEFAULT NULL, p_arg65  IN VARCHAR2 DEFAULT NULL,
812      p_arg66  IN VARCHAR2 DEFAULT NULL, p_arg67  IN VARCHAR2 DEFAULT NULL,
813      p_arg68  IN VARCHAR2 DEFAULT NULL, p_arg69  IN VARCHAR2 DEFAULT NULL,
814      p_arg70  IN VARCHAR2 DEFAULT NULL, p_arg71  IN VARCHAR2 DEFAULT NULL,
815      p_arg72  IN VARCHAR2 DEFAULT NULL, p_arg73  IN VARCHAR2 DEFAULT NULL,
816      p_arg74  IN VARCHAR2 DEFAULT NULL, p_arg75  IN VARCHAR2 DEFAULT NULL,
817      p_arg76  IN VARCHAR2 DEFAULT NULL, p_arg77  IN VARCHAR2 DEFAULT NULL,
818      p_arg78  IN VARCHAR2 DEFAULT NULL, p_arg79  IN VARCHAR2 DEFAULT NULL,
819      p_arg80  IN VARCHAR2 DEFAULT NULL, p_arg81  IN VARCHAR2 DEFAULT NULL,
820      p_arg82  IN VARCHAR2 DEFAULT NULL, p_arg83  IN VARCHAR2 DEFAULT NULL,
821      p_arg84  IN VARCHAR2 DEFAULT NULL, p_arg85  IN VARCHAR2 DEFAULT NULL,
822      p_arg86  IN VARCHAR2 DEFAULT NULL, p_arg87  IN VARCHAR2 DEFAULT NULL,
823      p_arg88  IN VARCHAR2 DEFAULT NULL, p_arg89  IN VARCHAR2 DEFAULT NULL,
824      p_arg90  IN VARCHAR2 DEFAULT NULL, p_arg91  IN VARCHAR2 DEFAULT NULL,
825      p_arg92  IN VARCHAR2 DEFAULT NULL, p_arg93  IN VARCHAR2 DEFAULT NULL,
826      p_arg94  IN VARCHAR2 DEFAULT NULL, p_arg95  IN VARCHAR2 DEFAULT NULL,
827      p_arg96  IN VARCHAR2 DEFAULT NULL, p_arg97  IN VARCHAR2 DEFAULT NULL,
828      p_arg98  IN VARCHAR2 DEFAULT NULL, p_arg99  IN VARCHAR2 DEFAULT NULL,
829      p_arg100 IN VARCHAR2 DEFAULT NULL
830      )
831  IS
832  l_return_status  NUMBER;
833  l_ret_status     VARCHAR2 (100);
834  l_return_message VARCHAR2 (3000);
835 
836  l_instr_status   IBY_PAY_INSTRUCTIONS_ALL.payment_instruction_status%TYPE;
837  l_instr_rec      IBY_PAY_INSTRUCTIONS_ALL%ROWTYPE;
838  l_instr_tab      IBY_PAYINSTR_PUB.pmtInstrTabType;
839 
840  l_doc_error_tab  IBY_VALIDATIONSETS_PUB.docErrorTabType;
841  l_doc_token_tab  IBY_VALIDATIONSETS_PUB.trxnErrTokenTabType;
842 
843  l_profile_attribs IBY_DISBURSE_SUBMIT_PUB_PKG.profileProcessAttribs;
844 
845  l_msg_count      NUMBER;
846  l_msg_data       VARCHAR2(4000);
847 
848  l_module_name    VARCHAR2(200) := G_PKG_NAME || '.rebuild_pmt_instruction';
849 
850  BEGIN
851 
852      SAVEPOINT BEGIN_REBUILD;
853 
854      print_debuginfo(l_module_name, 'ENTER');
855 
856      print_debuginfo(l_module_name, 'Provided payment instruction id: '
857          || p_pmt_instr_id);
858 
859      BEGIN
860 
861          /*
862           * Retrieve the attributes of the provided payment instruction.
863           */
864          l_instr_rec := get_instruction_attributes(p_pmt_instr_id);
865 
866          IF (l_instr_rec.payment_instruction_status IS NULL) THEN
867 
868              print_debuginfo(l_module_name, 'Attributes of payment '
869                  || 'instruction id: '
870                  || p_pmt_instr_id
871                  || ' could not be retrieved. Aborting rebuild ..',
872                  FND_LOG.LEVEL_UNEXPECTED
873                  );
874 
875              APP_EXCEPTION.RAISE_EXCEPTION;
876 
877          END IF;
878 
879          /*
880           * Check the status of the provided payment instruction.
881           */
882          l_instr_status := l_instr_rec.payment_instruction_status;
883 
884          print_debuginfo(l_module_name, 'Payment instruction status is: '
885              || l_instr_status);
886 
887          IF (l_instr_status <> INSTR_STATUS_RETRY_CREAT  AND
888              l_instr_status <> INSTR_STATUS_CREAT_ERROR) THEN
889 
890              print_debuginfo(l_module_name, 'Payment instruction '
891                  || 'should be in '
892                  || INSTR_STATUS_RETRY_CREAT
893                  || ' or '
894                  || INSTR_STATUS_CREAT_ERROR
895                  || ' status for rebuilding. '
896                  || 'Skipping payment instruction rebuild ..'
897                  );
898 
899          ELSE
900 
901              print_debuginfo(l_module_name,
902                  'Invoking recreatePaymentInstruction()');
903 
904              IBY_PAYINSTR_PUB.recreatePaymentInstruction(
905                  l_instr_rec,
906                  l_doc_error_tab,
907                  l_doc_token_tab,
908                  l_return_status);
909 
910              /*
911               * The provided payment instruction has been revalidated
912               * and (possibly) document sequencing and payment referencing
913               * has occured for the payments of this instruction.
914               * Therefore, the payment instruction status needs to be updated.
915               */
916              l_instr_tab(l_instr_tab.COUNT + 1) := l_instr_rec;
917              IBY_PAYINSTR_PUB.updatePaymentInstructions(l_instr_tab);
918 
919              /*
920               * If the payment instructions wwas again failed, the
921               * IBY_TRANSACTION_ERRORS table must be populated with the
922               * corresponding error messages.
923               */
924              IBY_VALIDATIONSETS_PUB.insert_transaction_errors('N',
925                  l_doc_error_tab, l_doc_token_tab);
926 
927              print_debuginfo(l_module_name, 'Status after payment '
928                  || 'instruction rebuild: '
929                  || l_return_status);
930 
931          END IF;
932 
933          /*
934           * After rebuilding completes, perform a commit.
935           */
936          print_debuginfo(l_module_name, 'Performing commit ..');
937          COMMIT;
938 
939      EXCEPTION
940          WHEN OTHERS THEN
941 
942          /*
943           * In the case of an exception rollback all the
944           * database changes and return failure response.
945           */
946          ROLLBACK TO SAVEPOINT BEGIN_REBUILD;
947 
948          x_errbuf  := 'PAY INSTRUCTION REBUILD ERROR';
949          x_retcode := '-1';
950 
951           /*
952            * The payment instruction was possibly locked by the UI.
953            * Unlock it if possible.
954            */
955           IBY_DISBURSE_UI_API_PUB_PKG.unlock_pmt_entity(
956               p_pmt_instr_id,
957               'PAYMENT_INSTRUCTION',
958               l_ret_status
959               );
960 
961          print_debuginfo(l_module_name, 'EXIT');
962 
963          RETURN;
964 
965      END;
966 
967 
968      /*
969       * Get the default processing related attributes
970       * from the payment process profile on the given
971       * payment instruction. These attributes like the
972       * processing type etc. will be used in check
973       * numbering and formatting calls.
974       */
975      IBY_DISBURSE_SUBMIT_PUB_PKG.get_profile_process_attribs(
976          l_instr_rec.payment_profile_id,
977          l_profile_attribs
978          );
979 
980      /*
981       * If we reached here, it means that the payment instruction
982       * re-creation program finished successfully. Invoke
983       * check numbering if we are building payment instructions
984       * of processing type 'printed'.
985       */
986      BEGIN
987 
988          IF (l_profile_attribs.processing_type = 'PRINTED') THEN
989 
990              IF (l_instr_tab.COUNT > 0) THEN
991 
992                  /*
993                   * Perform check numbering (paper document numbering)
994                   * for the first successful payment instruction. All
995                   * other payment instructions are to be moved to a
996                   * deferred status for later numbering.
997                   *
998                   * This is because the payment document (check stock)
999                   * is locked once it is used to number a payment
1000                   * instruction. This lock will only be released after
1001                   * the user has confirmed that the checks printed
1002                   * correctly. So, there is no point in proceeding
1003                   * with other payment instructions until the numbered
1004                   * instruction has been confirmed by the user.
1005                   */
1006                  FOR i IN l_instr_tab.FIRST .. l_instr_tab.LAST LOOP
1007 
1008                      /*
1009                       * Number only successful payment
1010                       * instructions.
1011                       */
1012                      IF (l_instr_tab(i).payment_instruction_status =
1013                              INS_STATUS_CREATED) THEN
1014 
1015                          print_debuginfo(l_module_name, 'Invoking '
1016                              || 'numbering for payment '
1017                              || 'instruction '
1018                              || l_instr_tab(i).payment_instruction_id
1019                              || ' with instruction status: '
1020                              || l_instr_tab(i).payment_instruction_status
1021                              );
1022 
1023                          /*
1024                           * Invoke check numbering for this payment
1025                           * instruction.
1026                           */
1027 
1028                          /*
1029                           * Fix for bug 5206725:
1030                           *
1031                           * Do not use the payment document on the profile
1032                           * for numbering. This is an optional attribute
1033                           * on the profile that may or may not be present.
1034                           *
1035                           * Since, this is a rebuild scenario, the pmt
1036                           * document id would have already been provided
1037                           * to the payment instruction in the first attempt.
1038                           *
1039                           * This value is stored as a payment instruction
1040                           * attribute. Re-use the stored value.
1041                           */
1042                          IBY_CHECKNUMBER_PUB.performCheckNumbering(
1043                              l_instr_tab(i).payment_instruction_id,
1044                              l_instr_rec.payment_document_id,
1045                              NULL,
1046                              l_ret_status,
1047                              l_return_message,
1048                              l_msg_count,
1049                              l_msg_data
1050                              );
1051 
1052                          print_debuginfo(l_module_name, 'After numbering, '
1053                              || 'return status: '
1054                              || l_ret_status
1055                              || ', and return message: '
1056                              || l_return_message
1057                              );
1058 
1059                          IF (l_ret_status <> FND_API.G_RET_STS_SUCCESS) THEN
1060 
1061                              print_debuginfo(l_module_name, 'Check '
1062                                  || 'numbering module returned failure '
1063                                  || 'response. Aborting.. ',
1064                                  FND_LOG.LEVEL_UNEXPECTED
1065                                  );
1066 
1067                              APP_EXCEPTION.RAISE_EXCEPTION;
1068 
1069                          END IF;
1070 
1071                          /*
1072                           * The first successful payment instruction has now
1073                           * been numbered.
1074                           *
1075                           * Invoke the set of post-payment instruction
1076                           * creation programs that are responsible for
1077                           * extracting, formatting and printing the
1078                           * payment instruction data.
1079                           */
1080                          BEGIN
1081 
1082                              print_debuginfo(l_module_name, 'Invoking '
1083                                  || 'extract and format programs for '
1084                                  || 'instruction '
1085                                  || l_instr_tab(i).payment_instruction_id
1086                                  );
1087 
1088                              IBY_FD_POST_PICP_PROGS_PVT.
1089                                  Run_Post_PI_Programs(
1090                                      l_instr_tab(i).payment_instruction_id,
1091                                      'N'
1092                                      );
1093 
1094                              print_debuginfo(l_module_name, 'Extract '
1095                                  || 'and format operation completed.'
1096                                  );
1097 
1098                          EXCEPTION
1099                              WHEN OTHERS THEN
1100 
1101                              print_debuginfo(l_module_name, 'Extract and '
1102                                  || 'format operation generated '
1103                                  || 'exception for payment instruction '
1104                                  || l_instr_tab(i).payment_instruction_id,
1105                                  FND_LOG.LEVEL_UNEXPECTED
1106                                  );
1107 
1108                              print_debuginfo(l_module_name, 'SQL code: '
1109                                  || SQLCODE, FND_LOG.LEVEL_UNEXPECTED);
1110                              print_debuginfo(l_module_name, 'SQL err msg: '
1111                                  || SQLERRM, FND_LOG.LEVEL_UNEXPECTED);
1112 
1113                              /*
1114                               * Propogate exception.
1115                               */
1116                              RAISE;
1117 
1118                          END;
1119 
1120                          /*
1121                           * Move all other successful payment instructions
1122                           * to deferred status (for later numbering).
1123                           */
1124                          moveInstrToDeferredStatus(l_instr_tab,
1125                              l_instr_tab(i).payment_instruction_id);
1126 
1127                          /*
1128                           * Once we have numbered and formatted the first
1129                           * successful payment instruction, exit.
1130                           */
1131                          EXIT;
1132 
1133                      ELSE
1134 
1135                          print_debuginfo(l_module_name, 'Not invoking '
1136                              || 'paper document numbering for payment '
1137                              || 'instruction '
1138                              || l_instr_tab(i).payment_instruction_id
1139                              || ', as it is in status '
1140                              || l_instr_tab(i).payment_instruction_status
1141                              );
1142 
1143                      END IF;
1144 
1145                  END LOOP;
1146 
1147              ELSE
1148 
1149                  print_debuginfo(l_module_name, 'Instruction count is '
1150                      || 'zero. Skipping paper document numbering ..'
1151                      );
1152 
1153              END IF; -- if instruction count > 0
1154 
1155          ELSE
1156 
1157              print_debuginfo(l_module_name, 'Processing type is '
1158                  || l_profile_attribs.processing_type
1159                  || '. Numbering of paper documents skipped ..'
1160                  );
1161 
1162              /*
1163               * If we reached here, it means the processing type
1164               * is electronic.
1165               *
1166               * For electronic payment instructions, check numbering
1167               * not required. Instead, directly call the extracting
1168               * and formatting programs.
1169               */
1170 
1171              IF (l_instr_tab.COUNT > 0) THEN
1172 
1173                  /*
1174                   * Loop through all the payment instructions one-by-one.
1175                   *
1176                   * Invoke extract and format for each successful payment
1177                   * instruction.
1178                   */
1179                  FOR i IN l_instr_tab.FIRST .. l_instr_tab.LAST LOOP
1180 
1181                      /*
1182                       * Call post-PICP programs only for successful
1183                       * payment instructions.
1184                       */
1185                      IF (l_instr_tab(i).payment_instruction_status =
1186                              INS_STATUS_CREATED) THEN
1187 
1188                          BEGIN
1189 
1190                              print_debuginfo(l_module_name, 'Invoking '
1191                                  || 'extract and format for payment '
1192                                  || 'instruction '
1193                                  || l_instr_tab(i).payment_instruction_id
1194                                  || ' with instruction status: '
1195                                  || l_instr_tab(i).payment_instruction_status
1196                                  );
1197 
1198                              IBY_FD_POST_PICP_PROGS_PVT.
1199                                  Run_Post_PI_Programs(
1200                                      l_instr_tab(i).payment_instruction_id,
1201                                      'N'
1202                                      );
1203 
1204                              print_debuginfo(l_module_name, 'Extract '
1205                                  || 'and format operation completed.'
1206                                  );
1207 
1208                          EXCEPTION
1209                              WHEN OTHERS THEN
1210 
1211                              print_debuginfo(l_module_name, 'Extract and '
1212                                  || 'format operation generated '
1213                                  || 'exception for payment instruction '
1214                                  || l_instr_tab(i).payment_instruction_id,
1215                                  FND_LOG.LEVEL_UNEXPECTED
1216                                  );
1217 
1218                              print_debuginfo(l_module_name, 'SQL code: '
1219                                  || SQLCODE, FND_LOG.LEVEL_UNEXPECTED);
1220                              print_debuginfo(l_module_name, 'SQL err msg: '
1221                                  || SQLERRM, FND_LOG.LEVEL_UNEXPECTED);
1222 
1223                              /*
1224                               * Propogate exception.
1225                               */
1226                              RAISE;
1227 
1228                          END;
1229 
1230                      ELSE
1231 
1232                          print_debuginfo(l_module_name, 'Not invoking '
1233                              || 'extract and format for payment '
1234                              || 'instruction '
1235                              || l_instr_tab(i).payment_instruction_id
1236                              || ' because it is in status: '
1237                              || l_instr_tab(i).payment_instruction_status
1238                              );
1239 
1240                      END IF;
1241 
1242                  END LOOP;
1243 
1244              END IF; -- if count of instructions > 0
1245 
1246          END IF; -- processing type = 'printed'
1247 
1248          /*
1249           * In case check numbering completes, perform a commit.
1250           */
1251          print_debuginfo(l_module_name, 'Performing commit ..');
1252          COMMIT;
1253 
1254      EXCEPTION
1255 
1256          WHEN OTHERS THEN
1257 
1258          print_debuginfo(l_module_name, 'Exception occured when performing '
1259              || 'check numbering / invoking extract and format. '
1260              || 'Processing aborted ..'
1261              );
1262          print_debuginfo(l_module_name, 'SQLCODE: ' || SQLCODE);
1263          print_debuginfo(l_module_name, 'SQLERRM: ' || SQLERRM);
1264 
1265          x_errbuf := 'PROGRAM ERROR - CANNOT PERFORM '
1266              || 'CHECK NUMBERING';
1267          x_retcode := '-1';
1268 
1269           /*
1270            * The payment instruction was possibly locked by the UI.
1271            * Unlock it if possible.
1272            */
1273           IBY_DISBURSE_UI_API_PUB_PKG.unlock_pmt_entity(
1274               p_pmt_instr_id,
1275               'PAYMENT_INSTRUCTION',
1276               l_ret_status
1277               );
1278 
1279          print_debuginfo(l_module_name, 'EXIT');
1280 
1281          RETURN;
1282 
1283      END;
1284 
1285      /*
1286       * If we reached here, it means that the payment instruction
1287       * creation program finished successfully. Set the response
1288       * message to 'success'.
1289       */
1290      x_errbuf := 'PAYMENT INSTRUCTION RE-CREATION PROGRAM COMPLETED '
1291                      || 'SUCCESSFULLY';
1292      x_retcode := '0';
1293 
1294      /*
1295       * The payment instruction was possibly locked by the UI.
1296       * Unlock it if possible.
1297       */
1298      IBY_DISBURSE_UI_API_PUB_PKG.unlock_pmt_entity(
1299          p_pmt_instr_id,
1300          'PAYMENT_INSTRUCTION',
1301          l_ret_status
1302          );
1303 
1304      print_debuginfo(l_module_name, 'EXIT');
1305 
1306 
1307  END rebuild_pmt_instruction;
1308 
1309 /*--------------------------------------------------------------------
1310  | NAME:
1311  |     moveInstrToDeferredStatus
1312  |
1313  |
1314  | PURPOSE:
1315  |     This method will set the status of a given payment instructions
1316  |     to 'CREATED_READY_FOR_PRINTING' | 'CREATED_READY_FOR_FORMATTING'
1317  |     status depending upon the payment profile on the instruction.
1318  |
1319  |     In case the second argument is not null, the status of that
1320  |     particular payment instruction will not be touched by this method.
1321  |
1322  | PARAMETERS:
1323  |     IN
1324  |
1325  |
1326  |     OUT
1327  |
1328  |
1329  | RETURNS:
1330  |
1331  | NOTES:
1332  |
1333  *---------------------------------------------------------------------*/
1334  PROCEDURE moveInstrToDeferredStatus(
1335      p_pmtInstrTab       IN OUT NOCOPY IBY_PAYINSTR_PUB.pmtInstrTabType,
1336      p_instr_to_skip     IN IBY_PAY_INSTRUCTIONS_ALL.
1337                                 payment_instruction_id%TYPE DEFAULT NULL
1338      )
1339  IS
1340  l_module_name    VARCHAR2(200) := G_PKG_NAME || '.moveInstrToDeferredStatus';
1341 
1342  l_send_to_file_flag VARCHAR2(1);
1343  l_instr_status      IBY_PAY_INSTRUCTIONS_ALL.payment_instruction_status%TYPE;
1344 
1345  BEGIN
1346 
1347      print_debuginfo(l_module_name, 'ENTER');
1348 
1349      IF (p_pmtInstrTab.COUNT = 0) THEN
1350 
1351          print_debuginfo(l_module_name, 'List of provided payment '
1352              || 'instructions is empty. Exiting .. '
1353              );
1354 
1355          print_debuginfo(l_module_name, 'EXIT');
1356          RETURN;
1357 
1358      END IF;
1359 
1360      FOR i in p_pmtInstrTab.FIRST..p_pmtInstrTab.LAST LOOP
1361 
1362          /*
1363           * Set the status of all payment instructions in the given
1364           * list to 'printing deferred' except for the specified
1365           * payment instruction which is to be skipped (because it
1366           * has been printed).
1367           */
1368          IF (p_instr_to_skip IS NULL OR p_pmtInstrTab(i).payment_instruction_id
1369              <> p_instr_to_skip) THEN
1370 
1371              SELECT
1372                  send_to_file_flag
1373              INTO
1374                  l_send_to_file_flag
1375              FROM
1376                  IBY_PAYMENT_PROFILES
1377              WHERE
1378                  payment_profile_id = p_pmtInstrTab(i).payment_profile_id
1379              ;
1380 
1381              /*
1382               * The payment instruction status is dependant upon
1383               * the 'send to file' flag. Pre-set the instruction
1384               * status appropriately.
1385               */
1386              IF (UPPER(l_send_to_file_flag) = 'Y') THEN
1387                  l_instr_status := INS_STATUS_READY_TO_FORMAT;
1388              ELSE
1389                  l_instr_status := INS_STATUS_READY_TO_PRINT;
1390              END IF;
1391 
1392 
1393              UPDATE
1394                  IBY_PAY_INSTRUCTIONS_ALL
1395              SET
1396                  payment_instruction_status = l_instr_status
1397              WHERE
1398                  payment_instruction_id = p_pmtInstrTab(i).
1399                                               payment_instruction_id;
1400 
1401              print_debuginfo(l_module_name, 'Updated payment '
1402                  || 'instruction '
1403                  || p_pmtInstrTab(i).payment_instruction_id
1404                  || ' to '
1405                  || l_instr_status
1406                  || ' status.'
1407                  );
1408 
1409          ELSE
1410 
1411              print_debuginfo(l_module_name, 'Skipping payment '
1412                  || 'instruction '
1413                  || p_pmtInstrTab(i).payment_instruction_id
1414                  || ' ..'
1415                  );
1416 
1417          END IF;
1418 
1419      END LOOP;
1420 
1421      print_debuginfo(l_module_name, 'EXIT');
1422 
1423  END moveInstrToDeferredStatus;
1424 
1425 /*--------------------------------------------------------------------
1426  | NAME:
1427  |     get_payreq_id
1428  |
1429  |
1430  | PURPOSE:
1431  |
1432  |
1433  | PARAMETERS:
1434  |     IN
1435  |
1436  |
1437  |     OUT
1438  |
1439  |
1440  | RETURNS:
1441  |
1442  | NOTES:
1443  |
1444  *---------------------------------------------------------------------*/
1445  FUNCTION get_payreq_id (
1446      l_ca_id        IN IBY_PAY_SERVICE_REQUESTS.calling_app_id%TYPE,
1447      l_ca_payreq_cd IN IBY_PAY_SERVICE_REQUESTS.
1448                            call_app_pay_service_req_code%TYPE
1449      )
1450      RETURN IBY_PAY_SERVICE_REQUESTS.payment_service_request_id%TYPE
1451  IS
1452 
1453  l_payreq_id     NUMBER := -1;
1454  l_module_name   VARCHAR2(200) := G_PKG_NAME || '.get_payreq_id';
1455 
1456  BEGIN
1457 
1458      print_debuginfo(l_module_name, 'ENTER');
1459 
1460      SELECT
1461          payment_service_request_id
1462      INTO
1463          l_payreq_id
1464      FROM
1465          IBY_PAY_SERVICE_REQUESTS
1466      WHERE
1467          calling_app_id = l_ca_id
1468      AND
1469          call_app_pay_service_req_code = l_ca_payreq_cd;
1470 
1471      print_debuginfo(l_module_name, 'EXIT');
1472      RETURN l_payreq_id;
1473 
1474  EXCEPTION
1475      WHEN OTHERS THEN
1476          print_debuginfo(l_module_name, 'Exception occured when '
1477              || 'retrieving payment request id for '
1478              || 'calling application '
1479              || l_ca_id
1480              || ' with calling app payment request cd '
1481              || l_ca_payreq_cd
1482              );
1483          print_debuginfo(l_module_name, 'SQLCODE: ' || SQLCODE);
1484          print_debuginfo(l_module_name, 'SQLERRM: ' || SQLERRM);
1485          print_debuginfo(l_module_name, 'Returning -1 for payreq id');
1486 
1487          l_payreq_id := -1;
1488          print_debuginfo(l_module_name, 'EXIT');
1489          RETURN l_payreq_id;
1490 
1491  END get_payreq_id;
1492 
1493 /*--------------------------------------------------------------------
1494  | NAME:
1495  |     get_instruction_attributes
1496  |
1497  |
1498  | PURPOSE:
1499  |
1500  |
1501  | PARAMETERS:
1502  |     IN
1503  |
1504  |
1505  |     OUT
1506  |
1507  |
1508  | RETURNS:
1509  |
1510  | NOTES:
1511  |
1512  *---------------------------------------------------------------------*/
1513  FUNCTION get_instruction_attributes(
1514      l_pmt_instr_id IN IBY_PAY_INSTRUCTIONS_ALL.payment_instruction_id%TYPE)
1515      RETURN IBY_PAY_INSTRUCTIONS_ALL%ROWTYPE
1516  IS
1517 
1518  l_module_name       VARCHAR2(200) := G_PKG_NAME ||
1519                                           '.get_instruction_attributes';
1520 
1521  l_instr_rec         IBY_PAY_INSTRUCTIONS_ALL%ROWTYPE;
1522 
1523  BEGIN
1524 
1525      SELECT
1526          payment_instruction_id,
1527          payment_profile_id,
1528          process_type,
1529          payment_instruction_status,
1530          payments_complete_code,
1531          generate_sep_remit_advice_flag,
1532          remittance_advice_created_flag,
1533          regulatory_report_created_flag,
1534          bill_payable_flag,
1535          legal_entity_id,
1536          payment_count,
1537          positive_pay_file_created_flag,
1538          print_instruction_immed_flag,
1539          transmit_instr_immed_flag,
1540          created_by,
1541          creation_date,
1542          last_updated_by,
1543          last_update_date,
1544          last_update_login,
1545          object_version_number,
1546          internal_bank_account_id,
1547          pay_admin_assigned_ref_code,
1548          transmission_date,
1549          acknowledgement_date,
1550          comments,
1551          bank_assigned_ref_code,
1552          org_id,
1553          org_type,
1554          payment_date,
1555          payment_currency_code,
1556          payment_service_request_id,
1557          payment_function,
1558          payment_reason_code,
1559          rfc_identifier,
1560          payment_reason_comments,
1561          payment_document_id,
1562          printer_name,
1563          attribute_category,
1564          attribute1,
1565          attribute2,
1566          attribute3,
1567          attribute4,
1568          attribute5,
1569          attribute6,
1570          attribute7,
1571          attribute8,
1572          attribute9,
1573          attribute10,
1574          attribute11,
1575          attribute12,
1576          attribute13,
1577          attribute14,
1578          attribute15
1579      INTO
1580          l_instr_rec.payment_instruction_id,
1581          l_instr_rec.payment_profile_id,
1582          l_instr_rec.process_type,
1583          l_instr_rec.payment_instruction_status,
1584          l_instr_rec.payments_complete_code,
1585          l_instr_rec.generate_sep_remit_advice_flag,
1586          l_instr_rec.remittance_advice_created_flag,
1587          l_instr_rec.regulatory_report_created_flag,
1588          l_instr_rec.bill_payable_flag,
1589          l_instr_rec.legal_entity_id,
1590          l_instr_rec.payment_count,
1591          l_instr_rec.positive_pay_file_created_flag,
1592          l_instr_rec.print_instruction_immed_flag,
1593          l_instr_rec.transmit_instr_immed_flag,
1594          l_instr_rec.created_by,
1595          l_instr_rec.creation_date,
1596          l_instr_rec.last_updated_by,
1597          l_instr_rec.last_update_date,
1598          l_instr_rec.last_update_login,
1599          l_instr_rec.object_version_number,
1600          l_instr_rec.internal_bank_account_id,
1601          l_instr_rec.pay_admin_assigned_ref_code,
1602          l_instr_rec.transmission_date,
1603          l_instr_rec.acknowledgement_date,
1604          l_instr_rec.comments,
1605          l_instr_rec.bank_assigned_ref_code,
1606          l_instr_rec.org_id,
1607          l_instr_rec.org_type,
1608          l_instr_rec.payment_date,
1609          l_instr_rec.payment_currency_code,
1610          l_instr_rec.payment_service_request_id,
1611          l_instr_rec.payment_function,
1612          l_instr_rec.payment_reason_code,
1613          l_instr_rec.rfc_identifier,
1614          l_instr_rec.payment_reason_comments,
1615          l_instr_rec.payment_document_id,
1616          l_instr_rec.printer_name,
1617          l_instr_rec.attribute_category,
1618          l_instr_rec.attribute1,
1619          l_instr_rec.attribute2,
1620          l_instr_rec.attribute3,
1621          l_instr_rec.attribute4,
1622          l_instr_rec.attribute5,
1623          l_instr_rec.attribute6,
1624          l_instr_rec.attribute7,
1625          l_instr_rec.attribute8,
1626          l_instr_rec.attribute9,
1627          l_instr_rec.attribute10,
1628          l_instr_rec.attribute11,
1629          l_instr_rec.attribute12,
1630          l_instr_rec.attribute13,
1631          l_instr_rec.attribute14,
1632          l_instr_rec.attribute15
1633      FROM
1634          IBY_PAY_INSTRUCTIONS_ALL
1635      WHERE
1636          payment_instruction_id = l_pmt_instr_id
1637      ;
1638 
1639 
1640      RETURN l_instr_rec;
1641 
1642  EXCEPTION
1643      WHEN OTHERS THEN
1644 
1645          print_debuginfo(l_module_name, 'Exception occured when '
1646              || 'retrieving payment instruction attributes for '
1647              || 'payment instruction '
1648              || l_pmt_instr_id
1649              );
1650          print_debuginfo(l_module_name, 'SQLCODE: ' || SQLCODE);
1651          print_debuginfo(l_module_name, 'SQLERRM: ' || SQLERRM);
1652          print_debuginfo(l_module_name, 'Returning NULL.');
1653 
1654          RETURN NULL;
1655 
1656  END get_instruction_attributes;
1657 
1658 /*--------------------------------------------------------------------
1659  | NAME:
1660  |     print_debuginfo
1661  |
1662  | PURPOSE:
1663  |
1664  |
1665  | PARAMETERS:
1666  |     IN
1667  |
1668  |
1669  |     OUT
1670  |
1671  |
1672  | RETURNS:
1673  |
1674  | NOTES:
1675  |
1676  *---------------------------------------------------------------------*/
1677  PROCEDURE print_debuginfo(
1678      p_module      IN VARCHAR2,
1679      p_debug_text  IN VARCHAR2,
1680      p_debug_level IN VARCHAR2  DEFAULT FND_LOG.LEVEL_STATEMENT
1681      )
1682  IS
1683  l_default_debug_level VARCHAR2(200) := FND_LOG.LEVEL_STATEMENT;
1684  BEGIN
1685 
1686      IF (p_debug_level IS NOT NULL) THEN
1687          l_default_debug_level := p_debug_level;
1688      END IF;
1689 
1690      /*
1691       * Write the debug message to the concurrent manager log file.
1692       */
1693      IF (l_default_debug_level >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
1694          iby_build_utils_pkg.print_debuginfo(p_module, p_debug_text,
1695              p_debug_level);
1696      END IF;
1697 
1698  END print_debuginfo;
1699 
1700 /*--------------------------------------------------------------------
1701  | NAME:
1702  |     build_electronic_instructions
1703  |
1704  | PURPOSE:
1705  |     Concurrent program wrapper for creating electronic payment
1706  |     instructions.
1707  |
1708  | PARAMETERS:
1709  |     IN
1710  |
1711  |
1712  |     OUT
1713  |
1714  |
1715  | RETURNS:
1716  |
1717  | NOTES:
1718  |
1719  *---------------------------------------------------------------------*/
1720  PROCEDURE build_electronic_instructions(
1721      x_errbuf                     OUT NOCOPY VARCHAR2,
1722      x_retcode                    OUT NOCOPY VARCHAR2,
1723 
1724      /*-- processing criteria --*/
1725      p_processing_type            IN         VARCHAR2,
1726 
1727      /*-- user/admin assigned criteria --*/
1728      p_admin_assigned_ref         IN         VARCHAR2 DEFAULT NULL,
1729      p_comments                   IN         VARCHAR2 DEFAULT NULL,
1730 
1731      /*-- selection criteria --*/
1732      p_payment_profile_id         IN         VARCHAR2 DEFAULT NULL,
1733      p_payment_currency           IN         VARCHAR2 DEFAULT NULL,
1734      p_internal_bank_account_id   IN         VARCHAR2 DEFAULT NULL,
1735      p_calling_app_id             IN         VARCHAR2 DEFAULT NULL,
1736      p_calling_app_payreq_cd      IN         VARCHAR2 DEFAULT NULL,
1737      p_le_id                      IN         VARCHAR2 DEFAULT NULL,
1738      p_org_type                   IN         VARCHAR2 DEFAULT NULL,
1739      p_org_id                     IN         VARCHAR2 DEFAULT NULL,
1740      p_payment_from_date          IN         VARCHAR2 DEFAULT NULL,
1741      p_payment_to_date            IN         VARCHAR2 DEFAULT NULL,
1742      p_transmit_now_flag          IN         VARCHAR2 DEFAULT NULL,
1743 
1744      p_arg16  IN VARCHAR2 DEFAULT NULL, p_arg17  IN VARCHAR2 DEFAULT NULL,
1745      p_arg18  IN VARCHAR2 DEFAULT NULL, p_arg19  IN VARCHAR2 DEFAULT NULL,
1746      p_arg20  IN VARCHAR2 DEFAULT NULL, p_arg21  IN VARCHAR2 DEFAULT NULL,
1747      p_arg22  IN VARCHAR2 DEFAULT NULL, p_arg23  IN VARCHAR2 DEFAULT NULL,
1748      p_arg24  IN VARCHAR2 DEFAULT NULL, p_arg25  IN VARCHAR2 DEFAULT NULL,
1749      p_arg26  IN VARCHAR2 DEFAULT NULL, p_arg27  IN VARCHAR2 DEFAULT NULL,
1750      p_arg28  IN VARCHAR2 DEFAULT NULL, p_arg29  IN VARCHAR2 DEFAULT NULL,
1751      p_arg30  IN VARCHAR2 DEFAULT NULL, p_arg31  IN VARCHAR2 DEFAULT NULL,
1752      p_arg32  IN VARCHAR2 DEFAULT NULL, p_arg33  IN VARCHAR2 DEFAULT NULL,
1753      p_arg34  IN VARCHAR2 DEFAULT NULL, p_arg35  IN VARCHAR2 DEFAULT NULL,
1754      p_arg36  IN VARCHAR2 DEFAULT NULL, p_arg37  IN VARCHAR2 DEFAULT NULL,
1755      p_arg38  IN VARCHAR2 DEFAULT NULL, p_arg39  IN VARCHAR2 DEFAULT NULL,
1756      p_arg40  IN VARCHAR2 DEFAULT NULL, p_arg41  IN VARCHAR2 DEFAULT NULL,
1757      p_arg42  IN VARCHAR2 DEFAULT NULL, p_arg43  IN VARCHAR2 DEFAULT NULL,
1758      p_arg44  IN VARCHAR2 DEFAULT NULL, p_arg45  IN VARCHAR2 DEFAULT NULL,
1759      p_arg46  IN VARCHAR2 DEFAULT NULL, p_arg47  IN VARCHAR2 DEFAULT NULL,
1760      p_arg48  IN VARCHAR2 DEFAULT NULL, p_arg49  IN VARCHAR2 DEFAULT NULL,
1761      p_arg50  IN VARCHAR2 DEFAULT NULL, p_arg51  IN VARCHAR2 DEFAULT NULL,
1762      p_arg52  IN VARCHAR2 DEFAULT NULL, p_arg53  IN VARCHAR2 DEFAULT NULL,
1763      p_arg54  IN VARCHAR2 DEFAULT NULL, p_arg55  IN VARCHAR2 DEFAULT NULL,
1764      p_arg56  IN VARCHAR2 DEFAULT NULL, p_arg57  IN VARCHAR2 DEFAULT NULL,
1765      p_arg58  IN VARCHAR2 DEFAULT NULL, p_arg59  IN VARCHAR2 DEFAULT NULL,
1766      p_arg60  IN VARCHAR2 DEFAULT NULL, p_arg61  IN VARCHAR2 DEFAULT NULL,
1767      p_arg62  IN VARCHAR2 DEFAULT NULL, p_arg63  IN VARCHAR2 DEFAULT NULL,
1768      p_arg64  IN VARCHAR2 DEFAULT NULL, p_arg65  IN VARCHAR2 DEFAULT NULL,
1769      p_arg66  IN VARCHAR2 DEFAULT NULL, p_arg67  IN VARCHAR2 DEFAULT NULL,
1770      p_arg68  IN VARCHAR2 DEFAULT NULL, p_arg69  IN VARCHAR2 DEFAULT NULL,
1771      p_arg70  IN VARCHAR2 DEFAULT NULL, p_arg71  IN VARCHAR2 DEFAULT NULL,
1772      p_arg72  IN VARCHAR2 DEFAULT NULL, p_arg73  IN VARCHAR2 DEFAULT NULL,
1773      p_arg74  IN VARCHAR2 DEFAULT NULL, p_arg75  IN VARCHAR2 DEFAULT NULL,
1774      p_arg76  IN VARCHAR2 DEFAULT NULL, p_arg77  IN VARCHAR2 DEFAULT NULL,
1775      p_arg78  IN VARCHAR2 DEFAULT NULL, p_arg79  IN VARCHAR2 DEFAULT NULL,
1776      p_arg80  IN VARCHAR2 DEFAULT NULL, p_arg81  IN VARCHAR2 DEFAULT NULL,
1777      p_arg82  IN VARCHAR2 DEFAULT NULL, p_arg83  IN VARCHAR2 DEFAULT NULL,
1778      p_arg84  IN VARCHAR2 DEFAULT NULL, p_arg85  IN VARCHAR2 DEFAULT NULL,
1779      p_arg86  IN VARCHAR2 DEFAULT NULL, p_arg87  IN VARCHAR2 DEFAULT NULL,
1780      p_arg88  IN VARCHAR2 DEFAULT NULL, p_arg89  IN VARCHAR2 DEFAULT NULL,
1781      p_arg90  IN VARCHAR2 DEFAULT NULL, p_arg91  IN VARCHAR2 DEFAULT NULL,
1782      p_arg92  IN VARCHAR2 DEFAULT NULL, p_arg93  IN VARCHAR2 DEFAULT NULL,
1783      p_arg94  IN VARCHAR2 DEFAULT NULL, p_arg95  IN VARCHAR2 DEFAULT NULL,
1784      p_arg96  IN VARCHAR2 DEFAULT NULL, p_arg97  IN VARCHAR2 DEFAULT NULL,
1785      p_arg98  IN VARCHAR2 DEFAULT NULL, p_arg99  IN VARCHAR2 DEFAULT NULL,
1786      p_arg100 IN VARCHAR2 DEFAULT NULL
1787      )
1788  IS
1789  l_module_name    VARCHAR2(200) := G_PKG_NAME
1790                                        || '.build_electronic_instructions';
1791  BEGIN
1792 
1793      print_debuginfo(l_module_name, 'ENTER');
1794 
1795      build_pmt_instructions(
1796          x_errbuf,
1797          x_retcode,
1798 
1799          /*-- processing criteria --*/
1800          p_processing_type,
1801          p_payment_profile_id,
1802          NULL,                  -- p_pmt_document_id
1803          p_internal_bank_account_id,
1804          NULL,                  -- p_print_now_flag
1805          NULL,                  -- p_printer_name
1806          p_payment_currency,
1807          p_transmit_now_flag,
1808 
1809          /*-- user/admin assigned criteria --*/
1810          p_admin_assigned_ref,
1811          p_comments,
1812 
1813          /*-- selection criteria --*/
1814          p_calling_app_id,
1815          p_calling_app_payreq_cd,
1816          p_le_id,
1817          p_org_id,
1818          p_org_type,
1819          p_payment_from_date,
1820          p_payment_to_date
1821          );
1822 
1823      print_debuginfo(l_module_name, 'EXIT');
1824 
1825  END build_electronic_instructions;
1826 
1827 /*--------------------------------------------------------------------
1828  | NAME:
1829  |     build_printed_instructions
1830  |
1831  | PURPOSE:
1832  |     Concurrent program wrapper for creating printed payment
1833  |     instructions.
1834  |
1835  | PARAMETERS:
1836  |     IN
1837  |
1838  |
1839  |     OUT
1840  |
1841  |
1842  | RETURNS:
1843  |
1844  | NOTES:
1845  |
1846  *---------------------------------------------------------------------*/
1847  PROCEDURE build_printed_instructions(
1848      x_errbuf                     OUT NOCOPY VARCHAR2,
1849      x_retcode                    OUT NOCOPY VARCHAR2,
1850 
1851      /*-- processing criteria --*/
1852      p_processing_type            IN         VARCHAR2,
1853 
1854      /*-- user/admin assigned criteria --*/
1855      p_admin_assigned_ref         IN         VARCHAR2 DEFAULT NULL,
1856      p_comments                   IN         VARCHAR2 DEFAULT NULL,
1857 
1858      /*-- selection criteria --*/
1859      p_payment_profile_id         IN         VARCHAR2 DEFAULT NULL,
1860      p_payment_currency           IN         VARCHAR2 DEFAULT NULL,
1861      p_internal_bank_account_id   IN         VARCHAR2 DEFAULT NULL,
1862      p_pmt_document_id            IN         VARCHAR2 DEFAULT NULL,
1863      p_calling_app_id             IN         VARCHAR2 DEFAULT NULL,
1864      p_calling_app_payreq_cd      IN         VARCHAR2 DEFAULT NULL,
1865      p_le_id                      IN         VARCHAR2 DEFAULT NULL,
1866      p_org_type                   IN         VARCHAR2 DEFAULT NULL,
1867      p_org_id                     IN         VARCHAR2 DEFAULT NULL,
1868      p_payment_from_date          IN         VARCHAR2 DEFAULT NULL,
1869      p_payment_to_date            IN         VARCHAR2 DEFAULT NULL,
1870      p_print_now_flag             IN         VARCHAR2 DEFAULT NULL,
1871      p_printer_name               IN         VARCHAR2 DEFAULT NULL,
1872 
1873      p_arg18  IN VARCHAR2 DEFAULT NULL, p_arg19  IN VARCHAR2 DEFAULT NULL,
1874      p_arg20  IN VARCHAR2 DEFAULT NULL, p_arg21  IN VARCHAR2 DEFAULT NULL,
1875      p_arg22  IN VARCHAR2 DEFAULT NULL, p_arg23  IN VARCHAR2 DEFAULT NULL,
1876      p_arg24  IN VARCHAR2 DEFAULT NULL, p_arg25  IN VARCHAR2 DEFAULT NULL,
1877      p_arg26  IN VARCHAR2 DEFAULT NULL, p_arg27  IN VARCHAR2 DEFAULT NULL,
1878      p_arg28  IN VARCHAR2 DEFAULT NULL, p_arg29  IN VARCHAR2 DEFAULT NULL,
1879      p_arg30  IN VARCHAR2 DEFAULT NULL, p_arg31  IN VARCHAR2 DEFAULT NULL,
1880      p_arg32  IN VARCHAR2 DEFAULT NULL, p_arg33  IN VARCHAR2 DEFAULT NULL,
1881      p_arg34  IN VARCHAR2 DEFAULT NULL, p_arg35  IN VARCHAR2 DEFAULT NULL,
1882      p_arg36  IN VARCHAR2 DEFAULT NULL, p_arg37  IN VARCHAR2 DEFAULT NULL,
1883      p_arg38  IN VARCHAR2 DEFAULT NULL, p_arg39  IN VARCHAR2 DEFAULT NULL,
1884      p_arg40  IN VARCHAR2 DEFAULT NULL, p_arg41  IN VARCHAR2 DEFAULT NULL,
1885      p_arg42  IN VARCHAR2 DEFAULT NULL, p_arg43  IN VARCHAR2 DEFAULT NULL,
1886      p_arg44  IN VARCHAR2 DEFAULT NULL, p_arg45  IN VARCHAR2 DEFAULT NULL,
1887      p_arg46  IN VARCHAR2 DEFAULT NULL, p_arg47  IN VARCHAR2 DEFAULT NULL,
1888      p_arg48  IN VARCHAR2 DEFAULT NULL, p_arg49  IN VARCHAR2 DEFAULT NULL,
1889      p_arg50  IN VARCHAR2 DEFAULT NULL, p_arg51  IN VARCHAR2 DEFAULT NULL,
1890      p_arg52  IN VARCHAR2 DEFAULT NULL, p_arg53  IN VARCHAR2 DEFAULT NULL,
1891      p_arg54  IN VARCHAR2 DEFAULT NULL, p_arg55  IN VARCHAR2 DEFAULT NULL,
1892      p_arg56  IN VARCHAR2 DEFAULT NULL, p_arg57  IN VARCHAR2 DEFAULT NULL,
1893      p_arg58  IN VARCHAR2 DEFAULT NULL, p_arg59  IN VARCHAR2 DEFAULT NULL,
1894      p_arg60  IN VARCHAR2 DEFAULT NULL, p_arg61  IN VARCHAR2 DEFAULT NULL,
1895      p_arg62  IN VARCHAR2 DEFAULT NULL, p_arg63  IN VARCHAR2 DEFAULT NULL,
1896      p_arg64  IN VARCHAR2 DEFAULT NULL, p_arg65  IN VARCHAR2 DEFAULT NULL,
1897      p_arg66  IN VARCHAR2 DEFAULT NULL, p_arg67  IN VARCHAR2 DEFAULT NULL,
1898      p_arg68  IN VARCHAR2 DEFAULT NULL, p_arg69  IN VARCHAR2 DEFAULT NULL,
1899      p_arg70  IN VARCHAR2 DEFAULT NULL, p_arg71  IN VARCHAR2 DEFAULT NULL,
1900      p_arg72  IN VARCHAR2 DEFAULT NULL, p_arg73  IN VARCHAR2 DEFAULT NULL,
1901      p_arg74  IN VARCHAR2 DEFAULT NULL, p_arg75  IN VARCHAR2 DEFAULT NULL,
1902      p_arg76  IN VARCHAR2 DEFAULT NULL, p_arg77  IN VARCHAR2 DEFAULT NULL,
1903      p_arg78  IN VARCHAR2 DEFAULT NULL, p_arg79  IN VARCHAR2 DEFAULT NULL,
1904      p_arg80  IN VARCHAR2 DEFAULT NULL, p_arg81  IN VARCHAR2 DEFAULT NULL,
1905      p_arg82  IN VARCHAR2 DEFAULT NULL, p_arg83  IN VARCHAR2 DEFAULT NULL,
1906      p_arg84  IN VARCHAR2 DEFAULT NULL, p_arg85  IN VARCHAR2 DEFAULT NULL,
1907      p_arg86  IN VARCHAR2 DEFAULT NULL, p_arg87  IN VARCHAR2 DEFAULT NULL,
1908      p_arg88  IN VARCHAR2 DEFAULT NULL, p_arg89  IN VARCHAR2 DEFAULT NULL,
1909      p_arg90  IN VARCHAR2 DEFAULT NULL, p_arg91  IN VARCHAR2 DEFAULT NULL,
1910      p_arg92  IN VARCHAR2 DEFAULT NULL, p_arg93  IN VARCHAR2 DEFAULT NULL,
1911      p_arg94  IN VARCHAR2 DEFAULT NULL, p_arg95  IN VARCHAR2 DEFAULT NULL,
1912      p_arg96  IN VARCHAR2 DEFAULT NULL, p_arg97  IN VARCHAR2 DEFAULT NULL,
1913      p_arg98  IN VARCHAR2 DEFAULT NULL, p_arg99  IN VARCHAR2 DEFAULT NULL,
1914      p_arg100 IN VARCHAR2 DEFAULT NULL
1915      )
1916  IS
1917  l_module_name    VARCHAR2(200) := G_PKG_NAME
1918                                        || '.build_printed_instructions';
1919  BEGIN
1920 
1921      print_debuginfo(l_module_name, 'ENTER');
1922 
1923      build_pmt_instructions(
1924          x_errbuf,
1925          x_retcode,
1926 
1927          /*-- processing criteria --*/
1928          p_processing_type,
1929          p_payment_profile_id,
1930          p_pmt_document_id,
1931          p_internal_bank_account_id,
1932          p_print_now_flag,
1933          p_printer_name,
1934          p_payment_currency,
1935          NULL,                  -- p_transmit_now_flag
1936 
1937          /*-- user/admin assigned criteria --*/
1938          p_admin_assigned_ref,
1939          p_comments,
1940 
1941          /*-- selection criteria --*/
1942          p_calling_app_id,
1943          p_calling_app_payreq_cd,
1944          p_le_id,
1945          p_org_id,
1946          p_org_type,
1947          p_payment_from_date,
1948          p_payment_to_date
1949          );
1950 
1951      print_debuginfo(l_module_name, 'EXIT');
1952 
1953  END build_printed_instructions;
1954 
1955 END IBY_BUILD_INSTRUCTIONS_PUB_PKG;