DBA Data[Home] [Help]

PACKAGE BODY: APPS.PO_ONLINE_REPORT

Source


1 PACKAGE BODY PO_ONLINE_REPORT AS
2 /* $Header: POXPOONB.pls 115.6 2002/11/25 22:40:04 sbull ship $ */
3 
4   -- Types :
5   --
6 
7   -- Constants :
8   -- This is used as a delimiter in the Debug Info String
9 
10   g_delim                   CONSTANT VARCHAR2(1) := '
11 ';
12 
13 
14   -- Private Global Variables :
15   --
16 
17   -- Debug String
18 
19   g_dbug                    VARCHAR2(200) := null;
20 
21 
22 /* ----------------------------------------------------------------------- */
23 /*                                                                         */
24 /*                      Private Function Definition                        */
25 /*                                                                         */
26 /* ----------------------------------------------------------------------- */
27 
28   FUNCTION online_finsert(p_docid       IN     NUMBER,
29                           p_doctyp      IN     VARCHAR2,
30                           p_docsubtyp   IN     VARCHAR2,
31                           p_lineid      IN     NUMBER,
32                           p_shipid      IN     NUMBER,
33                           p_message     IN     VARCHAR2,
34                           p_reportid    IN     NUMBER,
35                           p_numtokens   IN     NUMBER,
36                           p_sqlstring   IN     VARCHAR2,
37                           p_sequence    IN     NUMBER,
38                           p_action_date IN     DATE,
39                           p_return_code IN OUT NOCOPY VARCHAR2) RETURN BOOLEAN;
40 
41 
42   FUNCTION online_sinsert(p_docid       IN     NUMBER,
43                           p_doctyp      IN     VARCHAR2,
44                           p_docsubtyp   IN     VARCHAR2,
45                           p_lineid      IN     NUMBER,
46                           p_shipid      IN     NUMBER,
47                           p_message     IN     VARCHAR2,
48                           p_reportid    IN     NUMBER,
49                           p_numtokens   IN     NUMBER,
50                           p_sqlstring   IN     VARCHAR2,
51                           p_sequence    IN     NUMBER,
52                           p_action_date IN     DATE,
53                           p_return_code IN OUT NOCOPY VARCHAR2) RETURN BOOLEAN;
54 
55 
56 /* ----------------------------------------------------------------------- */
57 /*                                                                         */
58 /*   Determines how Multiple Inserts into the Online Reporting table are   */
59 /*   to be handled                                                         */
60 /*                                                                         */
61 /*   Multiple Inserts are handled differently for Messages with Tokens and */
62 /*   Messages without Tokens                                               */
63 /*                                                                         */
64 /*   For Messages with Tokens, Inserts are done using Array Fetch          */
65 /*                                                                         */
66 /*   For Messages without Tokens, Inserts are done using a Subquery        */
67 /*                                                                         */
68 /* ----------------------------------------------------------------------- */
69 
70   -- Parameters :
71 
72   -- p_docid : Header ID
73 
74   -- p_doctyp : Document Type
75 
76   -- p_docsubtyp : Document Subtype
77 
78   -- p_lineid : Line ID
79 
80   -- p_shipid : Shipment ID
81 
82   -- p_message : Message Name
83 
84   -- p_reportid : Online Reporting ID
85 
86   -- p_numtokens : Number of Tokens
87 
88   -- p_sqlstring : SQL String
89 
90   -- p_sequence : Sequence
91 
92   -- p_action_date : Action Date
93 
94   -- p_return_code : Return Code
95 
96   FUNCTION insert_many(p_docid       IN     NUMBER,
97                        p_doctyp      IN     VARCHAR2,
98                        p_docsubtyp   IN     VARCHAR2,
99                        p_lineid      IN     NUMBER,
100                        p_shipid      IN     NUMBER,
101                        p_message     IN     VARCHAR2,
102                        p_reportid    IN     NUMBER,
103                        p_numtokens   IN     NUMBER,
104                        p_sqlstring   IN     VARCHAR2,
105                        p_sequence    IN     NUMBER,
106                        p_action_date IN     DATE,
107                        p_return_code IN OUT NOCOPY VARCHAR2) RETURN BOOLEAN IS
108 
109   BEGIN
110 
111     g_dbug := 'Starting Online Insert' || g_delim;
112 
113     if p_numtokens <> 0 then
114 
115       if not online_finsert(p_docid => p_docid,
116                             p_doctyp => p_doctyp,
117                             p_docsubtyp => p_docsubtyp,
118                             p_lineid => p_lineid,
119                             p_shipid => p_shipid,
120                             p_message => p_message,
121                             p_reportid => p_reportid,
122                             p_numtokens => p_numtokens,
123                             p_sqlstring => p_sqlstring,
124                             p_sequence => p_sequence,
125                             p_action_date => p_action_date,
126                             p_return_code => p_return_code) then
127 
128         PO_MESSAGE_S.APP_ERROR(error_name => 'PO_ALL_TRACE_ERROR',
129                                token1 => 'FILE',
130                                value1 => 'PO_ONLINE_REPORT',
131                                token2 => 'ERR_NUMBER',
132                                value2 => '005',
133                                token3 => 'SUBROUTINE',
134                                value3 => 'INSERT_MANY()');
135         return(FALSE);
136 
137       end if;
138 
139     else
140 
141       if not online_sinsert(p_docid => p_docid,
142                             p_doctyp => p_doctyp,
143                             p_docsubtyp => p_docsubtyp,
144                             p_lineid => p_lineid,
145                             p_shipid => p_shipid,
146                             p_message => p_message,
147                             p_reportid => p_reportid,
148                             p_numtokens => p_numtokens,
149                             p_sqlstring => p_sqlstring,
150                             p_sequence => p_sequence,
151                             p_action_date => p_action_date,
152                             p_return_code => p_return_code) then
153 
154         PO_MESSAGE_S.APP_ERROR(error_name => 'PO_ALL_TRACE_ERROR',
155                                token1 => 'FILE',
156                                value1 => 'PO_ONLINE_REPORT',
157                                token2 => 'ERR_NUMBER',
158                                value2 => '010',
159                                token3 => 'SUBROUTINE',
160                                value3 => 'INSERT_MANY()');
161         return(FALSE);
162 
163       end if;
164 
165     end if;
166 
167     return(TRUE);
168 
169 
170   EXCEPTION
171 
172     WHEN OTHERS THEN
173 
174       PO_MESSAGE_S.SQL_ERROR(routine => 'PO_ONLINE_REPORT',
175                              location => '015',
176                              error_code => SQLCODE);
177 
178       return(FALSE);
179 
180   END insert_many;
181 
182 /* ----------------------------------------------------------------------- */
183 /*                                                                         */
184 /*   Determines how Single Inserts into the Online Reporting table are     */
185 /*   to be handled                                                         */
186 /*                                                                         */
187 /* ----------------------------------------------------------------------- */
188 
189   -- Parameters :
190 
191   -- p_linenum : Line ID
192 
193   -- p_shipnum : Shipment ID
194 
195   -- p_distnum : Distribution ID
196 
197   -- p_message : Message Name
198 
199   -- p_reportid : Online Reporting ID
200 
201   -- p_sequence : Sequence
202 
203   -- p_return_code : Return Code
204 
205   FUNCTION insert_single(p_linenum     IN     NUMBER,
206                          p_shipnum     IN     NUMBER,
207                          p_distnum     IN     NUMBER,
208                          p_message     IN     VARCHAR2,
209                          p_reportid    IN     NUMBER,
210                          p_sequence    IN     NUMBER,
211                          p_return_code IN OUT NOCOPY VARCHAR2) RETURN BOOLEAN IS
212 
213     l_userid     po_lines.last_updated_by%TYPE;
214     l_loginid    po_lines.last_update_login%TYPE;
215     l_textline   po_online_report_text.text_line%TYPE;
216 
217     l_shipmsg    VARCHAR2(25);
218     l_linemsg    VARCHAR2(25);
219     l_tokennam1  VARCHAR2(10);
220     l_tokennam2  VARCHAR2(10);
221     l_tokennam3  VARCHAR2(10);
222     l_tokennam4  VARCHAR2(10);
223 
224   BEGIN
225 
226     g_dbug := 'Starting Online Insert' || g_delim;
227 
228 
229     -- Get User ID and Login ID
230 
231     l_userid := FND_GLOBAL.USER_ID;
232 
233     if l_userid = -1 then
234 
235       PO_MESSAGE_S.APP_ERROR(error_name => 'PO_ALL_TRACE_ERROR_WITH_MSG',
236                              token1 => 'FILE',
237                              value1 => 'PO_ONLINE_REPORT',
238                              token2 => 'ERR_NUMBER',
239                              value2 => '020',
240                              token3 => 'SUBROUTINE',
241                              value3 => 'INSERT_SINGLE()',
242                              token4 => 'ERROR_MSG',
243                              value4 => 'CANNOT FIND USER ID');
244       return(FALSE);
245 
246     end if;
247 
248 -- FRKHAN: BUG 747290 Get concurrent login id
249 -- if there is one else get login id
250 
251     if (FND_GLOBAL.CONC_LOGIN_ID >= 0) then
252        l_loginid := FND_GLOBAL.CONC_LOGIN_ID;
253     else
254        l_loginid := FND_GLOBAL.LOGIN_ID;
255     end if;
256 
257     if l_loginid = -1 then
258 
259       PO_MESSAGE_S.APP_ERROR(error_name => 'PO_ALL_TRACE_ERROR_WITH_MSG',
260                              token1 => 'FILE',
261                              value1 => 'PO_ONLINE_REPORT',
262                              token2 => 'ERR_NUMBER',
263                              value2 => '025',
264                              token3 => 'SUBROUTINE',
265                              value3 => 'INSERT_SINGLE()',
266                              token4 => 'ERROR_MSG',
267                              value4 => 'CANNOT FIND LAST LOGIN ID');
268       return(FALSE);
269 
270     end if;
271 
272 
273     -- Get Message from the Message Dictionary
274 
275     l_textline := FND_MESSAGE.GET_STRING('PO', p_message);
276 
277 
278     -- Setup Headings for the Text Line that is displayed. Headings include
279     -- Line #, Shipment #, if they are passed in. Perform Token Substitution
280     -- for the Line and Shipment #s
281 
282     if ((p_linenum <> 0) and
283         (p_shipnum <> 0)) then
284 
285       l_shipmsg := substr(FND_MESSAGE.GET_STRING('PO', 'PO_ZMVOR_SHIPMENT'), 1,
286                           25);
287 
288       l_linemsg := substr(FND_MESSAGE.GET_STRING('PO', 'PO_ZMVOR_LINE'), 1, 25);
289 
290     end if;
291 
292     l_tokennam1 := '&' || 'LINE';
293     l_tokennam2 := '&' || 'LINE1';
294     l_tokennam3 := '&' || 'SHIP';
295     l_tokennam4 := '&' || 'SHIP1';
296 
297     l_textline := replace(l_textline, l_tokennam1, l_linemsg);
298     l_textline := replace(l_textline, l_tokennam2, p_linenum);
299     l_textline := replace(l_textline, l_tokennam3, l_shipmsg);
300     l_textline := replace(l_textline, l_tokennam4, p_shipnum);
301 
302     insert into po_online_report_text(online_report_id,
303                                       last_update_login,
304                                       last_updated_by,
305                                       last_update_date,
306                                       created_by,
307                                       creation_date,
308                                       line_num,
309                                       shipment_num,
310                                       distribution_num,
311                                       sequence,
312                                       text_line)
313                               values (p_reportid,
314                                       l_loginid,
315                                       l_userid,
316                                       sysdate,
317                                       l_userid,
318                                       sysdate,
319                                       p_linenum,
320                                       p_shipnum,
321                                       p_distnum,
322                                       p_sequence,
323                                       l_textline);
324 
325     if not SQL%NOTFOUND then
326 
327       g_dbug := g_dbug ||
328                 'Inserted into Online Report table' || g_delim;
329 
330       if nvl(p_return_code, 'X') <> 'SUBMISSION_FAILED' then
331         p_return_code := 'SUBMISSION_FAILED';
332       end if;
333 
334     end if;
335 
336     return(TRUE);
337 
338 
339   EXCEPTION
340 
341     WHEN OTHERS THEN
342 
343       PO_MESSAGE_S.SQL_ERROR(routine => 'PO_ONLINE_REPORT',
344                              location => '030',
345                              error_code => SQLCODE);
346 
347       return(FALSE);
348 
349   END insert_single;
350 
351 /* ----------------------------------------------------------------------- */
352 
353   -- Insert into the Online Reporting table using Array Fetch
354 
355   FUNCTION online_finsert(p_docid       IN     NUMBER,
356                           p_doctyp      IN     VARCHAR2,
357                           p_docsubtyp   IN     VARCHAR2,
358                           p_lineid      IN     NUMBER,
359                           p_shipid      IN     NUMBER,
360                           p_message     IN     VARCHAR2,
361                           p_reportid    IN     NUMBER,
362                           p_numtokens   IN     NUMBER,
363                           p_sqlstring   IN     VARCHAR2,
364                           p_sequence    IN     NUMBER,
365                           p_action_date IN     DATE,
366                           p_return_code IN OUT NOCOPY VARCHAR2) RETURN BOOLEAN IS
367 
368     l_docid      po_lines.line_num%TYPE;
369     l_linenum    po_lines.line_num%TYPE;
370     l_shipnum    po_line_locations.shipment_num%TYPE;
371     l_distnum    po_distributions.distribution_num%TYPE;
372     l_tokenval1  po_distributions.quantity_delivered%TYPE;
373     l_tokenval2  po_line_locations.quantity%TYPE;
374     l_userid     po_lines.last_updated_by%TYPE;
375     l_loginid    po_lines.last_update_login%TYPE;
376     l_textline   po_online_report_text.text_line%TYPE;
377 
378     l_tokennam1  VARCHAR2(10);
379     l_tokennam2  VARCHAR2(10);
380     l_message    VARCHAR2(2000);
381     l_distmsg    VARCHAR2(25);
382     l_shipmsg    VARCHAR2(25);
383     l_linemsg    VARCHAR2(25);
384 
385     cur_insert   INTEGER;
386     num_insert   INTEGER;
387 
388     l_found      BOOLEAN := FALSE;
389 
390   BEGIN
391 
392     if p_shipid <> 0 then
393 
394       l_docid := p_shipid;
395 
396     elsif p_lineid <> 0 then
397 
398       l_docid := p_lineid;
399 
400     else
401 
402       l_docid := p_docid;
403 
404     end if;
405 
406     g_dbug := g_dbug ||
407               'Doc ID:' || l_docid || g_delim;
408 
409 
410     -- Get User ID and Login ID
411 
412     l_userid := FND_GLOBAL.USER_ID;
413 
414     if l_userid = -1 then
415 
419                              token2 => 'ERR_NUMBER',
416       PO_MESSAGE_S.APP_ERROR(error_name => 'PO_ALL_TRACE_ERROR_WITH_MSG',
417                              token1 => 'FILE',
418                              value1 => 'PO_ONLINE_REPORT',
420                              value2 => '035',
421                              token3 => 'SUBROUTINE',
422                              value3 => 'ONLINE_FINSERT()',
423                              token4 => 'ERROR_MSG',
424                              value4 => 'CANNOT FIND USER ID');
425       return(FALSE);
426 
427     end if;
428 
429 -- FRKHAN: BUG 747290 Get concurrent login id
430 -- if there is one else get login id
431 
432     if (FND_GLOBAL.CONC_LOGIN_ID >= 0) then
433        l_loginid := FND_GLOBAL.CONC_LOGIN_ID;
434     else
435        l_loginid := FND_GLOBAL.LOGIN_ID;
436     end if;
437 
438     if l_loginid = -1 then
439 
440       PO_MESSAGE_S.APP_ERROR(error_name => 'PO_ALL_TRACE_ERROR_WITH_MSG',
441                              token1 => 'FILE',
442                              value1 => 'PO_ONLINE_REPORT',
443                              token2 => 'ERR_NUMBER',
444                              value2 => '040',
445                              token3 => 'SUBROUTINE',
446                              value3 => 'ONLINE_FINSERT()',
447                              token4 => 'ERROR_MSG',
448                              value4 => 'CANNOT FIND LAST LOGIN ID');
449       return(FALSE);
450 
451     end if;
452 
453 
454     -- Setup a portion of the displayed text line
455 
456     l_distmsg := substr(FND_MESSAGE.GET_STRING('PO', 'PO_ZMVOR_DISTRIBUTION'),
457                         1, 25);
458 
459     l_shipmsg := substr(FND_MESSAGE.GET_STRING('PO', 'PO_ZMVOR_SHIPMENT'),
460                         1, 25);
461 
462     l_linemsg := substr(FND_MESSAGE.GET_STRING('PO', 'PO_ZMVOR_LINE'), 1, 25);
463 
464     l_message := FND_MESSAGE.GET_STRING('PO', p_message);
465 
466     l_tokennam1 := '&' || 'QTY1';
467     l_tokennam2 := '&' || 'QTY2';
468 
469     -- Setup the SQL Statement
470 
471     cur_insert := dbms_sql.open_cursor;
472     dbms_sql.parse(cur_insert, p_sqlstring, dbms_sql.v7);
473 
474     dbms_sql.bind_variable(cur_insert, 'docid', l_docid);
475 
476     dbms_sql.define_column(cur_insert, 1, l_linenum);
477     dbms_sql.define_column(cur_insert, 2, l_shipnum);
478     dbms_sql.define_column(cur_insert, 3, l_distnum);
479     dbms_sql.define_column(cur_insert, 4, l_tokenval1);
480     dbms_sql.define_column(cur_insert, 5, l_tokenval2);
481 
482     num_insert := dbms_sql.execute(cur_insert);
483 
484     loop
485 
486       if dbms_sql.fetch_rows(cur_insert) > 0 then
487 
488         dbms_sql.column_value(cur_insert, 1, l_linenum);
489         dbms_sql.column_value(cur_insert, 2, l_shipnum);
490         dbms_sql.column_value(cur_insert, 3, l_distnum);
491         dbms_sql.column_value(cur_insert, 4, l_tokenval1);
492         dbms_sql.column_value(cur_insert, 5, l_tokenval2);
493 
494         l_message := replace(l_message, l_tokennam1, l_tokenval1);
495         l_message := replace(l_message, l_tokennam2, l_tokenval2);
496 
497         if l_distnum >= 1 then
498 
499           if p_doctyp <> 'RELEASE' then
500             l_textline := l_linemsg || l_linenum;
501           end if;
502 
503           l_textline := l_textline ||
504                         l_shipmsg || l_shipnum ||
505                         l_distmsg || l_distnum || l_message;
506 
507         elsif l_shipnum >= 1 then
508 
509           if p_doctyp <> 'RELEASE' then
510             l_textline := l_linemsg || l_linenum;
511           end if;
512 
513           l_textline := l_textline ||
514                         l_shipmsg || l_shipnum || l_message;
515 
516         elsif l_linenum >= 1 then
517           l_textline := l_linemsg || l_linenum || l_message;
518         else
519           l_textline := l_message;
520         end if;
521 
522         insert into po_online_report_text
523                    (online_report_id,
524                     last_update_login,
525                     last_updated_by,
526                     last_update_date,
527                     created_by,
528                     creation_date,
529                     line_num,
530                     shipment_num,
531                     distribution_num,
532                     sequence,
533                     text_line)
534             values (p_reportid,
535                     l_loginid,
536                     l_userid,
537                     sysdate,
538                     l_userid,
539                     sysdate,
540                     l_linenum,
541                     l_shipnum,
542                     l_distnum,
543                     p_sequence,
544                     l_textline);
545 
546         l_found := TRUE;
547 
548       else
549         exit;
550       end if;
551 
552     end loop;
553 
554     dbms_sql.close_cursor(cur_insert);
555 
556     if l_found then
557 
558       g_dbug := g_dbug ||
559                 'Inserted into Online Report table' || g_delim;
560 
561       if nvl(p_return_code, 'X') <> 'SUBMISSION_FAILED' then
562         p_return_code := 'SUBMISSION_FAILED';
563       end if;
564 
565     end if;
566 
567     return(TRUE);
568 
569 
570   EXCEPTION
571 
572     WHEN OTHERS THEN
573 
574       if dbms_sql.is_open(cur_insert) then
578       PO_MESSAGE_S.SQL_ERROR(routine => 'PO_ONLINE_REPORT',
575         dbms_sql.close_cursor(cur_insert);
576       end if;
577 
579                              location => '045',
580                              error_code => SQLCODE);
581 
582       return(FALSE);
583 
584   END online_finsert;
585 
586 /* ----------------------------------------------------------------------- */
587 
588   -- Insert into the Online Reporting table using Subquery
589 
590   FUNCTION online_sinsert(p_docid       IN     NUMBER,
591                           p_doctyp      IN     VARCHAR2,
592                           p_docsubtyp   IN     VARCHAR2,
593                           p_lineid      IN     NUMBER,
594                           p_shipid      IN     NUMBER,
595                           p_message     IN     VARCHAR2,
596                           p_reportid    IN     NUMBER,
597                           p_numtokens   IN     NUMBER,
598                           p_sqlstring   IN     VARCHAR2,
599                           p_sequence    IN     NUMBER,
600                           p_action_date IN     DATE,
601                           p_return_code IN OUT NOCOPY VARCHAR2) RETURN BOOLEAN IS
602 
603     l_docid     po_lines.line_num%TYPE;
604     l_userid    po_lines.last_updated_by%TYPE;
605     l_loginid   po_lines.last_update_login%TYPE;
606     l_textline  po_online_report_text.text_line%TYPE;
607 
608     l_distmsg   VARCHAR2(25);
609     l_shipmsg   VARCHAR2(25);
610     l_linemsg   VARCHAR2(25);
611 
612     sql_insert  VARCHAR2(1200);
613     cur_insert  INTEGER;
614     num_insert  INTEGER;
615 
616     l_found     BOOLEAN := FALSE;
617 
618   BEGIN
619 
620     if p_shipid <> 0 then
621 
622       l_docid := p_shipid;
623 
624     elsif p_lineid <> 0 then
625 
626       l_docid := p_lineid;
627 
628     else
629 
630       l_docid := p_docid;
631 
632     end if;
633 
634     g_dbug := g_dbug ||
635               'Doc ID:' || l_docid || g_delim;
636 
637 
638     -- Get User ID and Login ID
639 
640     l_userid := FND_GLOBAL.USER_ID;
641 
642     if l_userid = -1 then
643 
644       PO_MESSAGE_S.APP_ERROR(error_name => 'PO_ALL_TRACE_ERROR_WITH_MSG',
645                              token1 => 'FILE',
646                              value1 => 'PO_ONLINE_REPORT',
647                              token2 => 'ERR_NUMBER',
648                              value2 => '050',
649                              token3 => 'SUBROUTINE',
650                              value3 => 'ONLINE_SINSERT()',
651                              token4 => 'ERROR_MSG',
652                              value4 => 'CANNOT FIND USER ID');
653       return(FALSE);
654 
655     end if;
656 
657 -- FRKHAN: BUG 747290 Get concurrent login id
658 -- if there is one else get login id
659 
660     if (FND_GLOBAL.CONC_LOGIN_ID >= 0) then
661        l_loginid := FND_GLOBAL.CONC_LOGIN_ID;
662     else
663        l_loginid := FND_GLOBAL.LOGIN_ID;
664     end if;
665 
666     if l_loginid = -1 then
667 
668       PO_MESSAGE_S.APP_ERROR(error_name => 'PO_ALL_TRACE_ERROR_WITH_MSG',
669                              token1 => 'FILE',
670                              value1 => 'PO_ONLINE_REPORT',
671                              token2 => 'ERR_NUMBER',
672                              value2 => '055',
673                              token3 => 'SUBROUTINE',
674                              value3 => 'ONLINE_SINSERT()',
675                              token4 => 'ERROR_MSG',
676                              value4 => 'CANNOT FIND LAST LOGIN ID');
677       return(FALSE);
678 
679     end if;
680 
681 
682     -- Setup a portion of the displayed text line
683 
684     l_distmsg := substr(FND_MESSAGE.GET_STRING('PO', 'PO_ZMVOR_DISTRIBUTION'),
685                         1, 25);
686 
687     l_shipmsg := substr(FND_MESSAGE.GET_STRING('PO', 'PO_ZMVOR_SHIPMENT'),
688                         1, 25);
689 
690     l_linemsg := substr(FND_MESSAGE.GET_STRING('PO', 'PO_ZMVOR_LINE'), 1, 25);
691 
692     l_textline := FND_MESSAGE.GET_STRING('PO', p_message);
693 
694 
695     -- Setup the SQL Statement
696 
697     sql_insert := 'insert into po_online_report_text ' ||
698                          '(online_report_id, ' ||
699                           'last_update_login, ' ||
700                           'last_updated_by, ' ||
701                           'last_update_date, ' ||
702                           'created_by, ' ||
703                           'creation_date, ' ||
704                           'line_num, ' ||
705                           'shipment_num, ' ||
706                           'distribution_num, ' ||
707                           'sequence, ' ||
708                           'text_line) ';
709 
710     sql_insert := sql_insert ||
711                   p_sqlstring;
712 
713     cur_insert := dbms_sql.open_cursor;
714     dbms_sql.parse(cur_insert, sql_insert, dbms_sql.v7);
715 
716     dbms_sql.bind_variable(cur_insert, 'online_report_id', p_reportid);
717     dbms_sql.bind_variable(cur_insert, 'last_update_login', l_loginid);
718     dbms_sql.bind_variable(cur_insert, 'last_user_id', l_userid);
719     dbms_sql.bind_variable(cur_insert, 'sequence', p_sequence);
720     dbms_sql.bind_variable(cur_insert, 'msg_text', l_textline);
721     dbms_sql.bind_variable(cur_insert, 'docid', l_docid);
722 
723     -- Conditional Bind Variables
724 
725     if INSTR(sql_insert, ':line_heading', 1) > 0 then
726       dbms_sql.bind_variable(cur_insert, 'line_heading', l_linemsg);
727     end if;
728 
729     if INSTR(sql_insert, ':ship_heading', 1) > 0 then
730       dbms_sql.bind_variable(cur_insert, 'ship_heading', l_shipmsg);
731     end if;
732 
733     if INSTR(sql_insert, ':dist_heading', 1) > 0 then
734       dbms_sql.bind_variable(cur_insert, 'dist_heading', l_distmsg);
735     end if;
736 
737     if INSTR(sql_insert, ':action_date', 1) > 0 then
738       dbms_sql.bind_variable(cur_insert, 'action_date', p_action_date);
739     end if;
740 
741     num_insert := dbms_sql.execute(cur_insert);
742 
743     dbms_sql.close_cursor(cur_insert);
744 
745     if num_insert <> 0 then
746 
747       g_dbug := g_dbug ||
748                 'Inserted ' || num_insert || ' Records from online_sinsert' ||
749                 g_delim;
750 
751       if nvl(p_return_code, 'X') <> 'SUBMISSION_FAILED' then
752         p_return_code := 'SUBMISSION_FAILED';
753       end if;
754 
755     end if;
756 
757     return(TRUE);
758 
759 
760   EXCEPTION
761 
762     WHEN OTHERS THEN
763 
764       if dbms_sql.is_open(cur_insert) then
765         dbms_sql.close_cursor(cur_insert);
766       end if;
767 
768       PO_MESSAGE_S.SQL_ERROR(routine => 'PO_ONLINE_REPORT',
769                              location => '060',
770                              error_code => SQLCODE);
771 
772       return(FALSE);
773 
774   END online_sinsert;
775 
776 /* ----------------------------------------------------------------------- */
777 
778   -- Get Debug Information
779 
780   -- This Module is used to retrieve Debug Information for the Routines. It
781   -- prints Debug Information when run as a Batch Process from SQL*Plus. For
782   -- the Debug Information to be printed on the Screen, the SQL*Plus parameter
783   -- 'Serveroutput' should be set to 'ON'
784 
785   FUNCTION get_debug RETURN VARCHAR2 IS
786 
787   BEGIN
788 
789     return(g_dbug);
790 
791   END get_debug;
792 
793 /* ----------------------------------------------------------------------- */
794 
795 END PO_ONLINE_REPORT;
796