DBA Data[Home] [Help]

PACKAGE BODY: APPS.BIS_PORTLET_PMREGION

Source


1 package body BIS_PORTLET_PMREGION as
2 /* $Header: BISPPMRB.pls 120.2 2005/11/11 04:45:16 visuri noship $ */
3 
4 /* Customization tables
5 ICX_PORTLET_CUSTOMIZATIONS -- This will be available for anyone to use
6  REFERENCE_PATH                  NOT NULL VARCHAR2(1000)
7  PLUG_ID                                  NUMBER -- Not use in this portlet
8  APPLICATION_ID                           NUMBER
9  RESPONSIBILITY_ID                        NUMBER
10  SECURITY_GROUP_ID                        NUMBER
11  CACHING_KEY                              VARCHAR2(550)
12  TITLE                                    VARCHAR2(1000)
13 
14 BIS_USER_IND_SELECTIONS
15 */
16 --===========================================================
17 -- 12-DEC-01 juwang   modified for showing pre-seeded portlet
18 --===========================================================
19 
20 --===========================================================
21 -- private function
22 --===========================================================
23 
24 
25 
26 --============================================================
27 FUNCTION draw_portlet_header(
28   p_status_lbl  IN VARCHAR2
29  ,p_measure_lbl IN VARCHAR2
30  ,p_value_lbl IN VARCHAR2
31  ,p_change_lbl  IN VARCHAR2
32  ) RETURN VARCHAR2;
33 
34 
35 --============================================================
36 FUNCTION draw_portlet_footer RETURN VARCHAR2;
37 
38 
39 --============================================================
40 FUNCTION draw_status(
41   p_status_lbl IN VARCHAR2
42  ,p_row_style IN VARCHAR2
43  ,p_actual_val IN NUMBER
44  ,p_target_val IN NUMBER
45  ,p_range1_low_pcnt IN NUMBER
46  ,p_range1_high_pcnt IN NUMBER
47 ) RETURN VARCHAR2;
48 
49 --============================================================
50 FUNCTION draw_status(
51   p_status_lbl IN VARCHAR2
52  ,p_status IN NUMBER
53  ,p_row_style IN VARCHAR2
54  ) RETURN VARCHAR2;
55 
56 --============================================================
57 FUNCTION draw_measure_name(
58   p_actual_url IN VARCHAR2
59  ,p_label IN VARCHAR2
60  ,p_measure_lbl IN VARCHAR2
61  ,p_row_style IN VARCHAR2
62  ) RETURN VARCHAR2;
63 
64 --============================================================
65 FUNCTION draw_actual(
66   p_value_lbl IN VARCHAR2
67  ,p_formatted_actual IN VARCHAR2
68  ,p_row_style IN VARCHAR2
69  ,p_is_auth IN BOOLEAN DEFAULT TRUE
70  ) RETURN VARCHAR2;
71 
72 
73 
74 --============================================================
75 FUNCTION draw_change(
76   p_change_lbl IN VARCHAR2
77  ,p_change IN VARCHAR2
78  ,p_img IN VARCHAR2
79  ,p_arrow_alt_text IN VARCHAR2
80  ,p_row_style IN VARCHAR2
81 ) RETURN VARCHAR2;
82 
83 
84 
85 --============================================================
86 PROCEDURE display_demo_portlet(
87   p_session_id in NUMBER
88  ,p_plug_id    in pls_integer
89  ,p_user_id    in integer
90  ,x_html_buffer OUT NOCOPY VARCHAR2
91  ,x_html_clob OUT NOCOPY CLOB
92 );
93 
94 
95 
96 --===========================================================
97 FUNCTION get_image(
98   p_arrow_type IN NUMBER
99  ,p_worse_msg IN VARCHAR2
100  ,p_improve_msg IN VARCHAR2
101  ,p_arrow_alt_text OUT NOCOPY VARCHAR2
102 ) RETURN VARCHAR2;
103 
104 
105 --===========================================================
106 PROCEDURE delete_all_demo_rows(
107   p_plug_id IN NUMBER
108 );
109 
110 
111 --===========================================================
112 PROCEDURE show_cust_demo_url(
113   p_plug_id IN PLS_INTEGER
114  ,p_session_id IN PLS_INTEGER
115 );
116 
117 
118 --===========================================================
119 PROCEDURE get_actual(
120   p_target_rec IN BIS_TARGET_PUB.Target_Rec_Type
121  ,x_actual_url OUT NOCOPY VARCHAR2
122  ,x_actual_value OUT NOCOPY NUMBER
123  ,x_comparison_actual_value OUT NOCOPY NUMBER
124  ,x_err OUT NOCOPY VARCHAR2
125 );
126 
127 
128 --============================================================
129 PROCEDURE get_target(
130   p_target_in IN  BIS_TARGET_PUB.Target_Rec_Type
131  ,x_target OUT NOCOPY NUMBER
132  ,x_range1_low OUT NOCOPY NUMBER
133  ,x_range1_high OUT NOCOPY NUMBER
134  ,x_range2_low OUT NOCOPY NUMBER
135  ,x_range2_high OUT NOCOPY NUMBER
136  ,x_range3_low OUT NOCOPY NUMBER
137  ,x_range3_high OUT NOCOPY NUMBER
138  ,x_err OUT NOCOPY VARCHAR2
139 );
140 
141 
142 
143 --===========================================================
144 PROCEDURE get_time_dim_index(
145   p_ind_selection_id  IN NUMBER
146  ,x_target_rec    IN OUT NOCOPY BIS_TARGET_PUB.Target_Rec_Type
147  ,x_err OUT NOCOPY  VARCHAR2
148 ) ;
149 
150 --=============================================================
151 PROCEDURE assign_time_level_value_id(
152   p_is_rolling_level    IN NUMBER,
153   p_current_period_id IN VARCHAR,
154   p_time_dim_idx  IN NUMBER,
155   p_target_rec    IN OUT NOCOPY BIS_TARGET_PUB.Target_Rec_Type
156 ) ;
157 
158 
159 --===========================================================
160 PROCEDURE get_change(
161   p_actual_value IN NUMBER
162  ,p_comp_actual_value IN NUMBER
163  ,p_comp_source IN VARCHAR2
164  ,p_good_bad IN VARCHAR2
165  ,p_improve_msg  IN VARCHAR2
166  ,p_worse_msg  IN VARCHAR2
167  ,x_change OUT NOCOPY NUMBER
168  ,x_img OUT NOCOPY VARCHAR2
169  ,x_arrow_alt_text IN OUT NOCOPY VARCHAR2
170  ,x_err OUT NOCOPY VARCHAR2
171 ) ;
172 
173 
174 
175 --============================================================
176 PROCEDURE draw_portlet_content(
177   p_plug_id   IN PLS_INTEGER
178  ,p_reference_path  IN VARCHAR2
179  ,x_html_buffer   OUT NOCOPY VARCHAR2
180  ,x_html_clob   OUT NOCOPY CLOB
181 );
182 
183 
184 --===========================================================
185 PROCEDURE append(
186   p_string  IN VARCHAR2
187  ,x_clob    IN OUT NOCOPY CLOB
188  ,x_buffer  IN OUT NOCOPY VARCHAR2
189 );
190 
191 
192 --===========================================================
193 -- end of private functions/procedures declarations.
194 --============================================================
195 G_PKG_NAME  CONSTANT VARCHAR2(30):='BIS_PORTLET_PMREGION';
196 c_NULL      CONSTANT pls_integer := -9999;
197 c_key_menu  CONSTANT VARCHAR2(30):= 'pMeasureDefinition=';
198 c_key_target_level  CONSTANT VARCHAR2(50):= 'pTargetLevelShortName';
199 c_key_plan  CONSTANT VARCHAR2(50):= 'pPlanShortName';
200 c_key_dv_id1 CONSTANT VARCHAR2(50):= 'pDimensionLevel1ValueId';
201 c_key_dv_id2 CONSTANT VARCHAR2(50):= 'pDimensionLevel2ValueId';
202 c_key_dv_id3 CONSTANT VARCHAR2(50):= 'pDimensionLevel3ValueId';
203 c_key_dv_id4 CONSTANT VARCHAR2(50):= 'pDimensionLevel4ValueId';
204 c_key_dv_id5 CONSTANT VARCHAR2(50):= 'pDimensionLevel5ValueId';
205 c_key_dv_id6 CONSTANT VARCHAR2(50):= 'pDimensionLevel6ValueId';
206 c_key_dv_id7 CONSTANT VARCHAR2(50):= 'pDimensionLevel7ValueId';
207 c_key_status CONSTANT VARCHAR2(50):= 'pStatus';
208 c_key_value CONSTANT VARCHAR2(50):= 'pActual';
209 c_key_change CONSTANT VARCHAR2(50):= 'pChange';
210 c_key_arrow CONSTANT VARCHAR2(50):= 'pArrow';
211 
212 c_arrow_type_green_up CONSTANT NUMBER := 1;
213 c_arrow_type_green_down CONSTANT NUMBER := 2;
214 c_arrow_type_red_up CONSTANT NUMBER := 3;
215 c_arrow_type_red_down CONSTANT NUMBER := 4;
216 c_arrow_type_black_up CONSTANT NUMBER := 5;
217 c_arrow_type_black_down CONSTANT NUMBER := 6;
218 
219 c_down_green CONSTANT VARCHAR2(200) := 'bischdog.gif"';
220 c_down_red   CONSTANT VARCHAR2(200) := 'bischdob.gif"';
221 c_down_black CONSTANT VARCHAR2(200) := 'bischdon.gif"';
222 c_up_green   CONSTANT VARCHAR2(200) := 'bischupg.gif"';
223 c_up_red     CONSTANT VARCHAR2(200) := 'bischupb.gif"';
224 c_up_black   CONSTANT VARCHAR2(200) := 'bischupn.gif"';
225 
226 
227 c_caret  CONSTANT VARCHAR2(1) := '^';
228 c_eq  CONSTANT VARCHAR2(1) := '=';
229 c_squote  CONSTANT VARCHAR2(2) := '''';
230 
231 
232 
233 -- bug#2172266
234 c_fmt CONSTANT VARCHAR2(10) := '990D99';
235 
236 c_longfmt CONSTANT VARCHAR2(30) := '999G990D99';
237 c_long_nod_fmt CONSTANT VARCHAR2(10) := '999G990';
238 c_I CONSTANT VARCHAR2(1) := 'I';
239 c_F CONSTANT VARCHAR2(1) := 'F';
240 c_K CONSTANT VARCHAR2(1) := 'K';
241 c_M CONSTANT VARCHAR2(1) := 'M';
242 c_B CONSTANT VARCHAR2(1) := 'B';
243 c_T CONSTANT VARCHAR2(1) := 'T';
244 -- !!! NLS Issue
245 c_thousand CONSTANT NUMBER := 1000;
246 c_million CONSTANT NUMBER := 1000000;
247 c_billion CONSTANT NUMBER := 1000000000;
248 c_trillion CONSTANT NUMBER := 1000000000000;
249 
250 
251 --===========================================================
252 -- end of change by juwang
253 --===========================================================
254 
255 
256 c_counter   CONSTANT pls_integer := 150;
257 G_HELP      VARCHAR2(32000) := 'BISPM';
258 
259 
260 c_OR        CONSTANT VARCHAR2(2) := '||';
261 c_asterisk  CONSTANT VARCHAR2(1) := '*';
262 c_at        CONSTANT VARCHAR2(1) := '@';
263 c_plus      CONSTANT VARCHAR2(1) := '+';
264 c_minus     CONSTANT VARCHAR2(1) := '-';
265 c_percent   CONSTANT VARCHAR2(1) := '%';
266 c_hash      CONSTANT VARCHAR2(1) := '#';
267 
268 c_choose       CONSTANT VARCHAR2(32000) := BIS_UTILITIES_PVT.getPrompt('BIS_CHOOSE');
269 c_tarlevel     CONSTANT VARCHAR2(32000) := BIS_UTILITIES_PVT.getPrompt('BIS_MEASURE');
270 c_dim_and_plan CONSTANT VARCHAR2(32000) := BIS_UTILITIES_PVT.getPrompt('BIS_DIM_AND_PLAN');
271 c_plan         CONSTANT VARCHAR2(32000) := BIS_UTILITIES_PVT.getPrompt('BIS_PLAN');
272 c_displabel    CONSTANT VARCHAR2(32000) := BIS_UTILITIES_PVT.getPrompt('BIS_DISPLABEL');
273 c_display_homepage CONSTANT VARCHAR2(32000) := BIS_UTILITIES_PVT.getPrompt('BIS_DISPLAY_HOMEPAGE');
274 c_tarlevels_homepage CONSTANT VARCHAR2(32000) := BIS_UTILITIES_PVT.getPrompt('BIS_MEASURE_HOMEPAGE');
275 
276 
277 -- *****************************************************
278 --        Main - entry point
279 -- This is the same procedure in BIS_LOV_PUB.main
280 -- but working for Oracle Portal
281 -- ****************************************************
282 /*procedure bis_lov_pub_main
283 ( p_procname      in  varchar2 default NULL
284 , p_qrycnd        in  varchar2 default NULL
285 , p_jsfuncname    in  varchar2 default NULl
286 , p_startnum      in  pls_integer   default NULL
287 , p_rowcount      in  pls_integer   default NULL
288 , p_totalcount    in  pls_integer   default NULL
289 , p_search_str    in  varchar2 default NULL
290 --, p_sql           in  varchar2 default NULL
291 , p_dim_level_id   in number default NULL
292 , p_user_id        in pls_integer default NULL
293 , p_sqlcount      in  varchar2 default NULL
294 , p_coldata       in  BIS_LOV_PUB.colinfo_table
295 , p_rel_dim_lev_id         in varchar2 default NULL
296 , p_rel_dim_lev_val_id     in varchar2 default NULL
297 , p_rel_dim_lev_g_var      in varchar2 default NULL
298 , Z                        in pls_integer default NULL
299 )
300 IS
301 l_startnum              pls_integer;
302 l_pos1                  pls_integer;
303 l_titlename             varchar2(32000);
304 l_history               varchar2(2400);
305 l_message               varchar2(2400);
306 l_ccursor               pls_integer;
307 l_dummy1                pls_integer;
308 l_totalcount            pls_integer;
309 l_colstore              BIS_LOV_PUB.colstore_table;
310 l_totalpossible         pls_integer;
311 l_store1                varchar2(32000);
312 l_store2                varchar2(32000);
313 l_searchlink            varchar2(32000);
314 l_datalink              varchar2(32000);
315 l_buttonslink           varchar2(32000);
316 l_title                 varchar2(32000) := 'List Of Values: ';
317 l_head                  varchar2(32000);
318 l_value                 varchar2(32000);
319 l_link                  varchar2(32000);
320 l_disp                  varchar2(32000);
321 l_sql                   varchar2(32000);
322 l_search_str            varchar2(32000) := p_search_str;
323 l_rel_dim_lev_id        varchar2(32000);
324 l_rel_dim_lev_val_id    varchar2(32000);
325 l_rel_dim_lev_g_var     varchar2(32000);
326 l_Z                     varchar2(32000);
327 
328 l_var number;
329 l_return_sts VARCHAR2(100) := FND_API.G_RET_STS_SUCCESS;
330 l_sob_id     NUMBER;
331 l_plug_id    pls_integer;
332 
333 begin
334 --meastmon 09/10/2001 plug_id is not encrypted.
335 --l_plug_id := icx_call.decrypt2(Z);
336 l_plug_id := Z;
337 
338 if icx_portlet.validateSession then
339 --if ICX_SEC.validatePlugSession(l_plug_id) then
340      if instr(owa_util.get_cgi_env('HTTP_USER_AGENT'),'MSIE') > 0
341      then
342          l_history := '';
343      else
344          l_history := 'opener.history.go(0);';
345      end if;
346 
347   IF p_rel_dim_lev_val_id IS NOT NULL THEN
348     BIS_LOV_PUB.setGlobalVar
349         ( p_dim_lev_id      => p_rel_dim_lev_id
350         , p_dim_lev_val_id  => p_rel_dim_lev_val_id
351         , p_dim_lev_g_var   => p_rel_dim_lev_g_var
352         , x_return_status   => l_return_sts
353         );
354   END IF;
355 
356     -- If this page is being called the first time
357     -- parse the sqlcount to get totalcount
358      l_ccursor := DBMS_SQL.OPEN_CURSOR;
359      DBMS_SQL.PARSE(l_ccursor,p_sqlcount,DBMS_SQL.NATIVE);
360      DBMS_SQL.DEFINE_COLUMN(l_ccursor,1,l_totalcount);
361      l_dummy1 := DBMS_SQL.EXECUTE_AND_FETCH(l_ccursor);
362      DBMS_SQL.COLUMN_VALUE(l_ccursor,1,l_totalcount);
363      DBMS_SQL.CLOSE_CURSOR(l_ccursor);
364 
365     -- Set certain numbers and names
366      l_totalpossible := NVL(p_totalcount,l_totalcount);
367      for l_pos1 in p_coldata.FIRST .. p_coldata.COUNT loop
368         if (p_coldata(l_pos1).link = FND_API.G_TRUE) then
369           l_titlename := p_coldata(l_pos1).header;
370           exit;
371         end if;
372       end loop;
373 
374     htp.htmlOpen;
375     htp.headOpen;
376     -- htp.title(c_listofvalues||' '||l_titlename);
377     htp.title(bis_utilities_pvt.escape_html(l_titlename));
378 
379     htp.p('<SCRIPT LANGUAGE="Javascript">');
380 
381     htp.p('function blank() {
382            return "<HTML><BODY BGCOLOR=#336699></BODY></HTML>"
383             }');
384 
385     --  Transfer the clicked URL's name and id to the parent window box
386     htp.p('function transfer(name,id) {
387         parent.opener.parent.'||p_jsfuncname||'(name,id);
388          window.close();
389       }');
390 
391     -- Close the child window and clear all events on parent window
392     htp.p('function closeMe() {
393         if (opener){
394            opener.unblockEvents();
395         }
396        window.close();
397       }');
398 
399     htp.p('</SCRIPT>');
400     htp.headClose;
401 
402     -- Create the main form that communicates with the intermediate proc
403     htp.formOpen(owa_util.get_owa_service_path
404                 ||p_procname ,'POST','','','NAME="main"');
405     htp.formHidden('p_qrycnd',bis_utilities_pvt.escape_html(p_qrycnd));
406     htp.formHidden('p_jsfuncname',p_jsfuncname);
407     htp.formHidden('p_startnum',p_startnum);
408     htp.formHidden('p_rowcount',p_rowcount);
409     htp.formHidden('p_totalcount',l_totalpossible);
410     htp.formHidden('p_search_str',NVL(p_search_str,c_percent));
411     htp.formHidden('Z',Z);
412     htp.formClose;
413 
414     -- Replace the % sign in the sql string with an asterisk
415     -- because it tends to dissappear from the URL string
416     l_search_str := bis_utilities_pvt.escape_html(REPLACE(p_search_str,c_percent,c_asterisk));
417     l_searchlink := owa_util.get_owa_service_path
418                     ||'BIS_LOV_PUB.lov_search?p_totalpossible='||
419                      l_totalpossible||c_amp||
420                      'p_totalavailable='||l_totalcount||c_amp||
421 --modified for bug#2318543
422 --                   'p_titlename='||REPLACE(l_titlename,' ',c_plus)||c_amp||
423                      'p_titlename='||bis_utilities_pub.encode(l_titlename)
424          ||c_amp||
425                      'p_startnum='||p_startnum||c_amp||
426                      'p_rowcount='||p_rowcount||c_amp||
427                      'p_search_str='||l_search_str;
428 
429  -- Transfer the contents of p_coldata to separate tables because
430  -- frame src url does not understand plsql tables
431  for i in p_coldata.FIRST .. p_coldata.COUNT loop
432 --modified for bug#2318543
433 --  l_head  := l_head||c_amp||'p_head='||REPLACE(p_coldata(i).header,' ',c_plus);
434   l_head  := l_head||c_amp||'p_head='||bis_utilities_pub.encode(p_coldata(i).header);
435   l_value := l_value||c_amp||'p_value='||p_coldata(i).value;
436   l_link  := l_link||c_amp||'p_link='||p_coldata(i).link;
437   l_disp  := l_disp||c_amp||'p_disp='||p_coldata(i).display;
438  end loop;
439 
440 l_rel_dim_lev_id := l_rel_dim_lev_id ||c_amp
441                     ||'p_rel_dim_lev_id='||p_rel_dim_lev_id;
442 l_rel_dim_lev_val_id := l_rel_dim_lev_val_id ||c_amp
443                         ||'p_rel_dim_lev_val_id='||p_rel_dim_lev_val_id;
444 l_rel_dim_lev_g_var := l_rel_dim_lev_g_var ||c_amp
445                        ||'p_rel_dim_lev_g_var='||p_rel_dim_lev_g_var;
446 l_Z := l_Z||c_amp||'Z='||Z;
447 
448  -- Replace the % sign in the sql string with an asterisk
449  -- because it tends to dissappear from the URL string
450   --l_sql := REPLACE(p_sql,c_percent,c_asterisk);
451     l_datalink := owa_util.get_owa_service_path
452                   ||'BIS_PORTLET_PMREGION.lov_data?p_startnum='||
453                     p_startnum||c_amp||
454                    'p_rowcount='||p_rowcount||c_amp||
455                    'p_totalavailable='||l_totalcount||c_amp||
456                    --'p_sql='||REPLACE(l_sql,' ',c_plus)||
457                    'p_dim_level_id='||p_dim_level_id||c_amp||
458                    'p_user_id='||p_user_id||c_amp||
459                    'p_search_str='||p_search_str||
460                    l_head||l_value||l_link||l_disp||
461                    l_rel_dim_lev_id||l_rel_dim_lev_val_id||
462                    l_rel_dim_lev_g_var||l_Z;
463     l_buttonslink := owa_util.get_owa_service_path
464                      ||'BIS_LOV_PUB.lov_buttons?p_startnum='||
465                       p_startnum||c_amp||
466                      'p_rowcount='||p_rowcount||c_amp||
467                      'p_totalavailable='||l_totalcount;
468 
469     htp.p('<FRAMESET
470             FRAMEBORDER="no"
471             FRAMESPACING="0"
472             COLS="3,*,3"
473             BORDER="0"
474             onLoad="Javascript:if(opener) opener.blockEvents();"
475             onUnload="Javascript:if (opener) opener.unblockEvents();">');
476 
477        htp.p('<FRAME SRC="javascript:parent.blank()"
478               FRAMEBORDER="no" SCROLLING="no">');
479        htp.p('<FRAMESET FRAMESPACING="0" ROWS="90,*,65" BORDER="0">');
480 
481        htp.p('<FRAME NAME="LOVsearch" SRC= "'||l_searchlink
482               ||'" FRAMEBORDER="no" SCROLLING="no" MARGINWIDTH="0">');
483 
484        htp.p('<FRAME NAME="LOVdata" SRC="'||l_datalink
485               ||'" FRAMEBORDER="no" SCROLLING="auto" MARGINWIDTH="0">');
486 
487        htp.p('<FRAME NAME="LOVbuttons" SRC= "'||l_buttonslink||'"
488                 FRAMEBORDER="no"
489                 SCROLLING="no"
490                 MARGINWIDTH="0">');
491 
492       htp.p('</FRAMESET>');
493 
494       htp.p('<FRAME SRC="javascript:parent.blank()"
495               FRAMEBORDER="no" SCROLLING="no">');
496       htp.p('</FRAMESET>');
497 
498 
499     -- For browsers that do not support frames/javascript
500     htp.p('<NOFRAMESET>');
501     htp.p('A browser supporting Frames and JavaScript is required.');
502     htp.p('</NOFRAMESET>');
503 
504     htp.htmlClose;
505 
506 end if; -- icx_validate session
507 
508 exception
509   when others then htp.p(SQLERRM);
510 
511 end bis_lov_pub_main;*/
512 
513 
514 procedure build_html_banner (
515       title        IN  VARCHAR2,
516       help_target  IN  VARCHAR2,
517       menu_link    IN VARCHAR2
518       )
519 is
520      nls_language_code    varchar2(20000);
521      icx_report_images    varchar2(20000);
522      HTML_banner          varchar2(32000);
523 begin
524    nls_language_code := BIS_INDICATOR_REGION_UI_PVT.Get_NLS_Language;
525    icx_report_images := BIS_INDICATOR_REGION_UI_PVT.Get_Images_Server;
526 
527    Build_HTML_Banner (icx_report_images      -------------- VERSION 5 (call to)
528           , help_target
529           , nls_language_code
530           , title
531           , menu_link
532           , FALSE
533           , FALSE
534           , HTML_Banner
535           );
536      htp.p(HTML_Banner);
537 
538 end Build_HTML_Banner;
539 
540 
541 PROCEDURE build_html_banner   ------------ VERSION 5 (definition of)
542   (icx_report_images     IN  VARCHAR2,
543    more_info_directory   IN  VARCHAR2,
544    nls_language_code     IN  VARCHAR2,
545    title           IN  VARCHAR2,
546    menu_link           IN  VARCHAR2,
547    related_reports_exist IN  BOOLEAN,
548    parameter_page        IN  BOOLEAN,
549    HTML_Banner           OUT NOCOPY VARCHAR2
550    )
551 
552   IS
553       Related_Alt           VARCHAR2(800);
554       Menu_Alt              VARCHAR2(800);
555       Home_Alt              VARCHAR2(800);
556       Help_Alt              VARCHAR2(800);
557 
558    Return_Alt             VARCHAR2(10000);
559    Parameters_Alt         VARCHAR2(10000);
560    NewMenu_Alt            VARCHAR2(800);
561    NewHelp_Alt            VARCHAR2(800);
562    Return_Description     VARCHAR2(1000);
563    Parameters_Description VARCHAR2(1000);
564    NewMenu_Description    VARCHAR2(80);
565    NewHelp_Description    VARCHAR2(80);
566 
567    Related_Description   VARCHAR2(80);
568    Home_Description      VARCHAR2(80);
569    Menu_Description      VARCHAR2(80);
570    Help_Description      VARCHAR2(80);
571    Image_Directory       VARCHAR2(250);
572    Home_page             VARCHAR2(2000);
573    Menu_Padding          NUMBER(5);
574    Home_URL              VARCHAR2(200);
575    Plsql_Agent           VARCHAR2(100);
576    Host_File             VARCHAR2(80);
577    l_profile             VARCHAR2(2000);
578    l_section_header      VARCHAR2(1000);
579 
580    l_css                 VARCHAR2(1000);
581    CSSDirectory          VARCHAR2(1000);
582    l_HTML_HEADER         VARCHAR2(2000);
583    l_HTML_body           VARCHAR2(2000);
584    l_ampersand           VARCHAR2(20):=' ';
585 
586    Parampage_Alt   VARCHAR2(32000);
587    Parampage_Description VARCHAR2(32000);
588 
589 BEGIN
590 
591      BIS_INDICATOR_REGION_UI_PVT.Get_Translated_Icon_Text ('RELATED', Related_Alt, Related_Description);
592      BIS_INDICATOR_REGION_UI_PVT.Get_Translated_Icon_Text ('MENU', Menu_Alt, Menu_Description);
593      BIS_INDICATOR_REGION_UI_PVT.Get_Translated_Icon_Text ('HOME', Home_Alt, Home_Description);
594      BIS_INDICATOR_REGION_UI_PVT.Get_Translated_Icon_Text ('HELP', Help_Alt, Help_Description);
595      BIS_INDICATOR_REGION_UI_PVT.Get_Translated_Icon_Text ('PARAMPAGE', Parampage_Alt, Parampage_Description);
596 
597      BIS_INDICATOR_REGION_UI_PVT.Get_Translated_Icon_Text ('RETURNTOPORTAL', Return_Alt, Return_Description);
598      BIS_INDICATOR_REGION_UI_PVT.Get_Translated_Icon_Text ('PARAMETERS', Parameters_Alt, Parameters_Description);
599      BIS_INDICATOR_REGION_UI_PVT.Get_Translated_Icon_Text ('NEWHELP', NewHelp_Alt, NewHelp_Description);
600      BIS_INDICATOR_REGION_UI_PVT.Get_Translated_Icon_Text ('NEWMENU', NewMenu_Alt, NewMenu_Description);
601 
602      -- mdamle 05/31/2001 - New ICX Profile for OA_HTML, OA_MEDIA
603      -- l_css := FND_PROFILE.value('ICX_OA_HTML');
604      --added '/' here , otherwise the style sheet was not getting picked
605      -- CSSDirectory  := '/' || FND_WEB_CONFIG.TRAIL_SLASH(l_css);
606      CSSDirectory  :=BIS_REPORT_UTIL_PVT.get_html_server;
607 
608      -- mdamle 05/31/2001 - New ICX Profile for OA_HTML, OA_MEDIA
609      -- Image_Directory :=  FND_WEB_CONFIG.TRAIL_SLASH(ICX_REPORT_IMAGES);
610      Image_Directory := BIS_REPORT_UTIL_PVT.get_Images_Server;
611 
612      Home_URL := BIS_REPORT_UTIL_PVT.Get_Home_URL;
613      l_section_header := FND_MESSAGE.GET_STRING('BIS','BIS_SPECIFY_PARAMS');
614 
615       l_HTML_Header :=
616     '<head>
617        <!- Banner by BISVRUTB.pls V 5 ->
618        <title>' || bis_utilities_pvt.escape_html(title) || '</title>
619   <LINK REL="stylesheet" HREF="'
620   ||CSSDirectory
621   ||'bismarli.css">
622    <SCRIPT LANGUAGE="JavaScript">'
623    ||
624    icx_admin_sig.help_win_syntax(
625                more_info_directory
626                , NULL
627                , 'BIS')
628    ||
629    '
630    </SCRIPT>
631    </HEAD>
632   ';
633 
634     l_HTML_Body := '<body bgColor="#ffffff" link="#663300" vlink="#996633" alink="#FF6600" text="#000000">';
635 
636   HTML_Banner := l_HTML_Header||l_HTML_Body ;
637 
638 
639      IF (Parameter_Page) THEN
640         HTML_Banner := HTML_Banner ||
641 '<form method=post action="_action_">
642 <input name="hidden_run_parameters" type=hidden value="_hidden_">
643 <CENTEnR><P>
644 ';
645      END IF;
646 
647      HTML_Banner := HTML_Banner ||
648     '<!- Banner V 5 part 2 ->
649      <table border=0 cellspacing=0 cellpadding=0 width=100%>
650      <tr><td rowspan=2 valign=bottom width=371>
651      <table border=0 cellspacing=0 cellpadding=0 width=100%>
652      <tr align=left><td height=30><img src=' || Image_Directory || 'bisorcl.gif border=no height=23
653 width=141></a></td>
654      <tr align=left> <td valign=bottom><img src=' || Image_Directory || 'biscollg.gif border=no></a></td></td></tr>
655      </table>
656      </td>';
657 
658      IF (NOT Parameter_page) AND (Related_Reports_Exist)
659      THEN
660     menu_padding := 1050;
661      ELSE
662     menu_padding := 1000;
663      END IF;
664 
665      IF (NOT Parameter_Page) AND (Related_Reports_Exist) THEN
666         Menu_Padding := 50;
667      ELSE
668         Menu_Padding := 1000;
669      END IF;
670 
671      IF (NOT Parameter_Page) THEN
672          Menu_Padding := 50;
673      ELSE
674         Menu_Padding := 1000;
675      END IF;
676 
677    IF (NOT Parameter_Page)
678      AND (Related_Reports_Exist)
679    Then menu_padding := 50;
680    END IF;
681 
682 -- MENU
683 
684 -- meastmon: Dont show menu icon when menu_link is null
685    IF (menu_link is not null) THEN
686     HTML_Banner := HTML_Banner ||
687       '<td colspan=2 rowspan=2 valign=bottom align=right>
688       <table border=0 cellpadding=0 align=right cellspacing=4>
689         <tr valign=bottom>
690           <td width=60 align=center><a href='||menu_link||' onMouseOver="window.status=''' || ICX_UTIL.replace_onMouseOver_quotes(return_description) || '''; return true">
691 <img alt='||ICX_UTIL.replace_alt_quotes(Return_Alt)||' src='||Image_Directory||'bisrtrnp.gif width=32 border=0 height=32></a></td>
692 
693         </tr>
694         <tr align=center valign=top>
695           <td width=60><a href='||menu_link||' onMouseOver="window.status=''' || ICX_UTIL.replace_onMouseOver_quotes(return_description) || '''; return true">
696 <span class="OraGlobalButtonText">'||bis_utilities_pvt.escape_html(return_description)||'</span></a></td>
697 
698         </tr></table>
699     </td>';
700    END IF;
701 
702    HTML_Banner := HTML_Banner ||
703     '</tr></table>
704    </table>';
705 
706     HTML_Banner := HTML_Banner ||
707 '<table Border=0 cellpadding=0 cellspacing=0 width=100%>
708   <tbody>
709   <tr><td bgcolor=#ffffff colspan=3 height=1><img height=1 src='||Image_Directory||'bisspace.gif width=1></td>
710   </tr>
711   <tr>
712     <td bgcolor=#31659c colspan=2 height=21><img border=0 height=21 src='||Image_Directory||'bisspace.gif width=1></td>
713     <td bgcolor=#31659c  height=21><font face="Arial, Helvetica, sans-serif" size="4" color="#ffffff">'||l_ampersand||'</font></td>
714     <td background='||Image_Directory||'bisrhshd.gif height=21 width=5><img border=0 height=1
715 src='||Image_Directory||'bisspace.gif width=1></td>
716   </tr>
717   <tr>
718     <td bgcolor=#31659c height=16 width=9><img border=0 height=1 src='||Image_Directory||'bisspace.gif width=9></td>
719     <td bgcolor=#31659c height=16 width=5><img border=0 height=1 src='||Image_Directory||'bisspace.gif width=5></td>
720     <td background='||Image_Directory||'bisbot.gif width=1000><img align=top height=16
721 src='||Image_Directory||'bistopar.gif width=26></td>
722     <td align=left valign=top width=5><img height=8 src='||Image_Directory||'bisrend.gif width=8></td>
723   </tr>
724   <tr>
725     <td align=left background='||Image_Directory||'bisbot.gif height=8 valign=top width=9><img height=8
726 src='||Image_Directory||'bislend.gif width=10></td>
727     <td background='||Image_Directory||'bisbot.gif height=8 width=5><img border=0 height=1
728 src='||Image_Directory||'bisspace.gif width=1></td>
729     <td align=left valign=top width=1000><img height=8 src='||Image_Directory||'bisarchc.gif width=9></td>
730     <td width=5></td>
731   </tr>
732   </tbody>
733 </table>';
734 
735 
736    IF (NOT Parameter_Page) THEN
737     HTML_Banner := HTML_Banner ||
738 '<table width=100% border=0 cellspacing=0 cellpadding=15>
739 <tr><td><table width=100% border=0 cellspacing=0 cellpadding=0>
740         <tr><td class="OraHeader"><font face="Arial, Helvetica, sans-serif" size="5" color="#336699">'||bis_utilities_pvt.escape_html(title)||'</font></td></tr>
741         <tr bgcolor="#CCCC99"><td height=1><img src='||Image_Directory||'bisspace.gif width=1 height=1></td></tr>
742         </table>
743 </td></tr>
744 </table>';
745 
746    ELSE
747     HTML_Banner := HTML_Banner ||
748 '<table width=100% border=0 cellspacing=0 cellpadding=15>
749 <tr><td><table width=100% border=0 cellspacing=0 cellpadding=0>
750         <tr><td class="OraHeader"><font face="Arial, Helvetica, sans-serif" size="5" color="#336699">'||bis_utilities_pvt.escape_html(title)||'</font></td></tr>
751         <tr bgcolor="#CCCC99"><td height=1><img src='||Image_Directory||'bisspace.gif width=1 height=1></td></tr>
752         <tr><td><font face="Arial, Helvetica, sans-serif" size="2">'||bis_utilities_pvt.escape_html(l_section_header)||'</font></td></tr>
753         </table>
754 </td></tr>
755 </table>';
756    END IF;
757 
758 END Build_HTML_Banner;
759 
760 
761 PROCEDURE deregister(
762       p_reference_path in varchar2
763       )
764 IS
765   l_plug_id PLS_INTEGER;
766 --    l_current_user_id PLS_INTEGER;
767 --    l_user_id PLS_INTEGER;
768 --    l_owner_user_id PLS_INTEGER;
769 --    l_session_id NUMBER;
770 BEGIN
771 
772 --  IF icx_portlet.validateSession THEN
773     BEGIN
774         select PLUG_ID
775         into   l_plug_id
776         from   ICX_PORTLET_CUSTOMIZATIONS
777         where  REFERENCE_PATH = p_reference_path;
778     EXCEPTION
779         when no_data_found then
780           l_plug_id := -1;
781     END;
782 
783     IF l_plug_id > 0  THEN
784 
785 --      l_session_id := icx_sec.g_session_id;
786 --      l_current_user_id := icx_sec.getID(icx_sec.PV_USER_ID,'', l_session_id);
787       delete_all_demo_rows(l_plug_id);
788       DELETE
789       FROM BIS_USER_IND_SELECTIONS
790       WHERE  PLUG_ID = l_plug_id;
791 
792 
793       DELETE
794       FROM ICX_PORTLET_CUSTOMIZATIONS
795       WHERE  REFERENCE_PATH = p_reference_path;
796     END IF;
797 --  END IF;  --  icx_portlet.validateSession
798 
799 EXCEPTION
800     WHEN OTHERS THEN
801         htp.p(SQLERRM);
802 END deregister;
803 
804 
805 -- *******************************************************
806 --         Procedure creates the SQL query
807 -- This is the same procedure in BIS_INTERMEDIATE_LOV_PVT
808 -- but working for Oracle Portal
809 -- *******************************************************
810 /*procedure dim_level_values_query
811 (p_qrycnd        in varchar2    default NULL
812 ,p_jsfuncname     in varchar2    default NULL
813 ,p_startnum       in pls_integer default NULL
814 ,p_rowcount       in pls_integer default NULL
815 ,p_totalcount     in pls_integer default NULL
816 ,p_search_str     in varchar2    default NULL
817 ,Z                in pls_integer default NULL
818 ,p_dim1_lbl       in varchar2    default NULL  -- 1797465
819 )
820 
821 is
822 
823  l_qrycnd                 varchar2(32000);
824  l_sql                    varchar2(32000);
825  l_temp                   varchar2(32000);
826  l_sqlcount               varchar2(32000);
827  l_procname               varchar2(200);
828  l_col_object             bis_lov_pub.colinfo_table;
829  l_search_str             varchar2(200);
830  l_view_name              varchar2(80);
831  l_short_name             varchar2(30);
832  l_dimension_short_name   varchar2(30);
833  l_header                 varchar2(80);
834  l_id                     pls_integer;
835  l_point1                 pls_integer;
836  l_point2                 pls_integer;
837  l_point3                 pls_integer;
838  l_point4                 pls_integer;
839  l_point5                 pls_integer;
840  l_point6                 pls_integer;
841  l_point7                 pls_integer;
842  l_target_level_id        pls_integer;
843  l_user_id                pls_integer;
844  l_dim_level_id           number;
845 
846  l_rel_dim_lev_id     pls_integer;
847 -- l_rel_dim_lev_val_id pls_integer;
848  l_rel_dim_lev_val_id   VARCHAR2(32000);
849  l_rel_dim_lev_g_var  varchar2(32000);
850 
851  l_tar_level_rec          BIS_Target_Level_PUB.Target_Level_Rec_Type;
852 
853 begin
854 
855 if icx_portlet.validateSession then
856    -- mdamle 01/15/2001 - Modified routine to use getLOVSQL for EDW
857 
858    -- (1) Call a function to plug the the ' on both sides of the search string
859         l_search_str := bis_lov_pub.concat_string(p_search_str);
860 
861    -- (2)Set the procedure name
862        l_procname := 'bis_portlet_pmregion.dim_level_values_query';
863 
864    -- (3)Build two SQL queries, one for the statement and the other for
865    --    the row count
866 
867    -- Now unpack the qrycnd string to get the userid,tar id, dim level id
868    -- and other related dimension info
869 
870     l_point1 := instr(p_qrycnd,'*',1,1);
871     l_point2 := instr(p_qrycnd,'*',1,2);
872     l_point3 := instr(p_qrycnd,'*',1,3);
873     l_point4 := instr(p_qrycnd,'*',1,4);
874     l_point5 := instr(p_qrycnd,'*',1,5);
875     l_point6 := instr(p_qrycnd,'*',1,6);
876     l_point7 := instr(p_qrycnd,'*',1,7);
877 
878     l_user_id := substr(p_qrycnd,1,l_point1-1);
879     l_target_level_id := substr(p_qrycnd,l_point1+1,l_point2 - l_point1 - 1);
880 
881   IF (l_point3 <> 0) THEN
882     l_dim_level_id    := substr(p_qrycnd,l_point2+1,l_point3 - l_point2 - 1);
883   ELSE
884     l_dim_level_id    := substr(p_qrycnd,l_point2+1);
885   END IF;
886 
887   IF (l_point3 <> 0) AND (l_point4 <> 0) THEN
888     l_rel_dim_lev_g_var  := substr(p_qrycnd,l_point3+1,l_point4-l_point3-1);
889   END IF;
890   IF (l_point4 <> 0) AND (l_point5 <> 0) THEN
891     l_rel_dim_lev_id := substr(p_qrycnd,l_point4+1,l_point5-l_point4-1);
892   END IF;
893   IF (l_point5 <> 0)  THEN
894     l_rel_dim_lev_val_id  := substr(p_qrycnd,l_point5+1);
895   END if;
896 
897   l_temp := BIS_INTERMEDIATE_LOV_PVT.getLOVSQL(l_dim_level_id, l_search_str, 'LOV', l_user_id);
898 
899   -- meastmon 04/24/2001 It works for OLTP dimensions but not for EDW dimensions
900   -- which dont have id and value columns in the tables.
901   -- l_point1 := instr(lower(l_temp),' from ',1);
902   -- l_sql := 'select distinct id, value ' || substr(l_temp, l_point1);
903   --l_sql := 'select distinct id, value from ('||l_temp||')';
904   -- l_point1 := instr(lower(l_sql),' from ',1);
905   -- l_sqlcount := 'select count(distinct id) ' || substr(l_sql, l_point1);
906   l_sqlcount := 'select count(distinct id) from ('||l_temp||')';
907 
908 
909     -- (4)Build the plsql table to transfer column information
910     --
911       l_col_object(1).header := BIS_INTERMEDIATE_LOV_PVT.c_orgid;
912       l_col_object(1).value  := FND_API.G_TRUE;
913       l_col_object(1).link   := FND_API.G_FALSE;
914       l_col_object(1).display:= FND_API.G_FALSE;
915 
916       -- l_col_object(2).header := l_header;
917 --Bug 1797465
918   --  l_col_object(2).header := c_organization;
919       l_col_object(2).header := p_dim1_lbl;
920 --Bug 1797465
921       l_col_object(2).value  := FND_API.G_FALSE;
922       l_col_object(2).link   := FND_API.G_TRUE;
923       l_col_object(2).display:= FND_API.G_TRUE;
924 
925   --
926   -- (5)Now call LOV utility procedure to run the query and paint the window
927   --
928 
929      IF l_rel_dim_lev_g_var IS NOT NULL
930      THEN
931       bis_lov_pub_main (p_procname     => l_procname,
932                        p_qrycnd       => p_qrycnd,
933                        p_jsfuncname   => p_jsfuncname,
934                        p_startnum     => p_startnum,
935                        p_rowcount     => bis_lov_pub.c_rowcount,
936                        p_totalcount   => p_totalcount,
937                        p_search_str   => p_search_str,
938                        --p_sql          => l_sql,
939                        p_dim_level_id => l_dim_level_id,
940                        p_user_id      => l_user_id,
941                        p_sqlcount     => l_sqlcount,
942                        p_coldata      => l_col_object,
943                        p_rel_dim_lev_id     => l_rel_dim_lev_id,
944                        p_rel_dim_lev_val_id => l_rel_dim_lev_val_id,
945                        p_rel_dim_lev_g_var  => l_rel_dim_lev_g_var,
946                        Z                    => Z);
947 
948      ELSE
949 
950      bis_lov_pub_main (p_procname     => l_procname,
951                        p_qrycnd       => p_qrycnd,
952                        p_jsfuncname   => p_jsfuncname,
953                        p_startnum     => p_startnum,
954                        p_rowcount     => bis_lov_pub.c_rowcount,
955                        p_totalcount   => p_totalcount,
956                        p_search_str   => p_search_str,
957                        --p_sql          => l_sql,
958                        p_dim_level_id => l_dim_level_id,
959                        p_user_id      => l_user_id,
960                        p_sqlcount     => l_sqlcount,
961                        p_coldata      => l_col_object,
962                        Z              => Z);
963      END IF;
964 end if; -- icx_portlet.validateSession
965 
966 end dim_level_values_query;*/
967 
968 PROCEDURE display(
969   p_session_id  IN NUMBER
970  ,p_plug_id IN pls_integer
971  ,p_user_id IN integer
972  ,x_html_buffer OUT NOCOPY VARCHAR2
973  ,x_html_clob OUT NOCOPY CLOB
974 )
975 IS
976 e_notimevalue EXCEPTION;
977 
978 l_user_id PLS_INTEGER;
979 x_owner_user_id PLS_INTEGER;
980 l_target_rec          BIS_TARGET_PUB.Target_Rec_Type;
981 
982 
983 l_row_style  VARCHAR2(100);
984 
985 -- data variables
986 l_actual_value        NUMBER;
987 l_comparison_actual_value  NUMBER;
988 l_target              NUMBER:= NULL;
989 l_range1_low          NUMBER:= NULL;
990 l_range1_high         NUMBER:= NULL;
991 l_range2_low          NUMBER:= NULL;
992 l_range2_high         NUMBER:= NULL;
993 l_range3_low          NUMBER:= NULL;
994 l_range3_high         NUMBER:= NULL;
995 
996 l_format_actual   VARCHAR2(1000);
997 l_actual_url      VARCHAR2(32000) ;
998 
999 l_change          NUMBER(20,2);
1000 l_img             VARCHAR2(200);
1001 l_good_bad        VARCHAR2(200);
1002 l_arrow_alt_text  VARCHAR2(2000);  --2157402
1003 
1004 -- debugging variables
1005 l_err VARCHAR2(32000);
1006 l_err2 VARCHAR2(32000);
1007 
1008 
1009 
1010 -- labels
1011 l_none_lbl        VARCHAR2(200);
1012 l_na_lbl          VARCHAR2(200) ;
1013 l_un_auth         VARCHAR2(200);
1014 
1015 l_status_lbl      VARCHAR2(200);
1016 l_measure_lbl     VARCHAR2(200);
1017 l_value_lbl       VARCHAR2(200);
1018 l_change_lbl      VARCHAR2(200);
1019 l_perc_lbl        VARCHAR2(200);
1020 
1021 
1022 l_in_range_lbl    VARCHAR2(2000);
1023 l_out_range_lbl   VARCHAR2(2000);
1024 l_improve_msg     VARCHAR2(2000);  --2157402
1025 l_worse_msg       VARCHAR2(2000);  --2157402
1026 
1027 l_html_buffer   VARCHAR2(32000) := NULL;
1028 l_html_clob   CLOB := NULL;
1029 
1030 l_html_header   VARCHAR2(32000) := NULL;
1031 l_html_row    VARCHAR2(32000) := NULL;
1032 l_html_footer   VARCHAR2(32000) := NULL;
1033 
1034 /*
1035 l_target_lbl          VARCHAR2(2000);
1036 l_time_lbl            VARCHAR2(2000);
1037 l_changetarget_lbl    VARCHAR2(2000);
1038 l_lower_lbl          VARCHAR2(2000) ;
1039 l_higher_lbl         VARCHAR2(2000);
1040 l_target_url VARCHAR2(5000);
1041 */
1042 
1043 
1044 
1045  -- ========================================
1046  -- cusor declarations
1047  -- ========================================
1048  -- Cursor to grab selected rows from the
1049  -- juwang bug#2197758 01/24/2002
1050  CURSOR c_selections IS
1051    SELECT distinct a.ind_selection_id
1052           ,a.label
1053           ,a.target_level_id
1054         -- mdamle 01/15/2001 - Use Dim6 and Dim7
1055         -- ,a.org_level_value
1056           ,a.dimension1_level_value
1057           ,a.dimension2_level_value
1058           ,a.dimension3_level_value
1059           ,a.dimension4_level_value
1060           ,a.dimension5_level_value
1061           ,a.dimension6_level_value
1062           ,a.dimension7_level_value
1063           ,a.plan_id
1064           ,c.increase_in_measure  --1850860
1065           ,c.comparison_source  --2157402
1066           ,c.indicator_id  --2174470
1067   FROM   bis_user_ind_selections  a
1068          ,bis_indicators c    --1850860
1069          ,bisbv_target_levels d  --1850860
1070   WHERE a.plug_id = p_plug_id -- most selective first
1071   AND   a.user_id = l_user_id
1072   AND   d.target_level_id = a.target_level_id  --1850860
1073   AND   d.measure_id = c.indicator_id          --1850860
1074   ORDER BY  a.ind_selection_id;
1075 
1076   csel c_selections%ROWTYPE;
1077 
1078 BEGIN
1079   -- =======================
1080   -- loading messages
1081   -- =======================
1082   l_none_lbl := BIS_UTILITIES_PVT.Get_FND_Message('BIS_NONE');
1083   l_na_lbl := (BIS_UTILITIES_PVT.Get_FND_Message('BIS_PMF_NA_LBL'));
1084   l_un_auth := BIS_UTILITIES_PVT.Get_FND_Message('BIS_UNAUTHORIZED');
1085 
1086   -- header labels
1087   l_status_lbl := BIS_UTILITIES_PVT.Get_FND_Message('BIS_STATUS');
1088   l_measure_lbl := BIS_UTILITIES_PVT.Get_FND_Message('BIS_PMF_NAME');
1089   l_value_lbl := BIS_UTILITIES_PVT.Get_FND_Message('BIS_VALUE_LBL');
1090   l_change_lbl := (BIS_UTILITIES_PVT.Get_FND_Message('BIS_PMF_CHANGE'));
1091   l_perc_lbl := (BIS_UTILITIES_PVT.Get_FND_Message('BIS_PMF_PERC_LBL'));
1092 
1093   -- msgs
1094   l_in_range_lbl := BIS_UTILITIES_PVT.Get_FND_Message('BIS_WITHIN_RANGE');
1095   l_out_range_lbl := BIS_UTILITIES_PVT.Get_FND_Message('BIS_OUTSIDE_RANGE');
1096   l_worse_msg := BIS_UTILITIES_PVT.Get_FND_Message('BIS_PMF_CHANGE_WORSE');
1097   l_improve_msg := BIS_UTILITIES_PVT.Get_FND_Message('BIS_PMF_CHANGE_IMPROVE');
1098 
1099 
1100 --  l_measure_lbl := BIS_UTILITIES_PVT.Get_FND_Message('BIS_MEASURE'); -- 1850860
1101 --  l_actual_lbl := BIS_UTILITIES_PVT.Get_FND_Message('BIS_ALERT_ACTUAL');
1102 --  l_target_lbl := BIS_UTILITIES_PVT.Get_FND_Message('BIS_ALERT_TARGET');
1103 --  l_time_lbl := BIS_UTILITIES_PVT.Get_FND_Message('BIS_TIME');
1104 --  l_changetarget_lbl := BIS_UTILITIES_PVT.Get_FND_Message('BISPMF_SELTOCHANGE_FUTTARGET');
1105 
1106 --rchandra 11/10/2001 New messages
1107 --  l_lower_lbl := BIS_UTILITIES_PVT.Get_FND_Message('BIS_LOWER_RANGE_LBL');
1108 --  l_higher_lbl := BIS_UTILITIES_PVT.Get_FND_Message('BIS_HIGHER_RANGE_LBL');
1109 
1110   -- =======================
1111   -- Begin Main block
1112   -- =======================
1113   l_html_header := draw_portlet_header(
1114          l_status_lbl
1115         ,l_measure_lbl
1116         ,l_value_lbl
1117         ,l_change_lbl
1118        );
1119   append(
1120     p_string  => l_html_header
1121    ,x_clob  => l_html_clob
1122    ,x_buffer  => l_html_buffer
1123   );
1124 
1125   -- if there is no rows customized for this login user,
1126   -- use whatever customized
1127   -- for the owner of the portlet.
1128   IF (BIS_PMF_PORTLET_UTIL.has_customized_rows(p_plug_id, p_user_id, x_owner_user_id) ) THEN
1129     l_user_id := p_user_id;  -- current login user
1130   ELSE  -- no rows have been customized for the login user
1131     l_user_id := x_owner_user_id;
1132   END IF;
1133 
1134 
1135   OPEN c_selections;
1136   LOOP
1137     << c_selections_loop >>
1138     FETCH c_selections INTO csel;
1139     EXIT WHEN c_selections%NOTFOUND;
1140 
1141     l_html_row := '              <tr> ';
1142 
1143     l_target_rec.target_level_id      := csel.target_level_id;
1144     l_target_rec.plan_id              := csel.plan_id;
1145 
1146     -- l_target_rec.org_level_value_id   := csel.org_level_value;
1147     l_target_rec.dim1_level_value_id  := csel.dimension1_level_value;
1148     l_target_rec.dim2_level_value_id  := csel.dimension2_level_value;
1149     l_target_rec.dim3_level_value_id  := csel.dimension3_level_value;
1150     l_target_rec.dim4_level_value_id  := csel.dimension4_level_value;
1151     l_target_rec.dim5_level_value_id  := csel.dimension5_level_value;
1152     l_target_rec.dim6_level_value_id  := csel.dimension6_level_value;
1153     l_target_rec.dim7_level_value_id  := csel.dimension7_level_value;
1154     l_good_bad := csel.increase_in_measure; -- 1850860
1155 
1156 
1157     -- This is to display one row in white and the next in yellow
1158     l_row_style := BIS_PMF_PORTLET_UTIL.get_row_style(l_row_style);
1159 
1160     -- bug#2197758
1161 
1162     IF (NOT BIS_PMF_PORTLET_UTIL.is_authorized(
1163           p_cur_user_id => p_user_id
1164    ,p_target_level_id => csel.target_level_id) ) THEN
1165 
1166         l_html_row := l_html_row || draw_status(l_status_lbl, 0, l_row_style);
1167         l_html_row := l_html_row || draw_measure_name(l_actual_url, csel.label, l_measure_lbl,l_row_style);
1168       l_html_row := l_html_row || draw_actual(l_value_lbl, l_un_auth, l_row_style, FALSE);
1169 
1170         GOTO c_selections_loop;
1171     END IF;
1172 
1173 
1174     -- meastmon 05/09/2001 This block encloses logic to get target, actual
1175     -- for this user selection
1176 
1177     BEGIN
1178 
1179       get_time_dim_index(
1180         p_ind_selection_id => csel.ind_selection_id
1181        ,x_target_rec => l_target_rec
1182        ,x_err => l_err
1183       ) ;
1184 
1185       get_actual
1186       (  p_target_rec => l_target_rec
1187         ,x_actual_url => l_actual_url
1188   ,x_actual_value => l_actual_value
1189   ,x_comparison_actual_value => l_comparison_actual_value
1190   ,x_err => l_err2
1191       );
1192       -- retriving target
1193 
1194 
1195       get_target
1196       ( p_target_in  => l_target_rec
1197        ,x_target  => l_target
1198        ,x_range1_low  => l_range1_low
1199        ,x_range1_high  => l_range1_high
1200        ,x_range2_low  => l_range2_low
1201        ,x_range2_high  => l_range2_high
1202        ,x_range3_low  => l_range3_low
1203        ,x_range3_high => l_range3_high
1204        ,x_err => l_err2
1205       );
1206 
1207 
1208       --=============================================================
1209       -- rendering now
1210       --=============================================================
1211       -- draw status, measure name and actual
1212 
1213       -- Now paint the actual if exists in the appropriate color
1214       IF  l_actual_value IS NULL THEN
1215       --rchandra 10/10/2001
1216       --Paint the Label
1217   l_html_row := l_html_row || draw_status(l_status_lbl, 0, l_row_style);
1218         l_html_row := l_html_row || draw_measure_name(l_actual_url, csel.label, l_measure_lbl,l_row_style);
1219       l_html_row := l_html_row || draw_actual(l_value_lbl, l_none_lbl, l_row_style);
1220   l_html_row := l_html_row || draw_change(l_change_lbl,l_na_lbl,null,null,l_row_style);
1221 
1222       ELSE
1223         l_format_actual := BIS_PMF_PORTLET_UTIL.getAKFormatValue( p_measure_id =>csel.indicator_id ,p_val =>l_actual_value);
1224 
1225   get_change(
1226      p_actual_value => l_actual_value
1227     ,p_comp_actual_value  => l_comparison_actual_value
1228     ,p_comp_source  => csel.comparison_source
1229     ,p_good_bad  => l_good_bad
1230     ,p_improve_msg => l_improve_msg
1231     ,p_worse_msg => l_worse_msg
1232     ,x_change => l_change
1233     ,x_img => l_img
1234     ,x_arrow_alt_text => l_arrow_alt_text
1235     ,x_err => l_err2
1236    );
1237 
1238   l_html_row := l_html_row || draw_status(
1239               p_status_lbl => l_status_lbl
1240              ,p_row_style  => l_row_style
1241              ,p_actual_val => l_actual_value
1242              ,p_target_val => l_target
1243              ,p_range1_low_pcnt  => l_range1_low
1244              ,p_range1_high_pcnt => l_range1_high
1245              );
1246 
1247         l_html_row := l_html_row || draw_measure_name(l_actual_url, csel.label, l_measure_lbl, l_row_style);
1248   l_html_row := l_html_row || draw_actual(l_value_lbl, l_format_actual, l_row_style);
1249 
1250   IF ( l_change IS NULL) THEN
1251           l_html_row := l_html_row || draw_change(l_change_lbl,l_na_lbl,null,null,l_row_style);
1252   ELSE
1253     l_html_row := l_html_row || draw_change(l_change_lbl,
1254            TO_CHAR(l_change)||l_perc_lbl,l_img,l_arrow_alt_text,l_row_style);
1255   END IF;
1256       END IF;  -- (l_actual_value IS NULL)
1257 
1258     EXCEPTION
1259   --meastmon 05/10/2001
1260     WHEN e_notimevalue THEN
1261       l_html_row := l_html_row || draw_status(l_status_lbl, 0, l_row_style);
1262       l_html_row := l_html_row || draw_measure_name(l_err, csel.label, l_measure_lbl,l_row_style);
1263       l_html_row := l_html_row || draw_actual(l_value_lbl, l_none_lbl, l_row_style);
1264       l_html_row := l_html_row || draw_change(l_change_lbl,l_na_lbl,null,null,l_row_style);
1265 
1266     --IF c_date%ISOPEN THEN CLOSE c_date; END IF; -- 1850860
1267     WHEN OTHERS THEN
1268       l_html_row := l_html_row || draw_status(l_status_lbl, 0, l_row_style);
1269       l_html_row := l_html_row || draw_measure_name(l_err2, csel.label, l_measure_lbl,l_row_style);
1270       l_html_row := l_html_row || draw_actual(l_value_lbl, l_none_lbl, l_row_style);
1271       l_html_row := l_html_row || draw_change(l_change_lbl,l_na_lbl,null,null,l_row_style);
1272 
1273     END; -- end of block containing the c_notimelevels cursor
1274 
1275     l_html_row := l_html_row || '              </tr>';
1276     append(
1277       p_string    => l_html_row
1278      ,x_clob    => l_html_clob
1279      ,x_buffer    => l_html_buffer
1280     );
1281 
1282   END LOOP; -- end of c_selections loop
1283   l_html_footer := draw_portlet_footer;
1284   append(
1285     p_string    => l_html_footer
1286    ,x_clob    => l_html_clob
1287    ,x_buffer    => l_html_buffer
1288   );
1289 
1290   CLOSE c_selections;
1291 
1292   x_html_buffer := l_html_buffer;
1293   x_html_clob := l_html_clob;
1294 
1295   IF (l_html_clob IS NOT NULL) THEN
1296     free_clob(
1297       x_clob => l_html_clob
1298     );
1299   END IF;
1300 
1301 EXCEPTION
1302   WHEN OTHERS THEN
1303     x_html_buffer := SQLERRM;
1304     IF c_selections%ISOPEN THEN
1305       CLOSE c_selections;
1306     END IF;
1307 
1308     IF (l_html_clob IS NOT NULL) THEN
1309       free_clob(
1310   x_clob => l_html_clob
1311       );
1312       x_html_clob := NULL;
1313     END IF;
1314 
1315 END display;
1316 
1317 --===========================================================
1318 -- end of display
1319 --===========================================================
1320 
1321 
1322 
1323 -- ****************************************************
1324 --      Frame that paints the LOVdata
1325 -- This is the same procedure in BIS_LOV_PUB.lov_data
1326 -- but working for Oracle Portal
1327 -- ****************************************************
1328 /*procedure lov_data
1329 ( p_startnum          in  pls_integer   default NULL
1330 , p_rowcount          in  pls_integer   default NULL
1331 , p_totalavailable    in  pls_integer   default NULL
1332 --, p_sql               in  varchar2      default NULL
1333 , p_dim_level_id   in number default NULL
1334 , p_user_id        in pls_integer default NULL
1335 , p_search_str    in  varchar2 default NULL
1336 , p_head              in  BIS_LOV_PUB.colstore_table
1337 , p_value             in  BIS_LOV_PUB.colstore_table
1338 , p_link              in  BIS_LOV_PUB.colstore_table
1339 , p_disp              in  BIS_LOV_PUB.colstore_table
1340 , p_rel_dim_lev_id         in varchar2 default NULL
1341 , p_rel_dim_lev_val_id     in varchar2 default NULL
1342 , p_rel_dim_lev_g_var      in varchar2 default NULL
1343 , Z                        in pls_integer default NULL
1344 )
1345 is
1346 l_startnum               pls_integer;
1347 l_count                  pls_integer;
1348 l_totalcount             pls_integer := p_totalavailable;
1349 l_rcursor                pls_integer;
1350 l_row                    pls_integer;
1351 l_dummy2                 pls_integer;
1352 l_dummy3                 pls_integer;
1353 l_colstore               BIS_LOV_PUB.colstore_table;
1354 l_pos1                   pls_integer;
1355 l_pos2                   pls_integer;
1356 l_col                    pls_integer;
1357 l_linkvalue              varchar2(32000);
1358 l_linktext               varchar2(32000);
1359 l_string                 varchar2(32000);
1360 l_sql                    varchar2(32000);
1361 l_return_sts             VARCHAR2(100);
1362 l_var VARCHAR2(100);
1363 l_plug_id    pls_integer;
1364 l_temp                   varchar2(32000);
1365 l_search_str            varchar2(32000);
1366 
1367 begin
1368 --meastmon 09/10/2001 plug_id is not encrypted.
1369 --l_plug_id := icx_call.decrypt2(Z);
1370 l_plug_id := Z;
1371 
1372 --if ICX_SEC.validatePlugSession(l_plug_id) then
1373 if icx_portlet.validateSession then
1374 
1375   -- prepare SQl modified for enh#3559231
1376   -- Replace the asterisk with the percent sign
1377   --l_sql := REPLACE(p_sql,c_asterisk,c_percent);
1378 
1379   l_search_str := bis_lov_pub.concat_string(p_search_str);
1380   l_temp := BIS_INTERMEDIATE_LOV_PVT.getLOVSQL(p_dim_level_id, l_search_str, 'LOV',  p_user_id);
1381   l_sql := 'select distinct id, value from ('||l_temp||')';
1382 
1383 
1384 --htp.p('<SCRIPT LANGUAGE="Javascript">
1385 --         alert("Original sql: '||l_sql||'");
1386 --       </SCRIPT>');
1387 
1388    IF p_rel_dim_lev_val_id IS NOT NULL THEN
1389      BIS_LOV_PUB.setGlobalVar
1390         ( p_dim_lev_id      => p_rel_dim_lev_id
1391         , p_dim_lev_val_id  => p_rel_dim_lev_val_id
1392         , p_dim_lev_g_var   => p_rel_dim_lev_g_var
1393         , x_return_status   => l_return_sts
1394         );
1395    END IF;
1396 
1397    -- Now parse the actual query
1398    l_rcursor := DBMS_SQL.OPEN_CURSOR;
1399    DBMS_SQL.PARSE(l_rcursor,l_sql,DBMS_SQL.NATIVE);
1400 
1401    IF DBMS_SQL.IS_OPEN(l_rcursor) THEN
1402      for l_pos1 in p_head.FIRST .. p_head.COUNT loop
1403        l_colstore(l_pos1) := '';
1404        DBMS_SQL.DEFINE_COLUMN(l_rcursor,l_pos1,l_colstore(l_pos1),32000);
1405      end loop;
1406      l_dummy2 := DBMS_SQL.EXECUTE(l_rcursor);
1407    ELSE
1408      DBMS_SQL.CLOSE_CURSOR(l_rcursor);
1409      COMMIT;
1410    END IF;
1411    l_startnum := NVL(p_startnum,1);
1412 
1413    htp.htmlOpen;
1414    htp.headOpen;
1415    htp.headClose;
1416    htp.p('<BODY BGCOLOR="'||bis_lov_pub.c_pgbgcolor||'">');
1417 
1418   /**************** Debug ********************
1419    for i in 1 .. p_head.COUNT loop
1420    htp.p(i);
1421    htp.p(p_head(i));
1422    htp.p(p_value(i));
1423    htp.p(p_link(i));
1424    htp.p(p_disp(i));
1425    htp.p('<BR>');
1426    end loop;
1427   *******************************************
1428 
1429  -- Set the set of books id for GL dimension levels
1430  --
1431    l_var := BIS_TARGET_PVT.G_SET_OF_BOOK_ID;
1432 
1433    htp.p('<SCRIPT LANGUAGE="Javascript">');
1434 
1435    --  Transfer the clicked URL's name and id to the parent function
1436    htp.p('function transfer_value(name,id) {
1437          top.transfer(name,id);
1438       }');
1439    htp.p('</SCRIPT>');
1440 
1441  htp.formOpen('Javascript:setParameters()','POST','','','NAME="lovdata"');
1442  htp.centerOpen;
1443   htp.p('<table border=0 cellspacing=0 cellpadding=2 width=95%>');
1444   htp.tablerowOpen(cattributes=>'BGCOLOR='||bis_lov_pub.c_tblsurnd);
1445   htp.p('<td>');
1446    htp.p('<table border=0 cellspacing=1 cellpadding=2 width=100%>');
1447    htp.tablerowOpen(cattributes=>'BGCOLOR='||bis_lov_pub.c_fmbgcolor);
1448      for l_col in p_disp.FIRST..p_disp.COUNT loop
1449        if (p_disp(l_col) = FND_API.G_TRUE) then
1450          htp.tableheader('<font color='||bis_lov_pub.c_rowcolor||'>'||bis_utilities_pvt.escape_html(p_head(l_col))
1451                         ||'</font>');
1452        end if;
1453      end loop;
1454     htp.tablerowClose;
1455     --
1456     --    *******      Print LOV DATA       *********
1457     --
1458      l_count := 1;
1459      loop
1460 
1461       BEGIN
1462       -- Fetch the rows
1463       IF DBMS_SQL.IS_OPEN(l_rcursor) THEN
1464        l_dummy3 := DBMS_SQL.FETCH_ROWS(l_rcursor);
1465 
1466         IF l_dummy3 > 0 THEN
1467           -- Store in local plsql table of variables
1468           for l_pos1 in p_head.FIRST .. p_head.COUNT loop
1469             DBMS_SQL.COLUMN_VALUE(l_rcursor,l_pos1,l_colstore(l_pos1));
1470           end loop;
1471         ELSE
1472           DBMS_SQL.CLOSE_CURSOR(l_rcursor);
1473           COMMIT;
1474         END IF;
1475       ELSE
1476         DBMS_SQL.CLOSE_CURSOR(l_rcursor);
1477         COMMIT;
1478       END IF;
1479 
1480       EXCEPTION
1481         when others then
1482         htp.p('<SCRIPT LANGUAGE="Javascript">');
1483         htp.p('ERROR in LovData: '||SQLERRM);
1484         htp.p('</SCRIPT>');
1485       END;
1486 
1487      -- Start painting only those rows in the range specified
1488      if (l_count >= l_startnum AND l_count < l_startnum + p_rowcount) then
1489        htp.tablerowOpen(cattributes=>'BGCOLOR='||bis_lov_pub.c_rowcolor);
1490         -- Start painting the column values
1491         for l_pos1 in p_head.FIRST .. p_head.COUNT loop
1492           if (p_link(l_pos1) = FND_API.G_TRUE) then
1493              l_linktext := l_colstore(l_pos1);
1494              for l_pos2 in p_head.FIRST..p_head.COUNT loop
1495                if (p_value(l_pos2) = FND_API.G_TRUE) then
1496                   l_linkvalue := l_colstore(l_pos2);
1497                   exit;
1498                end if;
1499               end loop;
1500              htp.tableData(htf.anchor(curl=>'Javascript:transfer_value('''||
1501                           ICX_UTIL.replace_onMouseOver_quotes(l_linktext)||''','''||l_linkvalue||''')',
1502                           ctext=>l_linktext),
1503                           cnowrap=>'YES',
1504                           cattributes=>'HEIGHT=10');
1505           elsif (p_disp(l_pos1) = FND_API.G_TRUE) AND
1506                 (p_link(l_pos1) = FND_API.G_FALSE) then
1507              htp.tableData(bis_utilities_pvt.escape_html(l_colstore(l_pos1)),cnowrap=>'YES');
1508           end if;   -- to check type of column
1509         end loop; --  p_coldata loop to determine the context of each col
1510 
1511        htp.tableRowClose;
1512 
1513       end if;   -- if count of rows is between the start and end
1514       l_count := l_count + 1;
1515       exit when (l_count >= l_startnum + p_rowcount) OR
1516                 (l_count > l_totalcount);
1517 
1518      end loop;
1519 
1520    -- Close the cursor
1521    IF DBMS_SQL.IS_OPEN(l_rcursor) THEN
1522      DBMS_SQL.CLOSE_CURSOR(l_rcursor);
1523      COMMIT;
1524    END IF;
1525      htp.tableClose;
1526    htp.p('</td>');
1527    htp.tablerowClose;
1528    htp.tableClose;
1529 
1530    htp.formClose;
1531    htp.centerClose;
1532 
1533    htp.bodyClose;
1534    htp.htmlClose;
1535 
1536 end if; -- icx_validate session
1537 
1538 exception
1539   when others then
1540    htp.p(SQLERRM);
1541    IF DBMS_SQL.IS_OPEN(l_rcursor) THEN
1542      DBMS_SQL.CLOSE_CURSOR(l_rcursor);
1543      COMMIT;
1544    END IF;
1545 end lov_data;*/
1546 
1547 /*procedure setIndicators(
1548        Z in pls_integer
1549       ,p_back_url in varchar2
1550       ,p_selections_tbl IN Selected_Values_Tbl_Type
1551       )
1552 IS
1553 
1554 BEGIN
1555 
1556   setIndicators(
1557      Z => Z
1558     ,p_back_url => p_back_url
1559     ,p_selections_tbl => p_selections_tbl
1560     ,p_reference_path => NULL
1561   );
1562 
1563 END setIndicators;*/
1564 
1565 -- *********************************************
1566 -- Procedure to choose the Indicator levels
1567 -- *********************************************
1568 /*procedure setIndicators(
1569        Z in pls_integer
1570       ,p_back_url in varchar2
1571       ,p_selections_tbl IN Selected_Values_Tbl_Type
1572       ,p_reference_path IN VARCHAR2
1573       )
1574 is
1575     l_initialize            VARCHAR2(32000);
1576     l_nbsp                  VARCHAR2(32000);
1577     l_select_tarlevel       VARCHAR2(32000);
1578     l_dup_tarlevel          VARCHAR2(32000);
1579     l_history               VARCHAR2(32000);
1580     l_instruction           VARCHAR2(32000);
1581     l_plug_id               PLS_INTEGER;
1582     l_current_user_id       PLS_INTEGER;
1583     l_user_id               PLS_INTEGER;
1584     l_owner_user_id         PLS_INTEGER;
1585     l_session_id            NUMBER;
1586     l_loc                   PLS_INTEGER;
1587     l_value                 VARCHAR2(32000);
1588     l_text                  VARCHAR2(32000);
1589     l_return_status         VARCHAR2(32000);
1590     l_indicators_tbl        BIS_TARGET_LEVEL_PUB.Target_Level_Tbl_Type;
1591     l_displaylabels_tbl     Selected_Values_Tbl_Type;
1592     l_selections_tbl        BIS_INDICATOR_REGION_PUB.Indicator_Region_Tbl_Type;
1593     l_temp_tbl              BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
1594     l_unique                BOOLEAN;
1595     l_cnt                   pls_integer;
1596     l_error_tbl             BIS_UTILITIES_PUB.Error_Tbl_Type;
1597     -- meastmon 06/20/2001
1598     -- Fix for ADA buttons
1599     l_button_str             VARCHAR2(32000);
1600     l_button_tbl             BIS_UTILITIES_PVT.HTML_Button_Tbl_Type;
1601 
1602 
1603 begin
1604   if icx_portlet.validateSession then
1605     --meastmon 09/10/2001 plug_id is not encrypted.
1606     --l_plug_id := icx_call.decrypt2(Z);
1607     l_plug_id := Z;
1608 
1609     l_session_id := icx_sec.g_session_id;
1610     l_current_user_id := icx_sec.getID(icx_sec.PV_USER_ID,'', l_session_id);
1611     l_nbsp := '&'||'nbsp;';
1612     l_initialize := '                                ';
1613 
1614     if instr(owa_util.get_cgi_env('HTTP_USER_AGENT'),'MSIE') > 0 then
1615         l_history := '';
1616     else
1617         l_history := 'history.go(0);';
1618     end if;
1619 
1620     -- Get all the message strings from the database
1621     fnd_message.set_name('BIS','BIS_SELECT_TARLEVEL');
1622     l_select_tarlevel := icx_util.replace_quotes(fnd_message.get);
1623     --rmohanty BUG#1653751
1624     --changed from BIS_DUP_TARLEVEL to BIS_DUP_TARLEVELS
1625     fnd_message.set_name('BIS','BIS_DUP_TARLEVELS');
1626     l_dup_tarlevel := icx_util.replace_quotes(fnd_message.get);
1627 
1628     -- Create a dummy value in the indicators table to send it
1629     -- to the next proc because one of parameters is a plsql table
1630     -- which cannot be nullable
1631     l_displaylabels_tbl(1) := '';
1632 
1633     IF (BIS_PMF_PORTLET_UTIL.has_customized_rows(l_plug_id, l_current_user_id, l_owner_user_id) ) THEN
1634       l_user_id := l_current_user_id;
1635     ELSE
1636       l_user_id := l_owner_user_id;
1637     END IF;
1638 
1639 
1640     -- clean_user_ind_sel(l_plug_id);
1641     -- ********************************************
1642     -- Get all the Indicator Levels for this user
1643     -- ********************************************
1644     BIS_TARGET_LEVEL_PUB.Retrieve_User_Target_Levels
1645         ( p_api_version         => 1.0
1646         , p_all_info            => FND_API.G_FALSE
1647         , p_user_id             => l_current_user_id
1648         , x_Target_Level_Tbl    => l_indicators_tbl
1649         , x_return_status       => l_return_status
1650         , x_Error_Tbl           => l_error_tbl
1651         );
1652 
1653 
1654     -- Get all the previously selected Indicator levels from
1655     -- bis_user_ind_selections table.
1656     BIS_INDICATOR_REGION_PUB.Retrieve_User_Ind_Selections
1657         ( p_api_version          => 1.0
1658         , p_user_id              => l_user_id
1659         , p_all_info             => FND_API.G_TRUE
1660         , p_plug_id              => l_plug_id
1661         , x_Indicator_Region_Tbl => l_selections_tbl
1662         , x_return_status        => l_return_status
1663         , x_Error_Tbl            => l_error_tbl
1664         );
1665 
1666     -- Remove the duplicates from the l_selections_tbl
1667     IF (l_selections_tbl.COUNT <> 0) THEN
1668         FOR i in 1 .. l_selections_tbl.COUNT LOOP
1669             l_unique := TRUE;
1670             FOR j in 1 .. l_temp_tbl.COUNT LOOP
1671                 if l_selections_tbl(i).target_level_id = l_temp_tbl(j).id then
1672                     l_unique := FALSE;
1673                 end if;
1674             END LOOP;
1675     -- bug#2225110
1676 
1677             IF (l_unique AND
1678           BIS_PMF_PORTLET_UTIL.is_authorized(
1679     p_cur_user_id => l_current_user_id
1680     ,p_target_level_id => l_selections_tbl(i).target_level_id) ) THEN
1681                   l_cnt := l_temp_tbl.COUNT + 1;
1682                   l_temp_tbl(l_cnt).id := l_selections_tbl(i).target_level_id;
1683                   l_temp_tbl(l_cnt).name := l_selections_tbl(i).target_level_name;
1684 
1685             end if;
1686         END LOOP;
1687     END IF;
1688 
1689 
1690     htp.htmlOpen;
1691     htp.headOpen;
1692     htp.title(BIS_UTILITIES_PVT.getPrompt('BIS_PERFORMANCE_MEASURES'));
1693     BIS_UTILITIES_PVT.putStyle();
1694 
1695     htp.headClose;
1696     ---------------------------------------------------------------------------
1697     -- 19-SEP-00 gsanap    Modified this part to use putStyle and remove icon_show
1698     --                     Bug 1404224 which was the Banner on Customize pg.
1699     --                     was not displaying properly
1700     ---------------------------------------------------------------------------
1701     htp.p('<body>');
1702 
1703     BIS_UTILITIES_PVT.putStyle;
1704 
1705     Build_HTML_Banner(
1706         title       => BIS_UTILITIES_PVT.getPrompt('BIS_PERFORMANCE_MEASURES')
1707         ,help_target => G_HELP
1708         ,menu_link => p_back_url
1709         );
1710 
1711     -- Print out NOCOPY the instructions for this page
1712     fnd_message.set_name('BIS','BIS_PLUG_INSTRUCTION1');
1713     l_instruction := icx_util.replace_quotes(fnd_message.get);
1714     htp.p('<BR>');
1715     htp.p('<table width="100%" border=0 cellspacing=0 cellpadding=0>');
1716     htp.p('<tr><td width=5%></td><td width=90%>'
1717           ||bis_utilities_pvt.escape_html(l_instruction)||'</td><td width=5%></td></tr>');
1718     htp.p('</table>');
1719     htp.p('<BR>');
1720 
1721     htp.p('<SCRIPT LANGUAGE="JavaScript">');
1722 
1723 
1724     -- Function to move the selected target levels to the favorites box
1725     --meastmon 06/25/2001. Validate that user have seleted a target level before
1726     --clicking add button
1727     htp.p('function addTo() {
1728              var temp=document.favorites.B.selectedIndex;
1729              if (temp < 0)
1730                selectTo();
1731              else {
1732                var totext=document.favorites.B[temp].text;
1733                var tovalue=document.favorites.B[temp].value;
1734                var end=document.favorites.C.length;
1735                if (end > 0) {
1736                  if (document.favorites.C.options[end-1].value =="") {
1737                    end = end - 1;
1738                  }
1739                  for (var i=0;i<end;i++) {
1740                    if (tovalue == document.favorites.C[i].value)
1741                      var check = 0;
1742                  }
1743                  if (check == 0) {
1744                    alert("'||l_dup_tarlevel||'");
1745                  }
1746                  else {
1747                    document.favorites.C.options[end] = new Option(totext,tovalue);
1748                    document.favorites.C.selectedIndex = end;
1749                  }
1750                }
1751                else {
1752                  document.favorites.C.options[end] = new Option(totext,tovalue);
1753                  document.favorites.C.selectedIndex = end;
1754                }
1755              }
1756            }');
1757 
1758     htp.p('function selectTo() {
1759              alert("'||l_select_tarlevel||'")
1760            }');
1761 
1762     -- Function to move selections upwards in the favorites box
1763     -- meastmon 06/25/2001 Fix bug#1835495.
1764     htp.p('function upTo() {
1765              var temp = document.favorites.C.selectedIndex;
1766              if (temp < 0)
1767                selectTo();
1768              else {
1769                if (temp > 0) {
1770                  var text = document.favorites.C[temp-1].text;
1771                  var val = document.favorites.C.options[temp-1].value;
1772                  var totext = document.favorites.C[temp].text;
1773                  var toval = document.favorites.C.options[temp].value;
1774 
1775                  document.favorites.C[temp-1].text = totext;
1776                  document.favorites.C.options[temp-1].value = toval;
1777                  document.favorites.C[temp].text = text;
1778                  document.favorites.C.options[temp].value = val;
1779                  document.favorites.C.selectedIndex = temp-1;
1780                }
1781              }
1782              '||l_history||'
1783            }');
1784 
1785     -- Function to move selections downwards in the favorites box
1786     -- meastmon 06/25/2001 Fix bug#1835495.
1787     htp.p('function downTo() {
1788              var temp = document.favorites.C.selectedIndex;
1789              var end = document.favorites.C.length;
1790 
1791              if (temp < 0)
1792                selectTo();
1793              else {
1794                if (document.favorites.C.options[end-1].value == "")
1795                  end = end - 1;
1796 
1797                if (temp < (end-1)) {
1798                  var text = document.favorites.C[temp+1].text;
1799                  var val = document.favorites.C.options[temp+1].value;
1800                  var totext = document.favorites.C[temp].text;
1801                  var toval = document.favorites.C.options[temp].value;
1802 
1803                  document.favorites.C[temp+1].text = totext;
1804                  document.favorites.C.options[temp+1].value = toval;
1805                  document.favorites.C[temp].text = text;
1806                  document.favorites.C.options[temp].value = val;
1807                  document.favorites.C.selectedIndex = temp+1;
1808                }
1809              }
1810              '||l_history||'
1811            }');
1812 
1813 
1814     -- Function to delete entries in the favorites box
1815     htp.p('function deleteTo() {
1816              var temp=document.favorites.C.selectedIndex;
1817 
1818              if (temp < 0)
1819                selectTo();
1820              else {
1821                document.favorites.C.options[temp] = null;
1822              };
1823              '||l_history||'
1824            }');
1825 
1826     htp.p('function open_new_browser() {
1827              var attributes = "resizable=yes,scrollbars=yes,toolbar=no,width="+x+",height="+ y;
1828              var new_browser = window.open(url, "new_browser", attributes);
1829              if (new_browser != null) {
1830                if (new_browser.opener == null)
1831                  new_browser.opener = self;
1832                window.name = ''Oraclefavoritesroot'';
1833                new_browser.location.href = url;
1834              }
1835            }');
1836 
1837 
1838     --  Function to save the favorites
1839     htp.p('function savefavorites() {
1840              var end=document.favorites.C.length;
1841              for (var i=0; i<end; i++)
1842                if (document.favorites.C.options[i].value != "") {
1843                  document.showDimensions.p_selections_tbl[i].value = document.favorites.C.options[i].value + "*" + document.favorites.C.options[i].text;
1844                  document.showDimensions.submit();
1845                }
1846            }');
1847 
1848     -- Function to reset everything on the page
1849     htp.p('function resetfavorites() {
1850              loadFrom();
1851              loadTo();
1852           }');
1853 
1854     htp.p('</SCRIPT>');
1855 
1856     htp.formOpen('bis_portlet_pmregion.showDimensions','POST','','','NAME="showDimensions"');
1857     htp.formHidden('Z',Z);
1858     htp.formHidden('p_back_url',p_back_url);
1859     htp.formHidden('p_reference_path', p_reference_path);
1860     htp.formHidden('p_indlevel');
1861     htp.formHidden('p_ind_level_id');
1862     htp.formHidden('p_displaylabels_tbl');
1863 
1864     -- Create hidden values to grab selected indicator levels into
1865     for i in  1 .. c_counter LOOP
1866         htp.formHidden('p_selections_tbl');
1867     end loop;
1868     htp.formClose;
1869 
1870     htp.centerOpen;
1871     htp.formOpen('javascript:savefavorites()','POST','','','NAME="favorites"');
1872 
1873     htp.p('<table width="100%" border=0 cellspacing=0 cellpadding=0>');--main
1874     htp.p('<tr><td align=center>');
1875     htp.p('<table width="10%" border=0 cellspacing=0 cellpadding=0>');--cell
1876     htp.p('<tr><td nowrap="YES">');
1877     htp.p(bis_utilities_pvt.escape_html(BIS_UTILITIES_PVT.getPrompt('BIS_AVAILABLE_MEASURES'))||': ');
1878     htp.p('</td><td nowrap="YES">');
1879     htp.p(bis_utilities_pvt.escape_html(BIS_UTILITIES_PVT.getPrompt('BIS_SELECTED_MEASURES'))||': ');
1880     htp.p('</td></tr>');
1881     htp.p('<tr><td>');
1882     htp.p('<table border=0 cellspacing=0 cellpadding=0><tr><td>'); -- full menu cell
1883     htp.p('<select name="B" size=10>');
1884 
1885     IF (l_indicators_tbl.COUNT = 0) THEN
1886         htp.formSelectOption(l_initialize);
1887     ELSE
1888       for i in l_indicators_tbl.FIRST .. l_indicators_tbl.COUNT loop
1889     -- mdamle 01/12/2001 - Change display text of Performance Measure list
1890     -- changed l_indicators_tbl(i).target_level_name to getPerformanceMeasureName()
1891          htp.formSelectOption(
1892            cvalue=>bis_utilities_pvt.escape_html_input(BIS_INDICATOR_REGION_UI_PVT.getPerformanceMeasureName(l_indicators_tbl(i).target_level_id)),
1893               cattributes=>'VALUE='||bis_utilities_pvt.escape_html_input(l_indicators_tbl(i).target_level_id));
1894 
1895       end loop;
1896     END IF;
1897     htp.formSelectClose;
1898 
1899     htp.p('</td><td align="left">');
1900     htp.p('<table><tr><td>'); --add
1901     htp.p('<A HREF="javascript:addTo();'||l_history||
1902           '" onMouseOver="window.status='''||
1903           ICX_UTIL.replace_onMouseOver_quotes(BIS_UTILITIES_PVT.getPrompt('BIS_ADD'))||
1904           ''';return true"><image src="/OA_MEDIA/FNDRTARW.gif" alt="'||
1905           ICX_UTIL.replace_alt_quotes(BIS_UTILITIES_PVT.getPrompt('BIS_ADD'))||'" BORDER="0"></A>');
1906     htp.p('</td></tr></table>'); -- add
1907     htp.p('</td></tr></table>'); -- full menu cell
1908     htp.p('</td><td>');
1909     --favorite cell
1910     htp.p('<table border=0 cellspacing=0 cellpadding=0><tr><td>');
1911     htp.p('<select name="C" size=10>');
1912 
1913     if (p_selections_tbl(1) is NULL) then
1914         -- If first time to this page, get the data from database
1915         IF (l_temp_tbl.COUNT = 0) THEN
1916             htp.formSelectOption(l_initialize);
1917         ELSE
1918             for i in l_temp_tbl.FIRST .. l_temp_tbl.COUNT loop
1919               -- mdamle 01/12/2001 - Change display text of Performance Measure list
1920                 -- changed l_temp_tbl(i).name to getPerformanceMeasureName()
1921                 htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(BIS_INDICATOR_REGION_UI_PVT.getPerformanceMeasureName(l_temp_tbl(i).id)),
1922                                      cattributes=>'VALUE='||bis_utilities_pvt.escape_html_input(l_temp_tbl(i).id));
1923             end loop;
1924         END IF;
1925     else
1926         -- If coming back from the next page,get data from plsql table
1927         for i in p_selections_tbl.FIRST .. p_selections_tbl.COUNT loop
1928             l_loc := instr(p_selections_tbl(i),'*',1,1);
1929             l_value := substr (p_selections_tbl(i),1,l_loc - 1);
1930             l_text := substr (p_selections_tbl(i),l_loc + 1);
1931             htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_text),cattributes=>'VALUE='||bis_utilities_pvt.escape_html_input(l_value));
1932             exit when p_selections_tbl(i) is NULL;
1933         end LOOP;
1934     end if;
1935     htp.formSelectClose;
1936     htp.p('</td><td align="left">');
1937 
1938     -- up and down
1939     htp.p('<table><tr><td align="left" valign="bottom">');
1940     htp.p('<A HREF="javascript:upTo()" onMouseOver="window.status='''||
1941           ICX_UTIL.replace_onMouseOver_quotes(BIS_UTILITIES_PVT.getPrompt('BIS_UP'))||
1942           ''';return true"><image src="/OA_MEDIA/FNDUPARW.gif" alt="'||
1943           ICX_UTIL.replace_alt_quotes(BIS_UTILITIES_PVT.getPrompt('BIS_UP'))||'" BORDER="0"></A>');
1944     htp.p('</td></tr><tr><td align="left" valign="top">');
1945     htp.p('<A HREF="javascript:downTo()" onMouseOver="window.status='''||
1946           ICX_UTIL.replace_onMouseOver_quotes(BIS_UTILITIES_PVT.getPrompt('BIS_DOWN'))||
1947           ''';return true"><image src="/OA_MEDIA/FNDDNARW.gif" alt="'||
1948           ICX_UTIL.replace_alt_quotes(BIS_UTILITIES_PVT.getPrompt('BIS_DOWN'))||'" BORDER="0"></A>');
1949     htp.p('</td></tr></table>'); --up and down
1950     htp.p('</td></tr></table>'); --favorite cell
1951     htp.p('</td></tr>');
1952     htp.p('<tr><td></td><td>');
1953 
1954     --buttons
1955     htp.p('<table><tr>');
1956     htp.p('<td><BR></td>');
1957     htp.p('<td><BR></td><td>');
1958 
1959     --meastmon ICX Button is not ADA Complaint. ICX is not going to fix that.
1960     --icx_plug_utilities.buttonBoth(BIS_UTILITIES_PVT.getPrompt('BIS_DELETE')
1961     --                              ,'Javascript:deleteTo()');
1962     l_button_tbl(1).left_edge := BIS_UTILITIES_PVT.G_ROUND_EDGE;
1963     l_button_tbl(1).right_edge := BIS_UTILITIES_PVT.G_ROUND_EDGE;
1964     l_button_tbl(1).disabled := FND_API.G_FALSE;
1965     l_button_tbl(1).label := BIS_UTILITIES_PVT.getPrompt('BIS_DELETE');
1966     l_button_tbl(1).href := 'Javascript:deleteTo()';
1967     BIS_UTILITIES_PVT.GetButtonString(l_button_tbl, l_button_str);
1968     htp.p(l_button_str);
1969 
1970     htp.p('</td></tr></table>');
1971     htp.p('</td></tr>');
1972 
1973     htp.p('<!--   ********     Buttons Row   ********* -->');
1974     htp.p('<tr><td colspan="2"><BR></td></tr>');
1975     htp.p('<tr><td colspan="2">');
1976     htp.p('<table width="100%"><tr><td width=50% align="right">'); -- ok
1977 
1978     --meastmon ICX Button is not ADA Complaint. ICX is not going to fix that.
1979     --icx_plug_utilities.buttonLeft(BIS_UTILITIES_PVT.getPrompt('BIS_CONTINUE')
1980     --                             ,'Javascript:savefavorites()');
1981     l_button_tbl(1).left_edge := BIS_UTILITIES_PVT.G_ROUND_EDGE;
1982     l_button_tbl(1).right_edge := BIS_UTILITIES_PVT.G_FLAT_EDGE;
1983     l_button_tbl(1).disabled := FND_API.G_FALSE;
1984     l_button_tbl(1).label := BIS_UTILITIES_PVT.getPrompt('BIS_CONTINUE');
1985     l_button_tbl(1).href := 'Javascript:savefavorites()';
1986     BIS_UTILITIES_PVT.GetButtonString(l_button_tbl, l_button_str);
1987     htp.p(l_button_str);
1988 
1989     htp.p('</td><td align="left" width="50%">');
1990     --meastmon ICX Button is not ADA Complaint. ICX is not going to fix that.
1991     --icx_plug_utilities.buttonRight(BIS_UTILITIES_PVT.getPrompt('BIS_CANCEL')
1992     --                              ,'JavaScript:history.go(-1)');
1993     l_button_tbl(1).left_edge := BIS_UTILITIES_PVT.G_FLAT_EDGE;
1994     l_button_tbl(1).right_edge := BIS_UTILITIES_PVT.G_ROUND_EDGE;
1995     l_button_tbl(1).disabled := FND_API.G_FALSE;
1996     l_button_tbl(1).label := BIS_UTILITIES_PVT.getPrompt('BIS_CANCEL');
1997     --l_button_tbl(1).href := 'JavaScript:history.go(-1)';
1998     l_button_tbl(1).href := p_back_url;
1999     BIS_UTILITIES_PVT.GetButtonString(l_button_tbl, l_button_str);
2000     htp.p(l_button_str);
2001 
2002     htp.p('</td></tr></table>');
2003     htp.p('</td></tr>');
2004 
2005 
2006     htp.p('</table>'); --cell
2007     htp.p('</td></tr>');
2008 
2009     htp.p('</table>'); --main
2010 
2011 
2012 
2013     htp.formClose;
2014     htp.p('<SCRIPT LANGUAGE="JavaScript">
2015            document.favorites.B.focus();
2016            </SCRIPT>');
2017     htp.centerClose;
2018     -- show customization of demo url
2019     show_cust_demo_url(l_plug_id, l_session_id);
2020     htp.bodyClose;
2021     htp.htmlClose;
2022 
2023   end if; -- ValidateSession
2024 
2025 exception
2026     when others then
2027         htp.p(SQLERRM);
2028 
2029 end setIndicators;*/
2030 
2031 
2032 PROCEDURE SetSetOfBookVar(
2033   p_user_id      IN integer
2034 , p_formName     IN VARCHAR2
2035 , p_index        IN VARCHAR2
2036 , x_sobString    OUT NOCOPY VARCHAR2
2037 )
2038 IS
2039 l_sobString VARCHAR2(32000);
2040 BEGIN
2041 
2042   l_sobString :=
2043 '    if (document.'||p_formName||'.set_sob.value == "TRUE")
2044       {
2045        // mdamle 01/15/2001 - Dim0 is no longer mandatory
2046          var dim0_level_id = document.'||p_formName||'.dim0_level_id.value;
2047          var dim0_index = document.'||p_formName||'.dim0.selectedIndex;
2048          var dim0_id = document.'||p_formName||'.dim0.options[dim0_index].value;
2049          var dim0_g_var = "BIS_TARGET_PVT.G_SET_OF_BOOK_ID";
2050 
2051          var c_qry = "'||p_user_id||c_asterisk||'" + ind + "'||c_asterisk
2052                         ||'" + dim_lvl_id + "'||c_asterisk
2053                         ||'" + dim0_g_var + "'||c_asterisk
2054                         ||'" + dim0_level_id + "'||c_asterisk
2055                         ||'" + dim0_id;
2056 
2057        //var dim0_id=document.'||p_formName||'.dim0.options['||p_index||'].value;
2058        // alert("True. dim0_id: "+dim0_id);
2059       }
2060     else
2061       {
2062        var dim0_id="";
2063 
2064      // mdamle 01/15/2001 - Dim0 is no longer mandatory
2065        var c_qry = "'||p_user_id||c_asterisk||'" + ind + "'||c_asterisk
2066                         ||'" + dim_lvl_id + "'||c_asterisk
2067                         ||c_asterisk
2068                         ||c_asterisk ||'";
2069 
2070        // alert("False. dim0_id: "+dim0_id);
2071       }';
2072 
2073   x_sobString := l_sobString;
2074 
2075 EXCEPTION
2076   WHEN OTHERS THEN
2077     htp.p(SQLERRM);
2078 END SetSetOfBookVar;
2079 
2080 
2081 
2082 -- ************************************************************
2083 --   Show the Dimensions Page
2084 -- ************************************************************
2085 /*procedure showDimensions
2086 ( Z                      in PLS_INTEGER
2087 , p_back_url             in VARCHAR2
2088 , p_indlevel             in VARCHAR2 default NULL
2089 , p_ind_level_id         in PLS_INTEGER  default NULL
2090 , p_displaylabels_tbl    in Selected_Values_Tbl_Type
2091 , p_selections_tbl       in Selected_Values_Tbl_Type
2092 , p_reference_path       IN VARCHAR2
2093 )
2094 is
2095   l_cnt                   PLS_INTEGER;
2096   l_plug_id               PLS_INTEGER;
2097 
2098   l_current_user_id       PLS_INTEGER;
2099   l_user_id               PLS_INTEGER;
2100   l_owner_user_id         PLS_INTEGER;
2101   l_session_id            NUMBER;
2102 
2103   l_history                 VARCHAR2(32000);
2104   l_initialize              VARCHAR2(32000);
2105   l_title                   VARCHAR2(32000);
2106   l_choose_dim_value        VARCHAR2(32000);
2107   l_enter_displabel         VARCHAR2(32000);
2108   l_select_displabel        VARCHAR2(32000);
2109   l_dup_displabel           VARCHAR2(32000);
2110   l_dup_combo               VARCHAR2(32000);
2111   l_instruction              VARCHAR2(32000);
2112   l_blank                    VARCHAR2(32000);
2113   l_return_status            VARCHAR2(32000);
2114   l_loc                      PLS_INTEGER;
2115   l_value                    VARCHAR2(32000);
2116   l_text                     VARCHAR2(32000);
2117   l_labels_tbl               BIS_INDICATOR_REGION_PUB.Indicator_Region_Tbl_Type;
2118   l_orgs_tbl                 BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
2119 l_dim1_tbl                 BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
2120 l_dim2_tbl                 BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
2121 l_dim3_tbl                 BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
2122 l_dim4_tbl                 BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
2123 l_dim5_tbl                 BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
2124 -- mdamle 01/15/2001 - Use Dim6 and Dim7
2125 l_dim6_tbl                 BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
2126 l_dim7_tbl                 BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
2127 
2128 l_d0_tbl                   BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
2129 l_d1_tbl                   BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
2130 l_d2_tbl                   BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
2131 l_d3_tbl                   BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
2132 l_d4_tbl                   BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
2133 l_d5_tbl                   BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
2134 -- mdamle 01/15/2001 - Use Dim6 and Dim7
2135 l_d6_tbl                   BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
2136 l_d7_tbl                   BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
2137 -- meastmon 05/11/2001
2138 l_Time_Seq_Num              number;
2139 --
2140 l_Org_Seq_Num              number;
2141 l_Org_Level_ID             number;
2142 
2143 -- meastmon 09/19/2001 Fix bug#1993015 This variable needs to be VARCHAR2
2144 l_Org_Level_Value_ID       VARCHAR2(80); --number;
2145 
2146 l_Org_Level_Short_Name     VARCHAR2(240);
2147 l_Org_Level_Name           bis_levels_tl.name%TYPE;
2148 
2149 l_link                     VARCHAR2(32000);
2150 l_error_tbl                BIS_UTILITIES_PUB.Error_Tbl_Type;
2151 l_clear                    VARCHAR2(32000);
2152 l_sobString                VARCHAR2(32000);
2153 l_elements                 BIS_UTILITIES_PUB.BIS_VARCHAR_TBL;
2154 
2155 -- Grab the incoming indicator level id into a local var for use later
2156 v_ind_level_id                PLS_INTEGER := p_ind_level_id;
2157 
2158 cursor plan_cur is
2159  SELECT plan_id,short_name,name
2160  FROM BISBV_BUSINESS_PLANS
2161  ORDER BY name;
2162 
2163 -- mdamle 01/15/2001 - Use Dim6 and Dim7
2164 -- added short_names and additional levels
2165 cursor bisfv_target_levels_cur(p_tarid in PLS_INTEGER) is
2166  SELECT TARGET_LEVEL_ID,
2167         TARGET_LEVEL_NAME,
2168     -- mdamle 01/15/2001 - Use Dim6 and Dim7
2169         -- ORG_LEVEL_ID,
2170         -- ORG_LEVEL_SHORT_NAME,
2171         -- ORG_LEVEL_NAME,
2172         DIMENSION1_LEVEL_ID,
2173     DIMENSION1_LEVEL_SHORT_NAME,
2174         DIMENSION1_LEVEL_NAME,
2175         DIMENSION2_LEVEL_ID,
2176     DIMENSION2_LEVEL_SHORT_NAME,
2177         DIMENSION2_LEVEL_NAME,
2178         DIMENSION3_LEVEL_ID,
2179     DIMENSION3_LEVEL_SHORT_NAME,
2180         DIMENSION3_LEVEL_NAME,
2181         DIMENSION4_LEVEL_ID,
2182     DIMENSION4_LEVEL_SHORT_NAME,
2183         DIMENSION4_LEVEL_NAME,
2184         DIMENSION5_LEVEL_ID,
2185     DIMENSION5_LEVEL_SHORT_NAME,
2186         DIMENSION5_LEVEL_NAME,
2187         DIMENSION6_LEVEL_ID,
2188     DIMENSION6_LEVEL_SHORT_NAME,
2189         DIMENSION6_LEVEL_NAME,
2190         DIMENSION7_LEVEL_ID,
2191     DIMENSION7_LEVEL_SHORT_NAME,
2192         DIMENSION7_LEVEL_NAME
2193  FROM BISFV_TARGET_LEVELS
2194  WHERE TARGET_LEVEL_ID = p_tarid;
2195 
2196 -- meastmon 06/20/2001
2197 -- Fix for ADA buttons
2198 l_button_str             VARCHAR2(32000);
2199 l_button_tbl             BIS_UTILITIES_PVT.HTML_Button_Tbl_Type;
2200 --Bug 1797465
2201 l_dim0_lbl               VARCHAR2(1000);
2202 l_dim1_lbl               VARCHAR2(1000);
2203 l_dim2_lbl               VARCHAR2(1000);
2204 l_dim3_lbl               VARCHAR2(1000);
2205 l_dim4_lbl               VARCHAR2(1000);
2206 l_dim5_lbl               VARCHAR2(1000);
2207 l_dim6_lbl               VARCHAR2(1000);
2208 l_dim7_lbl               VARCHAR2(1000);
2209 l_un_auth                VARCHAR2(200);
2210 l_access                 VARCHAR2(200);
2211 l_string                 VARCHAR2(32000);
2212 begin
2213    --meastmon 09/10/2001 plug_id is not encrypted.
2214    --l_plug_id := icx_call.decrypt2(Z);
2215    l_plug_id := Z;
2216 
2217 if icx_portlet.validateSession then
2218   l_session_id := icx_sec.g_session_id;
2219   l_current_user_id := icx_sec.getID(icx_sec.PV_USER_ID,'', l_session_id);
2220 
2221   l_initialize := '                                  ';
2222   l_blank    := '';
2223 
2224 -- Set the message strings from the database
2225   fnd_message.set_name('BIS','BIS_ENTER_DISPLAY_LABEL');
2226   l_enter_displabel := icx_util.replace_quotes(fnd_message.get);
2227   fnd_message.set_name('BIS','BIS_SELECT_DISPLAY_LABEL');
2228   l_select_displabel := icx_util.replace_quotes(fnd_message.get);
2229   fnd_message.set_name('BIS','BIS_DUP_DISPLAY_LABEL');
2230   l_dup_displabel := icx_util.replace_quotes(fnd_message.get);
2231   fnd_message.set_name('BIS','BIS_DUP_COMBO');
2232   l_dup_combo := icx_util.replace_quotes(fnd_message.get);
2233   fnd_message.set_name('BIS','BIS_CHOOSE_DIM_VALUE');
2234   l_choose_dim_value := icx_util.replace_quotes(fnd_message.get);
2235 
2236   l_un_auth := BIS_UTILITIES_PVT.Get_FND_Message('BIS_UNAUTHORIZED');
2237 
2238   IF (BIS_PMF_PORTLET_UTIL.has_customized_rows(l_plug_id, l_current_user_id, l_owner_user_id) ) THEN
2239     l_user_id := l_current_user_id;
2240   ELSE
2241     l_user_id := l_owner_user_id;
2242   END IF;
2243 
2244 -- ******************************************************
2245 -- Call the procedure that paints the LOV javascript function
2246 -- ******************************************************
2247   BIS_LOV_PUB.lovjscript(x_string => l_string);
2248 
2249 
2250 -- Get all the previously selected labels from
2251 -- selections box.
2252 
2253   BIS_INDICATOR_REGION_PUB.Retrieve_User_Ind_Selections
2254   ( p_api_version          => 1.0
2255   , p_user_id              => l_user_id
2256   , p_all_info             => FND_API.G_TRUE
2257   , p_plug_id              => l_plug_id
2258   , x_Indicator_Region_Tbl => l_labels_tbl
2259   , x_return_status        => l_return_status
2260   , x_Error_Tbl            => l_error_tbl
2261   );
2262 
2263   htp.htmlOpen;
2264   htp.headOpen;
2265   BIS_UTILITIES_PVT.putStyle();
2266   htp.headClose;
2267 
2268   htp.p('<body>');
2269 
2270 -- Get the Banner
2271    Build_HTML_Banner(
2272    title       => BIS_UTILITIES_PVT.getPrompt('BIS_PERFORMANCE_MEASURES')
2273    ,help_target => G_HELP
2274    ,menu_link => p_back_url
2275    );
2276 
2277  -- Print out NOCOPY the instructions for this page
2278    fnd_message.set_name('BIS','BIS_PLUG_INSTRUCTION2');
2279    l_instruction := icx_util.replace_quotes(fnd_message.get);
2280    htp.p('<BR>');
2281    htp.p('<table width="100%" border=0 cellspacing=0 cellpadding=0>');
2282    htp.p('<tr><td width=5%></td><td width=90%>'||bis_utilities_pvt.escape_html_input(l_instruction)
2283    ||'</td><td width=5%></td></tr>');
2284    htp.p('</table>');
2285    htp.p('<BR>');
2286 
2287    htp.p('<SCRIPT LANGUAGE="Javascript">');
2288 
2289    htp.p('function selectTo() {
2290    alert("'||l_select_displabel||'")
2291    }');
2292 
2293    if instr(owa_util.get_cgi_env('HTTP_USER_AGENT'),'MSIE') > 0
2294    then
2295      l_history := '';
2296    else
2297      l_history := 'history.go(0);';
2298    end if;
2299 
2300  -- Function to move the new display label to the favorites box
2301    htp.p('function addTo() {
2302    if (document.dimensions.label.value == ""){
2303      alert ("'||l_enter_displabel||'");
2304      document.dimensions.label.focus();
2305    }
2306    else {
2307      var ind_tmp  = document.indicators.p_indlevel.selectedIndex;
2308      var ind    =   document.indicators.p_indlevel[ind_tmp].value;
2309 
2310      // Do some checks before grabbing the dimension level values
2311      // For dimension0
2312      if (document.dimensions.dim0_level_id.value != "") {
2313        var d0_tmp = document.dimensions.dim0.selectedIndex;
2314        var d0_end = document.dimensions.dim0.length;
2315        if ((document.dimensions.dim0[d0_tmp].text == "'||l_blank||'") '
2316           ||c_OR||
2317     ' (document.dimensions.dim0[d0_tmp].text == "'||c_choose
2318     ||'"))  {
2319         d0 = "+";
2320       alert("'||l_choose_dim_value||'");
2321       document.dimensions.dim0.focus();
2322       return FALSE;
2323         }
2324         else
2325           var d0 =  document.dimensions.dim0[d0_tmp].value;
2326         }
2327         else
2328         {d0 = "-";}
2329 
2330           // For dimension1
2331           if (document.dimensions.dim1_level_id.value != "") {
2332              var d1_tmp = document.dimensions.dim1.selectedIndex;
2333              var d1_end = document.dimensions.dim1.length;
2334        // mdamle 01/15/2001 - Changed the check |||r to Dim0 check
2335              // if (d1_tmp == 0 '||c_OR||' d1_tmp == d1_end - 1){
2336              if ((document.dimensions.dim1[d1_tmp].text == "'||l_blank||'") '
2337                 ||c_OR||
2338                 ' (document.dimensions.dim1[d1_tmp].text == "'||c_choose
2339                 ||'"))  {
2340                 d1 = "+";
2341                 alert("'||l_choose_dim_value||'");
2342                 document.dimensions.dim1.focus();
2343                 return FALSE;
2344                 }
2345              else
2346                 var d1 =  document.dimensions.dim1[d1_tmp].value;
2347              }
2348           else
2349              {d1 = "-";}
2350 
2351           // For dimension2
2352           if (document.dimensions.dim2_level_id.value != "") {
2353              var d2_tmp = document.dimensions.dim2.selectedIndex;
2354              var d2_end = document.dimensions.dim2.length;
2355        // mdamle 02/25/2002 - Changed the check |||r to Dim0 check
2356              // if (d2_tmp == 0 '||c_OR||' d2_tmp == d2_end - 2){
2357              if ((document.dimensions.dim2[d2_tmp].text == "'||l_blank||'") '
2358                 ||c_OR||
2359                 ' (document.dimensions.dim2[d2_tmp].text == "'||c_choose
2360                 ||'"))  {
2361                 d2 = "+";
2362                 alert("'||l_choose_dim_value||'");
2363                 document.dimensions.dim2.focus();
2364                 return FALSE;
2365                 }
2366              else
2367                 var d2 =  document.dimensions.dim2[d2_tmp].value;
2368              }
2369           else
2370              {d2 = "-";}
2371 
2372           // For dimension3
2373           if (document.dimensions.dim3_level_id.value != "") {
2374              var d3_tmp = document.dimensions.dim3.selectedIndex;
2375              var d3_end = document.dimensions.dim3.length;
2376        // mdamle 03/35/2003 - Changed the check |||r to Dim0 check
2377              // if (d3_tmp == 0 '||c_OR||' d3_tmp == d3_end - 3){
2378              if ((document.dimensions.dim3[d3_tmp].text == "'||l_blank||'") '
2379                 ||c_OR||
2380                 ' (document.dimensions.dim3[d3_tmp].text == "'||c_choose
2381                 ||'"))  {
2382                 d3 = "+";
2383                 alert("'||l_choose_dim_value||'");
2384                 document.dimensions.dim3.focus();
2385                 return FALSE;
2386                 }
2387              else
2388                 var d3 =  document.dimensions.dim3[d3_tmp].value;
2389              }
2390           else
2391              {d3 = "-";}
2392 
2393           // For dimension4
2394           if (document.dimensions.dim4_level_id.value != "") {
2395              var d4_tmp = document.dimensions.dim4.selectedIndex;
2396              var d4_end = document.dimensions.dim4.length;
2397        // mdamle 04/45/2004 - Changed the check |||r to Dim0 check
2398              // if (d4_tmp == 0 '||c_OR||' d4_tmp == d4_end - 4){
2399              if ((document.dimensions.dim4[d4_tmp].text == "'||l_blank||'") '
2400                 ||c_OR||
2401                 ' (document.dimensions.dim4[d4_tmp].text == "'||c_choose
2402                 ||'"))  {
2403 
2404                 d4 = "+";
2405                 alert("'||l_choose_dim_value||'");
2406                 document.dimensions.dim4.focus();
2407                 return FALSE;
2408                 }
2409              else
2410                 var d4 =  document.dimensions.dim4[d4_tmp].value;
2411              }
2412           else
2413              {d4 = "-";}
2414 
2415           // For dimension5
2416           if (document.dimensions.dim5_level_id.value != "") {
2417              var d5_tmp = document.dimensions.dim5.selectedIndex;
2418              var d5_end = document.dimensions.dim5.length;
2419        // mdamle 05/55/2005 - Changed the check |||r to Dim0 check
2420              // if (d5_tmp == 0 '||c_OR||' d5_tmp == d5_end - 5){
2421              if ((document.dimensions.dim5[d5_tmp].text == "'||l_blank||'") '
2422                 ||c_OR||
2423                 ' (document.dimensions.dim5[d5_tmp].text == "'||c_choose
2424                 ||'"))  {
2425                 d5 = "+";
2426                 alert("'||l_choose_dim_value||'");
2427                 document.dimensions.dim5.focus();
2428                 return FALSE;
2429                 }
2430              else
2431                 var d5 =  document.dimensions.dim5[d5_tmp].value;
2432              }
2433           else
2434              {d5 = "-";}
2435 
2436       // mdamle 01/15/2001 - Use Dim6 and Dim7
2437           // For dimension6
2438           if (document.dimensions.dim6_level_id.value != "") {
2439              var d6_tmp = document.dimensions.dim6.selectedIndex;
2440              var d6_end = document.dimensions.dim6.length;
2441        // mdamle 06/66/2006 - Changed the check |||r to Dim0 check
2442              // if (d6_tmp == 0 '||c_OR||' d6_tmp == d6_end - 6){
2443              if ((document.dimensions.dim6[d6_tmp].text == "'||l_blank||'") '
2444                 ||c_OR||
2445                 ' (document.dimensions.dim6[d6_tmp].text == "'||c_choose
2446                 ||'"))  {
2447                 d6 = "+";
2448                 alert("'||l_choose_dim_value||'");
2449                 document.dimensions.dim6.focus();
2450                 return FALSE;
2451                 }
2452              else
2453                 var d6 =  document.dimensions.dim6[d6_tmp].value;
2454              }
2455           else
2456              {d6 = "-";}
2457 
2458       // mdamle 01/15/2001 - Use Dim6 and Dim7
2459           // For dimension7
2460           if (document.dimensions.dim7_level_id.value != "") {
2461              var d7_tmp = document.dimensions.dim7.selectedIndex;
2462              var d7_end = document.dimensions.dim7.length;
2463        // mdamle 07/77/2007 - Changed the check |||r to Dim0 check
2464              // if (d7_tmp == 0 '||c_OR||' d7_tmp == d7_end - 7){
2465              if ((document.dimensions.dim7[d7_tmp].text == "'||l_blank||'") '
2466                 ||c_OR||
2467                 ' (document.dimensions.dim7[d7_tmp].text == "'||c_choose
2468                 ||'"))  {
2469                 d7 = "+";
2470                 alert("'||l_choose_dim_value||'");
2471                 document.dimensions.dim7.focus();
2472                 return FALSE;
2473                 }
2474              else
2475                 var d7 =  document.dimensions.dim7[d7_tmp].value;
2476              }
2477           else
2478              {d7 = "-";}
2479 
2480           // For Plan
2481            var plan_tmp = document.dimensions.plan.selectedIndex;
2482            var plan     = document.dimensions.plan[plan_tmp].value
2483 
2484            var totext=document.dimensions.label.value;
2485      // mdamle 01/15/2001 - Use Dim6 and Dim7
2486      // Put Org dimension value in the correct dimension
2487      if (document.dimensions.orgDimension.value == "1")
2488        d1 = d0;
2489      if (document.dimensions.orgDimension.value == "2")
2490          d2 = d0;
2491      if (document.dimensions.orgDimension.value == "3")
2492        d3 = d0;
2493      if (document.dimensions.orgDimension.value == "4")
2494        d4 = d0;
2495      if (document.dimensions.orgDimension.value == "5")
2496        d5 = d0;
2497      if (document.dimensions.orgDimension.value == "6")
2498        d6 = d0;
2499      if (document.dimensions.orgDimension.value == "7")
2500        d7 = d0;
2501 
2502      // mdamle 01/15/2001 - Add d6 and d7
2503      var tovalue= ind + "*" + d0 + "*" + d1 + "*" + d2 + "*" + d3 + "*" + d4 + "*" + d5 + "*" + d6 + "*" + d7 + "*" + plan;
2504           var end=document.dimensions.C.length;
2505     var duplicated_val = 0;
2506     var duplicated_txt = 0;
2507           if (end > 0) {
2508             if (document.dimensions.C.options[end-1].value =="") {
2509               end = end - 1;
2510       }
2511 
2512             for (var i=0;i<end;i++){
2513         var cvar = document.dimensions.C[i].value;
2514 
2515               if (tovalue == cvar.substr(0, cvar.length -2 )) {
2516                   duplicated_val = 1;
2517               }
2518               if (totext == document.dimensions.C[i].text) {
2519                 duplicated_txt = 1;
2520               }
2521       }
2522             if (duplicated_val == 1){
2523                alert("'||l_dup_combo||'");
2524             } else if (duplicated_txt == 1) {
2525                alert("'||l_dup_displabel||'");
2526             }
2527 
2528           }
2529     if ( (duplicated_val == 0) && (duplicated_txt == 0) ) {
2530             document.dimensions.C.options[end] = new Option(totext,tovalue+"*Y");
2531             document.dimensions.C.selectedIndex = end;
2532     }
2533           '||l_history||'
2534 
2535   }
2536        }');
2537 
2538 
2539        -- Function to move selections upwards
2540        -- meastmon 06/25/2001 Fix bug#1835495.
2541        htp.p('function upTo() {
2542             var temp = document.dimensions.C.selectedIndex;
2543             if (temp < 0)
2544                selectTo();
2545             else {
2546               if (temp > 0) {
2547                 var text = document.dimensions.C[temp-1].text;
2548                 var val = document.dimensions.C.options[temp-1].value;
2549                 var totext = document.dimensions.C[temp].text;
2550                 var toval = document.dimensions.C.options[temp].value;
2551 
2552                 document.dimensions.C[temp-1].text = totext;
2553                 document.dimensions.C.options[temp-1].value = toval;
2554                 document.dimensions.C[temp].text = text;
2555                 document.dimensions.C.options[temp].value = val;
2556                 document.dimensions.C.selectedIndex = temp-1;
2557               }
2558             }
2559             '||l_history||'
2560           }');
2561 
2562 
2563        -- Function to move selections downwards
2564        -- meastmon 06/25/2001 Fix bug#1835495.
2565        htp.p('function downTo() {
2566             var temp = document.dimensions.C.selectedIndex;
2567             var end = document.dimensions.C.length;
2568 
2569             if (temp < 0)
2570                selectTo();
2571             else {
2572               if (document.dimensions.C.options[end-1].value == "")
2573                 end = end - 1;
2574 
2575               if (temp < (end-1)) {
2576                 var text = document.dimensions.C[temp+1].text;
2577                 var val = document.dimensions.C.options[temp+1].value;
2578                 var totext = document.dimensions.C[temp].text;
2579                 var toval = document.dimensions.C.options[temp].value;
2580 
2581                 document.dimensions.C[temp+1].text = totext;
2582                 document.dimensions.C.options[temp+1].value = toval;
2583                 document.dimensions.C[temp].text = text;
2584                 document.dimensions.C.options[temp].value = val;
2585                 document.dimensions.C.selectedIndex = temp+1;
2586               }
2587             }
2588             '||l_history||'
2589           }');
2590 
2591 
2592       htp.p('function deleteTo() {
2593         var temp=document.dimensions.C.selectedIndex;
2594          if (temp < 0)
2595            selectTo();
2596          else {
2597            if (confirm("'||BIS_UTILITIES_PVT.getPrompt('BIS_DELETE')
2598               ||'" + " " + document.dimensions.C.options[temp].text + "?"))
2599            document.dimensions.C.options[temp] = null;
2600            };
2601         }');
2602 
2603     htp.p('function open_new_browser(url,x,y){
2604         var attributes = "resizable=yes,scrollbars=yes,toolbar=no,width="+x+",height="+ y;
2605         var new_browser = window.open(url, "new_browser", attributes);
2606         if (new_browser != null) {
2607             if (new_browser.opener == null)
2608                 new_browser.opener = self;
2609             window.name = ''favorite'';
2610             new_browser.location.href = url;
2611             }
2612         }');
2613 
2614      -- Function to Edit the Label
2615      -- meastmon 09/25/2001 Fix bug#1993005 There can be spaces in the dim level value id.
2616      -- We need to use escape() to encode the U parameter.
2617      htp.p('function editTo() {
2618         var temp=document.dimensions.C.selectedIndex;
2619         if (temp<0) {
2620            alert("'||l_select_displabel||'");
2621         } else {
2622 
2623          var cval = document.dimensions.C[temp].value;
2624 
2625          var c_access = cval.substr(cval.length-1, 1);
2626          if (c_access == "N" ) {
2627            alert("'||l_un_auth||'.");
2628          } else {
2629            var url = "bis_portlet_pmregion.editDimensions?U=" + escape(cval) + "'
2630                       ||c_amp||'" + "Z=" + "'||Z||'";
2631            open_new_browser(url,600,450);
2632          }
2633         }
2634        }');
2635 
2636      --  Function to save the selected labels
2637      htp.p('function savedimensions() {
2638         var end=document.dimensions.C.length;
2639         for (var i=0; i<end; i++) {
2640           if (document.dimensions.C.options[i].value != "") {
2641              var sval = document.dimensions.C.options[i].value;
2642        var tval = sval.substr(0, sval.length-2);
2643              document.strDimensions.p_displaylabels_tbl[i].value= tval + "*" + document.dimensions.C.options[i].text;
2644 
2645 //             document.strDimensions.p_displaylabels_tbl[i].value= document.dimensions.C.options[i].value + "*" + document.dimensions.C.options[i].text;
2646            }
2647 
2648         }
2649         document.strDimensions.submit();
2650 
2651       }');
2652 
2653      -- Function to set the indicator level and recreate the page
2654       htp.p('function setIndlevel() {
2655 
2656          var end=document.dimensions.C.length;
2657          for (var i=0;i < end;i++)
2658             if (document.dimensions.C.options[i].value != "")
2659               document.indicators.p_displaylabels_tbl[i].value = document.dimensions.C.options[i].value + "*" + document.dimensions.C.options[i].text;
2660            var tmp = document.indicators.p_indlevel.selectedIndex;
2661          document.indicators.p_ind_level_id.value = document.indicators.p_indlevel[tmp].value;
2662          document.indicators.submit();
2663        }');
2664 
2665        -- Get string to clear dim1-5 in case they are related to the org
2666        --
2667        l_elements(1) := 'plan';
2668        l_elements(2) := 'dim0';
2669        l_elements(3) := 'label';
2670        l_elements(4) := 'C';
2671 
2672        BIS_INDICATOR_REGION_UI_PVT.clearSelect
2673            ( p_formName     => 'dimensions'
2674            , p_elementTable => l_elements
2675            , x_clearString  => l_clear
2676            );
2677        --Bug 1797465
2678         for i in p_selections_tbl.FIRST .. p_selections_tbl.COUNT loop
2679           if (p_selections_tbl(i) is NULL) then
2680              EXIT;
2681           end if;
2682            l_loc := instr(p_selections_tbl(i),'*',1,1);
2683            l_value := substr (p_selections_tbl(i),1,l_loc - 1);
2684            l_text := substr (p_selections_tbl(i),l_loc + 1);
2685            if v_ind_level_id is NULL then
2686               v_ind_level_id := TO_NUMBER(l_value);
2687            end if;
2688            for c_recs in bisfv_target_levels_cur(v_ind_level_id) loop
2689              l_dim1_lbl := c_recs.Dimension1_Level_Name;
2690              l_dim2_lbl := c_recs.Dimension2_Level_Name;
2691              l_dim3_lbl := c_recs.Dimension3_Level_Name;
2692              l_dim4_lbl := c_recs.Dimension4_Level_Name;
2693              l_dim5_lbl := c_recs.Dimension5_Level_Name;
2694              l_dim6_lbl := c_recs.Dimension6_Level_Name;
2695              l_dim7_lbl := c_recs.Dimension7_Level_Name;
2696              l_Org_Seq_Num := BIS_INDICATOR_REGION_UI_PVT.getOrgSeqNum(v_ind_level_id);
2697 
2698          if l_Org_Seq_Num = 1 then
2699                l_dim0_lbl := c_recs.Dimension1_Level_Name;
2700          elsif l_Org_Seq_Num = 2 then
2701                l_dim0_lbl := c_recs.Dimension2_Level_Name;
2702        elsif l_Org_Seq_Num = 3 then
2703                l_dim0_lbl := c_recs.Dimension3_Level_Name;
2704        elsif l_Org_Seq_Num = 4 then
2705                l_dim0_lbl := c_recs.Dimension4_Level_Name;
2706        elsif l_Org_Seq_Num = 5 then
2707                l_dim0_lbl := c_recs.Dimension5_Level_Name;
2708        elsif l_Org_Seq_Num = 6 then
2709                l_dim0_lbl := c_recs.Dimension6_Level_Name;
2710        elsif l_Org_Seq_Num = 7 then
2711                l_dim0_lbl := c_recs.Dimension7_Level_Name;
2712        end if;
2713            end loop;
2714         end loop;
2715 
2716 
2717 -- meastmon 06/26/2001 Dont clear other dimensions
2718        htp.p('function setdim0() {
2719 // alert("setdim0");
2720          var end = document.dimensions.dim0.length;
2721          var temp = document.dimensions.dim0.selectedIndex;
2722          if (document.dimensions.dim0[temp].text == "'||c_choose||'") {
2723             var ind_tmp  = document.indicators.p_indlevel.selectedIndex;
2724             var ind    =   document.indicators.p_indlevel[ind_tmp].value;
2725             var dim_lvl_id = document.dimensions.dim0_level_id.value;
2726             var c_qry = "'||l_user_id||c_asterisk||'" + ind + "'
2727                           ||c_asterisk||'" + dim_lvl_id;
2728             var c_jsfuncname = "getdim0";
2729             document.dimensions.dim0.selectedIndex = 0;
2730 //modified for bug#2318543
2731             getLOV(''bis_portlet_pmregion.dim_level_values_query'',c_qry,c_jsfuncname,'||Z||',"'||bis_utilities_pub.encode(l_dim0_lbl)||'");
2732             }
2733         }');
2734 --         else {
2735 --         '||l_clear||'
2736 --         }
2737 
2738        SetSetOfBookVar
2739            ( p_user_id     => l_user_id
2740            , p_formName    => 'dimensions'
2741            , p_index       => 'dim0_index'
2742            , x_sobString   => l_sobString
2743            );
2744 
2745        htp.p('function setdim1() {
2746 // alert("setdim1");
2747          var end = document.dimensions.dim1.length;
2748          var temp = document.dimensions.dim1.selectedIndex;
2749          if (document.dimensions.dim1[temp].text == "'||c_choose||'") {
2750             var ind_tmp  = document.indicators.p_indlevel.selectedIndex;
2751             var ind    =   document.indicators.p_indlevel[ind_tmp].value;
2752             var dim_lvl_id = document.dimensions.dim1_level_id.value;
2753 
2754       // mdamle 01/15/2001 - Moved conditional code into l_sobString
2755             '||l_sobString||'
2756 
2757             var c_jsfuncname = "getdim1";
2758             document.dimensions.dim1.selectedIndex = 0;
2759 //  alert("dim1 query (user_id, ind, dim lvl, dim0 lvl, dim0 id, g_var): "+c_qry);
2760 
2761 //modified for bug#2318543
2762             getLOV(''bis_portlet_pmregion.dim_level_values_query'',c_qry,c_jsfuncname,'||Z||',"'||bis_utilities_pub.encode(l_dim1_lbl)||'");
2763             }
2764         }');
2765 
2766 
2767 
2768        htp.p('function setdim2() {
2769 // alert("setdim2");
2770          var end = document.dimensions.dim2.length;
2771          var temp = document.dimensions.dim2.selectedIndex;
2772          if (document.dimensions.dim2[temp].text == "'||c_choose||'") {
2773             var ind_tmp  = document.indicators.p_indlevel.selectedIndex;
2774             var ind    =   document.indicators.p_indlevel[ind_tmp].value;
2775             var dim_lvl_id = document.dimensions.dim2_level_id.value;
2776 
2777       // mdamle 01/15/2001 - Moved conditional code into l_sobString
2778             '||l_sobString||'
2779 
2780             var c_jsfuncname = "getdim2";
2781             document.dimensions.dim2.selectedIndex = 0;
2782 //modified for bug#2318543
2783             getLOV(''bis_portlet_pmregion.dim_level_values_query'',c_qry,c_jsfuncname,'||Z||',"'||bis_utilities_pub.encode(l_dim2_lbl)||'");
2784             }
2785         }');
2786 
2787 
2788 
2789        htp.p('function setdim3() {
2790 // alert("setdim3");
2791          var end = document.dimensions.dim3.length;
2792          var temp = document.dimensions.dim3.selectedIndex;
2793          if (document.dimensions.dim3[temp].text == "'||c_choose||'") {
2794             var ind_tmp  = document.indicators.p_indlevel.selectedIndex;
2795             var ind    =   document.indicators.p_indlevel[ind_tmp].value;
2796             var dim_lvl_id = document.dimensions.dim3_level_id.value;
2797 
2798       // mdamle 01/15/2001 - Moved conditional code into l_sobString
2799             '||l_sobString||'
2800 
2801             var c_jsfuncname = "getdim3";
2802             document.dimensions.dim3.selectedIndex = 0;
2803 
2804 //modified for bug#2318543
2805             getLOV(''bis_portlet_pmregion.dim_level_values_query'',c_qry,c_jsfuncname,'||Z||',"'||bis_utilities_pub.encode(l_dim3_lbl)||'");
2806             }
2807         }');
2808 
2809 
2810 
2811        htp.p('function setdim4() {
2812 // alert("setdim4");
2813          var end = document.dimensions.dim4.length;
2814          var temp = document.dimensions.dim4.selectedIndex;
2815          if (document.dimensions.dim4[temp].text == "'||c_choose||'") {
2816             var ind_tmp  = document.indicators.p_indlevel.selectedIndex;
2817             var ind    =   document.indicators.p_indlevel[ind_tmp].value;
2818             var dim_lvl_id = document.dimensions.dim4_level_id.value;
2819 
2820       // mdamle 01/15/2001 - Moved conditional code into l_sobString
2821             '||l_sobString||'
2822 
2823             var c_jsfuncname = "getdim4";
2824             document.dimensions.dim4.selectedIndex = 0;
2825 //modified for bug#2318543
2826             getLOV(''bis_portlet_pmregion.dim_level_values_query'',c_qry,c_jsfuncname,'||Z||',"'||bis_utilities_pub.encode(l_dim4_lbl)||'");
2827             }
2828         }');
2829 
2830 
2831 
2832        htp.p('function setdim5() {
2833 // alert("setdim5");
2834          var end = document.dimensions.dim5.length;
2835          var temp = document.dimensions.dim5.selectedIndex;
2836          if (document.dimensions.dim5[temp].text == "'||c_choose||'") {
2837             var ind_tmp  = document.indicators.p_indlevel.selectedIndex;
2838             var ind    =   document.indicators.p_indlevel[ind_tmp].value;
2839             var dim_lvl_id = document.dimensions.dim5_level_id.value;
2840 
2841       // mdamle 01/15/2001 - Moved conditional code into l_sobString
2842             '||l_sobString||'
2843 
2844             var c_jsfuncname = "getdim5";
2845             document.dimensions.dim5.selectedIndex = 0;
2846 //modified for bug#2318543
2847             getLOV(''bis_portlet_pmregion.dim_level_values_query'',c_qry,c_jsfuncname,'||Z||',"'||bis_utilities_pub.encode(l_dim5_lbl)||'");
2848             }
2849         }');
2850 
2851      -- mdamle 01/15/2001 - Use Dim6 and Dim7
2852        htp.p('function setdim6() {
2853 // alert("setdim6");
2854          var end = document.dimensions.dim6.length;
2855          var temp = document.dimensions.dim6.selectedIndex;
2856          if (document.dimensions.dim6[temp].text == "'||c_choose||'") {
2857             var ind_tmp  = document.indicators.p_indlevel.selectedIndex;
2858             var ind    =   document.indicators.p_indlevel[ind_tmp].value;
2859             var dim_lvl_id = document.dimensions.dim6_level_id.value;
2860 
2861       // mdamle 01/15/2001 - Moved conditional code into l_sobString
2862             '||l_sobString||'
2863 
2864             var c_jsfuncname = "getdim6";
2865             document.dimensions.dim6.selectedIndex = 0;
2866 //modified for bug#2318543
2867             getLOV(''bis_portlet_pmregion.dim_level_values_query'',c_qry,c_jsfuncname,'||Z||',"'||bis_utilities_pub.encode(l_dim6_lbl)||'");
2868             }
2869         }');
2870 
2871        htp.p('function setdim7() {
2872 // alert("setdim7");
2873          var end = document.dimensions.dim7.length;
2874          var temp = document.dimensions.dim7.selectedIndex;
2875          if (document.dimensions.dim7[temp].text == "'||c_choose||'") {
2876             var ind_tmp  = document.indicators.p_indlevel.selectedIndex;
2877             var ind    =   document.indicators.p_indlevel[ind_tmp].value;
2878             var dim_lvl_id = document.dimensions.dim7_level_id.value;
2879 
2880       // mdamle 01/15/2001 - Moved conditional code into l_sobString
2881             '||l_sobString||'
2882 
2883             var c_jsfuncname = "getdim7";
2884             document.dimensions.dim7.selectedIndex = 0;
2885 //modified for bug#2318543
2886             getLOV(''bis_portlet_pmregion.dim_level_values_query'',c_qry,c_jsfuncname,'||Z||',"'||bis_utilities_pub.encode(l_dim7_lbl)||'");
2887             }
2888         }');
2889 
2890 
2891    htp.p('</SCRIPT>');
2892    htp.p('<!-- End of Javascript -->');
2893 
2894     -- ***************
2895     htp.p('<!-- Paint the dummy form to grab the display labels -->');
2896     -- Dummy form to send selected labels to a procedure that inserts the
2897     -- display labels and dimlvl valss into the  BIS_USER_IND_SELECTIONS table
2898 
2899     htp.formOpen('bis_portlet_pmregion.strDimensions'
2900                 ,'POST','','','NAME="strDimensions"');
2901     htp.formHidden('W');
2902 
2903     -- Create hidden values to grab selected labels into
2904     for i in  1 .. c_counter LOOP
2905        htp.formHidden('p_displaylabels_tbl');
2906     end loop;
2907 
2908     htp.formHidden('Z',Z);
2909     htp.formHidden('p_back_url',p_back_url);
2910     htp.formHidden('p_reference_path', p_reference_path);
2911 
2912     htp.p('<!-- Close the dummy form to grab the display labels -->');
2913     htp.formClose;
2914     -- **************
2915 
2916     -- *************
2917     htp.p('<!-- Begin Layout of boxes -->');
2918     htp.centerOpen;
2919     htp.p('<!-- Begin Main table  -->');
2920     -- main
2921     htp.p('<table width="100%" border=0 cellspacing=0 cellpadding=0>');
2922 
2923     htp.p('<!-- Row 1 Main table  -->');
2924     htp.tableRowOpen;             -- Row one of Main
2925     htp.p('<td align="CENTER">');
2926     htp.p('<!-- Begin Cell table to center all items except the ok-cancel buttons  -->');
2927     htp.p('<table width="75%" border=0 cellspacing=0 cellpadding=0>');
2928 
2929     htp.p('<!-- Begin Row 1 of cell table -->');
2930     htp.tableRowOpen;             -- Row one of Cell table
2931     htp.p('<td align="LEFT" valign="TOP">');
2932 
2933      htp.p('<!-- Open table for left set of boxes -->');
2934      -- target level and dimensions boxes table
2935      htp.p('<table border=0 cellspacing=0 cellpadding=0>');
2936       htp.tableRowOpen;         -- row one of boxes table
2937       htp.tableData(bis_utilities_pvt.escape_html(c_tarlevel),calign=>'LEFT');
2938       htp.tableRowClose;
2939 
2940       htp.p('<!-- Row 2 Open for left side table -->');
2941       htp.tableRowOpen;   -- Row 2 containing target levels poplist
2942       htp.p('<td align="LEFT" valign="TOP">');
2943      -- **********
2944 
2945      -- **********
2946      -- Open a form for indicator levels
2947 
2948      htp.p('<!-- Open form to grab target levels for onchange event of tar level poplist -->');
2949      htp.formOpen('bis_portlet_pmregion.showDimensions'
2950                   ,'POST','','','NAME="indicators"');
2951 
2952         -- Create hidden values to grab selected labels into
2953         for i in 1 .. c_counter LOOP
2954            htp.formHidden('p_displaylabels_tbl');
2955         end loop;
2956 
2957         for i in p_selections_tbl.FIRST .. p_selections_tbl.COUNT loop
2958          if (p_selections_tbl(i) is NULL) then
2959             EXIT;
2960          end if;
2961         htp.formHidden('p_selections_tbl',p_selections_tbl(i));
2962         end loop;
2963 
2964         htp.formHidden('Z',Z);
2965         htp.formHidden('p_back_url',p_back_url);
2966   htp.formHidden('p_reference_path', p_reference_path);
2967         htp.formHidden('p_ind_level_id');
2968 
2969         htp.formSelectOpen('p_indlevel'
2970                            ,cattributes=>'onChange="setIndlevel()"');
2971         for i in p_selections_tbl.FIRST .. p_selections_tbl.COUNT loop
2972           if (p_selections_tbl(i) is NULL) then
2973              EXIT;
2974           end if;
2975            l_loc := instr(p_selections_tbl(i),'*',1,1);
2976            l_value := substr (p_selections_tbl(i),1,l_loc - 1);
2977            l_text := substr (p_selections_tbl(i),l_loc + 1);
2978            if v_ind_level_id is NULL then
2979               v_ind_level_id := TO_NUMBER(l_value);
2980            end if;
2981 
2982            if l_value = TO_CHAR(v_ind_level_id) then
2983               htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_text),cselected=>'YES',
2984               cattributes=>'VALUE='||bis_utilities_pvt.escape_html_input(l_value));
2985            else
2986               htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_text),
2987               cattributes=>'VALUE='||bis_utilities_pvt.escape_html_input(l_value));
2988            end if;
2989          end loop;
2990         htp.formSelectClose;
2991 
2992        -- Form close for indicator levels selection
2993        htp.formClose;
2994        htp.p('<!-- Close form for target levels poplist -->');
2995        htp.p('</td>');
2996        htp.tableRowClose;
2997 
2998        htp.tableRowOpen;
2999        htp.tableData(bis_utilities_pvt.escape_html(c_dim_and_plan), calign=>'LEFT');
3000        htp.tableRowClose;
3001 
3002        htp.p('<!-- Open row for embedded dimensions boxes table -->');
3003        htp.tableRowOpen;    -- Open row for dimensions boxes table
3004        htp.p('<td align="LEFT" valign="TOP">');
3005 
3006        htp.p('<!-- open table containing wireframe -->');
3007        -- target level and dimensions boxes table
3008        htp.p('<table border=0 cellspacing=0 cellpadding=0>');
3009         htp.tableRowOpen;
3010         htp.p('<td height=1 bgcolor=#000000 colspan=5>'||
3011               '<IMG SRC="/OA_MEDIA/FNDINVDT.gif" height=1 width=1></td>');
3012         htp.tableRowClose;
3013 
3014         htp.tableRowOpen;
3015          htp.p('<!-- Begin left edge of wireframe and left separator -->');
3016          htp.p('<td width=1 bgcolor=#000000>'||
3017                '<IMG SRC="/OA_MEDIA/FNDINVDT.gif" height=1 width=1></td>');
3018          htp.p('<td width=5></td>');
3019 
3020 
3021     -- ************************************
3022     -- Print out NOCOPY the main form
3023 
3024     htp.p('<!-- Begin main form to display and grab the labels -->');
3025     htp.formOpen('javascript:savedimensions()'
3026                 ,'POST','','','NAME="dimensions"');
3027 
3028     -- Grab the individual dim_level_values chosen previously for
3029     -- this target_level_id, to populate respective dimension level poplists
3030     if (l_labels_tbl.COUNT <> 0) THEN
3031        l_cnt := 1;
3032        for i in l_labels_tbl.FIRST .. l_labels_tbl.COUNT LOOP
3033          if (l_labels_tbl(i).target_level_id = v_ind_level_id) THEN
3034        -- mdamle 01/15/2001 - Use Dim6 and Dim7
3035        /*
3036            IF (l_labels_tbl(i).org_level_value_ID is NOT NULL) THEN
3037              l_orgs_tbl(l_cnt).id   := l_labels_tbl(i).org_level_value_ID;
3038              l_orgs_tbl(l_cnt).name := l_labels_tbl(i).org_level_value_name;
3039            END IF;
3040 
3041            -- mdamle 01/15/2001 - Use Dim6 and Dim7
3042            -- Get the Dimension No. for Org
3043        l_Org_Seq_Num := BIS_INDICATOR_REGION_UI_PVT.getOrgSeqNum(v_ind_level_id);
3044 
3045            IF (l_labels_tbl(i).dim1_level_value_id is NOT NULL) THEN
3046             l_dim1_tbl(l_cnt).id   := l_labels_tbl(i).dim1_level_value_id;
3047             l_dim1_tbl(l_cnt).name := l_labels_tbl(i).dim1_level_value_name;
3048       -- mdamle 01/15/2001 Use Dim6 and Dim7
3049       if l_Org_Seq_Num = 1 then
3050              l_orgs_tbl(l_cnt).id   := l_labels_tbl(i).dim1_level_value_id;
3051              l_orgs_tbl(l_cnt).name := l_labels_tbl(i).dim1_level_value_name;
3052       end if;
3053            END IF;
3054            IF (l_labels_tbl(i).dim2_level_value_id is NOT NULL) THEN
3055             l_dim2_tbl(l_cnt).id   := l_labels_tbl(i).dim2_level_value_id;
3056             l_dim2_tbl(l_cnt).name := l_labels_tbl(i).dim2_level_value_name;
3057       -- mdamle 01/15/2001 Use Dim6 and Dim7
3058       if l_Org_Seq_Num = 2 then
3059              l_orgs_tbl(l_cnt).id   := l_labels_tbl(i).dim2_level_value_id;
3060              l_orgs_tbl(l_cnt).name := l_labels_tbl(i).dim2_level_value_name;
3061       end if;
3062            END IF;
3063            IF (l_labels_tbl(i).dim3_level_value_id is NOT NULL) THEN
3064             l_dim3_tbl(l_cnt).id   := l_labels_tbl(i).dim3_level_value_id;
3065             l_dim3_tbl(l_cnt).name := l_labels_tbl(i).dim3_level_value_name;
3066       -- mdamle 01/15/2001 Use Dim6 and Dim7
3067       if l_Org_Seq_Num = 3 then
3068              l_orgs_tbl(l_cnt).id   := l_labels_tbl(i).dim3_level_value_id;
3069              l_orgs_tbl(l_cnt).name := l_labels_tbl(i).dim3_level_value_name;
3070       end if;
3071            END IF;
3072            IF (l_labels_tbl(i).dim4_level_value_id is NOT NULL) THEN
3073             l_dim4_tbl(l_cnt).id   := l_labels_tbl(i).dim4_level_value_id;
3074             l_dim4_tbl(l_cnt).name := l_labels_tbl(i).dim4_level_value_name;
3075       -- mdamle 01/15/2001 Use Dim6 and Dim7
3076       if l_Org_Seq_Num = 4 then
3077              l_orgs_tbl(l_cnt).id   := l_labels_tbl(i).dim4_level_value_id;
3078              l_orgs_tbl(l_cnt).name := l_labels_tbl(i).dim4_level_value_name;
3079       end if;
3080            END IF;
3081            IF (l_labels_tbl(i).dim5_level_value_id is NOT NULL) THEN
3082             l_dim5_tbl(l_cnt).id   := l_labels_tbl(i).dim5_level_value_id;
3083             l_dim5_tbl(l_cnt).name := l_labels_tbl(i).dim5_level_value_name;
3084       -- mdamle 01/15/2001 Use Dim6 and Dim7
3085       if l_Org_Seq_Num = 5 then
3086              l_orgs_tbl(l_cnt).id   := l_labels_tbl(i).dim5_level_value_id;
3087              l_orgs_tbl(l_cnt).name := l_labels_tbl(i).dim5_level_value_name;
3088       end if;
3089            END IF;
3090          -- mdamle 01/15/2001 - Use Dim6 and Dim7
3091            IF (l_labels_tbl(i).dim6_level_value_id is NOT NULL) THEN
3092             l_dim6_tbl(l_cnt).id   := l_labels_tbl(i).dim6_level_value_id;
3093             l_dim6_tbl(l_cnt).name := l_labels_tbl(i).dim6_level_value_name;
3094       -- mdamle 01/15/2001 Use Dim6 and Dim7
3095       if l_Org_Seq_Num = 6 then
3096              l_orgs_tbl(l_cnt).id   := l_labels_tbl(i).dim6_level_value_id;
3097              l_orgs_tbl(l_cnt).name := l_labels_tbl(i).dim6_level_value_name;
3098       end if;
3099            END IF;
3100        IF (l_labels_tbl(i).dim7_level_value_id is NOT NULL) THEN
3101             l_dim7_tbl(l_cnt).id   := l_labels_tbl(i).dim7_level_value_id;
3102             l_dim7_tbl(l_cnt).name := l_labels_tbl(i).dim7_level_value_name;
3103       -- mdamle 01/15/2001 Use Dim6 and Dim7
3104       if l_Org_Seq_Num = 7 then
3105              l_orgs_tbl(l_cnt).id   := l_labels_tbl(i).dim7_level_value_id;
3106              l_orgs_tbl(l_cnt).name := l_labels_tbl(i).dim7_level_value_name;
3107       end if;
3108            END IF;
3109 
3110        l_cnt := l_cnt + 1;
3111          END IF;
3112        END LOOP;
3113     END IF; -- if l_labels_tbl is not empty
3114 
3115    --Begin cell containing the embedded table of poplists
3116    htp.p('<td align="CENTER">');
3117 
3118    htp.p('<!-- Begin embedded table inside the wireframe containing the poplists -->');
3119     -- table containing the dimension_level names,boxes
3120    htp.tableOpen;
3121 
3122     for c_recs in bisfv_target_levels_cur(v_ind_level_id) loop
3123 
3124      -- *************************************************************
3125      -- Start painting the dimension levels poplists
3126      -- If no dimension level for this ind level, put a hidden value
3127      -- to user later
3128 
3129       -- ******************************
3130       -- Dimension0 for Organization
3131 
3132       -- meastmon 05/11/2001
3133       l_Time_Seq_Num := BIS_INDICATOR_REGION_UI_PVT.getTimeSeqNum(v_ind_level_id);
3134       htp.formHidden('timeDimension', l_Time_Seq_Num);
3135 
3136       -- mdamle 01/15/2001 - Use Dim6 and Dim7
3137       -- Get the Dimension No. for Org
3138       l_Org_Seq_Num := BIS_INDICATOR_REGION_UI_PVT.getOrgSeqNum(v_ind_level_id);
3139       htp.formHidden('orgDimension', l_Org_Seq_Num);
3140 
3141     -- mdamle 01/15/2001 - Use Dim6 and Dim7
3142     if l_Org_Seq_Num = 1 then
3143        l_Org_Level_ID := c_recs.Dimension1_level_id;
3144      l_Org_Level_Short_Name := c_recs.Dimension1_level_Short_name;
3145      l_Org_Level_Name := c_recs.Dimension1_level_Name;
3146     end if;
3147     if l_Org_Seq_Num = 2 then
3148        l_Org_Level_ID := c_recs.Dimension2_level_id;
3149      l_Org_Level_Short_Name := c_recs.Dimension2_level_Short_name;
3150      l_Org_Level_Name := c_recs.Dimension2_level_Name;
3151     end if;
3152     if l_Org_Seq_Num = 3 then
3153        l_Org_Level_ID := c_recs.Dimension3_level_id;
3154      l_Org_Level_Short_Name := c_recs.Dimension3_level_Short_name;
3155      l_Org_Level_Name := c_recs.Dimension3_level_Name;
3156     end if;
3157     if l_Org_Seq_Num = 4 then
3158        l_Org_Level_ID := c_recs.Dimension4_level_id;
3159      l_Org_Level_Short_Name := c_recs.Dimension4_level_Short_name;
3160      l_Org_Level_Name := c_recs.Dimension4_level_Name;
3161     end if;
3162     if l_Org_Seq_Num = 5 then
3163        l_Org_Level_ID := c_recs.Dimension5_level_id;
3164      l_Org_Level_Short_Name := c_recs.Dimension5_level_Short_name;
3165      l_Org_Level_Name := c_recs.Dimension5_level_Name;
3166     end if;
3167     if l_Org_Seq_Num = 6 then
3168        l_Org_Level_ID := c_recs.Dimension6_level_id;
3169      l_Org_Level_Short_Name := c_recs.Dimension6_level_Short_name;
3170      l_Org_Level_Name := c_recs.Dimension6_level_Name;
3171     end if;
3172     if l_Org_Seq_Num = 7 then
3173        l_Org_Level_ID := c_recs.Dimension7_level_id;
3174      l_Org_Level_Short_Name := c_recs.Dimension7_level_Short_name;
3175      l_Org_Level_Name := c_recs.Dimension7_level_Name;
3176     end if;
3177 
3178       if (l_Org_Level_ID is NULL) then
3179          htp.formHidden('dim0_level_id',l_blank);
3180      -- mdamle 01/15/2001
3181          htp.formHidden('set_sob','FALSE');
3182 
3183       elsif (l_Org_Level_Short_Name='TOTAL_ORGANIZATIONS') then
3184        htp.formHidden('dim0_level_id',l_Org_Level_ID);
3185        htp.formHidden('set_sob','FALSE');
3186        htp.tableRowOpen;
3187        htp.tableData(bis_utilities_pvt.escape_html(l_Org_Level_Name) ,calign=>'RIGHT',cnowrap=>'YES');
3188        htp.p('<td align="left">');
3189        htp.formSelectOpen('dim0');
3190        htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(LOWER(l_Org_Level_Short_Name)),
3191                   cselected=>'YES',
3192                   cattributes=>'VALUE=-1');
3193        htp.formSelectClose;
3194       else
3195        -- Print out NOCOPY label and input box for dimension0
3196        htp.formHidden('dim0_level_id',l_Org_Level_ID);
3197 
3198        -- Set flag to True if we need to pass the related sob info
3199        -- along
3200        --
3201         if (l_Org_Level_Short_Name='SET OF BOOKS') then
3202           htp.formHidden('set_sob','TRUE');
3203         else
3204           htp.formHidden('set_sob','FALSE');
3205         end if;
3206 
3207        htp.tableRowOpen;
3208        htp.tableData(bis_utilities_pvt.escape_html(l_Org_Level_Name) ,calign=>'RIGHT',cnowrap=>'YES');
3209        htp.p('<td align="left">');
3210        htp.formSelectOpen('dim0',cattributes=>'onchange="setdim0()"');
3211        htp.formSelectOption(l_blank,cselected=>'YES');
3212        if (l_orgs_tbl.COUNT <> 0) THEN
3213           BIS_INDICATOR_REGION_UI_PVT.removeDuplicates(p_original_tbl => l_orgs_tbl,
3214                            p_value        => NULL,
3215                            x_unique_tbl   => l_d0_tbl);
3216           for i in 1 ..l_d0_tbl.COUNT LOOP
3217              exit when (l_d0_tbl(i).id is NULL);
3218              htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_d0_tbl(i).name),
3219                   cattributes=>'VALUE='||bis_utilities_pvt.escape_html_input(l_d0_tbl(i).id));
3220           end loop;
3221        end if;
3222        htp.formSelectOption(c_choose);
3223        htp.formSelectClose;
3224        htp.p('</td>');
3225        htp.tablerowClose;
3226       end if;
3227 
3228       -- ***********************************
3229       -- Dimension1
3230     -- mdamle 01/15/2001 - Use Dim6 and Dim7
3231       -- meastmon 05/11/2001
3232       -- Dont show time dimension level
3233       if (c_recs.Dimension1_Level_ID is NULL) or (l_Org_Seq_Num = 1) or (l_Time_Seq_Num = 1) then
3234        if (l_Org_Seq_Num = 1) or (l_Time_Seq_Num = 1) then
3235       htp.formHidden('dim1_level_id', NULL);
3236          else
3237           htp.formHidden('dim1_level_id',c_recs.Dimension1_Level_ID);
3238      end if;
3239       else
3240 
3241       -- Print out NOCOPY label and input box for dimension1
3242        htp.formHidden('dim1_level_id',c_recs.Dimension1_Level_ID);
3243        htp.tableRowOpen;
3244        htp.tableData(bis_utilities_pvt.escape_html(c_recs.Dimension1_Level_Name)
3245                     ,calign=>'RIGHT',cnowrap=>'YES');
3246        htp.p('<td align="left">');
3247        htp.formSelectOpen('dim1',cattributes=>'onchange="setdim1()"');
3248        htp.formSelectOption(l_blank,cselected=>'YES');
3249        if (l_dim1_tbl.COUNT <> 0) THEN
3250           BIS_INDICATOR_REGION_UI_PVT.removeDuplicates(p_original_tbl => l_dim1_tbl,
3251                            p_value        => NULL,
3252                            x_unique_tbl   => l_d1_tbl);
3253           for i in 1 ..l_d1_tbl.COUNT LOOP
3254              exit when (l_d1_tbl(i).id is NULL);
3255        -- mdamle - 01/15/2001 - Add quotes around VALUE
3256              htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_d1_tbl(i).name),
3257                   cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_d1_tbl(i).id)||'"');
3258           end loop;
3259        end if;
3260        htp.formSelectOption(c_choose);
3261        htp.formSelectClose;
3262        htp.p('</td>');
3263        htp.tablerowClose;
3264       end if;
3265 
3266       -- *******************************************
3267       -- Dimension2
3268     -- mdamle 01/15/2001 - Use Dim6 and Dim
3269       -- meastmon 05/11/2001
3270       -- Dont show time dimension level
3271      if (c_recs.Dimension2_Level_ID is NULL) or (l_Org_Seq_Num = 2) or (l_Time_Seq_Num = 2) then
3272        if (l_Org_Seq_Num = 2) or (l_Time_Seq_Num = 2) then
3273       htp.formHidden('dim2_level_id', NULL);
3274          else
3275           htp.formHidden('dim2_level_id',c_recs.Dimension2_Level_ID);
3276      end if;
3277       else     -- Print out NOCOPY label and input box for dimension2
3278        htp.formHidden('dim2_level_id',c_recs.Dimension2_Level_ID);
3279        htp.tableRowOpen;
3280        htp.tableData(bis_utilities_pvt.escape_html(c_recs.Dimension2_Level_Name)
3281                     ,calign=>'RIGHT',cnowrap=>'YES');
3282        htp.p('<td align="left">');
3283        htp.formSelectOpen('dim2',cattributes=>'onchange="setdim2()"');
3284        htp.formSelectOption(l_blank,cselected=>'YES');
3285        if (l_dim2_tbl.COUNT <> 0) THEN
3286           BIS_INDICATOR_REGION_UI_PVT.removeDuplicates(p_original_tbl => l_dim2_tbl,
3287                            p_value        => NULL,
3288                            x_unique_tbl   => l_d2_tbl);
3289           for i in 1 ..l_d2_tbl.COUNT LOOP
3290              exit when (l_d2_tbl(i).id is NULL);
3291        -- mdamle - 01/15/2001 - Add quotes around VALUE
3292              htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_d2_tbl(i).name),
3293                   cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_d2_tbl(i).id)||'"');
3294           end loop;
3295        end if;
3296        htp.formSelectOption(c_choose);
3297        htp.formSelectClose;
3298        htp.p('</td>');
3299        htp.tablerowClose;
3300       end if;
3301 
3302       -- *****************************************
3303       -- Dimension3
3304     -- mdamle 01/15/2001 - Use Dim6 and Dim
3305       -- meastmon 05/11/2001
3306       -- Dont show time dimension level
3307       if (c_recs.Dimension3_Level_ID is NULL) or (l_Org_Seq_Num = 3) or (l_Time_Seq_Num = 3) then
3308        if (l_Org_Seq_Num = 3) or (l_Time_Seq_Num = 3) then
3309       htp.formHidden('dim3_level_id', NULL);
3310          else
3311           htp.formHidden('dim3_level_id',c_recs.Dimension3_Level_ID);
3312      end if;
3313       else       -- Print out NOCOPY label and input box for dimension3
3314         htp.formHidden('dim3_level_id',c_recs.Dimension3_Level_ID);
3315         htp.tableRowOpen;
3316         htp.tableData(bis_utilities_pvt.escape_html(c_recs.Dimension3_Level_Name)
3317                      ,calign=>'RIGHT',cnowrap=>'YES');
3318         htp.p('<td align="left">');
3319         htp.formSelectOpen('dim3',cattributes=>'onchange="setdim3()"');
3320         htp.formSelectOption(l_blank,cselected=>'YES');
3321        if (l_dim3_tbl.COUNT <> 0) THEN
3322           BIS_INDICATOR_REGION_UI_PVT.removeDuplicates(p_original_tbl => l_dim3_tbl,
3323                            p_value        => NULL,
3324                            x_unique_tbl   => l_d3_tbl);
3325           for i in 1 ..l_d3_tbl.COUNT LOOP
3326              exit when (l_d3_tbl(i).id is NULL);
3327        -- mdamle - 01/15/2001 - Add quotes around VALUE
3328              htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_d3_tbl(i).name),
3329                   cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_d3_tbl(i).id)||'"');
3330           end loop;
3331        end if;
3332         htp.formSelectOption(c_choose);
3333         htp.formSelectClose;
3334         htp.p('</td>');
3335         htp.tablerowClose;
3336        end if;
3337 
3338       -- *****************************************
3339       -- Dimension4
3340     -- mdamle 01/15/2001 - Use Dim6 and Dim
3341       -- meastmon 05/11/2001
3342       -- Dont show time dimension level
3343       if (c_recs.Dimension4_Level_ID is NULL) or (l_Org_Seq_Num = 4) or (l_Time_Seq_Num = 4) then
3344        if (l_Org_Seq_Num = 4) or (l_Time_Seq_Num = 4) then
3345       htp.formHidden('dim4_level_id', NULL);
3346          else
3347           htp.formHidden('dim4_level_id',c_recs.Dimension4_Level_ID);
3348      end if;
3349       else       -- Print out NOCOPY label and input box for dimension4
3350        htp.formHidden('dim4_level_id',c_recs.Dimension4_Level_ID);
3351        htp.tableRowOpen;
3352        htp.tableData(bis_utilities_pvt.escape_html(c_recs.Dimension4_Level_Name)
3353                     ,calign=>'RIGHT',cnowrap=>'YES');
3354        htp.p('<td align="left">');
3355        htp.formSelectOpen('dim4',cattributes=>'onchange="setdim4()"');
3356        htp.formSelectOption(l_blank,cselected=>'YES');
3357        if (l_dim4_tbl.COUNT <> 0) THEN
3358           BIS_INDICATOR_REGION_UI_PVT.removeDuplicates(p_original_tbl => l_dim4_tbl,
3359                            p_value        => NULL,
3360                            x_unique_tbl   => l_d4_tbl);
3361           for i in 1 ..l_d4_tbl.COUNT LOOP
3362              exit when (l_d4_tbl(i).id is NULL);
3363        -- mdamle - 01/15/2001 - Add quotes around VALUE
3364              htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_d4_tbl(i).name),
3365                   cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_d4_tbl(i).id)||'"');
3366           end loop;
3367        end if;
3368        htp.formSelectOption(c_choose);
3369        htp.formSelectClose;
3370        htp.p('</td>');
3371        htp.tablerowClose;
3372       end if;
3373 
3374       -- ****************************************
3375       -- Dimension5
3376     -- mdamle 01/15/2001 - Use Dim6 and Dim
3377       -- meastmon 05/11/2001
3378       -- Dont show time dimension level
3379       if (c_recs.Dimension5_Level_ID is NULL) or (l_Org_Seq_Num = 5) or (l_Time_Seq_Num = 5) then
3380        if (l_Org_Seq_Num = 5) or (l_Time_Seq_Num = 5) then
3381       htp.formHidden('dim5_level_id', NULL);
3382          else
3383           htp.formHidden('dim5_level_id',c_recs.Dimension5_Level_ID);
3384      end if;
3385       else
3386        -- Print out NOCOPY label and input box for dimension5
3387        htp.formHidden('dim5_level_id',c_recs.Dimension5_Level_ID);
3388        htp.tableRowOpen;
3389        htp.tableData(bis_utilities_pvt.escape_html(c_recs.Dimension5_Level_Name)
3390                     ,calign=>'RIGHT',cnowrap=>'YES');
3391        htp.p('<td align="left">');
3392        htp.formSelectOpen('dim5',cattributes=>'onchange="setdim5()"');
3393        htp.formSelectOption(l_blank,cselected=>'YES');
3394        if (l_dim5_tbl.COUNT <> 0) THEN
3395           BIS_INDICATOR_REGION_UI_PVT.removeDuplicates(p_original_tbl => l_dim5_tbl,
3396                            p_value        => NULL,
3397                            x_unique_tbl   => l_d5_tbl);
3398           for i in 1 ..l_d5_tbl.COUNT LOOP
3399              exit when (l_d5_tbl(i).id is NULL);
3400        -- mdamle - 01/15/2001 - Add quotes around VALUE
3401              htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_d5_tbl(i).name),
3402                   cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_d5_tbl(i).id)||'"');
3403           end loop;
3404        end if;
3405        htp.formSelectOption(c_choose);
3406        htp.formSelectClose;
3407        htp.p('</td>');
3408        htp.tablerowClose;
3409       end if;
3410 
3411       -- ****************************************
3412       -- Dimension6
3413     -- mdamle 01/15/2001 - Use Dim6 and Dim
3414       -- meastmon 05/11/2001
3415       -- Dont show time dimension level
3416       if (c_recs.Dimension6_Level_ID is NULL) or (l_Org_Seq_Num = 6) or (l_Time_Seq_Num = 6) then
3417        if (l_Org_Seq_Num = 6) or (l_Time_Seq_Num = 6) then
3418       htp.formHidden('dim6_level_id', NULL);
3419          else
3420           htp.formHidden('dim6_level_id',c_recs.Dimension6_Level_ID);
3421      end if;
3422       else
3423        -- Print out NOCOPY label and input box for dimension6
3424        htp.formHidden('dim6_level_id',c_recs.Dimension6_Level_ID);
3425        htp.tableRowOpen;
3426        htp.tableData(bis_utilities_pvt.escape_html(c_recs.Dimension6_Level_Name)
3427                     ,calign=>'RIGHT',cnowrap=>'YES');
3428        htp.p('<td align="left">');
3429        htp.formSelectOpen('dim6',cattributes=>'onchange="setdim6()"');
3430        htp.formSelectOption(l_blank,cselected=>'YES');
3431        if (l_dim6_tbl.COUNT <> 0) THEN
3432           BIS_INDICATOR_REGION_UI_PVT.removeDuplicates(p_original_tbl => l_dim6_tbl,
3433                            p_value        => NULL,
3434                            x_unique_tbl   => l_d6_tbl);
3435           for i in 1 ..l_d6_tbl.COUNT LOOP
3436              exit when (l_d6_tbl(i).id is NULL);
3437        -- mdamle - 01/15/2001 - Add quotes around VALUE
3438              htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_d6_tbl(i).name),
3439                   cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_d6_tbl(i).id)||'"');
3440           end loop;
3441        end if;
3442        htp.formSelectOption(c_choose);
3443        htp.formSelectClose;
3444        htp.p('</td>');
3445        htp.tablerowClose;
3446       end if;
3447 
3448       -- ****************************************
3449       -- Dimension7
3450     -- mdamle 01/15/2001 - Use Dim6 and Dim
3451       -- meastmon 05/11/2001
3452       -- Dont show time dimension level
3453       if (c_recs.Dimension7_Level_ID is NULL) or (l_Org_Seq_Num = 7) or (l_Time_Seq_Num = 7) then
3454        if (l_Org_Seq_Num = 7) or (l_Time_Seq_Num = 7) then
3455       htp.formHidden('dim7_level_id', NULL);
3456          else
3457           htp.formHidden('dim7_level_id',c_recs.Dimension7_Level_ID);
3458      end if;
3459       else
3460        -- Print out NOCOPY label and input box for dimension7
3461        htp.formHidden('dim7_level_id',c_recs.Dimension7_Level_ID);
3462        htp.tableRowOpen;
3463        htp.tableData(bis_utilities_pvt.escape_html(c_recs.Dimension7_Level_Name)
3464                     ,calign=>'RIGHT',cnowrap=>'YES');
3465        htp.p('<td align="left">');
3466        htp.formSelectOpen('dim7',cattributes=>'onchange="setdim7()"');
3467        htp.formSelectOption(l_blank,cselected=>'YES');
3468        if (l_dim7_tbl.COUNT <> 0) THEN
3469           BIS_INDICATOR_REGION_UI_PVT.removeDuplicates(p_original_tbl => l_dim7_tbl,
3470                            p_value        => NULL,
3471                            x_unique_tbl   => l_d7_tbl);
3472           for i in 1 ..l_d7_tbl.COUNT LOOP
3473              exit when (l_d7_tbl(i).id is NULL);
3474        -- mdamle - 01/15/2001 - Add quotes around VALUE
3475              htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_d7_tbl(i).name),
3476                   cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_d7_tbl(i).id)||'"');
3477           end loop;
3478        end if;
3479        htp.formSelectOption(c_choose);
3480        htp.formSelectClose;
3481        htp.p('</td>');
3482        htp.tablerowClose;
3483       end if;
3484 
3485      end loop; -- end of loop of c_recs cursor
3486 
3487      htp.p('<!-- Row open for Business Plan poplist -->');
3488 
3489      -- Have a poplist for the Business Plan
3490      htp.tableRowOpen;
3491      htp.tableData(bis_utilities_pvt.escape_html(c_plan),calign=>'RIGHT',cnowrap=>'YES');
3492      htp.p('<td align="left">');
3493      htp.formSelectOpen('plan');
3494      for pl in plan_cur loop
3495        htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(pl.name),
3496                   cattributes=>'VALUE='||bis_utilities_pvt.escape_html_input(pl.plan_id));
3497      end loop;
3498      htp.formSelectClose;
3499      htp.p('</td>');
3500      htp.tableRowClose;
3501 
3502     htp.tableRowOpen;
3503     htp.p('<!-- Horizontal line separating the poplists and the display label box -->');
3504     htp.p('<td height=1 colspan=2 bgcolor=#000000 nowrap="YES">'||
3505           '<IMG SRC="/OA_MEDIA/FNDINVDT.gif" height=1 width=1></td>');
3506     htp.tableRowClose;
3507 
3508     htp.tableRowOpen;
3509      htp.p('<td align="left" colspan=2>');
3510      htp.p(c_displabel);
3511      htp.p('</td>');
3512     htp.tableRowClose;
3513 
3514     htp.tableRowOpen;
3515      htp.p('<td colspan=2 valign="TOP" nowrap="YES">');
3516      htp.formText(cname=>'label',csize=>41,cmaxlength=>40);
3517      htp.p('</td>');
3518     htp.tableRowClose;
3519 
3520    htp.p('<!-- Close embedded table containing the dim level poplists -->');
3521    -- close embedded table containing dim labels and input boxes
3522    htp.tableClose;
3523    -- close cell with dim labels and input boxes
3524    htp.p('</td>');
3525 
3526    htp.p('<!-- Put the right side separator and right edge of wire frame box -->');
3527    htp.p('<td width=5></td>');
3528    htp.p('<td width=1 bgcolor=#000000>'||
3529           '<IMG SRC="/OA_MEDIA/FNDINVDT.gif" height=1 width=1></td>');
3530 
3531    htp.tableRowClose;
3532 
3533    htp.tableRowOpen;
3534    htp.p('<!-- Put the bottom edge of wireframe box -->');
3535    htp.p('<td height=1 bgcolor=#000000 colspan=5>'||
3536          '<IMG SRC="/OA_MEDIA/FNDINVDT.gif" height=1 width=1></td>');
3537    htp.tableRowClose;
3538 
3539    htp.p('<!-- Close wireframe table -->');
3540    htp.tableClose;
3541    htp.p('</td>');
3542    htp.tableRowClose;
3543 
3544    htp.tableRowOpen;
3545     htp.p('<td height=5></td>');
3546    htp.tableRowClose;
3547 
3548    htp.tableRowOpen;
3549     htp.p('<td align="CENTER" valign="TOP">');
3550     htp.p('<table border=0 cellspacing=0 cellpadding=0 width=50%>');
3551     htp.tableRowOpen;
3552     -- cell containing the add button
3553     htp.p('<td align="CENTER" valign="TOP">');
3554 
3555     --meastmon ICX Button is not ADA Complaint. ICX is not going to fix that.
3556     --icx_plug_utilities.buttonBoth(c_display_homepage,'Javascript:addTo()');
3557     l_button_tbl(1).left_edge := BIS_UTILITIES_PVT.G_ROUND_EDGE;
3558     l_button_tbl(1).right_edge := BIS_UTILITIES_PVT.G_ROUND_EDGE;
3559     l_button_tbl(1).disabled := FND_API.G_FALSE;
3560     l_button_tbl(1).label := c_display_homepage;
3561     l_button_tbl(1).href := 'Javascript:addTo()';
3562     BIS_UTILITIES_PVT.GetButtonString(l_button_tbl, l_button_str);
3563     htp.p(l_button_str);
3564 
3565      htp.p('</td>');
3566      htp.tableRowClose;
3567      htp.tableClose;
3568      htp.p('</td>');
3569    htp.tableRowClose;
3570 
3571    htp.p('<!-- Close left side table containing the dimension poplists -->');
3572    htp.tableClose;
3573    htp.p('</td>');
3574 
3575    -- **********************************************************************
3576    -- Put a separator to move the dimensions and selected boxes  apart
3577    htp.p('<td><BR></td>');
3578 
3579    htp.p('<!-- Open cell for Display labels box -->');
3580    -- open cell for right side box
3581    htp.p('<td align="RIGHT" valign="TOP">');
3582      htp.p('<table border=0 cellspacing=0 cellpadding=0 width=90%>');
3583       htp.tableRowOpen;
3584       htp.tableData(bis_utilities_pvt.escape_html(c_tarlevels_homepage),
3585                     calign=>'LEFT',
3586                     cnowrap=>'YES');
3587       htp.tableData('<BR>');
3588       htp.tableRowClose;
3589 
3590       htp.tableRowOpen;
3591       htp.p('<td valign="TOP">');
3592       htp.formSelectOpen(cname=>'C',cattributes=>'SIZE=20');
3593        -- If first time to this page, get favorites from database
3594        if (p_ind_level_id is NULL) then
3595          if (l_labels_tbl.COUNT = 0) THEN
3596             htp.formSelectOption(l_initialize);
3597          else
3598           for i in l_labels_tbl.FIRST .. l_labels_tbl.COUNT loop
3599 
3600       l_Org_level_value_id := null;
3601 
3602               --meastmon 06/07/2001 - Bug.
3603               -- l_Org_Seq_Num should be initialized within the loop, because every loop
3604               -- it is a different target.
3605     l_Org_Seq_Num := BIS_INDICATOR_REGION_UI_PVT.getOrgSeqNum(l_labels_tbl(i).target_level_id);
3606 
3607     if l_Org_Seq_Num = 1 then
3608       l_Org_Level_Value_ID := l_labels_tbl(i).dim1_level_value_id;
3609     end if;
3610     if l_Org_Seq_Num = 2 then
3611       l_Org_Level_Value_ID := l_labels_tbl(i).dim2_level_value_id;
3612     end if;
3613     if l_Org_Seq_Num = 3 then
3614         l_Org_Level_Value_ID := l_labels_tbl(i).dim3_level_value_id;
3615     end if;
3616     if l_Org_Seq_Num = 4 then
3617       l_Org_Level_Value_ID := l_labels_tbl(i).dim4_level_value_id;
3618     end if;
3619     if l_Org_Seq_Num = 5 then
3620         l_Org_Level_Value_ID := l_labels_tbl(i).dim5_level_value_id;
3621     end if;
3622     if l_Org_Seq_Num = 6 then
3623         l_Org_Level_Value_ID := l_labels_tbl(i).dim6_level_value_id;
3624     end if;
3625     if l_Org_Seq_Num = 7 then
3626         l_Org_Level_Value_ID := l_labels_tbl(i).dim7_level_value_id;
3627     end if;
3628 
3629               --meastmon 06/08/2001
3630               -- Dont need to put time level value id
3631     l_Time_Seq_Num := BIS_INDICATOR_REGION_UI_PVT.getTimeSeqNum(l_labels_tbl(i).target_level_id);
3632 
3633         --  mdamle 01/15/2001 - Replace plus in data with c_hash
3634         -- The browser converts plus into space - and incorrect data is passed through
3635     l_link := l_labels_tbl(i).target_level_id||
3636                 '*'||NVL(l_org_level_value_id,'+1');
3637     IF l_Time_Seq_Num = 1 THEN
3638                   l_link := l_link||'*+1';
3639     ELSE
3640                   l_link := l_link||'*'||NVL(l_labels_tbl(i).DIM1_LEVEL_VALUE_ID,'+1');
3641     END IF;
3642     IF l_Time_Seq_Num = 2 THEN
3643                   l_link := l_link||'*+1';
3644     ELSE
3645       l_link := l_link||'*'||NVL(l_labels_tbl(i).DIM2_LEVEL_VALUE_ID,'+1');
3646     END IF;
3647     IF l_Time_Seq_Num = 3 THEN
3648                   l_link := l_link||'*+1';
3649     ELSE
3650                   l_link := l_link||'*'||NVL(l_labels_tbl(i).DIM3_LEVEL_VALUE_ID,'+1');
3651     END IF;
3652     IF l_Time_Seq_Num = 4 THEN
3653                   l_link := l_link||'*+1';
3654     ELSE
3655                   l_link := l_link||'*'||NVL(l_labels_tbl(i).DIM4_LEVEL_VALUE_ID,'+1');
3656     END IF;
3657     IF l_Time_Seq_Num = 5 THEN
3658                   l_link := l_link||'*+1';
3659     ELSE
3660                   l_link := l_link||'*'||NVL(l_labels_tbl(i).DIM5_LEVEL_VALUE_ID,'+1');
3661       END IF;
3662     IF l_Time_Seq_Num = 6 THEN
3663                   l_link := l_link||'*+1';
3664     ELSE
3665                   l_link := l_link||'*'||NVL(l_labels_tbl(i).DIM6_LEVEL_VALUE_ID,'+1');
3666     END IF;
3667     IF l_Time_Seq_Num = 7 THEN
3668                   l_link := l_link||'*+1';
3669     ELSE
3670                   l_link := l_link||'*'||NVL(l_labels_tbl(i).DIM7_LEVEL_VALUE_ID,'+1');
3671     END IF;
3672 
3673     l_link := l_link||'*'||NVL(l_labels_tbl(i).PLAN_ID,'+1');
3674   -- bug#2225110
3675              IF (BIS_PMF_PORTLET_UTIL.is_authorized(
3676            p_cur_user_id => l_current_user_id
3677     ,p_target_level_id => l_labels_tbl(i).target_level_id) ) THEN
3678 
3679                  l_access := '*Y';
3680              ELSE
3681                  l_access := '*N';
3682        END IF;
3683      -- mdamle 01/15/2001 - Added quotes around the VALUE
3684        htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_labels_tbl(i).label),
3685        cattributes=>' VALUE="'||bis_utilities_pvt.escape_html_input(REPLACE(REPLACE(l_link,'+1',c_minus),'+',c_at))||
3686        bis_utilities_pvt.escape_html_input(l_access)||'"');
3687 
3688            end LOOP;
3689           end if; -- if l_labels_tbl is empty
3690 
3691         else
3692           -- Else get the favorites stored in the plsql table
3693           for i in  1 .. p_displaylabels_tbl.COUNT LOOP
3694        -- find the separator between text and value
3695              l_loc := instr(p_displaylabels_tbl(i),'*',-1,1);
3696              l_value := substr (p_displaylabels_tbl(i),1,l_loc - 1);
3697              l_text := substr (p_displaylabels_tbl(i),l_loc + 1);
3698 
3699        -- bug#2225110
3700        IF ( (instr(l_value, '*Y', -1, 1 ) = 0) AND
3701             (instr(l_value, '*N', -1, 1 ) = 0)) THEN
3702       l_value := l_value || '*Y';  -- first time added
3703        END IF;
3704              htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_text)
3705                                  ,cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_value)||'"');
3706              exit when p_displaylabels_tbl(i) is NULL;
3707            end LOOP;
3708         end if;    -- endif for checking if p_ind_level_id is null or not
3709 
3710       htp.formSelectClose;
3711       htp.p('</td>');
3712 
3713       htp.p('<!-- Open cell for up down buttons -->');
3714       htp.p('<td align="LEFT">');  -- open cell for up down buttons
3715        htp.tableOpen;   -- table for up-down buttons
3716        htp.p('<tr><td align="left" valign="bottom">');
3717        htp.p('<A HREF="javascript:upTo()" onMouseOver="window.status='''||
3718               icx_util.replace_onMouseOver_quotes(
3719                        BIS_UTILITIES_PVT.getPrompt('BIS_UP'))
3720               ||''';return true"><image src="/OA_MEDIA/FNDUPARW.gif" alt="'||
3721               icx_util.replace_alt_quotes(
3722                        BIS_UTILITIES_PVT.getPrompt('BIS_UP'))
3723               ||'" BORDER="0"></A>');
3724        htp.p('</td></tr>');
3725        htp.p('<tr><td align="left" valign="top">');
3726        htp.p('<A HREF="javascript:downTo()" onMouseOver="window.status='''||
3727               icx_util.replace_onMouseOver_quotes(
3728                        BIS_UTILITIES_PVT.getPrompt('BIS_DOWN'))||
3729               ''';return true"><image src="/OA_MEDIA/FNDDNARW.gif" alt="'||
3730               icx_util.replace_alt_quotes(
3731                        BIS_UTILITIES_PVT.getPrompt('BIS_DOWN'))||
3732                        '" BORDER="0"></A>');
3733        htp.p('</td></tr>');
3734        htp.tableClose; --up and down
3735      htp.p('</td>');
3736     htp.tableRowClose;
3737 
3738     htp.p('<!-- Open third row with edit-delete buttons for right side box -->');
3739     htp.tableRowOpen;
3740      htp.p('<td align="CENTER" valign="TOP">');
3741       htp.p('<!-- Open embedded table having buttons -->');
3742       htp.tableOpen;
3743       htp.p('<tr><td align="right" nowrap="Yes">');
3744 
3745       --meastmon ICX Button is not ADA Complaint. ICX is not going to fix that.
3746       --icx_plug_utilities.buttonBoth(
3747       --                   BIS_UTILITIES_PVT.getPrompt('BIS_EDIT')
3748       --                  ,'Javascript:editTo()');
3749       l_button_tbl(1).left_edge := BIS_UTILITIES_PVT.G_ROUND_EDGE;
3750       l_button_tbl(1).right_edge := BIS_UTILITIES_PVT.G_ROUND_EDGE;
3751       l_button_tbl(1).disabled := FND_API.G_FALSE;
3752       l_button_tbl(1).label := BIS_UTILITIES_PVT.getPrompt('BIS_EDIT');
3753       l_button_tbl(1).href := 'Javascript:editTo()';
3754       BIS_UTILITIES_PVT.GetButtonString(l_button_tbl, l_button_str);
3755       htp.p(l_button_str);
3756 
3757       htp.p('</td>');
3758       htp.p('<td align="left" nowrap="Yes">');
3759 
3760       --meastmon ICX Button is not ADA Complaint. ICX is not going to fix that.
3761       --icx_plug_utilities.buttonBoth(
3762       --                   BIS_UTILITIES_PVT.getPrompt('BIS_DELETE')
3763       --                   ,'Javascript:deleteTo()');
3764       l_button_tbl(1).left_edge := BIS_UTILITIES_PVT.G_ROUND_EDGE;
3765       l_button_tbl(1).right_edge := BIS_UTILITIES_PVT.G_ROUND_EDGE;
3766       l_button_tbl(1).disabled := FND_API.G_FALSE;
3767       l_button_tbl(1).label := BIS_UTILITIES_PVT.getPrompt('BIS_DELETE');
3768       l_button_tbl(1).href := 'Javascript:deleteTo()';
3769       BIS_UTILITIES_PVT.GetButtonString(l_button_tbl, l_button_str);
3770       htp.p(l_button_str);
3771 
3772       htp.p('</td></tr>');
3773       htp.tableClose;
3774     htp.p('</td>');
3775 
3776     htp.p('<td><BR></td>');
3777 
3778     htp.tableRowClose;
3779     htp.tableClose;
3780    htp.p('</td>');  -- close right side cell containing favorites and arrow buttons
3781 
3782    htp.p('<!-- Close row for cell table containing the boxes -->');
3783    htp.tableRowClose;     -- row one of cell close
3784 
3785   htp.tableRowOpen;
3786   htp.p('<td colspan=2><BR></td>');
3787   htp.tableRowClose;
3788 
3789   htp.tableRowOpen;
3790   htp.p('<td height=1 colspan=3 bgcolor=#000000>'||
3791         '<IMG SRC="/OA_MEDIA/FNDINVDT.gif" height=1 width=1></td>');
3792   htp.tableRowClose;
3793 
3794    htp.p('<!-- Close cell table containing the boxes -->');
3795    htp.tableClose;
3796    htp.p('</td>');
3797 
3798    htp.p('<!-- Close row 1 of main -->');
3799    htp.tableRowClose;
3800 
3801 
3802  htp.tableRowOpen;
3803   htp.p('<td><BR></td>');
3804  htp.tableRowClose;
3805 
3806  htp.p('<!-- Open row with table containing the ok and cancel buttons -->');
3807  htp.tableRowOpen;
3808   htp.p('<td align="CENTER">');
3809    --meastmon 06/20/2001. Added valign attribute
3810    htp.p('<table width="100%"><tr><td width=50% align="right" valign="top">'); -- ok
3811 
3812     --meastmon ICX Button is not ADA Complaint. ICX is not going to fix that.
3813     --icx_plug_utilities.buttonLeft(BIS_UTILITIES_PVT.getPrompt('BIS_OK'),
3814     --                             'Javascript:savedimensions()');
3815     l_button_tbl(1).left_edge := BIS_UTILITIES_PVT.G_ROUND_EDGE;
3816     l_button_tbl(1).right_edge := BIS_UTILITIES_PVT.G_FLAT_EDGE;
3817     l_button_tbl(1).disabled := FND_API.G_FALSE;
3818     l_button_tbl(1).label := BIS_UTILITIES_PVT.getPrompt('BIS_OK');
3819     l_button_tbl(1).href := 'Javascript:savedimensions()';
3820     BIS_UTILITIES_PVT.GetButtonString(l_button_tbl, l_button_str);
3821     htp.p(l_button_str);
3822 
3823 
3824   htp.p('<!-- Close Main form to save the display lables -->');
3825   htp.formClose;
3826   --meastmon 06/20/2001. Added valign attribute
3827   htp.p('</td><td align="left" valign="top" width="50%">');
3828 
3829     htp.p('<!-- Open form to do work of going to prev page  -->');
3830     htp.formOpen('bis_portlet_pmregion.setIndicators'
3831                 ,'POST','','','NAME="actionback"');
3832 
3833     for i in p_selections_tbl.FIRST .. p_selections_tbl.COUNT loop
3834     htp.formHidden('p_selections_tbl',p_selections_tbl(i));
3835     end loop;
3836     htp.formHidden('Z',Z);
3837     htp.formHidden('p_back_url',p_back_url);
3838     htp.formHidden('p_reference_path', p_reference_path);
3839 
3840     --meastmon 06/20/2001. This should not be here
3841     --htp.formOpen('bis_indicator_region_ui_pvt.setIndicators'
3842     --            ,'POST','','','NAME="actionback"');
3843 
3844     htp.p('<!-- Close form to do work of going to prev page  -->');
3845     htp.formClose;
3846 
3847     --meastmon ICX Button is not ADA Complaint. ICX is not going to fix that.
3848     --icx_plug_utilities.buttonRight(BIS_UTILITIES_PVT.getPrompt('BIS_CANCEL'),
3849     --                              'Javascript:document.actionback.submit()');
3850     l_button_tbl(1).left_edge := BIS_UTILITIES_PVT.G_FLAT_EDGE;
3851     l_button_tbl(1).right_edge := BIS_UTILITIES_PVT.G_ROUND_EDGE;
3852     l_button_tbl(1).disabled := FND_API.G_FALSE;
3853     l_button_tbl(1).label := BIS_UTILITIES_PVT.getPrompt('BIS_CANCEL');
3854     l_button_tbl(1).href := 'Javascript:document.actionback.submit()';
3855     BIS_UTILITIES_PVT.GetButtonString(l_button_tbl, l_button_str);
3856     htp.p(l_button_str);
3857 
3858      htp.p('</td></tr>');
3859      htp.p('</table>');
3860      htp.p('</td>');
3861  htp.tableRowClose;
3862 
3863  htp.p('<!-- Close Main Table -->');
3864  htp.tableClose;       -- main table
3865  htp.centerClose;
3866 
3867  htp.bodyClose;
3868  htp.htmlClose;
3869 
3870 end if; -- icx_validatesession
3871 
3872 exception
3873   when others then htp.p(SQLERRM);
3874 
3875 end showDimensions;*/
3876 
3877 
3878 -- *****************************************************
3879 --  Procedure inserts all the selected values
3880 -- *****************************************************
3881 /*procedure strDimensions(
3882  W                      in varchar2 DEFAULT NULL
3883 ,Z                      in pls_integer
3884 ,p_back_url             in varchar2
3885 ,p_displaylabels_tbl    in Selected_Values_Tbl_Type
3886 ,p_reference_path       IN VARCHAR2
3887 )
3888 
3889 is
3890   l_plug_id                 pls_integer;
3891   l_user_id                 integer;
3892   l_session_id              NUMBER;
3893   l_line                    varchar2(32000);
3894   l_line_length             pls_integer;
3895   l_point1                  pls_integer;
3896   l_point2                  pls_integer;
3897   l_point3                  pls_integer;
3898   l_point4                  pls_integer;
3899   l_point5                  pls_integer;
3900   l_point6                  pls_integer;
3901   l_point7                  pls_integer;
3902   l_point8                  pls_integer;
3903   -- mdamle 01/15/2001 - Use Dim6 and Dim7
3904   l_point9                  pls_integer;
3905   l_point10                 pls_integer;
3906 
3907   l_indlevel_id             pls_integer;
3908   l_d0                      varchar2(32000);
3909   l_d1                      varchar2(32000);
3910   l_d2                      varchar2(32000);
3911   l_d3                      varchar2(32000);
3912   l_d4                      varchar2(32000);
3913   l_d5                      varchar2(32000);
3914   -- mdamle 01/15/2001 - Use Dim6 and Dim7
3915   l_d6                      varchar2(32000);
3916   l_d7                      varchar2(32000);
3917 
3918   l_plan                    varchar2(32000);
3919   l_length                  pls_integer;
3920   l_display_label           varchar2(32000);
3921   l_error_tbl               BIS_UTILITIES_PUB.Error_Tbl_Type;
3922   l_return_status           varchar2(32000);
3923   l_indicator_region_values BIS_INDICATOR_REGION_PUB.Indicator_Region_Rec_Type;
3924   l_plan_idnum              pls_integer;
3925 
3926 begin
3927 
3928 --meastmon 09/10/2001 plug_id is not encrypted.
3929 --l_plug_id := icx_call.decrypt2(Z);
3930 l_plug_id := Z;
3931 
3932 if icx_portlet.validateSession then
3933    l_session_id := icx_sec.g_session_id;
3934    l_user_id := icx_sec.getID(icx_sec.PV_USER_ID,'', l_session_id);
3935 
3936   -- Deleting the old rows of this userid and plugid from the selections table
3937    BIS_INDICATOR_REGION_PUB.Delete_User_Ind_Selections(
3938         p_api_version    => 1.0,
3939         p_user_id        => l_user_id,
3940         p_plug_id        => l_plug_id,
3941         x_return_status  => l_return_status,
3942         x_error_Tbl      => l_error_tbl);
3943 
3944 
3945   -- Read the contents of the plsql table of favorite display labels
3946   for i in 1 .. p_displaylabels_tbl.COUNT LOOP
3947      EXIT when p_displaylabels_tbl(i) is NULL;
3948      -- Unpack an item  from the Favorites box
3949      -- to obtain individual dim_level_value id's
3950 
3951     l_point1 := instr(p_displaylabels_tbl(i),'*',1,1);
3952     l_point2 := instr(p_displaylabels_tbl(i),'*',1,2);
3953     l_point3 := instr(p_displaylabels_tbl(i),'*',1,3);
3954     l_point4 := instr(p_displaylabels_tbl(i),'*',1,4);
3955     l_point5 := instr(p_displaylabels_tbl(i),'*',1,5);
3956     l_point6 := instr(p_displaylabels_tbl(i),'*',1,6);
3957     l_point7 := instr(p_displaylabels_tbl(i),'*',1,7);
3958     l_point8 := instr(p_displaylabels_tbl(i),'*',1,8);
3959     -- mdamle 01/15/2001 - Use Dim6 and Dim7
3960     l_point9 := instr(p_displaylabels_tbl(i),'*',1,9);
3961     l_point10 := instr(p_displaylabels_tbl(i),'*',1,10);
3962 
3963     l_indlevel_id := substr(p_displaylabels_tbl(i),1,l_point1-1);
3964 
3965     -- mdamle 01/15/2001 - Use Dim6 and Dim7
3966   -- d0 contains the org value for backward compatibility
3967   -- Replace @ with plus (actual data contains plus)
3968 
3969     l_d0 := substr(p_displaylabels_tbl(i),l_point1+1,l_point2 - l_point1 - 1);
3970     l_d1 := REPLACE(substr(p_displaylabels_tbl(i),l_point2+1,l_point3 - l_point2 - 1), c_at, c_plus) ;
3971     l_d2 := REPLACE(substr(p_displaylabels_tbl(i),l_point3+1,l_point4 - l_point3 - 1), c_at, c_plus);
3972     l_d3 := REPLACE(substr(p_displaylabels_tbl(i),l_point4+1,l_point5 - l_point4 - 1), c_at, c_plus);
3973     l_d4 := REPLACE(substr(p_displaylabels_tbl(i),l_point5+1,l_point6 - l_point5 - 1), c_at, c_plus);
3974     l_d5 := REPLACE(substr(p_displaylabels_tbl(i),l_point6+1,l_point7 - l_point6 - 1), c_at, c_plus);
3975     l_d6 := REPLACE(substr(p_displaylabels_tbl(i),l_point7+1,l_point8 - l_point7 - 1), c_at, c_plus);
3976     l_d7 := REPLACE(substr(p_displaylabels_tbl(i),l_point8+1,l_point9 - l_point8 - 1), c_at, c_plus);
3977 
3978     -- mdamle 01/15/2001 - Use Dim6 and Dim7
3979     -- l_plan := substr(p_displaylabels_tbl(i),l_point7+1,l_point8-l_point7-1);
3980     -- l_display_label := substr(p_displaylabels_tbl(i),l_point8+1);
3981     l_plan := substr(p_displaylabels_tbl(i),l_point9+1,l_point10-l_point9-1);
3982     l_display_label := substr(p_displaylabels_tbl(i),l_point10+1);
3983 
3984   --
3985   -- ****************************** Debug stuff ***************
3986    -- htp.p('p_display_label_tbl '||p_displaylabels_tbl(i)||'<BR>');
3987    -- htp.p('<BR>'||l_indlevel_id||'*'||l_d0||'*'||l_d1||'*'||l_d2||'*'
3988    --      ||l_d3||'*'||l_d4||
3989    --      '*'||l_d5||'*'||l_plan||'*'||l_display_label||'<BR>');
3990   -- ***********************************************************
3991 
3992   -- Transfer the values to the fields in the record
3993   l_indicator_region_values.USER_ID             :=  l_user_id;
3994   l_indicator_region_values.TARGET_LEVEL_ID     :=  l_indlevel_id;
3995   -- mdamle 01/15/2001 - Don't pass in the Org_level_value_id anymore
3996   -- l_indicator_region_values.ORG_LEVEL_VALUE_id  :=  l_d0;
3997   l_indicator_region_values.LABEL               :=  l_display_label;
3998   l_indicator_region_values.PLUG_ID             :=  l_plug_id;
3999   l_indicator_region_values.DIM1_LEVEL_VALUE_ID :=  l_d1;
4000   l_indicator_region_values.DIM2_LEVEL_VALUE_ID :=  l_d2;
4001   l_indicator_region_values.DIM3_LEVEL_VALUE_ID :=  l_d3;
4002   l_indicator_region_values.DIM4_LEVEL_VALUE_ID :=  l_d4;
4003   l_indicator_region_values.DIM5_LEVEL_VALUE_ID :=  l_d5;
4004   -- mdamle 01/15/2001 - Use Dim6 and Dim7
4005   l_indicator_region_values.DIM6_LEVEL_VALUE_ID :=  l_d6;
4006   l_indicator_region_values.DIM7_LEVEL_VALUE_ID :=  l_d7;
4007 
4008   l_indicator_region_values.PLAN_ID             :=  l_plan;
4009 
4010     BIS_INDICATOR_REGION_PUB.Create_User_Ind_Selection(
4011         p_api_version          => 1.0,
4012         p_Indicator_Region_Rec => l_indicator_region_values,
4013         x_return_status        => l_return_status,
4014         x_error_Tbl            => l_error_tbl);
4015 
4016   -- ********* Debug stuff ********************
4017 -- htp.p('respid :'||l_resp_id);
4018 -- htp.p('tarid  :'||l_tar_id);
4019 -- htp.p('orgid  :'||l_org_id);
4020 -- htp.p('disp   :'||l_disp);
4021   -- *******************************************
4022 
4023    end loop;  --  loop  for the input plsql table
4024 
4025 
4026    -- 2418741 owa_util.redirect_url(p_back_url);
4027 
4028   IF (p_reference_path IS NOT NULL) THEN
4029     UPDATE icx_portlet_customizations
4030       SET caching_key = TO_CHAR(NVL(caching_key, 0) + 1)
4031       WHERE reference_path = p_reference_path;
4032     COMMIT;
4033   END IF;
4034 
4035   owa_util.redirect_url(p_back_url);
4036 
4037 --   owa_util.redirect_url(bis_utilities_pub.encode(p_back_url));    -- 2418741
4038 
4039 
4040 end if;  -- icx_validate_session
4041 
4042  exception
4043    when no_data_found then NULL;
4044    when others then htp.p(SQLERRM);
4045 
4046 end strDimensions;*/
4047 
4048 
4049 -- ********************************************************
4050 -- Procedure that allows Editing/renaming of indicators
4051 -- *********************************************************
4052 /*procedure editDimensions(
4053      U   in    varchar2,
4054      Z   in    pls_integer
4055      )
4056 is
4057   l_var1                 VARCHAR2(32000) := NULL;
4058   V                      varchar2(32000);
4059   l_cnt                  pls_integer;
4060   l_plug_id              pls_integer;
4061   l_user_id              integer;
4062   l_session_id           NUMBER;
4063   l_choose_dim_value     varchar2(32000);
4064   l_enter_displabel      varchar2(32000);
4065   l_select_displabel     varchar2(32000);
4066   l_dup_displabel        varchar2(32000);
4067   l_dup_combo            varchar2(32000);
4068   l_history              varchar2(32000);
4069   l_selfhistory          varchar2(32000);
4070   l_blank                varchar2(32000);
4071   l_length               pls_integer;
4072   l_indlevel_id          pls_integer;
4073   l_d0                   varchar2(32000);
4074   l_d1                   varchar2(32000);
4075   l_d2                   varchar2(32000);
4076   l_d3                   varchar2(32000);
4077   l_d4                   varchar2(32000);
4078   l_d5                   varchar2(32000);
4079   -- mdamle 01/15/2001 - Use Dim6 and Dim7
4080   l_d6                   varchar2(32000);
4081   l_d7                   varchar2(32000);
4082 
4083   l_plan                 varchar2(32000);
4084   l_plan_name            varchar2(32000);
4085   l_indlevel_name        varchar2(32000);
4086   l_orgname              varchar2(32000);
4087   l_label                varchar2(32000);
4088   l_point1               pls_integer;
4089   l_point2               pls_integer;
4090   l_point3               pls_integer;
4091   l_point4               pls_integer;
4092   l_point5               pls_integer;
4093   l_point6               pls_integer;
4094   l_point7               pls_integer;
4095   -- mdamle 01/15/2001 - Use Dim6 and Dim7
4096   l_point8               pls_integer;
4097   l_point9               pls_integer;
4098   l_point10              pls_integer;
4099 
4100   l_point23              pls_integer;
4101 --
4102   l_msg_count              number;
4103   l_msg_data               varchar2(32000);
4104   l_return_status          varchar2(32000);
4105   l_indicators_tbl         BIS_TARGET_LEVEL_PUB.Target_Level_Tbl_Type;
4106   l_dim0_level_value_rec   BIS_DIM_LEVEL_VALUE_PUB.Dim_Level_Value_Rec_Type;
4107   l_dim1_level_value_rec   BIS_DIM_LEVEL_VALUE_PUB.Dim_Level_Value_Rec_Type;
4108   l_dim2_level_value_rec   BIS_DIM_LEVEL_VALUE_PUB.Dim_Level_Value_Rec_Type;
4109   l_dim3_level_value_rec   BIS_DIM_LEVEL_VALUE_PUB.Dim_Level_Value_Rec_Type;
4110   l_dim4_level_value_rec   BIS_DIM_LEVEL_VALUE_PUB.Dim_Level_Value_Rec_Type;
4111   l_dim5_level_value_rec   BIS_DIM_LEVEL_VALUE_PUB.Dim_Level_Value_Rec_Type;
4112   -- mdamle 01/15/2001 - Use Dim6 and Dim7
4113   l_dim6_level_value_rec   BIS_DIM_LEVEL_VALUE_PUB.Dim_Level_Value_Rec_Type;
4114   l_dim7_level_value_rec   BIS_DIM_LEVEL_VALUE_PUB.Dim_Level_Value_Rec_Type;
4115 
4116   l_favorites_tbl          BIS_INDICATOR_REGION_PUB.Indicator_Region_Tbl_Type;
4117   l_orgs_tbl               BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
4118   l_dim1_tbl               BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
4119   l_dim2_tbl               BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
4120   l_dim3_tbl               BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
4121   l_dim4_tbl               BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
4122   l_dim5_tbl               BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
4123   -- mdamle 01/15/2001 - Use Dim6 and Dim7
4124   l_dim6_tbl               BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
4125   l_dim7_tbl               BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
4126 
4127   l_d0_tbl                 BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
4128   l_d1_tbl                 BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
4129   l_d2_tbl                 BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
4130   l_d3_tbl                 BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
4131   l_d4_tbl                 BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
4132   l_d5_tbl                 BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
4133   -- mdamle 01/15/2001 - Use Dim6 and Dim7
4134   l_d6_tbl                 BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
4135   l_d7_tbl                 BIS_INDICATOR_REGION_UI_PVT.no_duplicates_tbl_Type;
4136 
4137   l_d0_name                varchar2(32000);
4138   l_d1_name                varchar2(32000);
4139   l_d2_name                varchar2(32000);
4140   l_d3_name                varchar2(32000);
4141   l_d4_name                varchar2(32000);
4142   l_d5_name                varchar2(32000);
4143 
4144   -- mdamle 01/15/2001 - Use Dim6 and Dim7
4145   l_d6_name                varchar2(32000);
4146   l_d7_name                varchar2(32000);
4147 
4148   -- meastmon 05/11/2001
4149   l_Time_Seq_Num              number;
4150   --
4151   l_Org_Seq_Num              number;
4152   l_Org_Level_Value_ID       number;
4153   l_Org_Level_Short_Name     varchar2(240);
4154   l_Org_Level_Name           bis_levels_tl.name%TYPE;
4155 
4156   l_error_tbl              BIS_UTILITIES_PUB.Error_Tbl_Type;
4157   l_clear                  VARCHAR2(32000);
4158   l_sobString              VARCHAR2(32000);
4159   l_sob_level_id           NUMBER;
4160   l_org_level_id           NUMBER;
4161   l_elements               BIS_UTILITIES_PUB.BIS_VARCHAR_TBL;
4162 
4163   -- meastmon 06/20/2001
4164   -- Fix for ADA buttons
4165   l_button_str             varchar2(32000);
4166   l_button_tbl             BIS_UTILITIES_PVT.HTML_Button_Tbl_Type;
4167   l_set_of_books_id        VARCHAR2(200); -- 2665526
4168   l_string                 VARCHAR2(32000);
4169 
4170 
4171 CURSOR plan_cur is
4172  SELECT plan_id,short_name,name
4173  FROM BISBV_BUSINESS_PLANS
4174  ORDER BY name;
4175 
4176 -- mdamle 01/15/2001 - Use Dim6 and Dim7
4177 cursor bisfv_target_levels_cur(p_tarid in pls_integer) is
4178  SELECT TARGET_LEVEL_ID,
4179         TARGET_LEVEL_NAME,
4180     -- mdamle 01/15/2001 - Use Dim6 and Dim7
4181         -- ORG_LEVEL_ID,
4182         -- ORG_LEVEL_SHORT_NAME,
4183         -- ORG_LEVEL_NAME,
4184         DIMENSION1_LEVEL_ID,
4185     DIMENSION1_LEVEL_SHORT_NAME,
4186         DIMENSION1_LEVEL_NAME,
4187         DIMENSION2_LEVEL_ID,
4188     DIMENSION2_LEVEL_SHORT_NAME,
4189         DIMENSION2_LEVEL_NAME,
4190         DIMENSION3_LEVEL_ID,
4191     DIMENSION3_LEVEL_SHORT_NAME,
4192         DIMENSION3_LEVEL_NAME,
4193         DIMENSION4_LEVEL_ID,
4194     DIMENSION4_LEVEL_SHORT_NAME,
4195         DIMENSION4_LEVEL_NAME,
4196         DIMENSION5_LEVEL_ID,
4197     DIMENSION5_LEVEL_SHORT_NAME,
4198         DIMENSION5_LEVEL_NAME,
4199         DIMENSION6_LEVEL_ID,
4200     DIMENSION6_LEVEL_SHORT_NAME,
4201         DIMENSION6_LEVEL_NAME,
4202         DIMENSION7_LEVEL_ID,
4203     DIMENSION7_LEVEL_SHORT_NAME,
4204         DIMENSION7_LEVEL_NAME
4205  FROM BISFV_TARGET_LEVELS
4206  WHERE TARGET_LEVEL_ID = p_tarid;
4207 
4208 begin
4209 
4210 --meastmon 09/10/2001 plug_id is not encrypted.
4211 --l_plug_id := icx_call.decrypt2(Z);
4212 l_plug_id := Z;
4213 
4214 --if ICX_SEC.validatePlugSession(l_plug_id) then
4215 if icx_portlet.validateSession then
4216     l_session_id := icx_sec.g_session_id;
4217     l_user_id := icx_sec.getID(icx_sec.PV_USER_ID,'', l_session_id);
4218     l_blank      := '';
4219 
4220 
4221     -- Replace the plus signs from the string
4222     -- mdamle 01/15/2001 -
4223   -- 1) Replace @ with plus (actual data plus)
4224   -- 2) Using c_hash instead of c_plus everywhere bec. data could contain c_plus
4225     V := REPLACE(U, c_at, c_plus);
4226     V := REPLACE(V,' ',c_hash);
4227 
4228      if instr(owa_util.get_cgi_env('HTTP_USER_AGENT'),'MSIE') > 0
4229      then
4230          l_history := '';
4231          l_selfhistory := '';
4232      else
4233          l_history := 'opener.history.go(0);';
4234          l_selfhistory := 'history.go(0);';
4235      end if;
4236 
4237   -- ********  Debug stuff ******************
4238   --    htp.p('passed in values (tar lev, org val, dim1-5,plan) :'||V||'<BR>');
4239   -- *****************************************
4240 
4241   -- Set the message strings from the database
4242   fnd_message.set_name('BIS','BIS_ENTER_DISPLABEL');
4243   l_enter_displabel := icx_util.replace_quotes(fnd_message.get);
4244   fnd_message.set_name('BIS','BIS_SELECT_DISPLABEL');
4245   l_select_displabel := icx_util.replace_quotes(fnd_message.get);
4246   fnd_message.set_name('BIS','BIS_DUP_DISPLAY_LABEL');
4247   l_dup_displabel := icx_util.replace_quotes(fnd_message.get);
4248 
4249   fnd_message.set_name('BIS','BIS_DUP_COMBO');
4250   l_dup_combo := icx_util.replace_quotes(fnd_message.get);
4251   fnd_message.set_name('BIS','BIS_CHOOSE_DIM_VALUE');
4252   l_choose_dim_value := icx_util.replace_quotes(fnd_message.get);
4253 
4254   -- Unpack the one element that was selected for edit from the Favorites box
4255   -- to obtain individual dim_level_value id's
4256     l_length := length(V);
4257     l_point1 := instr(V,'*',1,1);
4258     l_point2 := instr(V,'*',1,2);
4259     l_point3 := instr(V,'*',1,3);
4260     l_point4 := instr(V,'*',1,4);
4261     l_point5 := instr(V,'*',1,5);
4262     l_point6 := instr(V,'*',1,6);
4263     l_point7 := instr(V,'*',1,7);
4264   -- mdamle 01/15/2001 - Use Dim6 and Dim7
4265     l_point8 := instr(V,'*',1,8);
4266     l_point9 := instr(V,'*',1,9);
4267     l_point10 := instr(V,'*',1,10);
4268 
4269     l_indlevel_id := substr(V,1,l_point1-1);
4270 
4271   -- mdamle 01/15/2001 - Use Dim6 and Dim7
4272     l_d0 := substr(V,l_point1+1,l_point2 - l_point1 - 1);
4273     l_d1 := substr(V,l_point2+1,l_point3 - l_point2 - 1);
4274     l_d2 := substr(V,l_point3+1,l_point4 - l_point3 - 1);
4275     l_d3 := substr(V,l_point4+1,l_point5 - l_point4 - 1);
4276     l_d4 := substr(V,l_point5+1,l_point6 - l_point5 - 1);
4277     l_d5 := substr(V,l_point6+1,l_point7 - l_point6 - 1);
4278     l_d6 := substr(V,l_point7+1,l_point8 - l_point7 - 1);
4279     l_d7 := substr(V,l_point8+1,l_point9 - l_point8 - 1);
4280     l_plan := substr(V,l_point9+1,l_point10 - l_point9 - 1);
4281 
4282     l_var1 := l_d0;
4283 
4284   -- ************** Debug stuff ****************************
4285   -- htp.p(l_indlevel_id||'*'||l_d0||'*'||l_d1||'*'||l_d2||'*'||
4286   --       l_d3||'*'||l_d4||'*'||l_d5||'*'||l_plan);
4287   -- htp.p('<BR>*****************************************************<BR>');
4288 
4289   -- Get all the previously selected labels from
4290   -- selections table.
4291   BIS_INDICATOR_REGION_PUB.Retrieve_User_Ind_Selections
4292   ( p_api_version          => 1.0
4293   , p_user_id              => l_user_id
4294   , p_all_info             => FND_API.G_TRUE
4295   , p_plug_id              => l_plug_id
4296   , x_Indicator_Region_Tbl => l_favorites_tbl
4297   , x_return_status        => l_return_status
4298   , x_Error_Tbl           => l_error_tbl
4299   );
4300 
4301  -- Grab the Target level Name for this target level id
4302  -- to paint at the top of the page
4303  -- mdamle 01/15/2001 - Use getPerformanceMeasureName() instead
4304  --  SELECT target_level_name
4305  --  INTO l_indlevel_name
4306  --  FROM BISBV_TARGET_LEVELS
4307  --  WHERE TARGET_LEVEL_ID = l_indlevel_id;
4308  l_indlevel_name := BIS_INDICATOR_REGION_UI_PVT.getPerformanceMeasureName(l_indlevel_id);
4309 
4310  -- Set the set of books id for GL dimension levels
4311  --
4312    SELECT level_id
4313    INTO l_sob_level_id
4314    FROM BIS_LEVELS
4315    WHERE SHORT_NAME = 'SET OF BOOKS';
4316 
4317    -- mdamle 01/15/2001 - Use Dim6 and Dim7
4318    /*
4319    SELECT org_level_id
4320    INTO l_org_level_id
4321    FROM BIS_TARGET_LEVELS
4322    WHERE target_level_id = l_indlevel_ID;
4323 
4324    l_org_level_id := BIS_INDICATOR_REGION_UI_PVT.getOrgLevelID(l_indlevel_id);
4325 
4326    IF l_sob_level_id = l_org_level_ID
4327    THEN
4328      BIS_TARGET_PVT.G_SET_OF_BOOK_ID := TO_NUMBER(l_var1);
4329    END IF;
4330 
4331   -- Grab the individual dim_level_values chosen previously for
4332   -- this target_level_id, to populate respective poplists
4333     if (l_favorites_tbl.COUNT <> 0) THEN
4334        l_cnt := 1;
4335        for i in l_favorites_tbl.FIRST .. l_favorites_tbl.COUNT LOOP
4336          if (l_favorites_tbl(i).target_level_id = l_indlevel_id) THEN
4337        -- mdamle 01/15/2001 - Use Dim6 and Dim7
4338        /*
4339            IF (l_favorites_tbl(i).org_level_value_id is NOT NULL) THEN
4340             l_orgs_tbl(l_cnt).id   := l_favorites_tbl(i).org_level_value_id;
4341             l_orgs_tbl(l_cnt).name := l_favorites_tbl(i).org_level_value_name;
4342            END IF;
4343 
4344            -- mdamle 01/15/2001 - Use Dim6 and Dim7
4345            -- Get the Dimension No. for Org
4346        l_Org_Seq_Num := BIS_INDICATOR_REGION_UI_PVT.getOrgSeqNum(l_indlevel_id);
4347 
4348            IF (l_favorites_tbl(i).dim1_level_value_id is NOT NULL) THEN
4349             l_dim1_tbl(l_cnt).id   := l_favorites_tbl(i).dim1_level_value_id;
4350             l_dim1_tbl(l_cnt).name := l_favorites_tbl(i).dim1_level_value_name;
4351       -- mdamle 01/15/2001 Use Dim6 and Dim7
4352       if l_Org_Seq_Num = 1 then
4353              l_orgs_tbl(l_cnt).id   := l_favorites_tbl(i).dim1_level_value_id;
4354              l_orgs_tbl(l_cnt).name := l_favorites_tbl(i).dim1_level_value_name;
4355       end if;
4356            END IF;
4357            IF (l_favorites_tbl(i).dim2_level_value_id is NOT NULL) THEN
4358             l_dim2_tbl(l_cnt).id   := l_favorites_tbl(i).dim2_level_value_id;
4359             l_dim2_tbl(l_cnt).name := l_favorites_tbl(i).dim2_level_value_name;
4360       -- mdamle 01/15/2001 Use Dim6 and Dim7
4361       if l_Org_Seq_Num = 2 then
4362              l_orgs_tbl(l_cnt).id   := l_favorites_tbl(i).dim2_level_value_id;
4363              l_orgs_tbl(l_cnt).name := l_favorites_tbl(i).dim2_level_value_name;
4364       end if;
4365            END IF;
4366            IF (l_favorites_tbl(i).dim3_level_value_id is NOT NULL) THEN
4367             l_dim3_tbl(l_cnt).id   := l_favorites_tbl(i).dim3_level_value_id;
4368             l_dim3_tbl(l_cnt).name := l_favorites_tbl(i).dim3_level_value_name;
4369       -- mdamle 01/15/2001 Use Dim6 and Dim7
4370       if l_Org_Seq_Num = 3 then
4371              l_orgs_tbl(l_cnt).id   := l_favorites_tbl(i).dim3_level_value_id;
4372              l_orgs_tbl(l_cnt).name := l_favorites_tbl(i).dim3_level_value_name;
4373       end if;
4374            END IF;
4375            IF (l_favorites_tbl(i).dim4_level_value_id is NOT NULL) THEN
4376             l_dim4_tbl(l_cnt).id   := l_favorites_tbl(i).dim4_level_value_id;
4377             l_dim4_tbl(l_cnt).name := l_favorites_tbl(i).dim4_level_value_name;
4378       -- mdamle 01/15/2001 Use Dim6 and Dim7
4379       if l_Org_Seq_Num = 4 then
4380              l_orgs_tbl(l_cnt).id   := l_favorites_tbl(i).dim4_level_value_id;
4381              l_orgs_tbl(l_cnt).name := l_favorites_tbl(i).dim4_level_value_name;
4382       end if;
4383            END IF;
4384            IF (l_favorites_tbl(i).dim5_level_value_id is NOT NULL) THEN
4385             l_dim5_tbl(l_cnt).id   := l_favorites_tbl(i).dim5_level_value_id;
4386             l_dim5_tbl(l_cnt).name := l_favorites_tbl(i).dim5_level_value_name;
4387       -- mdamle 01/15/2001 Use Dim6 and Dim7
4388       if l_Org_Seq_Num = 5 then
4389              l_orgs_tbl(l_cnt).id   := l_favorites_tbl(i).dim5_level_value_id;
4390              l_orgs_tbl(l_cnt).name := l_favorites_tbl(i).dim5_level_value_name;
4391       end if;
4392            END IF;
4393            -- mdamle 01/15/2001 - Use Dim6 and Dim7
4394            IF (l_favorites_tbl(i).dim6_level_value_id is NOT NULL) THEN
4395             l_dim6_tbl(l_cnt).id   := l_favorites_tbl(i).dim6_level_value_id;
4396             l_dim6_tbl(l_cnt).name := l_favorites_tbl(i).dim6_level_value_name;
4397       -- mdamle 01/15/2001 Use Dim6 and Dim7
4398       if l_Org_Seq_Num = 6 then
4399              l_orgs_tbl(l_cnt).id   := l_favorites_tbl(i).dim6_level_value_id;
4400              l_orgs_tbl(l_cnt).name := l_favorites_tbl(i).dim6_level_value_name;
4401       end if;
4402            END IF;
4403            IF (l_favorites_tbl(i).dim7_level_value_id is NOT NULL) THEN
4404             l_dim7_tbl(l_cnt).id   := l_favorites_tbl(i).dim7_level_value_id;
4405             l_dim7_tbl(l_cnt).name := l_favorites_tbl(i).dim7_level_value_name;
4406       -- mdamle 01/15/2001 Use Dim6 and Dim7
4407       if l_Org_Seq_Num = 7 then
4408              l_orgs_tbl(l_cnt).id   := l_favorites_tbl(i).dim7_level_value_id;
4409              l_orgs_tbl(l_cnt).name := l_favorites_tbl(i).dim7_level_value_name;
4410       end if;
4411            END IF;
4412           l_cnt := l_cnt + 1;
4413          END IF;
4414        END LOOP;
4415     END IF; -- if l_favorites_tbl is empty
4416 
4417     htp.htmlOpen;
4418 
4419     -- *********************************************************
4420     -- Call the procedure that paints the LOV javascript function
4421     htp.headOpen;
4422      BIS_UTILITIES_PVT.putStyle();
4423    -- mdamle 01/15/2001 - the form name is different for edit
4424    -- hence the script is different as well
4425      -- BIS_LOV_PUB.lovjscript;
4426    BIS_LOV_PUB.editlovjscript(x_string => l_string);
4427     htp.headClose;
4428 
4429      htp.p('<body>');
4430 
4431      BIS_UTILITIES_PVT.putStyle;
4432 
4433     Build_HTML_Banner(
4434        title       => BIS_UTILITIES_PVT.getPrompt('BIS_PERFORMANCE_MEASURES')
4435        ,help_target => G_HELP
4436        ,menu_link => NULL
4437        );
4438 
4439    htp.p('<SCRIPT LANGUAGE="Javascript">');
4440 
4441     htp.p('function saveRename() {
4442       var temp = opener.document.dimensions.C.selectedIndex;
4443       var end  = opener.document.dimensions.C.length;
4444       if (document.editDimensions.label.value == "") {
4445         alert ("'||l_enter_displabel||'");
4446         document.editDimensions.label.focus();
4447         }
4448       else {
4449 
4450         var ind  =  document.editDimensions.ind.value;
4451         var l_var1 = "'||l_d0||'";
4452 
4453        // Do some checks before grabbing the dimension level values
4454        // For dimension0
4455           if (document.editDimensions.dim0_level_id.value != "") {
4456              var d0_tmp = document.editDimensions.dim0.selectedIndex;
4457              var d0_end = document.editDimensions.dim0.length;
4458              if ((document.editDimensions.dim0[d0_tmp].text == "'
4459                  ||l_blank||'") '||c_OR||
4460                  ' (document.editDimensions.dim0[d0_tmp].text == "'
4461                  ||c_choose||'"))   {
4462                 d0 = "+";
4463                 alert("'||l_choose_dim_value||'");
4464                 document.editDimensions.dim0.focus();
4465                 return FALSE;
4466                 }
4467              else
4468                 var d0 =  document.editDimensions.dim0[d0_tmp].value;
4469              }
4470           else
4471              {d0 = "-";}
4472 
4473 
4474           // For dimension1
4475           if (document.editDimensions.dim1_level_id.value != "") {
4476              var d1_tmp = document.editDimensions.dim1.selectedIndex;
4477              var d1_end = document.editDimensions.dim1.length;
4478        // mdamle 01/15/2001 - Changed the check |||r to Dim0 check
4479              // if (d1_tmp == 0 '||c_OR||' d1_tmp == d1_end - 1){
4480              if ((document.editDimensions.dim1[d1_tmp].text == "'||l_blank||'") '
4481                 ||c_OR||
4482                 ' (document.editDimensions.dim1[d1_tmp].text == "'||c_choose
4483                 ||'"))  {
4484                 d1 = "+";
4485                 alert("'||l_choose_dim_value||'");
4486                 document.editDimensions.dim1.focus();
4487                 return FALSE;
4488                 }
4489              else
4490                 var d1 =  document.editDimensions.dim1[d1_tmp].value;
4491              }
4492           else
4493              {d1 = "-";}
4494 
4495 
4496           // For dimension2
4497           if (document.editDimensions.dim2_level_id.value != "") {
4498              var d2_tmp = document.editDimensions.dim2.selectedIndex;
4499              var d2_end = document.editDimensions.dim2.length;
4500        // mdamle 02/25/2002 - Changed the check |||r to Dim0 check
4501              // if (d2_tmp == 0 '||c_OR||' d2_tmp == d2_end - 2){
4502              if ((document.editDimensions.dim2[d2_tmp].text == "'||l_blank||'") '
4503                 ||c_OR||
4504                 ' (document.editDimensions.dim2[d2_tmp].text == "'||c_choose
4505                 ||'"))  {
4506                 d2 = "+";
4507                 alert("'||l_choose_dim_value||'");
4508                 document.editDimensions.dim2.focus();
4509                 return FALSE;
4510                 }
4511              else
4512                 var d2 =  document.editDimensions.dim2[d2_tmp].value;
4513              }
4514           else
4515              {d2 = "-";}
4516 
4517 
4518           // For dimension3
4519           if (document.editDimensions.dim3_level_id.value != "") {
4520              var d3_tmp = document.editDimensions.dim3.selectedIndex;
4521              var d3_end = document.editDimensions.dim3.length;
4522        // mdamle 03/35/3003 - Changed the check |||r to Dim0 check
4523              // if (d3_tmp == 0 '||c_OR||' d3_tmp == d3_end - 3){
4524              if ((document.editDimensions.dim3[d3_tmp].text == "'||l_blank||'") '
4525                 ||c_OR||
4526                 ' (document.editDimensions.dim3[d3_tmp].text == "'||c_choose
4527                 ||'"))  {
4528                 d3 = "+";
4529                 alert("'||l_choose_dim_value||'");
4530                 document.editDimensions.dim3.focus();
4531                 return FALSE;
4532                 }
4533              else
4534                 var d3 =  document.editDimensions.dim3[d3_tmp].value;
4535              }
4536           else
4537              {d3 = "-";}
4538 
4539 
4540           // For dimension4
4541           if (document.editDimensions.dim4_level_id.value != "") {
4542              var d4_tmp = document.editDimensions.dim4.selectedIndex;
4543              var d4_end = document.editDimensions.dim4.length;
4544        // mdamle 04/45/4004 - Changed the check |||r to Dim0 check
4545              // if (d4_tmp == 0 '||c_OR||' d4_tmp == d4_end - 4){
4546              if ((document.editDimensions.dim4[d4_tmp].text == "'||l_blank||'") '
4547                 ||c_OR||
4548                 ' (document.editDimensions.dim4[d4_tmp].text == "'||c_choose
4549                 ||'"))  {
4550                 d4 = "+";
4551                 alert("'||l_choose_dim_value||'");
4552                 document.editDimensions.dim4.focus();
4553                 return FALSE;
4554                 }
4555              else
4556                 var d4 =  document.editDimensions.dim4[d4_tmp].value;
4557              }
4558           else
4559              {d4 = "-";}
4560 
4561 
4562           // For dimension5
4563           if (document.editDimensions.dim5_level_id.value != "") {
4564              var d5_tmp = document.editDimensions.dim5.selectedIndex;
4565              var d5_end = document.editDimensions.dim5.length;
4566        // mdamle 05/55/5005 - Changed the check |||r to Dim0 check
4567              // if (d5_tmp == 0 '||c_OR||' d5_tmp == d5_end - 5){
4568              if ((document.editDimensions.dim5[d5_tmp].text == "'||l_blank||'") '
4569                 ||c_OR||
4570                 ' (document.editDimensions.dim5[d5_tmp].text == "'||c_choose
4571                 ||'"))  {
4572                 d5 = "+";
4573                 alert("'||l_choose_dim_value||'");
4574                 document.editDimensions.dim5.focus();
4575                 return FALSE;
4576                 }
4577              else
4578                 var d5 =  document.editDimensions.dim5[d5_tmp].value;
4579              }
4580            else
4581              {d5 = "-";}
4582 
4583       // mdamle 01/15/2001 - Use Dim6 and Dim7
4584           // For dimension6
4585           if (document.editDimensions.dim6_level_id.value != "") {
4586              var d6_tmp = document.editDimensions.dim6.selectedIndex;
4587              var d6_end = document.editDimensions.dim6.length;
4588        // mdamle 06/66/6006 - Changed the check |||r to Dim0 check
4589              // if (d6_tmp == 0 '||c_OR||' d6_tmp == d6_end - 6){
4590              if ((document.editDimensions.dim6[d6_tmp].text == "'||l_blank||'") '
4591                 ||c_OR||
4592                 ' (document.editDimensions.dim6[d6_tmp].text == "'||c_choose
4593                 ||'"))  {
4594                 d6 = "+";
4595                 alert("'||l_choose_dim_value||'");
4596                 document.editDimensions.dim6.focus();
4597                 return FALSE;
4598                 }
4599              else
4600                 var d6 =  document.editDimensions.dim6[d6_tmp].value;
4601              }
4602            else
4603              {d6 = "-";}
4604 
4605       // mdamle 01/15/2001 - Use Dim6 and Dim7
4606           // For dimension7
4607           if (document.editDimensions.dim7_level_id.value != "") {
4608              var d7_tmp = document.editDimensions.dim7.selectedIndex;
4609              var d7_end = document.editDimensions.dim7.length;
4610        // mdamle 07/77/7007 - Changed the check |||r to Dim0 check
4611              // if (d7_tmp == 0 '||c_OR||' d7_tmp == d7_end - 7){
4612              if ((document.editDimensions.dim7[d7_tmp].text == "'||l_blank||'") '
4613                 ||c_OR||
4614                 ' (document.editDimensions.dim7[d7_tmp].text == "'||c_choose
4615                 ||'"))  {
4616                 d7 = "+";
4617                 alert("'||l_choose_dim_value||'");
4618                 document.editDimensions.dim7.focus();
4619                 return FALSE;
4620                 }
4621              else
4622                 var d7 =  document.editDimensions.dim7[d7_tmp].value;
4623              }
4624            else
4625              {d7 = "-";}
4626 
4627           // For Plan
4628            var plan_tmp = document.editDimensions.plan.selectedIndex;
4629            var plan     = document.editDimensions.plan[plan_tmp].value
4630 
4631         var totext=document.editDimensions.label.value;
4632 
4633   // mdamle 01/15/2001 - Use Dim6 and Dim7
4634   // Put Org dimension value in the correct dimension
4635   if (document.editDimensions.orgDimension.value == "1")
4636     d1 = d0;
4637   if (document.editDimensions.orgDimension.value == "2")
4638     d2 = d0;
4639   if (document.editDimensions.orgDimension.value == "3")
4640     d3 = d0;
4641   if (document.editDimensions.orgDimension.value == "4")
4642     d4 = d0;
4643   if (document.editDimensions.orgDimension.value == "5")
4644     d5 = d0;
4645   if (document.editDimensions.orgDimension.value == "6")
4646     d6 = d0;
4647   if (document.editDimensions.orgDimension.value == "7")
4648       d7 = d0;
4649 
4650   // mdamle 01/15/2001 - Add d6 and d7
4651     var tovalue= ind + "*" + d0 + "*" + d1 + "*" + d2 + "*" + d3 + "*" + d4 + "*" + d5 + "*" + d6 + "*" + d7 + "*" + plan;
4652         // Now go through the contents of right side box to see if
4653         // this exists already
4654   // bug#2225110
4655   var duplicatedComb = 0;
4656         var duplicatedText = 0;
4657         for (var i=0;i<end;i++){
4658           if (i != temp) {
4659       var cval = opener.document.dimensions.C[i].value;
4660             if (tovalue == cval.substr(0, cval.length-2)) {
4661               duplicatedComb = 1;
4662       }
4663             if (totext == opener.document.dimensions.C[i].text) {
4664               duplicatedText = 1;
4665       }
4666           }
4667         }
4668         if (duplicatedComb == 1){
4669           alert("'||l_dup_combo||'");
4670         } else if (duplicatedText == 1) {
4671           alert("'||l_dup_displabel||'");
4672         } else {
4673           opener.document.dimensions.C.options[temp].text  = totext;
4674           opener.document.dimensions.C.options[temp].value = tovalue+"*Y";
4675           '||l_history||'
4676           window.close();
4677         }
4678        }  //  to check if  editDimensions.value is null or not
4679     }');
4680 
4681     htp.p('function open_new_browser(url,x,y){
4682         var attributes = "resizable=yes,scrollbars=yes,toolbar=no,width="+x+",height="+y;
4683         var new_browser = window.open(url, "new_browser", attributes);
4684         if (new_browser != null) {
4685             if (new_browser.opener == null)
4686                 new_browser.opener = self;
4687             new_browser.name = ''editLOVValues'';
4688             new_browser.location.href = url;
4689             }
4690         }');
4691 
4692      htp.p('function loadName() {
4693        var temp=opener.document.dimensions.C.selectedIndex;
4694        document.editDimensions.label.value = opener.document.dimensions.C.options[temp].text;
4695       }');
4696 
4697      -- Get string to clear dim1-5 in case they are related to the org
4698      --
4699      l_elements(1) := 'plan';
4700      l_elements(2) := 'dim0';
4701      l_elements(3) := 'label';
4702 
4703      BIS_INDICATOR_REGION_UI_PVT.clearSelect
4704          ( p_formName     => 'editDimensions'
4705          , p_elementTable => l_elements
4706          , x_clearString  => l_clear
4707          );
4708 
4709 -- meastmon 06/26/2001 Dont clear other dimensions
4710      htp.p('function setdim0() {
4711          var end = document.editDimensions.dim0.length;
4712          var temp = document.editDimensions.dim0.selectedIndex;
4713          if (document.editDimensions.dim0[temp].text == "'||c_choose||'") {
4714             var ind  =  document.editDimensions.ind.value;
4715             var dim_lvl_id = document.editDimensions.dim0_level_id.value;
4716             var c_qry = "'||l_user_id||c_asterisk||'" + ind + "'
4717                         ||c_asterisk||'" + dim_lvl_id;
4718             var c_jsfuncname = "getdim0";
4719             document.editDimensions.dim0.selectedIndex = 0;
4720             getLOV(''bis_portlet_pmregion.dim_level_values_query''
4721                   ,c_qry,c_jsfuncname,'||Z||');
4722             }
4723         }');
4724 --         else {
4725 --         '||l_clear||'
4726 --         }
4727 
4728        SetSetOfBookVar
4729            ( p_user_id     => l_user_id
4730            , p_formName    => 'editDimensions'
4731            , p_index       => 'dim0_index'
4732            , x_sobString   => l_sobString
4733            );
4734 
4735      htp.p('function setdim1() {
4736 // alert("dim0 = "+dim0_id);
4737          var end = document.editDimensions.dim1.length;
4738          var temp = document.editDimensions.dim1.selectedIndex;
4739          if (document.editDimensions.dim1[temp].text == "'||c_choose||'") {
4740             var ind  =  document.editDimensions.ind.value;
4741             var dim_lvl_id = document.editDimensions.dim1_level_id.value;
4742 
4743       // mdamle 01/15/2001 - Moved conditional code into l_sobString
4744             '||l_sobString||'
4745 
4746             var c_jsfuncname = "getdim1";
4747             document.editDimensions.dim1.selectedIndex = 0;
4748             getLOV(''bis_portlet_pmregion.dim_level_values_query'',c_qry,c_jsfuncname,'||Z||');
4749             }
4750         }');
4751 
4752 
4753      htp.p('function setdim2() {
4754 // alert("dim0 = "+dim0_id);
4755          var end = document.editDimensions.dim2.length;
4756          var temp = document.editDimensions.dim2.selectedIndex;
4757          if (document.editDimensions.dim2[temp].text == "'||c_choose||'") {
4758             var ind  =  document.editDimensions.ind.value;
4759             var dim_lvl_id = document.editDimensions.dim2_level_id.value;
4760 
4761       // mdamle 01/15/2001 - Moved conditional code into l_sobString
4762             '||l_sobString||'
4763 
4764             var c_jsfuncname = "getdim2";
4765             document.editDimensions.dim2.selectedIndex = 0;
4766             getLOV(''bis_portlet_pmregion.dim_level_values_query'',c_qry,c_jsfuncname,'||Z||');
4767             }
4768         }');
4769 
4770 
4771      htp.p('function setdim3() {
4772 // alert("dim0 = "+dim0_id);
4773          var end = document.editDimensions.dim3.length;
4774          var temp = document.editDimensions.dim3.selectedIndex;
4775          if (document.editDimensions.dim3[temp].text == "'||c_choose||'") {
4776             var ind  =  document.editDimensions.ind.value;
4777             var dim_lvl_id = document.editDimensions.dim3_level_id.value;
4778 
4779       // mdamle 01/15/2001 - Moved conditional code into l_sobString
4780             '||l_sobString||'
4781 
4782             var c_jsfuncname = "getdim3";
4783             document.editDimensions.dim3.selectedIndex = 0;
4784             getLOV(''bis_portlet_pmregion.dim_level_values_query'',c_qry,c_jsfuncname,'||Z||');
4785             }
4786         }');
4787 
4788 
4789      htp.p('function setdim4() {
4790 // alert("dim0 = "+dim0_id);
4791          var end = document.editDimensions.dim4.length;
4792          var temp = document.editDimensions.dim4.selectedIndex;
4793          if (document.editDimensions.dim4[temp].text == "'||c_choose||'") {
4794             var ind  =  document.editDimensions.ind.value;
4795             var dim_lvl_id = document.editDimensions.dim4_level_id.value;
4796 
4797       // mdamle 01/15/2001 - Moved conditional code into l_sobString
4798             '||l_sobString||'
4799 
4800             var c_jsfuncname = "getdim4";
4801             document.editDimensions.dim4.selectedIndex = 0;
4802             getLOV(''bis_portlet_pmregion.dim_level_values_query'',c_qry,c_jsfuncname,'||Z||');
4803             }
4804         }');
4805 
4806 
4807      htp.p('function setdim5() {
4808 // alert("dim0 = "+dim0_id);
4809          var end = document.editDimensions.dim5.length;
4810          var temp = document.editDimensions.dim5.selectedIndex;
4811          if (document.editDimensions.dim5[temp].text == "'||c_choose||'") {
4812             var ind  =  document.editDimensions.ind.value;
4813             var dim_lvl_id = document.editDimensions.dim5_level_id.value;
4814 
4815       // mdamle 01/15/2001 - Moved conditional code into l_sobString
4816             '||l_sobString||'
4817 
4818             var c_jsfuncname = "getdim5";
4819             document.editDimensions.dim5.selectedIndex = 0;
4820             getLOV(''bis_portlet_pmregion.dim_level_values_query'',c_qry,c_jsfuncname,'||Z||');
4821             }
4822         }');
4823 
4824 
4825    -- mdamle - 01/15/2001 - Use Dim6 and Dim7
4826      htp.p('function setdim6() {
4827 // alert("dim0 = "+dim0_id);
4828          var end = document.editDimensions.dim6.length;
4829          var temp = document.editDimensions.dim6.selectedIndex;
4830          if (document.editDimensions.dim6[temp].text == "'||c_choose||'") {
4831             var ind  =  document.editDimensions.ind.value;
4832             var dim_lvl_id = document.editDimensions.dim6_level_id.value;
4833 
4834       // mdamle 01/15/2001 - Moved conditional code into l_sobString
4835             '||l_sobString||'
4836 
4837             var c_jsfuncname = "getdim6";
4838             document.editDimensions.dim6.selectedIndex = 0;
4839             getLOV(''bis_portlet_pmregion.dim_level_values_query'',c_qry,c_jsfuncname,'||Z||');
4840             }
4841         }');
4842 
4843 
4844    -- mdamle - 01/15/2001 - Use Dim6 and Dim7
4845      htp.p('function setdim7() {
4846 // alert("dim0 = "+dim0_id);
4847          var end = document.editDimensions.dim7.length;
4848          var temp = document.editDimensions.dim7.selectedIndex;
4849          if (document.editDimensions.dim7[temp].text == "'||c_choose||'") {
4850             var ind  =  document.editDimensions.ind.value;
4851             var dim_lvl_id = document.editDimensions.dim7_level_id.value;
4852 
4853       // mdamle 01/15/2001 - Moved conditional code into l_sobString
4854             '||l_sobString||'
4855 
4856             var c_jsfuncname = "getdim7";
4857             document.editDimensions.dim7.selectedIndex = 0;
4858             getLOV(''bis_portlet_pmregion.dim_level_values_query'',c_qry,c_jsfuncname,'||Z||');
4859             }
4860         }');
4861 
4862 
4863     htp.p('</SCRIPT>');
4864 
4865     htp.p('<!-- Open form for this window -->');
4866     htp.formOpen('javascript:saveRename()'
4867                 ,'POST','','','name="editDimensions"');
4868 
4869     htp.centerOpen;
4870     htp.p('<!-- Open table -->');
4871     htp.p('<table border=0 cellspacing=0 cellpadding=0 width=100%>'); -- main
4872     htp.formHidden('ind',l_indlevel_id);
4873      htp.p('<!-- Open first row for this table -->');
4874      htp.tableRowOpen;
4875        htp.p('<td align="CENTER">');
4876        htp.tableOpen;
4877        htp.tableRowOpen;
4878        htp.tableData(bis_utilities_pvt.escape_html(c_tarlevel)||' ',calign=>'RIGHT');
4879        htp.tableData(htf.bold(bis_utilities_pvt.escape_html(l_indlevel_name)),calign=>'LEFT');
4880        htp.tableRowClose;
4881        htp.tableClose;
4882        htp.p('</td>');
4883      htp.tableRowClose;
4884 
4885      htp.p('<!-- Open second row for this table -->');
4886      htp.tableRowOpen;
4887       htp.tableData('<BR>');
4888      htp.tableRowClose;
4889 
4890     htp.tableRowOpen;
4891      htp.p('<td align="CENTER">');
4892      htp.p('<table border=0 cellspacing=0 cellpadding=0>');
4893      htp.p('<!-- Open row containing the string dimensions -->');
4894       htp.tableRowOpen;
4895        htp.tableData(bis_utilities_pvt.escape_html(c_dim_and_plan), calign=>'LEFT');
4896       htp.tableRowClose;
4897 
4898      htp.p('<!-- Open row for wireframe box table -->');
4899      htp.tableRowOpen;    -- Open row for dimensions boxes table
4900        htp.p('<td align="LEFT" valign="TOP">');
4901 
4902        htp.p('<!-- open table containing wireframe -->');
4903        htp.p('<table border=0 cellspacing=0 cellpadding=0>');
4904 
4905        htp.p('<!-- Top edge of wireframe box -->');
4906        htp.tableRowOpen;
4907        htp.p('<td height=1 bgcolor=#000000 colspan=5>'||
4908              '<IMG SRC="/OA_MEDIA/FNDINVDT.gif" height=1 width=1></td>');
4909        htp.tableRowClose;
4910 
4911        htp.tableRowOpen;
4912         htp.p('<!-- Begin left edge of wireframe and left separator -->');
4913         htp.p('<td width=1 bgcolor=#000000>'||
4914               '<IMG SRC="/OA_MEDIA/FNDINVDT.gif" height=1 width=1></td>');
4915         htp.p('<td width=5></td>');
4916 
4917        htp.p('<!-- Begin cell having embedded table with dimension boxes -->');
4918        htp.p('<td align="center" nowrap="yes">');
4919        htp.p('<table border=0 cellspacing=0 cellpadding=0>');
4920 
4921    htp.tableRowOpen;
4922    htp.p('<td height=5></td>');
4923    htp.tableRowClose;
4924 
4925    htp.p('<!-- Begin one more cell to center dimension boxes inside the wireframe -->');
4926    htp.tableRowOpen;
4927     htp.p('<td align="center" nowrap="yes">');
4928     htp.p('<table border=0 cellspacing=0 cellpadding=0>');
4929 
4930    -- ****************************************************************
4931    --  Table containing the dimension names,boxes
4932 
4933     for c_recs in bisfv_target_levels_cur(l_indlevel_id) LOOP
4934 
4935       -- ******************************
4936       -- Dimension0 for Organization
4937 
4938       -- meastmon 06/07/2001
4939       l_Time_Seq_Num := BIS_INDICATOR_REGION_UI_PVT.getTimeSeqNum(l_indlevel_id);
4940       htp.formHidden('timeDimension', l_Time_Seq_Num);
4941 
4942       -- mdamle 01/15/2001 - Use Dim6 and Dim7
4943       -- Get the Dimension No. for Org
4944       l_Org_Seq_Num := BIS_INDICATOR_REGION_UI_PVT.getOrgSeqNum(l_indlevel_id);
4945       htp.formHidden('orgDimension', l_Org_Seq_Num);
4946 
4947     -- mdamle 01/15/2001 - Use Dim6 and Dim7
4948     if l_Org_Seq_Num = 1 then
4949        l_Org_Level_ID := c_recs.Dimension1_level_id;
4950      l_Org_Level_Short_Name := c_recs.Dimension1_level_Short_name;
4951      l_Org_Level_Name := c_recs.Dimension1_level_Name;
4952     end if;
4953     if l_Org_Seq_Num = 2 then
4954        l_Org_Level_ID := c_recs.Dimension2_level_id;
4955      l_Org_Level_Short_Name := c_recs.Dimension2_level_Short_name;
4956      l_Org_Level_Name := c_recs.Dimension2_level_Name;
4957     end if;
4958     if l_Org_Seq_Num = 3 then
4959        l_Org_Level_ID := c_recs.Dimension3_level_id;
4960      l_Org_Level_Short_Name := c_recs.Dimension3_level_Short_name;
4961      l_Org_Level_Name := c_recs.Dimension3_level_Name;
4962     end if;
4963     if l_Org_Seq_Num = 4 then
4964        l_Org_Level_ID := c_recs.Dimension4_level_id;
4965      l_Org_Level_Short_Name := c_recs.Dimension4_level_Short_name;
4966      l_Org_Level_Name := c_recs.Dimension4_level_Name;
4967     end if;
4968     if l_Org_Seq_Num = 5 then
4969        l_Org_Level_ID := c_recs.Dimension5_level_id;
4970      l_Org_Level_Short_Name := c_recs.Dimension5_level_Short_name;
4971      l_Org_Level_Name := c_recs.Dimension5_level_Name;
4972     end if;
4973     if l_Org_Seq_Num = 6 then
4974        l_Org_Level_ID := c_recs.Dimension6_level_id;
4975      l_Org_Level_Short_Name := c_recs.Dimension6_level_Short_name;
4976      l_Org_Level_Name := c_recs.Dimension6_level_Name;
4977     end if;
4978     if l_Org_Seq_Num = 7 then
4979        l_Org_Level_ID := c_recs.Dimension7_level_id;
4980      l_Org_Level_Short_Name := c_recs.Dimension7_level_Short_name;
4981      l_Org_Level_Name := c_recs.Dimension7_level_Name;
4982     end if;
4983 
4984       if (l_Org_Level_ID is NULL) then
4985          htp.formHidden('dim0_level_id',l_blank);
4986          -- meastmon 06/07/2001
4987          htp.formHidden('set_sob','FALSE');
4988          --
4989       elsif (l_Org_Level_Short_Name='TOTAL_ORGANIZATIONS') then
4990        htp.formHidden('dim0_level_id',l_Org_Level_ID);
4991        -- meastmon 06/07/2001
4992        htp.formHidden('set_sob','FALSE');
4993        --
4994        htp.tableRowOpen;
4995        htp.tableData(bis_utilities_pvt.escape_html(l_Org_Level_Name),calign=>'RIGHT',cnowrap=>'YES');
4996        htp.p('<td align="left" nowrap="YES">');
4997        htp.formSelectOpen('dim0');
4998        htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(LOWER(l_Org_Level_Short_Name)),
4999                   cselected=>'YES',
5000                   cattributes=>'VALUE=-1');
5001        htp.formSelectClose;
5002       else
5003        -- Print out NOCOPY label and input box for dimension0
5004        htp.formHidden('dim0_level_id',l_Org_Level_ID);
5005 
5006        -- Set flag to True if we need to pass the related sob info
5007        -- along
5008        --
5009         if (l_Org_Level_Short_Name='SET OF BOOKS') then
5010           htp.formHidden('set_sob','TRUE');
5011         else
5012           htp.formHidden('set_sob','FALSE');
5013         end if;
5014 
5015        htp.tableRowOpen;
5016        htp.tableData(bis_utilities_pvt.escape_html(l_Org_Level_Name),calign=>'RIGHT',cnowrap=>'YES');
5017        htp.p('<td align="left">');
5018        htp.formSelectOpen('dim0',cattributes=>'onchange="setdim0()"');
5019        htp.formSelectOption(l_blank);
5020 
5021         if (l_d0 <> c_hash) then
5022        -- mdamle 01/15/2001 - Replace c_hash with ' ' icase data was changed
5023      l_d0 := REPLACE(l_d0, c_hash, ' ');
5024           IF (l_Org_Level_Short_Name='SET OF BOOKS') THEN -- 2665526
5025             l_set_of_books_id := l_d0;
5026           ELSE
5027       l_set_of_books_id := NULL;
5028     END IF;
5029          l_dim0_level_value_rec.Dimension_Level_ID := l_Org_Level_ID;
5030          l_dim0_level_value_rec.Dimension_level_Value_ID := l_d0;
5031 
5032          -- meastmon 09/17/2001 Org_Id_To_Value does not work for EDW Dimensions
5033          -- Instead use DimensionX_ID_to_Value.
5034          BIS_DIM_LEVEL_VALUE_PVT.DimensionX_ID_to_Value(
5035            p_api_version               => 1.0,
5036            p_Dim_Level_Value_Rec       => l_dim0_level_value_rec,
5037            x_Dim_Level_Value_rec       => l_dim0_level_value_rec,
5038            x_Return_Status             => l_return_status,
5039            x_error_Tbl                 => l_error_tbl
5040           );
5041 
5042          --BIS_DIM_LEVEL_VALUE_PVT.ORG_ID_TO_VALUE(
5043          -- p_api_version               => 1.0,
5044          -- p_Dim_Level_Value_Rec       => l_dim0_level_value_rec,
5045          -- x_Dim_Level_Value_rec       => l_dim0_level_value_rec,
5046          -- x_Return_Status             => l_return_status,
5047          -- x_error_Tbl                 => l_error_tbl
5048          --);
5049 
5050         htp.formSelectOption
5051        (cvalue=>bis_utilities_pvt.escape_html_input(l_dim0_level_value_rec.Dimension_level_Value_Name),
5052         cattributes=>'VALUE='||bis_utilities_pvt.escape_html_input(l_dim0_level_value_rec.Dimension_level_Value_ID),
5053         cselected=>'YES');
5054 
5055         end if;
5056         if (l_orgs_tbl.COUNT <> 0) THEN
5057           BIS_INDICATOR_REGION_UI_PVT.removeDuplicates(p_original_tbl => l_orgs_tbl,
5058                            p_value        => l_d0,
5059                            x_unique_tbl   => l_d0_tbl);
5060           for i in 1 ..l_d0_tbl.COUNT LOOP
5061              exit when (l_d0_tbl(i).id is NULL);
5062              htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_d0_tbl(i).name),
5063                   cattributes=>'VALUE='||bis_utilities_pvt.escape_html_input(l_d0_tbl(i).id));
5064           end loop;
5065         end if;
5066        htp.formSelectOption(c_choose);
5067        htp.formSelectClose;
5068        htp.p('</td>');
5069        htp.tablerowClose;
5070       end if;
5071 
5072       -- ***********************************
5073       -- Dimension1
5074     -- mdamle 01/15/2001 - Use Dim6 and Dim7
5075       -- meastmon 06/07/2001
5076       -- Dont show time dimension level
5077       if (c_recs.Dimension1_Level_ID is NULL) or (l_Org_Seq_Num = 1) or (l_Time_Seq_Num = 1) then
5078        if (l_Org_Seq_Num = 1) or (l_Time_Seq_Num = 1) then
5079       htp.formHidden('dim1_level_id', NULL);
5080          else
5081           htp.formHidden('dim1_level_id',c_recs.Dimension1_Level_ID);
5082      end if;
5083       else
5084       -- Print out NOCOPY label and input box for dimension1
5085        htp.formHidden('dim1_level_id',c_recs.Dimension1_Level_ID);
5086        htp.tableRowOpen;
5087        htp.tableData(bis_utilities_pvt.escape_html(c_recs.Dimension1_Level_Name)||' '
5088                     ,calign=>'RIGHT'
5089                     ,cnowrap=>'YES');
5090        htp.p('<td align="LEFT" nowrap="YES">');
5091        htp.formSelectOpen('dim1',cattributes=>'onchange="setdim1()"');
5092        htp.formSelectOption(l_blank);
5093 
5094         if (l_d1 <> c_hash) then
5095        -- mdamle 01/15/2001 - Replace c_hash with ' ' icase data was changed
5096      l_d1 := REPLACE(l_d1, c_hash, ' ');
5097 
5098          l_dim1_level_value_rec.Dimension_level_ID:=c_recs.Dimension1_Level_ID;
5099          l_dim1_level_value_rec.Dimension_level_Value_ID := l_d1;
5100          l_dim1_level_value_rec.dimension_Level_short_name := c_recs.dimension1_Level_short_name;
5101          BIS_DIM_LEVEL_VALUE_PVT.DimensionX_ID_to_Value(
5102            p_api_version               => 1.0,
5103            p_Dim_Level_Value_Rec       => l_dim1_level_value_rec,
5104            p_set_of_books_id           => l_set_of_books_id,
5105            x_Dim_Level_Value_rec       => l_dim1_level_value_rec,
5106            x_Return_Status             => l_return_status,
5107            x_error_Tbl                 => l_error_tbl
5108           );
5109         htp.formSelectOption
5110 
5111         -- mdamle - 01/15/2001 - Add quotes around VALUE
5112        (cvalue=>bis_utilities_pvt.escape_html_input(l_dim1_level_value_rec.Dimension_level_Value_Name),
5113         cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_dim1_level_value_rec.Dimension_level_Value_ID)||'"',
5114         cselected=>'YES');
5115         end if;
5116 
5117        if (l_dim1_tbl.COUNT <> 0) THEN
5118           BIS_INDICATOR_REGION_UI_PVT.removeDuplicates(p_original_tbl => l_dim1_tbl,
5119                            p_value        => l_d1,
5120                            x_unique_tbl   => l_d1_tbl);
5121           for i in 1 ..l_d1_tbl.COUNT LOOP
5122              exit when (l_d1_tbl(i).id is NULL);
5123        -- mdamle - 01/15/2001 - Add quotes around VALUE
5124              htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_d1_tbl(i).name),
5125                   cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_d1_tbl(i).id)||'"');
5126           end loop;
5127        end if;
5128        htp.formSelectOption(c_choose);
5129        htp.formSelectClose;
5130        htp.p('</td>');
5131        htp.tablerowClose;
5132       end if;
5133 
5134       -- Dimension2
5135       -- *******************************************
5136     -- mdamle 02/25/2002 - Use Dim6 and Dim7
5137       -- meastmon 06/07/2001
5138       -- Dont show time dimension level
5139       if (c_recs.Dimension2_Level_ID is NULL) or (l_Org_Seq_Num = 2) or (l_Time_Seq_Num = 2) then
5140        if (l_Org_Seq_Num = 2) or (l_Time_Seq_Num = 2) then
5141       htp.formHidden('dim2_level_id', NULL);
5142          else
5143           htp.formHidden('dim2_level_id',c_recs.Dimension2_Level_ID);
5144      end if;
5145       else      -- Print out NOCOPY label and input box for dimension2
5146        htp.formHidden('dim2_level_id',c_recs.Dimension2_Level_ID);
5147        htp.tableRowOpen;
5148        htp.tableData(bis_utilities_pvt.escape_html(c_recs.Dimension2_Level_Name)||' '
5149                     ,calign=>'RIGHT'
5150                     ,cnowrap=>'YES');
5151        htp.p('<td align="LEFT" nowrap="YES">');
5152        htp.formSelectOpen('dim2',cattributes=>'onchange="setdim2()"');
5153        htp.formSelectOption(l_blank);
5154        if (l_d2 <> c_hash) then
5155        -- mdamle 01/15/2001 - Replace c_hash with ' ' icase data was changed
5156      l_d2 := REPLACE(l_d2, c_hash, ' ');
5157 
5158          l_dim2_level_value_rec.Dimension_level_ID:=c_recs.Dimension2_Level_ID;
5159          l_dim2_level_value_rec.Dimension_level_Value_ID := l_d2;
5160          l_dim2_level_value_rec.dimension_Level_short_name := c_recs.dimension2_Level_short_name;
5161 
5162          BIS_DIM_LEVEL_VALUE_PVT.DimensionX_ID_to_Value(
5163            p_api_version               => 1.0,
5164            p_Dim_Level_Value_Rec       => l_dim2_level_value_rec,
5165            p_set_of_books_id           => l_set_of_books_id,
5166            x_Dim_Level_Value_rec       => l_dim2_level_value_rec,
5167            x_Return_Status             => l_return_status,
5168            x_error_Tbl                 => l_error_tbl
5169           );
5170 
5171 
5172         htp.formSelectOption
5173         -- mdamle - 01/15/2001 - Add quotes around VALUE
5174        (cvalue=>bis_utilities_pvt.escape_html_input(l_dim2_level_value_rec.Dimension_level_Value_Name),
5175         cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_dim2_level_value_rec.Dimension_level_Value_ID)||'"',
5176         cselected=>'YES');
5177         end if;
5178 
5179        if (l_dim2_tbl.COUNT <> 0) THEN
5180           BIS_INDICATOR_REGION_UI_PVT.removeDuplicates(p_original_tbl => l_dim2_tbl,
5181                            p_value        => l_d2,
5182                            x_unique_tbl   => l_d2_tbl);
5183           for i in 1 ..l_d2_tbl.COUNT LOOP
5184              exit when (l_d2_tbl(i).id is NULL);
5185        -- mdamle - 01/15/2001 - Add quotes around VALUE
5186              htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_d2_tbl(i).name),
5187                   cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_d2_tbl(i).id)||'"');
5188           end loop;
5189        end if;
5190        htp.formSelectOption(c_choose);
5191        htp.formSelectClose;
5192        htp.p('</td>');
5193        htp.tablerowClose;
5194       end if;
5195 
5196       -- Dimension3
5197       -- *****************************************
5198     -- mdamle 03/35/3003 - Use Dim6 and Dim7
5199       -- meastmon 06/07/2001
5200       -- Dont show time dimension level
5201       if (c_recs.Dimension3_Level_ID is NULL) or (l_Org_Seq_Num = 3) or (l_Time_Seq_Num = 3) then
5202        if (l_Org_Seq_Num = 3) or (l_Time_Seq_Num = 3) then
5203       htp.formHidden('dim3_level_id', NULL);
5204          else
5205           htp.formHidden('dim3_level_id',c_recs.Dimension3_Level_ID);
5206      end if;
5207       else       -- Print out NOCOPY label and input box for dimension3
5208         htp.formHidden('dim3_level_id',c_recs.Dimension3_Level_ID);
5209         htp.tableRowOpen;
5210         htp.tableData(bis_utilities_pvt.escape_html(c_recs.Dimension3_Level_Name)||' '
5211                      ,calign=>'RIGHT'
5212                      ,cnowrap=>'YES');
5213         htp.p('<td align="LEFT" nowrap="YES">');
5214         htp.formSelectOpen('dim3',cattributes=>'onchange="setdim3()"');
5215         htp.formSelectOption(l_blank);
5216         if (l_d3 <> c_hash) then
5217        -- mdamle 01/15/2001 - Replace c_hash with ' ' icase data was changed
5218      l_d3 := REPLACE(l_d3, c_hash, ' ');
5219 
5220          l_dim3_level_value_rec.Dimension_level_ID:=c_recs.Dimension3_Level_ID;
5221          l_dim3_level_value_rec.Dimension_level_Value_ID := l_d3;
5222          l_dim3_level_value_rec.dimension_Level_short_name := c_recs.dimension3_Level_short_name;
5223          BIS_DIM_LEVEL_VALUE_PVT.DimensionX_ID_to_Value(
5224            p_api_version               => 1.0,
5225            p_Dim_Level_Value_Rec       => l_dim3_level_value_rec,
5226            p_set_of_books_id           => l_set_of_books_id,
5227            x_Dim_Level_Value_rec       => l_dim3_level_value_rec,
5228            x_Return_Status             => l_return_status,
5229            x_error_Tbl                 => l_error_tbl
5230           );
5231 
5232         htp.formSelectOption
5233         -- mdamle - 01/15/2001 - Add quotes around VALUE
5234        (cvalue=>bis_utilities_pvt.escape_html_input(l_dim3_level_value_rec.Dimension_level_Value_Name),
5235         cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_dim3_level_value_rec.Dimension_level_Value_ID)||'"',
5236         cselected=>'YES');
5237         end if;
5238 
5239         if (l_dim3_tbl.COUNT <> 0) THEN
5240           BIS_INDICATOR_REGION_UI_PVT.removeDuplicates(p_original_tbl => l_dim3_tbl,
5241                            p_value        => l_d3,
5242                            x_unique_tbl   => l_d3_tbl);
5243           for i in 1 ..l_d3_tbl.COUNT LOOP
5244              exit when (l_d3_tbl(i).id is NULL);
5245        -- mdamle - 01/15/2001 - Add quotes around VALUE
5246              htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_d3_tbl(i).name),
5247                   cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_d3_tbl(i).id)||'"');
5248           end loop;
5249         end if;
5250         htp.formSelectOption(c_choose);
5251         htp.formSelectClose;
5252         htp.p('</td>');
5253         htp.tablerowClose;
5254        end if;
5255 
5256       -- Dimension4
5257       -- ****************************************
5258     -- mdamle 04/45/4004 - Use Dim6 and Dim7
5259       -- meastmon 06/07/2001
5260       -- Dont show time dimension level
5261       if (c_recs.Dimension4_Level_ID is NULL) or (l_Org_Seq_Num = 4) or (l_Time_Seq_Num = 4) then
5262        if (l_Org_Seq_Num = 4) or (l_Time_Seq_Num = 4) then
5263       htp.formHidden('dim4_level_id', NULL);
5264          else
5265           htp.formHidden('dim4_level_id',c_recs.Dimension4_Level_ID);
5266      end if;
5267       else
5268        -- Print out NOCOPY label and input box for dimension4
5269        htp.formHidden('dim4_level_id',c_recs.Dimension4_Level_ID);
5270        htp.tableRowOpen;
5271        htp.tableData(bis_utilities_pvt.escape_html(c_recs.Dimension4_Level_Name)||' '
5272                     ,calign=>'RIGHT'
5273                     ,cnowrap=>'YES');
5274        htp.p('<td align="LEFT" nowrap="YES">');
5275        htp.formSelectOpen('dim4',cattributes=>'onchange="setdim4()"');
5276        htp.formSelectOption(l_blank);
5277        if (l_d4 <> c_hash) then
5278        -- mdamle 01/15/2001 - Replace c_hash with ' ' icase data was changed
5279      l_d4 := REPLACE(l_d4, c_hash, ' ');
5280 
5281          l_dim4_level_value_rec.Dimension_level_ID:=c_recs.Dimension4_Level_ID;
5282          l_dim4_level_value_rec.Dimension_level_Value_ID := l_d4;
5283          l_dim4_level_value_rec.dimension_Level_short_name := c_recs.dimension4_Level_short_name;
5284          BIS_DIM_LEVEL_VALUE_PVT.DimensionX_ID_to_Value(
5285            p_api_version               => 1.0,
5286            p_Dim_Level_Value_Rec       => l_dim4_level_value_rec,
5287            p_set_of_books_id           => l_set_of_books_id,
5288            x_Dim_Level_Value_rec       => l_dim4_level_value_rec,
5289            x_Return_Status             => l_return_status,
5290            x_error_Tbl                 => l_error_tbl
5291           );
5292        htp.formSelectOption
5293         -- mdamle - 01/15/2001 - Add quotes around VALUE
5294        (cvalue=>bis_utilities_pvt.escape_html_input(l_dim4_level_value_rec.Dimension_level_Value_Name),
5295         cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_dim4_level_value_rec.Dimension_level_Value_ID)||'"',
5296         cselected=>'YES');
5297         end if;
5298 
5299        if (l_dim4_tbl.COUNT <> 0) THEN
5300           BIS_INDICATOR_REGION_UI_PVT.removeDuplicates(p_original_tbl => l_dim4_tbl,
5301                            p_value        => l_d4,
5302                            x_unique_tbl   => l_d4_tbl);
5303           for i in 1 ..l_d4_tbl.COUNT LOOP
5304              exit when (l_d4_tbl(i).id is NULL);
5305        -- mdamle - 01/15/2001 - Add quotes around VALUE
5306              htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_d4_tbl(i).name),
5307                   cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_d4_tbl(i).id)||'"');
5308           end loop;
5309        end if;
5310        htp.formSelectOption(c_choose);
5311        htp.formSelectClose;
5312        htp.p('</td>');
5313        htp.tablerowClose;
5314       end if;
5315 
5316       -- Dimension5
5317       -- ***************************************
5318     -- mdamle 05/55/5005 - Use Dim6 and Dim7
5319       -- meastmon 06/07/2001
5320       -- Dont show time dimension level
5321       if (c_recs.Dimension5_Level_ID is NULL) or (l_Org_Seq_Num = 5) or (l_Time_Seq_Num = 5) then
5322        if (l_Org_Seq_Num = 5) or (l_Time_Seq_Num = 5) then
5323       htp.formHidden('dim5_level_id', NULL);
5324          else
5325           htp.formHidden('dim5_level_id',c_recs.Dimension5_Level_ID);
5326      end if;
5327       else
5328        -- Print out NOCOPY label and input box for dimension5
5329        htp.formHidden('dim5_level_id',c_recs.Dimension5_Level_ID);
5330        htp.tableRowOpen;
5331        htp.tableData(bis_utilities_pvt.escape_html(c_recs.Dimension5_Level_Name)||' '
5332                     ,calign=>'RIGHT'
5333                     ,cnowrap=>'YES');
5334        htp.p('<td align="LEFT" nowrap="YES">');
5335        htp.formSelectOpen('dim5',cattributes=>'onchange="setdim5()"');
5336        htp.formSelectOption(l_blank);
5337        if (l_d5 <> c_hash) then
5338        -- mdamle 01/15/2001 - Replace c_hash with ' ' icase data was changed
5339      l_d5 := REPLACE(l_d5, c_hash, ' ');
5340 
5341          l_dim5_level_value_rec.Dimension_level_ID:=c_recs.Dimension5_Level_ID;
5342          l_dim5_level_value_rec.Dimension_level_Value_ID := l_d5;
5343          l_dim5_level_value_rec.dimension_Level_short_name := c_recs.dimension5_Level_short_name;
5344          BIS_DIM_LEVEL_VALUE_PVT.DimensionX_ID_to_Value(
5345            p_api_version               => 1.0,
5346            p_Dim_Level_Value_Rec       => l_dim5_level_value_rec,
5347            p_set_of_books_id           => l_set_of_books_id,
5348            x_Dim_Level_Value_rec       => l_dim5_level_value_rec,
5349            x_Return_Status             => l_return_status,
5350            x_error_Tbl                 => l_error_tbl
5351           );
5352         htp.formSelectOption
5353         -- mdamle - 01/15/2001 - Add quotes around VALUE
5354        (cvalue=>bis_utilities_pvt.escape_html_input(l_dim5_level_value_rec.Dimension_level_Value_Name),
5355         cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_dim5_level_value_rec.Dimension_level_Value_ID)||'"',
5356         cselected=>'YES');
5357         end if;
5358 
5359        if (l_dim5_tbl.COUNT <> 0) THEN
5360           BIS_INDICATOR_REGION_UI_PVT.removeDuplicates(p_original_tbl => l_dim5_tbl,
5361                            x_unique_tbl   => l_d5_tbl);
5362           for i in 1 ..l_d5_tbl.COUNT LOOP
5363              exit when (l_d5_tbl(i).id is NULL);
5364        -- mdamle - 01/15/2001 - Add quotes around VALUE
5365              htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_d5_tbl(i).name),
5366                   cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_d5_tbl(i).id)||'"');
5367           end loop;
5368        end if;
5369        htp.formSelectOption(c_choose);
5370        htp.formSelectClose;
5371        htp.p('</td>');
5372        htp.tablerowClose;
5373       end if;
5374 
5375       -- mdamle 01/15/2001 - Use Dim6 and Dim7
5376       -- Dimension6
5377       -- ***************************************
5378     -- mdamle 06/66/6006 - Use Dim6 and Dim7
5379       -- meastmon 06/07/2001
5380       -- Dont show time dimension level
5381       if (c_recs.Dimension6_Level_ID is NULL) or (l_Org_Seq_Num = 6) or (l_Time_Seq_Num = 6) then
5382        if (l_Org_Seq_Num = 6) or (l_Time_Seq_Num = 6) then
5383       htp.formHidden('dim6_level_id', NULL);
5384          else
5385           htp.formHidden('dim6_level_id',c_recs.Dimension6_Level_ID);
5386      end if;
5387       else       -- Print out NOCOPY label and input box for dimension6
5388        htp.formHidden('dim6_level_id',c_recs.Dimension6_Level_ID);
5389        htp.tableRowOpen;
5390        htp.tableData(bis_utilities_pvt.escape_html(c_recs.Dimension6_Level_Name)||' '
5391                     ,calign=>'RIGHT'
5392                     ,cnowrap=>'YES');
5393        htp.p('<td align="LEFT" nowrap="YES">');
5394        htp.formSelectOpen('dim6',cattributes=>'onchange="setdim6()"');
5395        htp.formSelectOption(l_blank);
5396        if (l_d6 <> c_hash) then
5397        -- mdamle 01/15/2001 - Replace c_hash with ' ' icase data was changed
5398      l_d6 := REPLACE(l_d6, c_hash, ' ');
5399 
5400          l_dim6_level_value_rec.Dimension_level_ID:=c_recs.Dimension6_Level_ID;
5401          l_dim6_level_value_rec.Dimension_level_Value_ID := l_d6;
5402          l_dim6_level_value_rec.dimension_Level_short_name := c_recs.dimension6_Level_short_name;
5403          BIS_DIM_LEVEL_VALUE_PVT.DimensionX_ID_to_Value(
5404            p_api_version               => 1.0,
5405            p_Dim_Level_Value_Rec       => l_dim6_level_value_rec,
5406            p_set_of_books_id           => l_set_of_books_id,
5407            x_Dim_Level_Value_rec       => l_dim6_level_value_rec,
5408            x_Return_Status             => l_return_status,
5409            x_error_Tbl                 => l_error_tbl
5410           );
5411         htp.formSelectOption
5412         -- mdamle - 01/15/2001 - Add quotes around VALUE
5413        (cvalue=>bis_utilities_pvt.escape_html_input(l_dim6_level_value_rec.Dimension_level_Value_Name),
5414         cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_dim6_level_value_rec.Dimension_level_Value_ID)||'"',
5415         cselected=>'YES');
5416         end if;
5417 
5418        if (l_dim6_tbl.COUNT <> 0) THEN
5419           BIS_INDICATOR_REGION_UI_PVT.removeDuplicates(p_original_tbl => l_dim6_tbl,
5420                            x_unique_tbl   => l_d6_tbl);
5421           for i in 1 ..l_d6_tbl.COUNT LOOP
5422              exit when (l_d6_tbl(i).id is NULL);
5423        -- mdamle - 01/15/2001 - Add quotes around VALUE
5424              htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_d6_tbl(i).name),
5425                   cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_d6_tbl(i).id)||'"');
5426           end loop;
5427        end if;
5428        htp.formSelectOption(c_choose);
5429        htp.formSelectClose;
5430        htp.p('</td>');
5431        htp.tablerowClose;
5432       end if;
5433 
5434       -- mdamle 01/15/2001 - Use Dim6 and Dim7
5435       -- Dimension7
5436       -- ***************************************
5437     -- mdamle 07/77/7007 - Use Dim7 and Dim7
5438       -- meastmon 06/07/2001
5439       -- Dont show time dimension level
5440       if (c_recs.Dimension7_Level_ID is NULL) or (l_Org_Seq_Num = 7) or (l_Time_Seq_Num = 7) then
5441        if (l_Org_Seq_Num = 7) or (l_Time_Seq_Num = 7) then
5442       htp.formHidden('dim7_level_id', NULL);
5443          else
5444           htp.formHidden('dim7_level_id',c_recs.Dimension7_Level_ID);
5445      end if;
5446       else       -- Print out NOCOPY label and input box for dimension7
5447        htp.formHidden('dim7_level_id',c_recs.Dimension7_Level_ID);
5448        htp.tableRowOpen;
5449        htp.tableData(bis_utilities_pvt.escape_html(c_recs.Dimension7_Level_Name)||' '
5450                     ,calign=>'RIGHT'
5451                     ,cnowrap=>'YES');
5452        htp.p('<td align="LEFT" nowrap="YES">');
5453        htp.formSelectOpen('dim7',cattributes=>'onchange="setdim7()"');
5454        htp.formSelectOption(l_blank);
5455        if (l_d7 <> c_hash) then
5456        -- mdamle 01/15/2001 - Replace c_hash with ' ' icase data was changed
5457      l_d7 := REPLACE(l_d7, c_hash, ' ');
5458 
5459          l_dim7_level_value_rec.Dimension_level_ID:=c_recs.Dimension7_Level_ID;
5460          l_dim7_level_value_rec.Dimension_level_Value_ID := l_d7;
5461          l_dim7_level_value_rec.dimension_Level_short_name := c_recs.dimension7_Level_short_name;
5462          BIS_DIM_LEVEL_VALUE_PVT.DimensionX_ID_to_Value(
5463            p_api_version               => 1.0,
5464            p_Dim_Level_Value_Rec       => l_dim7_level_value_rec,
5465            p_set_of_books_id           => l_set_of_books_id,
5466            x_Dim_Level_Value_rec       => l_dim7_level_value_rec,
5467            x_Return_Status             => l_return_status,
5468            x_error_Tbl                 => l_error_tbl
5469           );
5470         htp.formSelectOption
5471         -- mdamle - 01/15/2001 - Add quotes around VALUE
5472        (cvalue=>bis_utilities_pvt.escape_html_input(l_dim7_level_value_rec.Dimension_level_Value_Name),
5473         cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_dim7_level_value_rec.Dimension_level_Value_ID)||'"',
5474         cselected=>'YES');
5475         end if;
5476 
5477        if (l_dim7_tbl.COUNT <> 0) THEN
5478           BIS_INDICATOR_REGION_UI_PVT.removeDuplicates(p_original_tbl => l_dim7_tbl,
5479                            x_unique_tbl   => l_d7_tbl);
5480           for i in 1 ..l_d7_tbl.COUNT LOOP
5481              exit when (l_d7_tbl(i).id is NULL);
5482        -- mdamle - 01/15/2001 - Add quotes around VALUE
5483              htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(l_d7_tbl(i).name),
5484                   cattributes=>'VALUE="'||bis_utilities_pvt.escape_html_input(l_d7_tbl(i).id)||'"');
5485           end loop;
5486        end if;
5487        htp.formSelectOption(c_choose);
5488        htp.formSelectClose;
5489        htp.p('</td>');
5490        htp.tablerowClose;
5491       end if;
5492 
5493      exit;
5494    --  end if;
5495   -- end loop;     -- end of loop of l_indicators_tbl
5496   end loop;     -- end of   c_recs looop
5497    -- ***********************************************
5498 
5499     -- Have a poplist for the Business Plan
5500      htp.p('<!-- Row open for Business Plan poplist -->');
5501      htp.tableRowOpen;
5502      htp.tableData(bis_utilities_pvt.escape_html(c_plan)||' ',calign=>'RIGHT',cnowrap=>'YES');
5503      htp.p('<td align="left">');
5504      htp.formSelectOpen('plan');
5505      for pl in plan_cur loop
5506       if pl.plan_id = TO_NUMBER(l_plan) then
5507        htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(pl.name),cselected=>'YES',
5508                   cattributes=>'VALUE='||bis_utilities_pvt.escape_html_input(pl.plan_id));
5509       else
5510        htp.formSelectOption(cvalue=>bis_utilities_pvt.escape_html_input(pl.name),
5511                   cattributes=>'VALUE='||bis_utilities_pvt.escape_html_input(pl.plan_id));
5512       end if;
5513      end loop;
5514      htp.formSelectClose;
5515      htp.p('</td>');
5516      htp.tableRowClose;
5517 
5518   htp.tableClose;
5519   htp.p('</td>');
5520   htp.tableRowClose;
5521   htp.p('<!-- end of row containing one more cell to center poplists -->');
5522 
5523   htp.p('<!-- row open with horizontal line separator -->');
5524   htp.tableRowOpen;
5525    htp.p('<td height=1 bgcolor=#000000>'||
5526          '<IMG SRC="/OA_MEDIA/FNDINVDT.gif" height=1 width=1></td>');
5527   htp.tableRowClose;
5528 
5529   htp.tableRowOpen;
5530    htp.p('<td height=5></td>');
5531   htp.tableRowClose;
5532 
5533   htp.p('<!-- row open for display label string  -->');
5534   htp.tableRowOpen;
5535    htp.p('<td align="left">');
5536    htp.p(c_displabel);
5537    htp.p('</td>');
5538   htp.tableRowClose;
5539 
5540   htp.tableRowOpen;
5541    htp.p('<td align="left" valign="TOP" nowrap="YES">');
5542    htp.formText(cname=>'label',csize=>41,cmaxlength=>40);
5543    htp.p('</td>');
5544   htp.tableRowClose;
5545 
5546 
5547   htp.tableRowOpen;
5548    htp.p('<td height=5></td>');
5549   htp.tableRowClose;
5550 
5551   htp.p('<!-- Close embedded table containing the dim level poplists etc -->');
5552   htp.tableClose; -- close embedded table containing dim labels and input boxes
5553   htp.p('</td>');  -- close cell with dim labels and input boxes
5554 
5555   htp.p('<!-- Put the right side separator and right edge of wire frame box -->');
5556   htp.p('<td width=5></td>');
5557   htp.p('<td width=1 bgcolor=#000000>'||
5558         '<IMG SRC="/OA_MEDIA/FNDINVDT.gif" height=1 width=1></td>');
5559   htp.tableRowClose;
5560 
5561   htp.tableRowOpen;
5562    htp.p('<!-- Put the bottom edge of wireframe box -->');
5563    htp.p('<td height=1 bgcolor=#000000 colspan=5>'||
5564          '<IMG SRC="/OA_MEDIA/FNDINVDT.gif" height=1 width=1></td>');
5565   htp.tableRowClose;
5566 
5567   htp.p('<!-- close table wireframe box -->');
5568   htp.tableClose;
5569   htp.p('</td>');
5570  htp.tableRowClose;
5571 
5572  htp.tableClose;
5573  htp.p('</td>');
5574  htp.tableRowClose;
5575 
5576  htp.tableRowOpen;
5577   htp.p('<td><BR></td>');
5578 
5579  htp.p('<!-- Open last row containing the ok and cancel buttons -->');
5580  htp.tableRowOpen;
5581     htp.p('<td align="center" colspan=2>');
5582     htp.p('<table width="100%"><tr>');
5583     htp.p('<td align="right" width="50%">');
5584 
5585     --meastmon ICX Button is not ADA Complaint. ICX is not going to fix that.
5586     --icx_plug_utilities.buttonLeft
5587     --  (BIS_UTILITIES_PVT.getPrompt('BIS_OK'),'javascript:saveRename()');
5588     l_button_tbl(1).left_edge := BIS_UTILITIES_PVT.G_ROUND_EDGE;
5589     l_button_tbl(1).right_edge := BIS_UTILITIES_PVT.G_FLAT_EDGE;
5590     l_button_tbl(1).disabled := FND_API.G_FALSE;
5591     l_button_tbl(1).label := BIS_UTILITIES_PVT.getPrompt('BIS_OK');
5592     l_button_tbl(1).href := 'javascript:saveRename()';
5593     BIS_UTILITIES_PVT.GetButtonString(l_button_tbl, l_button_str);
5594     htp.p(l_button_str);
5595 
5596     htp.p('</td><td align="left" width="50%">');
5597 
5598     --meastmon ICX Button is not ADA Complaint. ICX is not going to fix that.
5599     --icx_plug_utilities.buttonRight
5600     -- (BIS_UTILITIES_PVT.getPrompt('BIS_CANCEL'),'javascript:window.close()');
5601     l_button_tbl(1).left_edge := BIS_UTILITIES_PVT.G_FLAT_EDGE;
5602     l_button_tbl(1).right_edge := BIS_UTILITIES_PVT.G_ROUND_EDGE;
5603     l_button_tbl(1).disabled := FND_API.G_FALSE;
5604     l_button_tbl(1).label := BIS_UTILITIES_PVT.getPrompt('BIS_CANCEL');
5605     l_button_tbl(1).href := 'javascript:window.close()';
5606     BIS_UTILITIES_PVT.GetButtonString(l_button_tbl, l_button_str);
5607     htp.p(l_button_str);
5608 
5609 
5610     htp.p('</td></tr></table>');
5611     htp.p('</td>');
5612  htp.p('<!-- Close last row containing the ok and cancel buttons -->');
5613  htp.tableRowClose;
5614 
5615  htp.tableClose;
5616  htp.centerClose;
5617 
5618  htp.p('<!-- close form for this page -->');
5619  htp.formClose;
5620  htp.p('<SCRIPT LANGUAGE="JavaScript">loadName();</SCRIPT>');
5621 
5622  htp.bodyClose;
5623  htp.htmlClose;
5624 
5625 end if;    -- icx_validate session
5626 
5627 exception
5628     when others then
5629         htp.p(SQLERRM);
5630 
5631 end editDimensions;*/
5632 
5633 
5634 --===========================================================
5635 -- start of change by juwang
5636 -- 12-DEC-01 juwang   modified for showing pre-seeded portlet
5637 --===========================================================
5638 
5639 
5640 
5641 --==========================================================================+
5642 --    FUNCTION
5643 --       get_menu_name
5644 --
5645 --    PURPOSE
5646 --
5647 --    PARAMETERS
5648 --
5649 --    HISTORY
5650 --       11-DEC-2001 juwang Created.
5651 --==========================================================================
5652 FUNCTION get_menu_name(
5653   p_reference_path IN VARCHAR2
5654 ) RETURN VARCHAR2 IS
5655 
5656 
5657   l_menu_name VARCHAR2(30);
5658   l_function_name VARCHAR2(30);
5659   l_parameters    VARCHAR2(2000);
5660 
5661 
5662   CURSOR c1 IS
5663     SELECT parameters
5664     FROM fnd_form_functions
5665     WHERE function_name = l_function_name;
5666 BEGIN
5667 
5668   l_function_name := BIS_PMF_PORTLET_UTIL.get_function_name(p_reference_path);
5669   IF ( l_function_name IS NULL ) THEN
5670     RETURN NULL;
5671   END IF;
5672 
5673   -- l_function_name is not null now
5674 
5675   OPEN c1;
5676   FETCH c1 INTO l_parameters;
5677 
5678   IF c1%FOUND THEN  -- found, parse it
5679     IF INSTRB(l_parameters, c_key_menu) > 0 THEN
5680       l_menu_name := SUBSTRB(l_parameters, length(c_key_menu)+1);
5681           --dbms_output.put_line('menu name='|| l_menu_name);
5682     ELSE  -- no key, user err
5683       CLOSE c1;
5684       RETURN NULL;
5685     END IF;
5686   ELSE  -- no such function exists.  program err
5687     CLOSE c1;
5688     RETURN NULL;
5689   END IF;  -- c1%FOUND
5690 
5691   CLOSE c1;
5692   RETURN l_menu_name;
5693 
5694 EXCEPTION
5695 
5696   WHEN OTHERS THEN
5697     RETURN NULL;
5698 
5699 END get_menu_name;
5700 
5701 
5702 
5703 
5704 
5705 --============================================================
5706 FUNCTION get_menu_name(
5707   p_plug_id IN NUMBER
5708 ) RETURN VARCHAR2
5709 IS
5710   l_ref_path VARCHAR2(100);
5711 
5712   CURSOR c_ipc IS
5713   SELECT REFERENCE_PATH
5714   FROM   ICX_PORTLET_CUSTOMIZATIONS
5715   WHERE  PLUG_ID = p_plug_id;
5716 
5717 BEGIN
5718 
5719   OPEN c_ipc;
5720   FETCH c_ipc INTO l_ref_path;
5721 
5722   IF c_ipc%FOUND THEN  -- found, parse it
5723     CLOSE c_ipc;
5724     RETURN get_menu_name(l_ref_path);
5725 
5726   ELSE  -- no such plug_id exists.
5727     CLOSE c_ipc;
5728     RETURN NULL;
5729   END IF;
5730 
5731 
5732 EXCEPTION
5733 
5734   WHEN OTHERS THEN
5735     IF c_ipc%ISOPEN THEN
5736       CLOSE c_ipc;
5737     END IF;
5738     RETURN NULL;
5739 
5740 END get_menu_name;
5741 
5742 --============================================================
5743 -- Fix for 2661248
5744 FUNCTION get_functionid_from_refpath(
5745   p_reference_path IN VARCHAR2
5746   ) RETURN NUMBER IS
5747 
5748   l_function_name FND_FORM_FUNCTIONS.FUNCTION_NAME%TYPE;
5749   l_function_id   NUMBER;
5750 
5751   CURSOR cFunctionId (cp_function_name VARCHAR2) IS
5752     SELECT function_id
5753     FROM fnd_form_functions
5754     WHERE function_name = cp_function_name;
5755 
5756 BEGIN
5757 
5758   l_function_name := BIS_PMF_PORTLET_UTIL.get_function_name(p_reference_path => p_reference_path);
5759 
5760   IF ( l_function_name IS NULL ) THEN
5761     RETURN NULL;
5762   END IF;
5763 
5764   IF (cFunctionId%ISOPEN) THEN
5765     CLOSE cFunctionId;
5766   END IF;
5767 
5768   OPEN cFunctionId(cp_function_name => l_function_name);
5769   FETCH cFunctionId INTO l_function_id;
5770   CLOSE cFunctionId;
5771 
5772   RETURN l_function_id;
5773 
5774 EXCEPTION
5775   WHEN OTHERS THEN
5776     IF (cFunctionId%ISOPEN) THEN
5777       CLOSE cFunctionId;
5778     END IF;
5779     RETURN NULL;
5780 END get_functionid_from_refpath;
5781 
5782 
5783 --==========================================================================+
5784 --    FUNCTION
5785 --       getTargetLevelId
5786 --
5787 --    PURPOSE
5788 --       This functoin returns the target level id by the given
5789 --       p_parameters in the folloiwng format:
5790 --       [pTaragetLevelShortName=myLevelshortName]
5791 --       It will find out NOCOPY the target level id for this short name.
5792 --       Returns null if no such level short name or cannot find the
5793 --       target level id.
5794 --    PARAMETERS
5795 --
5796 --    HISTORY
5797 --       11-DEC-2001 juwang Created.
5798 --==========================================================================
5799 FUNCTION getTargetLevelId(
5800   p_parameters IN VARCHAR2
5801  ,x_return_status OUT NOCOPY VARCHAR2
5802  ,x_error_tbl     OUT NOCOPY BIS_UTILITIES_PUB.Error_Tbl_Type
5803 ) RETURN NUMBER
5804 IS
5805   l_level_short_name      VARCHAR2(80);
5806   l_target_level_rec      BIS_TARGET_LEVEL_PUB.Target_Level_Rec_Type;
5807 BEGIN
5808   x_return_status := FND_API.G_RET_STS_SUCCESS;
5809 
5810   l_level_short_name := BIS_PMF_PORTLET_UTIL.get_pl_value(c_key_target_level,p_parameters);
5811   IF (l_level_short_name IS NULL) THEN --bug#2210756
5812     RETURN NULL;
5813   END IF;
5814 
5815   l_Target_level_rec.TARGET_LEVEL_SHORT_NAME := l_level_short_name;
5816 
5817   ---------------------------
5818   -- get target level id now
5819   ---------------------------
5820   BIS_TARGET_LEVEL_PUB.Retrieve_Target_Level
5821       ( p_api_version         => 1.0
5822       , p_Target_level_rec    => l_Target_level_rec
5823       , p_all_info            => FND_API.G_FALSE
5824       , x_Target_level_rec    => l_Target_level_rec
5825       , x_return_status       => x_return_status
5826       , x_error_Tbl           => x_error_tbl
5827       );
5828   -- bug#2210756
5829 
5830   IF (BIS_UTILITIES_PUB.Value_Missing(l_Target_level_rec.TARGET_LEVEL_ID) = FND_API.G_TRUE) THEN
5831 
5832     RETURN NULL;
5833   END IF;
5834 
5835   RETURN l_Target_level_rec.TARGET_LEVEL_ID;
5836 
5837 
5838 EXCEPTION
5839   WHEN OTHERS THEN
5840     RETURN NULL;
5841 
5842 
5843 END getTargetLevelId;
5844 
5845 
5846 
5847 
5848 
5849 --==========================================================================+
5850 --    FUNCTION
5851 --       getDefaultPlanId
5852 --
5853 --    PURPOSE
5854 --    PARAMETERS
5855 --
5856 --    HISTORY
5857 --       11-DEC-2001 juwang Created.
5858 --==========================================================================
5859 FUNCTION getDefaultPlanId(
5860   x_return_status OUT NOCOPY VARCHAR2
5861  ,x_error_Tbl     OUT NOCOPY BIS_UTILITIES_PUB.Error_Tbl_Type
5862 ) RETURN NUMBER
5863 IS
5864   l_plan_id NUMBER := c_NULL;
5865 
5866   CURSOR cPlan is
5867     SELECT plan_id
5868     FROM BISBV_BUSINESS_PLANS
5869     ORDER BY name;
5870 
5871 BEGIN
5872   x_return_status := FND_API.G_RET_STS_SUCCESS;
5873 
5874   OPEN cPlan;
5875   FETCH cPlan INTO l_plan_id;
5876   IF cPlan%NOTFOUND THEN
5877     l_plan_id := c_NULL;  -- No plans are available
5878   END IF;
5879   CLOSE cPlan;
5880   RETURN l_plan_id;
5881 
5882 
5883 EXCEPTION
5884   WHEN OTHERS THEN
5885     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
5886     --added last two parameters
5887     BIS_UTILITIES_PVT.Add_Error_Message
5888     ( p_error_msg_id       => SQLCODE
5889     , p_error_description => SQLERRM
5890     , p_error_proc_name   => G_PKG_NAME||'.getDefaultPlanId'
5891     , p_error_table       => x_error_tbl
5892     , x_error_table       => x_error_tbl
5893     );
5894 
5895 
5896 END getDefaultPlanId;
5897 
5898 
5899 
5900 
5901 --==========================================================================+
5902 --    FUNCTION
5903 --       getPlanId
5904 --
5905 --    PURPOSE
5906 --       This functoin returns the target level id by the given
5907 --       p_parameters in the folloiwng format:
5908 --       [pTaragetLevelShortName=myLevelshortName]
5909 --       It will find out NOCOPY the target level id for this short name.
5910 --    PARAMETERS
5911 --
5912 --    HISTORY
5913 --       11-DEC-2001 juwang Created.
5914 --==========================================================================
5915 FUNCTION getPlanId(
5916   p_parameters IN VARCHAR2
5917  ,p_default_plan_id IN NUMBER
5918  ,x_return_status OUT NOCOPY VARCHAR2
5919  ,x_error_Tbl     OUT NOCOPY BIS_UTILITIES_PUB.Error_Tbl_Type
5920 ) RETURN NUMBER
5921 IS
5922 
5923   l_business_plan_rec BIS_BUSINESS_PLAN_PUB.Business_Plan_Rec_Type;
5924   l_plan_short_name     VARCHAR2(80);
5925 
5926 
5927 
5928 BEGIN
5929   x_return_status := FND_API.G_RET_STS_SUCCESS;
5930 
5931   l_plan_short_name := BIS_PMF_PORTLET_UTIL.get_pl_value(c_key_plan,p_parameters);
5932 
5933 -- plan short name is not specified
5934   IF ( l_plan_short_name IS NULL) THEN
5935     RETURN p_default_plan_id;
5936   END IF;
5937 
5938   l_business_plan_rec.Business_Plan_Short_Name := l_plan_short_name;
5939 
5940   ---------------------------
5941   --  retrieve business plans;
5942   ---------------------------
5943   BIS_BUSINESS_PLAN_PUB.Retrieve_Business_Plan
5944   ( p_api_version       => 1.0
5945   , p_Business_Plan_Rec => l_business_plan_rec
5946   , x_Business_Plan_Rec => l_business_plan_rec
5947   , x_return_status     => x_return_status
5948   , x_error_tbl         => x_error_tbl
5949   );
5950 /*
5951     IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5952        RETURN p_default_plan_id;
5953     END IF;
5954 */
5955   RETURN l_business_plan_rec.Business_Plan_id;
5956 
5957 
5958 EXCEPTION
5959 /*
5960     WHEN FND_API.G_EXC_ERROR then
5961       x_return_status := FND_API.G_RET_STS_ERROR ;
5962 */
5963   WHEN OTHERS THEN
5964     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
5965   --added last two parameters
5966     BIS_UTILITIES_PVT.Add_Error_Message
5967     ( p_error_msg_id       => SQLCODE
5968     , p_error_description => SQLERRM
5969     , p_error_proc_name   => G_PKG_NAME||'.getPlanId'
5970     , p_error_table       => x_error_tbl
5971     , x_error_table       => x_error_tbl
5972       );
5973 
5974 END getPlanId;
5975 
5976 
5977 
5978 
5979 
5980 --==========================================================================+
5981 --    PROCEDURE
5982 --       saveAsMeasures
5983 --
5984 --    PURPOSE
5985 --       Tasks include
5986 --         1. parse p_parameters
5987 --         2. save the parsed parameters into bis_user_ind_selections
5988 --    PARAMETERS
5989 --
5990 --    HISTORY
5991 --       11-DEC-2001 juwang Created.
5992 --==========================================================================
5993 PROCEDURE saveAsMeasures(
5994   p_parameters IN VARCHAR2
5995  ,p_plug_id IN NUMBER
5996  ,p_user_id IN NUMBER
5997  ,p_user_fname IN VARCHAR2
5998  ,p_default_plan_id IN NUMBER
5999  ,x_return_status OUT NOCOPY VARCHAR2
6000  ,x_error_Tbl OUT NOCOPY BIS_UTILITIES_PUB.Error_Tbl_Type
6001       )
6002 IS
6003 
6004   l_plan_id NUMBER;
6005   l_tar_level_id NUMBER;
6006   l_ind_rec BIS_INDICATOR_REGION_PUB.Indicator_Region_Rec_Type;
6007 
6008 BEGIN
6009 --dbms_output.put_line('p_parameters='|| p_parameters);
6010 --Transfer the values to the fields in the record
6011 
6012   l_ind_rec.USER_ID             :=  p_user_id;
6013   --------------------------
6014   --get the target level id
6015   --------------------------
6016   -- bug#2210756
6017   l_tar_level_id := getTargetLevelId( p_parameters  ,x_return_status  ,x_error_Tbl);
6018 
6019   IF ( l_tar_level_id IS NULL) THEN
6020     RETURN;
6021   END IF;
6022 
6023   l_ind_rec.TARGET_LEVEL_ID  := l_tar_level_id;
6024 
6025   --------------------------
6026   --get the plan id
6027   --------------------------
6028   l_plan_id := getPlanId(
6029    p_parameters => p_parameters
6030   ,p_default_plan_id => p_default_plan_id
6031   ,x_return_status => x_return_status
6032   ,x_error_Tbl     => x_error_tbl
6033   );
6034 
6035   IF (l_plan_id <> c_NULL) THEN
6036     l_ind_rec.PLAN_ID :=  l_plan_id ;
6037   END IF;
6038 
6039 
6040   l_ind_rec.LABEL               :=  p_user_fname;
6041   l_ind_rec.PLUG_ID             :=  p_plug_id;
6042   l_ind_rec.DIM1_LEVEL_VALUE_ID :=BIS_PMF_PORTLET_UTIL.get_pl_value(c_key_dv_id1,p_parameters);
6043   l_ind_rec.DIM2_LEVEL_VALUE_ID :=BIS_PMF_PORTLET_UTIL.get_pl_value(c_key_dv_id2,p_parameters);
6044   l_ind_rec.DIM3_LEVEL_VALUE_ID :=BIS_PMF_PORTLET_UTIL.get_pl_value(c_key_dv_id3,p_parameters);
6045   l_ind_rec.DIM4_LEVEL_VALUE_ID :=BIS_PMF_PORTLET_UTIL.get_pl_value(c_key_dv_id4,p_parameters);
6046   l_ind_rec.DIM5_LEVEL_VALUE_ID :=BIS_PMF_PORTLET_UTIL.get_pl_value(c_key_dv_id5,p_parameters);
6047   l_ind_rec.DIM6_LEVEL_VALUE_ID :=BIS_PMF_PORTLET_UTIL.get_pl_value(c_key_dv_id6,p_parameters);
6048   l_ind_rec.DIM7_LEVEL_VALUE_ID :=BIS_PMF_PORTLET_UTIL.get_pl_value(c_key_dv_id7,p_parameters);
6049 
6050 
6051 -- save to database
6052   BIS_INDICATOR_REGION_PUB.Create_User_Ind_Selection(
6053    p_api_version          => 1.0
6054   ,p_Indicator_Region_Rec => l_ind_rec
6055   ,x_return_status        => x_return_status
6056   ,x_error_Tbl            => x_error_tbl
6057   );
6058 
6059 
6060 
6061 EXCEPTION
6062   WHEN OTHERS THEN
6063     IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6064 
6065       --dbms_output.put_line('l_return_status='|| x_return_status);
6066       FOR i in 1 .. x_error_tbl.COUNT LOOP
6067         NULL;
6068 htp.p('err='||x_error_tbl(i).Error_Description);
6069         --dbms_output.put_line('err='||x_error_tbl(i).Error_Description);
6070       END LOOP;
6071 
6072     END IF;
6073 
6074 END saveAsMeasures;
6075 
6076 --==========================================================================+
6077 --    PROCEDURE
6078 --       copyMeasureDefs
6079 --
6080 --    PURPOSE
6081 --       Tasks include
6082 --         1. See if this portlet is pre-seeded
6083 --         2. If it is pre-seeded portlet,  parse p_parameters
6084 --         3. save the parsed parameters into bis_user_ind_selections
6085 --    PARAMETERS
6086 --
6087 --    HISTORY
6088 --       11-DEC-2001 juwang Created.
6089 --==========================================================================
6090 
6091 PROCEDURE copyMeasureDefs(
6092   p_reference_path IN VARCHAR2
6093  ,p_plug_id IN NUMBER
6094  ,p_user_id IN NUMBER
6095  ,x_return_status  OUT NOCOPY VARCHAR2
6096  ,x_error_Tbl      OUT NOCOPY BIS_UTILITIES_PUB.Error_Tbl_Type
6097 )
6098 IS
6099   l_menu_name VARCHAR2(30);
6100   l_parameters VARCHAR2(2000);
6101   l_user_fname VARCHAR2(80);
6102 
6103   l_default_plan_id NUMBER;
6104 
6105 -- measures cursor
6106   CURSOR cMs IS
6107     SELECT ff.parameters, ff.USER_FUNCTION_NAME
6108     FROM
6109       fnd_menus fm,
6110       fnd_menu_entries_vl fme,
6111       fnd_form_functions_vl ff
6112     WHERE
6113       fm.menu_name = l_menu_name AND
6114       fme.menu_id = fm.menu_id AND
6115       fme.function_id = ff.function_id AND
6116       ff.TYPE <> 'DBPORTLET';
6117 
6118 BEGIN
6119 
6120   l_menu_name := get_menu_name(p_reference_path);
6121   IF ( l_menu_name IS NULL ) THEN
6122 --dbms_output.put_line('l_menu_name is null!');
6123 --note : do not throw exception because it can be a plain portlet
6124     RETURN;
6125   END IF;
6126 
6127 -- l_menu_name not null now
6128 -- get the default plan id
6129 
6130   l_default_plan_id := getDefaultPlanId(
6131    x_return_status => x_return_status
6132   ,x_error_Tbl => x_error_Tbl
6133   );
6134 
6135 -- in order to set the last_updated_by correctly
6136   IF icx_portlet.validateSession THEN
6137       NULL;
6138   END IF;
6139 
6140 
6141   OPEN cMs;
6142   FETCH cMs INTO l_parameters, l_user_fname ;
6143   WHILE cMs%FOUND LOOP
6144     saveAsMeasures(
6145      p_parameters => l_parameters
6146     ,p_plug_id =>  p_plug_id
6147     ,p_user_id =>  p_user_id
6148     ,p_user_fname => l_user_fname
6149     ,p_default_plan_id => l_default_plan_id
6150     ,x_return_status => x_return_status
6151     ,x_error_Tbl => x_error_Tbl
6152     );
6153     FETCH cMs INTO l_parameters, l_user_fname;
6154   END LOOP;
6155 
6156   CLOSE cMs;
6157 
6158 EXCEPTION
6159   WHEN OTHERS THEN
6160     IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6161       --dbms_output.put_line('l_return_status='|| x_return_status);
6162       FOR i in 1 .. x_error_tbl.COUNT LOOP
6163         NULL;
6164         --dbms_output.put_line('err='||x_error_tbl(i).Error_Description);
6165       END LOOP;
6166     END IF;
6167 
6168 END copyMeasureDefs;
6169 
6170 
6171 
6172 --============================================================
6173 FUNCTION createParameters(
6174   p_ind_sel IN NUMBER
6175 ) RETURN VARCHAR2
6176 IS
6177 
6178   l_param VARCHAR2(2000);
6179 
6180   l_target_sn VARCHAR2(30);
6181   l_dv1_id NUMBER;
6182   l_dv2_id NUMBER;
6183   l_dv3_id NUMBER;
6184   l_dv4_id NUMBER;
6185   l_dv5_id NUMBER;
6186   l_dv6_id NUMBER;
6187   l_dv7_id NUMBER;
6188   l_plan_sn VARCHAR2(30);
6189   l_label VARCHAR2(40);
6190 
6191 
6192    CURSOR cMs IS
6193      SELECT bt.SHORT_NAME
6194        , bu.DIMENSION1_LEVEL_VALUE
6195        , bu.DIMENSION2_LEVEL_VALUE
6196        , bu.DIMENSION3_LEVEL_VALUE
6197        , bu.DIMENSION4_LEVEL_VALUE
6198        , bu.DIMENSION5_LEVEL_VALUE
6199        , bu.DIMENSION6_LEVEL_VALUE
6200        , bu.DIMENSION7_LEVEL_VALUE
6201        , bp.SHORT_NAME
6202        , bu.LABEL
6203      FROM
6204        bis_user_ind_selections bu
6205        , bis_target_levels bt
6206        , BISBV_BUSINESS_PLANS bp
6207      WHERE
6208        bu.IND_SELECTION_ID = p_ind_sel
6209      AND bu.TARGET_LEVEL_ID = bt.TARGET_LEVEL_ID
6210      AND bu.PLAN_ID = bp.PLAN_ID;
6211 
6212 
6213 BEGIN
6214 
6215   OPEN cMs;
6216   FETCH cMs INTO
6217     l_target_sn
6218     ,l_dv1_id
6219     ,l_dv2_id
6220     ,l_dv3_id
6221     ,l_dv4_id
6222     ,l_dv5_id
6223     ,l_dv6_id
6224     ,l_dv7_id
6225     ,l_plan_sn
6226     ,l_label;
6227 
6228   IF cMs%FOUND THEN
6229     l_param := c_key_target_level || c_eq || l_target_sn || c_amp
6230     || c_key_plan || c_eq || l_plan_sn;
6231     IF ( l_dv1_id IS NOT NULL) THEN
6232       l_param := l_param || c_amp || c_key_dv_id1 || c_eq || l_dv1_id;
6233     END IF;
6234     IF ( l_dv2_id IS NOT NULL) THEN
6235       l_param := l_param || c_amp || c_key_dv_id2 || c_eq || l_dv2_id;
6236     END IF;
6237     IF ( l_dv3_id IS NOT NULL) THEN
6238       l_param := l_param || c_amp || c_key_dv_id3 || c_eq || l_dv3_id;
6239     END IF;
6240     IF ( l_dv4_id IS NOT NULL) THEN
6241       l_param := l_param || c_amp || c_key_dv_id4 || c_eq || l_dv4_id;
6242     END IF;
6243     IF ( l_dv5_id IS NOT NULL) THEN
6244       l_param := l_param || c_amp || c_key_dv_id5 || c_eq || l_dv5_id;
6245     END IF;
6246     IF ( l_dv6_id IS NOT NULL) THEN
6247       l_param := l_param || c_amp || c_key_dv_id6 || c_eq || l_dv6_id;
6248     END IF;
6249     IF ( l_dv7_id IS NOT NULL) THEN
6250       l_param := l_param || c_amp || c_key_dv_id7 || c_eq || l_dv7_id;
6251     END IF;
6252     IF ( l_label IS NOT NULL) THEN
6253       l_param := l_param || c_amp || 'pLabel' || c_eq || l_label;
6254     END IF;
6255   END IF;
6256   CLOSE cMs;
6257   RETURN l_param;
6258 
6259 
6260 END createParameters;
6261 
6262 
6263 --============================================================
6264 --    PROCEDURE
6265 --      use_current_period
6266 --
6267 --    PURPOSE
6268 --      If in bis_actuals_values, the actual does
6269 --      not exist for the current period, use the period
6270 --      that has the latest last update date
6271 --    PARAMETERS
6272 --
6273 --    HISTORY
6274 --       08JAN-2002 juwang Created for bug#2173745
6275 --=============================================================
6276 FUNCTION use_current_period(
6277   p_target_rec IN BIS_TARGET_PUB.Target_Rec_Type
6278  ,p_time_dimension_index IN NUMBER
6279  ,p_current_period_id IN VARCHAR2
6280  ,x_last_period_id OUT NOCOPY VARCHAR2
6281 ) RETURN BOOLEAN IS
6282   ldv1 VARCHAR2(80);
6283   ldv2 VARCHAR2(80);
6284   ldv3 VARCHAR2(80);
6285   ldv4 VARCHAR2(80);
6286   ldv5 VARCHAR2(80);
6287   ldv6 VARCHAR2(80);
6288   ldv7 VARCHAR2(80);
6289   l_use_cur_period BOOLEAN := FALSE;
6290   l_first_rec BOOLEAN := TRUE;
6291 
6292 /*
6293   CURSOR c_actual_value IS
6294          SELECT
6295            DIMENSION1_LEVEL_VALUE
6296           ,DIMENSION2_LEVEL_VALUE
6297           ,DIMENSION3_LEVEL_VALUE
6298           ,DIMENSION4_LEVEL_VALUE
6299           ,DIMENSION5_LEVEL_VALUE
6300           ,DIMENSION6_LEVEL_VALUE
6301           ,DIMENSION7_LEVEL_VALUE
6302          FROM   bisbv_actuals acts
6303          WHERE  acts.target_level_id    = p_target_rec.target_level_id
6304          AND NVL(acts.dimension1_level_value, 'NILL')
6305            = NVL(p_target_rec.dim1_level_value_id, 'NILL')
6306          AND NVL(acts.dimension2_level_value, 'NILL')
6307            = NVL(p_target_rec.dim2_level_value_id, 'NILL')
6308          AND NVL(acts.dimension3_level_value, 'NILL')
6309            = NVL(p_target_rec.dim3_level_value_id, 'NILL')
6310          AND NVL(acts.dimension4_level_value, 'NILL')
6311            = NVL(p_target_rec.dim4_level_value_id, 'NILL')
6312          AND NVL(acts.dimension5_level_value, 'NILL')
6313            = NVL(p_target_rec.dim5_level_value_id, 'NILL')
6314          AND NVL(acts.dimension6_level_value, 'NILL')
6315            = NVL(p_target_rec.dim6_level_value_id, 'NILL')
6316          AND NVL(acts.dimension7_level_value, 'NILL')
6317            = NVL(p_target_rec.dim7_level_value_id, 'NILL')
6318         ORDER BY acts.LAST_UPDATE_DATE DESC;
6319 */
6320        CURSOR c_actual_value IS
6321          SELECT
6322            DIMENSION1_LEVEL_VALUE
6323           ,DIMENSION2_LEVEL_VALUE
6324           ,DIMENSION3_LEVEL_VALUE
6325           ,DIMENSION4_LEVEL_VALUE
6326           ,DIMENSION5_LEVEL_VALUE
6327           ,DIMENSION6_LEVEL_VALUE
6328           ,DIMENSION7_LEVEL_VALUE
6329         FROM   bisbv_actuals acts
6330         WHERE  acts.target_level_id    = p_target_rec.target_level_id
6331         AND DECODE(p_time_dimension_index,
6332              1, 'NILL', NVL(acts.dimension1_level_value, 'NILL'))
6333           = DECODE(p_time_dimension_index,
6334              1, 'NILL', NVL(p_target_rec.dim1_level_value_id, 'NILL'))
6335         AND DECODE(p_time_dimension_index,
6336              2, 'NILL', NVL(acts.dimension2_level_value, 'NILL'))
6337           = DECODE(p_time_dimension_index,
6338                  2, 'NILL', NVL(p_target_rec.dim2_level_value_id, 'NILL'))
6339         AND DECODE(p_time_dimension_index,
6340              3, 'NILL', NVL(acts.dimension3_level_value, 'NILL'))
6341           = DECODE(p_time_dimension_index,
6342              3, 'NILL', NVL(p_target_rec.dim3_level_value_id, 'NILL'))
6343         AND DECODE(p_time_dimension_index,
6344              4, 'NILL', NVL(acts.dimension4_level_value, 'NILL'))
6345           = DECODE(p_time_dimension_index,
6346              4, 'NILL', NVL(p_target_rec.dim4_level_value_id, 'NILL'))
6347         AND DECODE(p_time_dimension_index,
6348              5, 'NILL', NVL(acts.dimension5_level_value, 'NILL'))
6349           = DECODE(p_time_dimension_index,
6350              5, 'NILL', NVL(p_target_rec.dim5_level_value_id, 'NILL'))
6351         AND DECODE(p_time_dimension_index,
6352              6, 'NILL', NVL(acts.dimension6_level_value, 'NILL'))
6353           = DECODE(p_time_dimension_index,
6354              6, 'NILL', NVL(p_target_rec.dim6_level_value_id, 'NILL'))
6355         AND DECODE(p_time_dimension_index,
6356              7, 'NILL', NVL(acts.dimension7_level_value, 'NILL'))
6357           = DECODE(p_time_dimension_index,
6358              7, 'NILL', NVL(p_target_rec.dim7_level_value_id, 'NILL'))
6359         ORDER BY acts.LAST_UPDATE_DATE DESC;
6360 BEGIN
6361 
6362   OPEN c_actual_value;
6363   LOOP
6364     FETCH c_actual_value INTO ldv1, ldv2, ldv3, ldv4, ldv5, ldv6, ldv7;
6365     EXIT WHEN c_actual_value%NOTFOUND;
6366 
6367     IF ( l_first_rec ) THEN  -- remember the latest period
6368       IF     ( p_time_dimension_index = 1 ) THEN
6369         x_last_period_id := ldv1;
6370       ELSIF  ( p_time_dimension_index = 2 ) THEN
6371         x_last_period_id := ldv2;
6372       ELSIF  ( p_time_dimension_index = 3 ) THEN
6373         x_last_period_id := ldv3;
6374       ELSIF  ( p_time_dimension_index = 4 ) THEN
6375         x_last_period_id := ldv4;
6376       ELSIF  ( p_time_dimension_index = 5 ) THEN
6377         x_last_period_id := ldv5;
6378       ELSIF  ( p_time_dimension_index = 6 ) THEN
6379         x_last_period_id := ldv6;
6380       ELSIF  ( p_time_dimension_index = 7 ) THEN
6381         x_last_period_id := ldv7;
6382       END IF;
6383 
6384     END IF;  -- ( l_first_rec )
6385     l_first_rec := FALSE;
6386 
6387     -- check if the given period exists in actuals table
6388     IF    ( p_time_dimension_index = 1 ) THEN
6389       IF ( ldv1 = p_current_period_id ) THEN
6390         l_use_cur_period := TRUE;
6391         EXIT;
6392       END IF;
6393     ELSIF ( p_time_dimension_index = 2 ) THEN
6394       IF ( ldv2 = p_current_period_id ) THEN
6395         l_use_cur_period := TRUE;
6396         EXIT;
6397       END IF;
6398     ELSIF  ( p_time_dimension_index = 3 ) THEN
6399       IF ( ldv3 = p_current_period_id ) THEN
6400         l_use_cur_period := TRUE;
6401         EXIT;
6402       END IF;
6403     ELSIF  ( p_time_dimension_index = 4 ) THEN
6404       IF ( ldv4 = p_current_period_id ) THEN
6405         l_use_cur_period := TRUE;
6406         EXIT;
6407       END IF;
6408     ELSIF  ( p_time_dimension_index = 5 ) THEN
6409       IF ( ldv5 = p_current_period_id ) THEN
6410         l_use_cur_period := TRUE;
6411         EXIT;
6412       END IF;
6413     ELSIF  ( p_time_dimension_index = 6 ) THEN
6414       IF ( ldv6 = p_current_period_id ) THEN
6415         l_use_cur_period := TRUE;
6416         EXIT;
6417       END IF;
6418     ELSIF  ( p_time_dimension_index = 7 ) THEN
6419       IF ( ldv6 = p_current_period_id ) THEN
6420         l_use_cur_period := TRUE;
6421         EXIT;
6422       END IF;
6423     END IF;
6424   END LOOP;
6425   CLOSE c_actual_value;
6426 
6427 
6428   -- No row at all, should remain
6429   IF ( l_first_rec ) THEN
6430     l_use_cur_period := TRUE;
6431   END IF;
6432   RETURN l_use_cur_period;
6433 
6434 EXCEPTION
6435   WHEN OTHERS THEN
6436 
6437     IF c_actual_value%ISOPEN THEN
6438       CLOSE c_actual_value;
6439     END IF;
6440     RETURN TRUE;
6441 
6442 END use_current_period;
6443 --============================================================
6444 
6445 
6446 
6447 
6448 
6449 --============================================================
6450 FUNCTION draw_portlet_footer
6451 RETURN VARCHAR2
6452 IS
6453 
6454   l_html_string VARCHAR2(20) := NULL;
6455 
6456 BEGIN
6457 
6458   l_html_string := l_html_string || '            </table>';
6459 
6460   RETURN l_html_string;
6461 
6462 END draw_portlet_footer;
6463 
6464 
6465 
6466 
6467 --============================================================
6468 FUNCTION draw_portlet_header(
6469   p_status_lbl  IN VARCHAR2
6470  ,p_measure_lbl IN VARCHAR2
6471  ,p_value_lbl IN VARCHAR2
6472  ,p_change_lbl  IN VARCHAR2
6473  ) RETURN VARCHAR2
6474 IS
6475 
6476   l_html_header VARCHAR2(32000) := NULL;
6477 
6478 BEGIN
6479 
6480 -- style
6481   l_html_header := l_html_header || '<STYLE TYPE="text/css">';
6482   l_html_header := l_html_header || 'A.OraPortletLink:link {COLOR: #663300; FONT-FAMILY: Arial, Helvetica, Geneva, sans-serif; FONT-SIZE: 9pt}';
6483   l_html_header := l_html_header || 'A.OraPortletLink:active {COLOR: #663300; FONT-FAMILY: Arial, Helvetica, Geneva, sans-serif; FONT-SIZE: 9pt}';
6484   l_html_header := l_html_header || 'A.OraPortletLink:visited {COLOR: #663300; FONT-FAMILY: Arial, Helvetica, Geneva, sans-serif; FONT-SIZE: 9pt}';
6485   l_html_header := l_html_header || '.OraPortletHeaderSub1 {font-family: Arial, Helvetica, sans-serif; font-size: 9pt; color: #000000;
6486                                       background-color: #CCCC99}';
6487   l_html_header := l_html_header || '.OraPortletTableCellText {font-family:Arial, Helvetica, Geneva, sans-serif; font-size:9pt; text-align:left; background-color:#f7f7e7; color:#000000}';
6488   l_html_header := l_html_header || '.OraPortletTableCellNumber {font-family:Arial, Helvetica, Geneva, sans-serif; font-size:9pt; text-align:right; background-color:#f7f7e7; color:#000000; text-indent:1}';
6489   l_html_header := l_html_header || '.OraPortletTableCellUnAuth {font-family:Arial, Helvetica, Geneva, sans-serif; font-size:9pt; text-align:center; background-color:#f7f7e7; color:#000000; text-indent:1}';
6490 
6491   l_html_header := l_html_header || '.OraPortletBodyTextBlack { FONT-FAMILY: Arial, Helvetica, Geneva, sans-serif; FONT-SIZE: 9pt}';
6492   l_html_header := l_html_header || '.OraPortletBodyTextGreen { FONT-FAMILY: Arial, Helvetica, Geneva, sans-serif; FONT-SIZE: 9pt; color: #009900}';
6493   l_html_header := l_html_header || '.OraPortletBodyTextRed { FONT-FAMILY: Arial, Helvetica, Geneva, sans-serif; FONT-SIZE: 9pt; color: #FF0000}';
6494   l_html_header := l_html_header || '.OraPortletTableCellTextBand {font-family:Arial, Helvetica, Geneva, sans-serif; font-size:9pt; text-align:left;  background-color:#ffffff; color:#000000}';
6495   l_html_header := l_html_header || '.OraPortletTableCellNumberBand {font-family:Arial, Helvetica, Geneva, sans-serif; font-size:9pt; text-align:right; background-color:#ffffff; color:#000000; text-indent:1}';
6496   l_html_header := l_html_header || '.OraPortletTableCellUnAuthBand {font-family:Arial, Helvetica, Geneva, sans-serif; font-size:9pt; text-align:center; background-color:#ffffff; color:#000000; text-indent:1}';
6497   l_html_header := l_html_header || '</STYLE>';
6498 
6499   -- Table
6500   l_html_header := l_html_header || '            <table bgcolor=white  border=0  cellpadding=3 cellspacing=0 width="100%">';
6501 
6502   l_html_header := l_html_header || '              <tr> ';
6503   l_html_header := l_html_header || '                <th id="'||p_status_lbl||'" class=OraPortletHeaderSub1 ';
6504   l_html_header := l_html_header || '                        style="COLOR: #336699;BORDER-TOP: #f7f7e7 1px solid" align=left  valign=bottom>'||' </th>';
6505 --width="5%"
6506   l_html_header := l_html_header || '                <th id="'||p_measure_lbl||'" class=OraPortletHeaderSub1 ';
6507   l_html_header := l_html_header || '                        style="BORDER-LEFT: #cccc99 1px solid;COLOR: #336699; BORDER-TOP: #f7f7e7 1px solid" align=left valign=bottom>'||bis_utilities_pvt.escape_html(p_measure_lbl)||'</th>';
6508   l_html_header := l_html_header || '                <th id="'||p_value_lbl||'" class=OraPortletHeaderSub1 ';
6509   l_html_header := l_html_header || '                        style="BORDER-LEFT: #f7f7e7 1px solid; COLOR: #336699;BORDER-TOP: #f7f7e7 1px solid" align=right valign=bottom>'||' </th>';
6510   l_html_header := l_html_header || '                <th id="'||p_change_lbl||'" class=OraPortletHeaderSub1 ';
6511   l_html_header := l_html_header || '                        style="BORDER-LEFT: #f7f7e7 1px solid;COLOR: #336699;BORDER-TOP: #f7f7e7 1px solid" align=right  valign=bottom >'||bis_utilities_pvt.escape_html(p_change_lbl)||'</th>';
6512 
6513   l_html_header := l_html_header || '                <th id="'||'change_img'||'" class=OraPortletHeaderSub1';
6514   l_html_header := l_html_header || '                        style="COLOR: #336699;BORDER-TOP: #f7f7e7 1px solid"  align=left valign=bottom>'||' </th>';
6515 
6516   l_html_header := l_html_header || '              </tr>';
6517 
6518   RETURN l_html_header;
6519 
6520 END draw_portlet_header ;
6521 
6522 --============================================================
6523 --    FUNCTION
6524 --      draw_status
6525 --
6526 --    PURPOSE
6527 --       p_status_lbl => status header label (for ADA compliant)
6528 --       p_row_style => style of row, white or yellow background
6529 --       p_actual_val => actual value
6530 --       p_target_val => target value
6531 --       p_range1_low_pcnt => percentage for range1 low
6532 --       p_range1_high_pcnt => percentage for range1 high
6533 
6534 --    PARAMETERS
6535 --
6536 --    HISTORY
6537 --       22-JAN-2002 juwang Created.
6538 --============================================================
6539 FUNCTION draw_status(
6540   p_status_lbl IN VARCHAR2
6541  ,p_row_style IN VARCHAR2
6542  ,p_actual_val IN NUMBER
6543  ,p_target_val IN NUMBER
6544  ,p_range1_low_pcnt IN NUMBER
6545  ,p_range1_high_pcnt IN NUMBER
6546 ) RETURN VARCHAR2
6547 IS
6548   l_range1_low_val  NUMBER:= NULL;
6549   l_range1_high_val NUMBER:= NULL;
6550 
6551   l_html_string  VARCHAR2(32000) := NULL;
6552 
6553 BEGIN
6554 
6555   IF ( (p_target_val IS NULL) OR
6556        (p_range1_low_pcnt IS NULL) OR
6557        (p_range1_high_pcnt IS NULL)) THEN
6558     l_html_string := draw_status(p_status_lbl, 0, p_row_style);
6559     RETURN l_html_string;
6560   END IF;
6561 
6562 -- Compute the min, max value of tolerance ranges
6563 
6564 
6565   l_range1_low_val := p_target_val-((p_range1_low_pcnt/100)*p_target_val);
6566   l_range1_high_val:= p_target_val+ ((p_range1_high_pcnt/100)*p_target_val);
6567 
6568 
6569 -- If actual is inside tolerance range print in forest green color
6570 -- bug#2187778
6571   -- target, low, high ranges are not null
6572   IF ((p_actual_val >= NVL(l_range1_low_val, p_target_val)) AND
6573       (p_actual_val <= NVL(l_range1_high_val, p_target_val))) THEN
6574 
6575     l_html_string := draw_status(p_status_lbl, 1, p_row_style);
6576 
6577   -- If actual is outside tolerance range print in red color
6578   ELSIF  (p_actual_val < NVL(l_range1_low_val, p_target_val) OR
6579           p_actual_val > NVL(l_range1_high_val, p_target_val)) THEN
6580 
6581     l_html_string := draw_status(p_status_lbl, 2, p_row_style);
6582 
6583   ELSE
6584     l_html_string := draw_status(p_status_lbl, 0, p_row_style);
6585 
6586   END IF; -- actual colors
6587 
6588   RETURN l_html_string;
6589 
6590 END draw_status;
6591 
6592 
6593 
6594 --============================================================
6595 -- p_status :
6596 -- 0 -> None
6597 -- 1 -> within target range
6598 -- 2 -> outside target range
6599 --============================================================
6600 FUNCTION draw_status(
6601   p_status_lbl IN VARCHAR2
6602  ,p_status IN NUMBER
6603  ,p_row_style IN VARCHAR2
6604  ) RETURN VARCHAR2
6605 IS
6606   l_range_lbl VARCHAR2(2000); -- incr the size for 2617137
6607   l_in_range_lbl VARCHAR2(2000);
6608   l_out_range_lbl VARCHAR2(2000);
6609   l_gif VARCHAR2(100);
6610 
6611   l_html_string VARCHAR2(32000) := NULL;
6612   l_image_path    VARCHAR2(250);
6613 
6614 BEGIN
6615 
6616   l_in_range_lbl := BIS_UTILITIES_PVT.Get_FND_Message('BIS_WITHIN_RANGE');
6617   l_out_range_lbl := BIS_UTILITIES_PVT.Get_FND_Message('BIS_OUTSIDE_RANGE');
6618   l_image_path := BIS_INDICATOR_REGION_UI_PVT.Get_Images_Server;
6619   IF ( p_status = 1 ) THEN
6620     l_gif := 'bisinrng.gif';
6621 --    l_gif := 'okind_status.gif';
6622     l_range_lbl := l_in_range_lbl;
6623   ELSIF ( p_status = 2 ) THEN
6624     l_gif := 'bisourng.gif';
6625 --    l_gif := 'criticalind_status.gif';
6626     l_range_lbl := l_out_range_lbl;
6627   ELSE
6628     l_gif := 'FNDINVDT.gif';
6629     l_range_lbl := '';
6630   END IF;
6631 
6632 --width="5%"
6633   l_html_string := l_html_string || '                <td headers="'||p_status_lbl||'" class=OraPortletTableCellText'||p_row_style;
6634   l_html_string := l_html_string || '                        style="BORDER-LEFT: #cccc99 1px solid; BORDER-BOTTOM: #cccc99 1px solid;  BORDER-TOP: #f7f7e7 1px solid "  align=left> <img src="'|| l_image_path || l_gif || '" width="16" height="16" alt="'||
6635   ICX_UTIL.replace_alt_quotes(l_range_lbl)||'">';
6636   l_html_string := l_html_string || '</td>';
6637 
6638   RETURN   l_html_string;
6639 
6640 END draw_status;
6641 
6642 
6643 
6644 
6645 --============================================================
6646 FUNCTION draw_measure_name(
6647   p_actual_url IN VARCHAR2
6648  ,p_label IN VARCHAR2
6649  ,p_measure_lbl IN VARCHAR2
6650  ,p_row_style IN VARCHAR2
6651  ) RETURN VARCHAR2
6652 IS
6653 
6654   l_html_string VARCHAR2(32000) := NULL;
6655 
6656 BEGIN
6657   l_html_string := l_html_string || '                <td headers="'||p_measure_lbl||'" class=OraPortletTableCellText'||p_row_style;
6658   l_html_string := l_html_string || '                        style="BORDER-BOTTOM: #cccc99 1px solid;  BORDER-TOP: #f7f7e7 1px solid " align=left>';
6659   IF p_actual_url IS NOT NULL THEN
6660   --htp.p('<a href="' || p_actual_url || '" >' || p_label || ' </a> '); -- 2164190 sashaik --
6661     l_html_string := l_html_string || (bis_utilities_pvt.escape_html(LTRIM(p_label)));
6662   ELSE
6663     l_html_string := l_html_string || (bis_utilities_pvt.escape_html(LTRIM(p_label)));
6664   END IF;
6665   l_html_string := l_html_string || '                </td>';
6666 
6667   RETURN   l_html_string;
6668 
6669 END draw_measure_name;
6670 
6671 
6672 
6673 --============================================================
6674 -- p_formatted_actual -> the value displayed in value column
6675 --============================================================
6676 FUNCTION draw_actual(
6677   p_value_lbl IN VARCHAR2
6678  ,p_formatted_actual IN VARCHAR2
6679  ,p_row_style IN VARCHAR2
6680  ,p_is_auth IN BOOLEAN DEFAULT TRUE
6681  ) RETURN VARCHAR2
6682 
6683 IS
6684 
6685  l_col_span PLS_INTEGER := 1;
6686  l_align VARCHAR2(10) := 'right';
6687 
6688  l_html_string VARCHAR2(32000) := NULL;
6689 
6690 BEGIN
6691 
6692   IF ( NOT p_is_auth ) THEN
6693     l_col_span := 3;
6694     l_align := 'CENTER';
6695   END IF;
6696 
6697   l_html_string := l_html_string || '                <td align=' || l_align
6698   ||' headers="'|| p_value_lbl
6699   || '" colspan=' || l_col_span;
6700 
6701   IF ( p_is_auth ) THEN
6702     l_html_string := l_html_string || ' class=OraPortletTableCellNumber'|| p_row_style;
6703   ELSE
6704     l_html_string := l_html_string || ' class=OraPortletTableCellUnAuth'|| p_row_style;
6705   END IF;
6706 
6707   l_html_string := l_html_string || '                        style="BORDER-BOTTOM: #cccc99 1px solid;BORDER-LEFT: #cccc99 1px solid" width="15%" valign="bottom"  nowrap> ';
6708   l_html_string := l_html_string || '                  <span class=OraPortletBodyTextBlack>'|| bis_utilities_pvt.escape_html(p_formatted_actual) ||'</span>';
6709 
6710   l_html_string := l_html_string || '                </td>';
6711 
6712   RETURN   l_html_string;
6713 
6714 END draw_actual;
6715 
6716 
6717 
6718 --============================================================
6719 --
6720 --============================================================
6721 FUNCTION draw_change(
6722   p_change_lbl IN VARCHAR2
6723  ,p_change IN VARCHAR2
6724  ,p_img IN VARCHAR2
6725  ,p_arrow_alt_text IN VARCHAR2
6726  ,p_row_style IN VARCHAR2
6727 ) RETURN VARCHAR2
6728 IS
6729 
6730   l_html_string VARCHAR2(32000) := NULL;
6731   l_image_path    VARCHAR2(250);
6732 
6733 BEGIN
6734   l_image_path := BIS_INDICATOR_REGION_UI_PVT.Get_Images_Server;
6735 
6736   l_html_string := l_html_string || '                <td headers="'|| p_change_lbl||'" class=OraPortletTableCellNumber'|| p_row_style;
6737   l_html_string := l_html_string || '                        style="BORDER-LEFT: #cccc99 1px solid; BORDER-BOTTOM: #cccc99 1px solid; BORDER-TOP: #f7f7e7 1px solid " align="right"  valign="bottom" nowrap>'|| bis_utilities_pvt.escape_html(p_change);
6738   l_html_string := l_html_string || '                </td>';
6739 
6740   l_html_string := l_html_string || '                <td headers="change_img"  class=OraPortletTableCellNumber'|| p_row_style;
6741   l_html_string := l_html_string || '                        style="
6742   BORDER-BOTTOM: #cccc99 1px solid;BORDER-TOP: #f7f7e7 1px solid " align="left"   valign="bottom" nowrap >';
6743 
6744   IF ( p_img IS NOT NULL ) THEN
6745     l_html_string := l_html_string || '                <img src="'||l_image_path|| p_img||' alt="'|| ICX_UTIL.replace_alt_quotes(p_arrow_alt_text)||'"  height="12" >';
6746   ELSE
6747     l_html_string := l_html_string || ' ';
6748   END IF;
6749 
6750   l_html_string := l_html_string || '</td>';
6751 
6752   RETURN   l_html_string;
6753 
6754 END draw_change;
6755 
6756 --============================================================
6757 PROCEDURE display_demo_portlet(
6758   p_session_id  IN NUMBER
6759  ,p_plug_id IN pls_integer
6760  ,p_user_id IN integer
6761  ,x_html_buffer OUT NOCOPY VARCHAR2
6762  ,x_html_clob OUT NOCOPY CLOB
6763 )
6764 IS
6765   l_status_lbl VARCHAR2(2000);
6766   l_measure_lbl VARCHAR2(2000);
6767   l_value_lbl VARCHAR2(2000);
6768   l_change_lbl VARCHAR2(2000);
6769   l_perc_lbl VARCHAR2(2000);
6770   l_none_lbl VARCHAR2(2000);
6771   l_na_lbl VARCHAR2(2000);
6772   l_improve_msg VARCHAR2(2000);
6773   l_worse_msg VARCHAR2(2000);
6774   l_arrow_alt_text     VARCHAR2(2000);
6775 
6776   l_actual_url VARCHAR2(500) := '';
6777   l_status NUMBER;
6778   l_value VARCHAR2(500);
6779   l_change VARCHAR2(500);
6780   l_arrow NUMBER;
6781   l_row_style VARCHAR2(100);
6782   l_img VARCHAR2(200);
6783 
6784   l_html_buffer   VARCHAR2(32000) := NULL;
6785   l_html_clob   CLOB := NULL;
6786 
6787   l_html_header   VARCHAR2(32000) := NULL;
6788   l_html_row    VARCHAR2(32000) := NULL;
6789   l_html_footer   VARCHAR2(32000) := NULL;
6790 
6791 
6792 
6793   CURSOR cDemo is
6794     SELECT LABEL, PARAM_DATA
6795     FROM bis_pmf_populate_portlet bpp
6796     WHERE bpp.PLUG_ID = p_plug_id
6797     ORDER BY bpp.SEQ_ID;
6798 
6799 BEGIN
6800 
6801   l_worse_msg := BIS_UTILITIES_PVT.Get_FND_Message('BIS_PMF_CHANGE_WORSE');
6802   l_improve_msg := BIS_UTILITIES_PVT.Get_FND_Message('BIS_PMF_CHANGE_IMPROVE');
6803 
6804   l_none_lbl := BIS_UTILITIES_PVT.Get_FND_Message('BIS_NONE');
6805   l_status_lbl := BIS_UTILITIES_PVT.Get_FND_Message('BIS_PMF_STATUS');
6806   l_measure_lbl := BIS_UTILITIES_PVT.Get_FND_Message('BIS_PMF_NAME');
6807   l_value_lbl := BIS_UTILITIES_PVT.Get_FND_Message('BIS_VALUE_LBL');
6808   l_change_lbl := (BIS_UTILITIES_PVT.Get_FND_Message('BIS_PMF_CHANGE'));
6809 
6810   l_na_lbl := (BIS_UTILITIES_PVT.Get_FND_Message('BIS_PMF_NA_LBL'));
6811 
6812 
6813 
6814    l_html_header := draw_portlet_header(
6815          l_status_lbl
6816         ,l_measure_lbl
6817                           ,l_value_lbl
6818         ,l_change_lbl
6819         );
6820    append(
6821      p_string => l_html_header
6822     ,x_clob => l_html_clob
6823     ,x_buffer => l_html_buffer
6824    );
6825 
6826   FOR demo_rec IN cDemo LOOP
6827     l_html_row := '              <tr> ';
6828     l_row_style := BIS_PMF_PORTLET_UTIL.get_row_style(l_row_style);
6829 
6830     BEGIN
6831 
6832     --getting info from table
6833       l_status := TO_NUMBER(BIS_PMF_PORTLET_UTIL.getValue(c_key_status,demo_rec.PARAM_DATA,c_caret));
6834       l_value := NVL(BIS_PMF_PORTLET_UTIL.getValue(c_key_value, demo_rec.PARAM_DATA, c_caret), l_none_lbl);
6835       l_change := NVL(BIS_PMF_PORTLET_UTIL.getValue(c_key_change, demo_rec.PARAM_DATA, c_caret), l_na_lbl);
6836       l_arrow := TO_NUMBER(BIS_PMF_PORTLET_UTIL.getValue(c_key_arrow, demo_rec.PARAM_DATA,c_caret));
6837       l_img := get_image(l_arrow, l_worse_msg, l_improve_msg,l_arrow_alt_text);
6838       -- drawing now
6839       l_html_row := l_html_row || draw_status(l_status_lbl, l_status, l_row_style);
6840       l_html_row := l_html_row || draw_measure_name(l_actual_url, demo_rec.LABEL,
6841                         l_measure_lbl,l_row_style);
6842       l_html_row := l_html_row || draw_actual(l_value_lbl, l_value, l_row_style);
6843       l_html_row := l_html_row || draw_change(l_change_lbl,l_change,l_img,l_arrow_alt_text,l_row_style);
6844 
6845   EXCEPTION  -- inloop
6846       WHEN OTHERS THEN
6847         l_html_row := l_html_row || draw_status(l_status_lbl, 0, l_row_style);
6848         l_html_row := l_html_row || draw_measure_name(l_actual_url, demo_rec.label, l_measure_lbl,l_row_style);
6849   l_html_row := l_html_row || draw_actual(l_value_lbl, l_none_lbl, l_row_style);
6850   l_html_row := l_html_row || draw_change(l_change_lbl,l_na_lbl,null,null,l_row_style);
6851 
6852     END;
6853     l_html_row := l_html_row || '              </tr>';
6854     append(
6855       p_string    => l_html_row
6856      ,x_clob    => l_html_clob
6857      ,x_buffer    => l_html_buffer
6858     );
6859   END LOOP;
6860   l_html_footer := draw_portlet_footer;
6861   append(
6862     p_string    => l_html_footer
6863    ,x_clob    => l_html_clob
6864    ,x_buffer    => l_html_buffer
6865   );
6866 
6867   x_html_buffer := l_html_buffer;
6868   x_html_clob := l_html_clob;
6869 
6870   IF (l_html_clob IS NOT NULL) THEN
6871     free_clob(
6872       x_clob => l_html_clob
6873     );
6874   END IF;
6875 
6876 EXCEPTION
6877   WHEN OTHERS THEN
6878     x_html_buffer := SQLERRM;
6879 
6880     IF (l_html_clob IS NOT NULL) THEN
6881       free_clob(
6882   x_clob => l_html_clob
6883       );
6884       x_html_clob := NULL;
6885     END IF;
6886 
6887 END display_demo_portlet;
6888 
6889 
6890 
6891 --===========================================================
6892 FUNCTION get_image(
6893   p_arrow_type IN NUMBER
6894  ,p_worse_msg IN VARCHAR2
6895  ,p_improve_msg IN VARCHAR2
6896  ,p_arrow_alt_text OUT NOCOPY VARCHAR2
6897 ) RETURN VARCHAR2
6898 IS
6899 
6900 BEGIN
6901 
6902   IF (p_arrow_type = c_arrow_type_green_up) THEN
6903     p_arrow_alt_text := p_improve_msg;
6904     RETURN c_up_green;
6905   ELSIF (p_arrow_type = c_arrow_type_green_down) THEN
6906     p_arrow_alt_text := p_improve_msg;
6907     RETURN c_down_green;
6908   ELSIF (p_arrow_type = c_arrow_type_red_up) THEN
6909     p_arrow_alt_text := p_worse_msg;
6910     RETURN c_up_red;
6911   ELSIF (p_arrow_type = c_arrow_type_red_down) THEN
6912     p_arrow_alt_text := p_worse_msg;
6913     RETURN c_down_red;
6914   ELSIF (p_arrow_type = c_arrow_type_black_up) THEN
6915     p_arrow_alt_text := '';
6916     RETURN c_up_black;
6917   ELSIF (p_arrow_type = c_arrow_type_black_down) THEN
6918     p_arrow_alt_text := '';
6919     RETURN c_down_black;
6920   END IF;
6921 
6922   RETURN NULL;
6923 EXCEPTION
6924   WHEN OTHERS THEN
6925     RETURN NULL;
6926 
6927 END get_image;
6928 
6929 
6930 --===========================================================
6931 PROCEDURE insert_row(
6932   p_plug_id IN NUMBER
6933  ,p_seq_id IN NUMBER
6934  ,p_label IN VARCHAR2
6935  ,p_status IN NUMBER
6936  ,p_value IN VARCHAR2
6937  ,p_change IN VARCHAR2
6938  ,p_arrow IN NUMBER
6939  ,p_user_id IN NUMBER
6940  ,x_return_status OUT NOCOPY VARCHAR2
6941 )
6942 
6943 IS
6944   l_param VARCHAR2(20000);
6945 BEGIN
6946 
6947   l_param := c_key_status || c_eq || NVL(p_status, 0);
6948   IF ( p_value IS NOT NULL) THEN
6949     l_param := l_param  || c_caret ||
6950                c_key_value || c_eq || p_value;
6951   END IF;
6952 
6953   IF ( p_change IS NOT NULL) THEN
6954     l_param := l_param  || c_caret ||
6955                c_key_change || c_eq || p_change;
6956   END IF;
6957 
6958   IF ( p_arrow IS NOT NULL) THEN
6959     l_param := l_param  || c_caret ||
6960                c_key_arrow || c_eq || p_arrow;
6961   END IF;
6962 
6963 
6964   insert_row(p_plug_id => p_plug_id
6965             ,p_seq_id  => p_seq_id
6966       ,p_label => p_label
6967       ,p_param_data  => l_param
6968       ,p_user_id  => p_user_id
6969       ,x_return_status  => x_return_status
6970       );
6971 
6972 END insert_row;
6973 
6974 
6975 --===========================================================
6976 PROCEDURE insert_row(
6977   p_plug_id IN NUMBER
6978  ,p_seq_id IN NUMBER
6979  ,p_label IN VARCHAR2
6980  ,p_param_data IN VARCHAR2
6981  ,p_user_id IN NUMBER
6982  ,x_return_status OUT NOCOPY VARCHAR2
6983 )
6984 
6985 IS
6986 
6987 BEGIN
6988   FND_MSG_PUB.INITIALIZE;
6989   INSERT INTO  bis_pmf_populate_portlet(
6990     PLUG_ID,
6991     SEQ_ID,
6992     LABEL,
6993     PARAM_DATA,
6994     CREATION_DATE,
6995     CREATED_BY,
6996     LAST_UPDATE_DATE,
6997     LAST_UPDATED_BY,
6998     LAST_UPDATE_LOGIN
6999   ) values (
7000     p_plug_id
7001    ,p_seq_id
7002    ,p_label
7003    ,p_param_data
7004    ,sysdate
7005    ,p_user_id
7006    ,sysdate
7007    ,p_user_id
7008    ,p_user_id
7009   );
7010 
7011   x_return_status := FND_API.G_RET_STS_SUCCESS;
7012 EXCEPTION
7013   WHEN OTHERS THEN
7014     x_return_status := FND_API.G_RET_STS_ERROR;
7015 /*
7016     BIS_UTILITIES_PVT.Add_Error_Message
7017                       ( p_error_table       => x_error_Tbl
7018                       , p_error_msg_id      => SQLCODE
7019                       , p_error_description => SQLERRM
7020                       , x_error_table       => x_error_Tbl
7021                       );
7022 */
7023 END insert_row;
7024 
7025 
7026 
7027 --===========================================================
7028 PROCEDURE delete_all_demo_rows(
7029   p_plug_id IN NUMBER
7030 )
7031 
7032 IS
7033 
7034 BEGIN
7035   DELETE  bis_pmf_populate_portlet
7036   WHERE  PLUG_ID = p_plug_id;
7037 
7038 EXCEPTION
7039   WHEN OTHERS THEN
7040      htp.p(SQLERRM);
7041 
7042 END delete_all_demo_rows;
7043 
7044 
7045 --===========================================================
7046 PROCEDURE show_cust_demo_url(
7047   p_plug_id IN PLS_INTEGER
7048  ,p_session_id IN PLS_INTEGER
7049 )
7050 IS
7051   l_url VARCHAR2(10000);
7052   l_url_lbl VARCHAR2(10000);
7053   l_servlet_agent VARCHAR2(5000) := NULL;
7054 BEGIN
7055 
7056   IF ( NOT BIS_PMF_PORTLET_UTIL.is_demo_on ) THEN  -- demo not on
7057     RETURN;
7058   END IF;
7059 
7060   -- demo is on
7061   l_url_lbl := BIS_UTILITIES_PVT.Get_FND_Message('BIS_PMF_ENTER_PT_DATA');
7062 
7063   l_servlet_agent := FND_WEB_CONFIG.JSP_AGENT;   -- 'http://serv:port/OA_HTML/'
7064   IF ( l_servlet_agent IS NULL ) THEN   -- 'APPS_SERVLET_AGENT' is null
7065      l_servlet_agent := FND_WEB_CONFIG.WEB_SERVER || 'OA_HTML/';
7066   END IF;
7067 
7068 -- juwang
7069   l_url := l_servlet_agent ||
7070          'bisptdta.jsp?dbc=' || FND_WEB_CONFIG.database_id() || -- 2454902
7071    '&pPlugId=' || p_plug_id ||
7072    '&sessionid=' || p_session_id;
7073 
7074   htp.p('<table>');
7075   htp.p('<tr><td align="LEFT"><a href="' || l_url ||'">' || l_url_lbl
7076   ||'</a></td></tr>');
7077   htp.p('</table>');
7078 
7079 
7080  -- juwang
7081 
7082 EXCEPTION
7083   WHEN OTHERS THEN
7084     RETURN;
7085 
7086 END show_cust_demo_url;
7087 
7088 
7089 
7090 --===========================================================
7091 -- retriving actual and report url
7092 --===========================================================
7093 PROCEDURE get_actual(
7094   p_target_rec IN  BIS_TARGET_PUB.Target_Rec_Type
7095  ,x_actual_url OUT NOCOPY VARCHAR2
7096  ,x_actual_value OUT NOCOPY NUMBER
7097  ,x_comparison_actual_value OUT NOCOPY NUMBER
7098  ,x_err OUT NOCOPY VARCHAR2
7099 )
7100 IS
7101 
7102   l_act_in   BIS_ACTUAL_PUB.Actual_rec_type;    -- 2164190 sashaik
7103   l_act_out   BIS_ACTUAL_PUB.Actual_rec_type;   -- 2164190 sashaik
7104   l_msg_count     NUMBER;       -- 2164190 sashaik
7105   l_msg_data      VARCHAR2(32000);      -- 2164190 sashaik
7106   l_error_tbl     BIS_UTILITIES_PUB.Error_Tbl_Type; -- 2164190 sashaik
7107   l_return_status VARCHAR2(300);      -- 2164190 sashaik
7108 
7109 BEGIN
7110 
7111   l_act_in.Target_level_ID      := p_target_rec.target_level_id;
7112   l_act_in.Dim1_Level_Value_ID := p_target_rec.dim1_level_value_id;
7113   l_act_in.Dim2_Level_Value_ID := p_target_rec.dim2_level_value_id;
7114   l_act_in.Dim3_Level_Value_ID := p_target_rec.dim3_level_value_id;
7115   l_act_in.Dim4_Level_Value_ID := p_target_rec.dim4_level_value_id;
7116   l_act_in.Dim5_Level_Value_ID := p_target_rec.dim5_level_value_id;
7117   l_act_in.Dim6_Level_Value_ID := p_target_rec.dim6_level_value_id;
7118   l_act_in.Dim7_Level_Value_ID := p_target_rec.dim7_level_value_id;
7119 
7120   bis_actual_pub.Retrieve_Actual
7121   (  p_api_version      => 1.0
7122   ,p_all_info           => FND_API.G_FALSE
7123   ,p_Actual_Rec         => l_act_in
7124   ,x_Actual_Rec         => l_act_out
7125   ,x_return_Status      => l_return_status
7126   ,x_msg_count          => l_msg_count
7127   ,x_msg_data           => l_msg_data
7128   ,x_error_tbl          => l_error_tbl
7129   );
7130 
7131   x_actual_url := l_act_out.Report_URL;
7132   x_actual_value := l_act_out.ACTUAL;
7133   x_comparison_actual_value := l_act_out.COMPARISON_ACTUAL_VALUE;
7134 
7135 EXCEPTION
7136   WHEN OTHERS THEN
7137 --  htp.p(l_msg_data);
7138     x_actual_url := NULL;
7139     x_actual_value := NULL;
7140     x_comparison_actual_value := NULL;
7141     x_err := SQLERRM;
7142 
7143 END get_actual;
7144 
7145 
7146 
7147 
7148 
7149 --===========================================================
7150 -- retriving taget, Note: do not use BIS_TARGET_PUB.Rrieve_Target
7151 -- Procedure.  Bug exists.
7152 --===========================================================
7153 PROCEDURE get_target(
7154   p_target_in IN  BIS_TARGET_PUB.Target_Rec_Type
7155  ,x_target OUT NOCOPY NUMBER
7156  ,x_range1_low OUT NOCOPY NUMBER
7157  ,x_range1_high OUT NOCOPY NUMBER
7158  ,x_range2_low OUT NOCOPY NUMBER
7159  ,x_range2_high OUT NOCOPY NUMBER
7160  ,x_range3_low OUT NOCOPY NUMBER
7161  ,x_range3_high OUT NOCOPY NUMBER
7162  ,x_err OUT NOCOPY VARCHAR2
7163 )
7164 IS
7165 
7166   l_comp_tar_id    NUMBER;
7167 
7168  -- Cursor to get the computing function id
7169   CURSOR c_comp_tar (p_target_level_id pls_integer) IS
7170     SELECT computing_function_id
7171     FROM bisbv_target_levels
7172     WHERE target_level_id = p_target_level_id;
7173 
7174 
7175 -- Cursor to get the target ranges
7176 -- mdamle 01/15/2001 - Use Dim6 and Dim7
7177   CURSOR c_target_range_rec IS
7178     SELECT
7179        target
7180       ,range1_low, range1_high
7181       ,range2_low, range2_high
7182       ,range3_low, range3_high
7183     FROM bisbv_targets  tars
7184     WHERE tars.target_level_id    = p_target_in.target_level_id
7185       -- mdamle 01/15/2001
7186         -- AND   tars.org_level_value_id    = p_target_in.org_level_value_id
7187         -- AND   NVL(tars.time_level_value_id,'NILL')
7188         --  = NVL(p_target_in.time_level_value_id, 'NILL')
7189    AND   tars.plan_id               = p_target_in.plan_id
7190    AND NVL(tars.dim1_level_value_id, 'NILL')
7191      = NVL(p_target_in.dim1_level_value_id, 'NILL')
7192    AND NVL(tars.dim2_level_value_id, 'NILL')
7193      = NVL(p_target_in.dim2_level_value_id, 'NILL')
7194    AND NVL(tars.dim3_level_value_id, 'NILL')
7195      = NVL(p_target_in.dim3_level_value_id, 'NILL')
7196    AND NVL(tars.dim4_level_value_id, 'NILL')
7197      = NVL(p_target_in.dim4_level_value_id, 'NILL')
7198    AND NVL(tars.dim5_level_value_id, 'NILL')
7199      = NVL(p_target_in.dim5_level_value_id, 'NILL')
7200    AND NVL(tars.dim6_level_value_id, 'NILL')
7201      = NVL(p_target_in.dim6_level_value_id, 'NILL')
7202    AND NVL(tars.dim7_level_value_id, 'NILL')
7203      = NVL(p_target_in.dim7_level_value_id, 'NILL');
7204 
7205 BEGIN
7206 
7207   OPEN c_target_range_rec;
7208   FETCH c_target_range_rec INTO
7209     x_target
7210    ,x_range1_low, x_range1_high
7211    ,x_range2_low, x_range2_high
7212    ,x_range3_low, x_range3_high;
7213 
7214    IF c_target_range_rec%NOTFOUND THEN
7215      x_target := NULL;
7216      x_range1_low := NULL;
7217      x_range1_high := NULL;
7218      x_range2_low := NULL;
7219      x_range2_high := NULL;
7220      x_range3_low := NULL;
7221      x_range3_high := NULL;
7222    END IF;
7223    CLOSE c_target_range_rec;
7224 
7225    IF x_target IS NULL THEN
7226 
7227      OPEN c_comp_tar(p_target_in.target_level_id);
7228      FETCH c_comp_tar INTO l_comp_tar_id;
7229      CLOSE c_comp_tar;
7230 
7231      IF (l_comp_tar_id IS NOT NULL) THEN
7232        x_target := BIS_TARGET_PVT.Get_Target(l_comp_tar_id
7233        , p_target_in);
7234      END IF;
7235    END IF;
7236 
7237 
7238 
7239 EXCEPTION
7240 
7241   WHEN OTHERS THEN
7242     IF c_target_range_rec%ISOPEN THEN CLOSE c_target_range_rec; END IF;
7243     IF c_comp_tar%ISOPEN THEN CLOSE c_comp_tar; END IF;
7244     x_target := NULL;
7245     x_range1_low := NULL;
7246     x_range1_high := NULL;
7247     x_range2_low := NULL;
7248     x_range2_high := NULL;
7249     x_range3_low := NULL;
7250     x_range3_high := NULL;
7251     x_err := SQLERRM;
7252 END get_target;
7253 
7254 
7255 
7256 
7257 --===========================================================
7258 -- 1. Find out NOCOPY the time dimension level index and level id
7259 -- 2. If the above exists, find out NOCOPY the current period id
7260 --    and sets it into x_target_rec.dim[n]_level_value_id
7261 -- 3. If the the current period id doesnt have the actual,
7262 --    use the latest actual
7263 -- 4. If the above does not exist, return immediately
7264 --===========================================================
7265 PROCEDURE get_time_dim_index(
7266   p_ind_selection_id IN NUMBER
7267  ,x_target_rec IN OUT NOCOPY BIS_TARGET_PUB.Target_Rec_Type
7268  ,x_err OUT NOCOPY VARCHAR2
7269 )
7270 IS
7271   e_notimevalue EXCEPTION;
7272   l_time_dimension_level_id NUMBER;
7273   l_time_dimension_index    NUMBER;
7274   l_last_period_id          VARCHAR2(800) := NULL; -- bug#2173745
7275   l_current_period_id       VARCHAR2(32000) := NULL;
7276   l_current_period_name     VARCHAR2(32000) := NULL;
7277   isRollingLevel      NUMBER;
7278   level_short_name      VARCHAR2(3000);
7279 
7280 
7281 -- meastmon 05/09/2001
7282 -- Cursor to get the index (1 to 7) of the time dimension level and
7283 -- the time dimension level id given a target level id.
7284 -- If the cursor returns no rows or null, then this target level
7285 -- doesn't have a time dimension level
7286 
7287   CURSOR c_time_dimension_index (p_tarid pls_integer) IS
7288   SELECT
7289     x.sequence_no,
7290     decode(x.sequence_no,
7291            1, z.dimension1_level_id,
7292            2, z.dimension2_level_id,
7293            3, z.dimension3_level_id,
7294            4, z.dimension4_level_id,
7295            5, z.dimension5_level_id,
7296            6, z.dimension6_level_id,
7297            7, z.dimension7_level_id,
7298            NULL) time_dimension_level_id
7299   FROM
7300     bis_indicator_dimensions x
7301     ,bis_dimensions y
7302     ,bis_target_levels z
7303   WHERE  x.dimension_id = y.dimension_id
7304   AND y.short_name=BIS_UTILITIES_PVT.GET_TIME_DIMENSION_NAME_TL(p_tarid,NULL)
7305   AND   x.indicator_id = z.indicator_id
7306   AND   z.target_level_id = p_tarid;
7307 
7308 
7309 
7310 BEGIN
7311 
7312 -- Find out NOCOPY which dimension level index corresponds to time
7313 -- dimension level. Also get the time dimension level id
7314 
7315   OPEN c_time_dimension_index(x_target_rec.target_level_id);
7316   FETCH c_time_dimension_index INTO
7317     l_time_dimension_index,
7318     l_time_dimension_level_id;
7319 
7320   IF c_time_dimension_index%NOTFOUND THEN -- no time dimension level
7321     l_time_dimension_index := -1;
7322   END IF;
7323   CLOSE c_time_dimension_index;
7324 
7325   -- no time dimension level
7326   IF l_time_dimension_index <= 0 THEN
7327     RETURN;
7328   END IF;
7329 
7330 
7331   SELECT short_name
7332   INTO   level_short_name
7333   FROM   bis_levels
7334   WHERE  level_id = l_time_dimension_level_id;
7335 
7336   isRollingLevel := bis_utilities_pvt.Is_Rolling_Period_Level(level_short_name);
7337 
7338   IF ( isRollingLevel = 0 ) THEN
7339 
7340     -- Set the variable x_target_rec.dimX_level_value_id that correspond
7341     -- to the time dimension whith the value id of the current period.
7342     -- target level contain a time dimension.
7343     -- Get the time level value id and name to be used to get actual and target
7344     -- Right now this is the current period
7345     BIS_INDICATOR_REGION_UI_PVT.getCurrentPeriodInfo(
7346        p_ind_selection_id
7347       ,x_target_rec.target_level_id
7348       ,l_time_dimension_level_id
7349       ,l_current_period_id
7350       ,l_current_period_name);
7351 
7352     IF l_current_period_id IS NULL THEN
7353       -- Conflicting!! If there is time level, there is current period
7354       -- Only in this case we raise an excepion ignore this selection
7355       RAISE e_notimevalue;
7356     END IF;
7357 
7358     --bug#2173475, if current period id's actual not exist,
7359     --use the latest one
7360     IF ( NOT bis_indicator_region_ui_pvt.use_current_period(x_target_rec
7361                                   ,l_time_dimension_index
7362                                   ,l_current_period_id
7363                                   ,l_last_period_id) ) THEN
7364         -- should use last period id in query
7365 
7366       l_current_period_id := l_last_period_id;
7367     END IF;
7368 
7369   END IF;
7370 
7371 
7372   assign_time_level_value_id(
7373     p_is_rolling_level  => isRollingLevel
7374    ,p_current_period_id => l_current_period_id
7375    ,p_time_dim_idx  => l_time_dimension_index
7376    ,p_target_rec  => x_target_rec
7377   );
7378 
7379 
7380 EXCEPTION
7381 
7382   WHEN e_notimevalue THEN
7383     x_err := 'Time dimension level exists but no current period.';
7384     RAISE e_notimevalue;
7385 
7386   WHEN OTHERS THEN
7387     IF c_time_dimension_index%ISOPEN THEN CLOSE c_time_dimension_index; END IF;
7388     x_err := SQLERRM;
7389 END get_time_dim_index;
7390 
7391 
7392 
7393 --===========================================================
7394 -- Assign time level value id
7395 --===========================================================
7396 PROCEDURE assign_time_level_value_id(
7397   p_is_rolling_level    IN NUMBER,
7398   p_current_period_id IN VARCHAR,
7399   p_time_dim_idx  IN NUMBER,
7400   p_target_rec    IN OUT NOCOPY BIS_TARGET_PUB.Target_Rec_Type
7401 )
7402 IS
7403 BEGIN
7404 
7405   -- Set the variable x_target_rec.dimX_level_value_id that correspond to
7406   -- the time dimension whith the value id of the current period.
7407 
7408   IF p_time_dim_idx = 1 THEN
7409     IF ( p_is_rolling_level = 0 ) THEN
7410       p_target_rec.dim1_level_value_id := p_current_period_id ;
7411     ELSE
7412       p_target_rec.dim1_level_value_id := '-1';
7413     END IF;
7414   ELSIF p_time_dim_idx = 2 THEN
7415     IF ( p_is_rolling_level = 0 ) THEN
7416       p_target_rec.dim2_level_value_id := p_current_period_id ;
7417     ELSE
7418       p_target_rec.dim2_level_value_id := '-1';
7419     END IF;
7420   ELSIF p_time_dim_idx = 3 THEN
7421     IF ( p_is_rolling_level = 0 ) THEN
7422       p_target_rec.dim3_level_value_id := p_current_period_id ;
7423     ELSE
7424       p_target_rec.dim3_level_value_id := '-1';
7425     END IF;
7426   ELSIF p_time_dim_idx = 4 THEN
7427     IF ( p_is_rolling_level = 0 ) THEN
7428       p_target_rec.dim4_level_value_id := p_current_period_id ;
7429     ELSE
7430       p_target_rec.dim4_level_value_id := '-1';
7431     END IF;
7432   ELSIF p_time_dim_idx = 5 THEN
7433     IF ( p_is_rolling_level = 0 ) THEN
7434       p_target_rec.dim5_level_value_id := p_current_period_id ;
7435     ELSE
7436       p_target_rec.dim5_level_value_id := '-1';
7437     END IF;
7438   ELSIF p_time_dim_idx = 6 THEN
7439     IF ( p_is_rolling_level = 0 ) THEN
7440       p_target_rec.dim6_level_value_id := p_current_period_id ;
7441     ELSE
7442       p_target_rec.dim6_level_value_id := '-1';
7443     END IF;
7444   ELSIF p_time_dim_idx = 7 THEN
7445     IF ( p_is_rolling_level = 0 ) THEN
7446       p_target_rec.dim7_level_value_id := p_current_period_id ;
7447     ELSE
7448       p_target_rec.dim7_level_value_id := '-1';
7449     END IF;
7450   END IF;
7451 
7452 EXCEPTION
7453   WHEN OTHERS THEN
7454     NULL;
7455 END assign_time_level_value_id;
7456 
7457 
7458 
7459 
7460 --===========================================================
7461 -- retriving actual and report url
7462 --===========================================================
7463 PROCEDURE get_change(
7464   p_actual_value IN NUMBER
7465  ,p_comp_actual_value IN NUMBER
7466  ,p_comp_source IN VARCHAR2
7467  ,p_good_bad IN VARCHAR2
7468  ,p_improve_msg  IN VARCHAR2
7469  ,p_worse_msg  IN VARCHAR2
7470  ,x_change OUT NOCOPY NUMBER
7471  ,x_img OUT NOCOPY VARCHAR2
7472  ,x_arrow_alt_text IN OUT NOCOPY VARCHAR2
7473  ,x_err OUT NOCOPY VARCHAR2
7474 )
7475 IS
7476   l_long_label VARCHAR2(20000);  --2157402
7477 
7478 BEGIN
7479 --  1850860  -- rchandra 22-NOv-2001
7480 -- do not calculate if there is no acutal or comp actual
7481   IF ( (p_comp_actual_value IS NULL) OR (p_actual_value IS NULL) ) THEN
7482     x_change := NULL;
7483     x_img := NULL;
7484     x_arrow_alt_text := NULL;
7485     x_err := NULL;
7486     RETURN;
7487   END IF;
7488 
7489 
7490   l_long_label := NULL;
7491 
7492   IF (p_comp_source IS NOT NULL) THEN  -- comparison source is not null
7493     BIS_INDICATOR_REGION_UI_PVT.getAKRegionItemLongLabel(p_comp_source,
7494     l_long_label);
7495     IF (l_long_label IS NOT NULL) THEN
7496       x_arrow_alt_text := l_long_label ||'.';
7497     END IF;
7498 
7499   END IF;
7500 
7501 
7502 
7503 -- calculate the change %
7504   x_change := ((p_actual_value - p_comp_actual_value)/ ABS(p_comp_actual_value)) * 100;
7505 -- determine the dirction of arrow and the color
7506   x_change := ROUND(  x_change );   -- 2309916
7507   IF x_change < 0 THEN
7508     IF p_good_bad = 'G' THEN
7509 
7510       x_img := c_down_green;
7511       x_arrow_alt_text := x_arrow_alt_text ||p_improve_msg;--2157402
7512     ELSIF p_good_bad = 'B' THEN
7513       x_img := c_down_red;
7514      x_arrow_alt_text := x_arrow_alt_text ||p_worse_msg; --2157402
7515     ELSE
7516       x_img := c_down_black;
7517     END IF;
7518   ELSIF x_change > 0 THEN -- 2309916
7519     IF p_good_bad = 'G' THEN
7520       x_img := c_up_green;
7521       x_arrow_alt_text := x_arrow_alt_text ||p_improve_msg;--2157402
7522     ELSIF p_good_bad = 'B' THEN
7523       x_img := c_up_red;
7524       x_arrow_alt_text := x_arrow_alt_text ||p_worse_msg; --2157402
7525     ELSE
7526       x_img := c_up_black;
7527     END IF;
7528 
7529   END IF;
7530 
7531 
7532 
7533 EXCEPTION
7534   WHEN OTHERS THEN
7535 
7536     x_err := SQLERRM;
7537 
7538 END get_change;
7539 
7540 
7541 --============================================================
7542 PROCEDURE draw_portlet_content(
7543   p_plug_id   IN PLS_INTEGER
7544  ,p_reference_path  IN VARCHAR2
7545  ,x_html_buffer   OUT NOCOPY VARCHAR2
7546  ,x_html_clob   OUT NOCOPY CLOB
7547 )
7548 IS
7549   l_session_id          NUMBER;
7550   l_login_user_id       integer;
7551   l_owner_user_id       integer;
7552   l_return_status VARCHAR2(2000);
7553   l_error_Tbl   BIS_UTILITIES_PUB.Error_Tbl_Type;
7554 
7555   l_html_buffer   VARCHAR2(32000) := NULL;
7556   l_html_clob   CLOB := NULL;
7557 
7558 
7559 BEGIN
7560   l_session_id := icx_sec.g_session_id;
7561   l_login_user_id := icx_sec.getID(icx_sec.PV_USER_ID,'', l_session_id);
7562 
7563   IF ( BIS_PMF_PORTLET_UTIL.has_demo_rows(p_plug_id) ) THEN
7564 
7565     display_demo_portlet(
7566       p_session_id  => l_session_id
7567      ,p_plug_id     => p_plug_id
7568      ,p_user_id     => l_login_user_id
7569      ,x_html_buffer => l_html_buffer
7570      ,x_html_clob   => l_html_clob
7571     );
7572   ELSE  -- no demo rows, use the production rows
7573         --bug#2210756, make sure the target level id specified exists
7574 
7575     BIS_PMF_PORTLET_UTIL.clean_user_ind_sel(p_plug_id);
7576 
7577   -- bug#2203485 render the portlet at runtime
7578     IF (NOT BIS_PMF_PORTLET_UTIL.has_rows(p_plug_id, l_owner_user_id) ) THEN
7579       copyMeasureDefs(
7580         p_reference_path => p_reference_path
7581        ,p_plug_id  => p_plug_id
7582        ,p_user_id  => l_owner_user_id
7583        ,x_return_status => l_return_status
7584        ,x_error_Tbl => l_error_Tbl
7585       );
7586 
7587     END IF;
7588 
7589     display(
7590       p_session_id  => l_session_id
7591      ,p_plug_id     => p_plug_id
7592      ,p_user_id     => l_login_user_id
7593      ,x_html_buffer => l_html_buffer
7594      ,x_html_clob   => l_html_clob
7595     );
7596 
7597   END IF;
7598 
7599   x_html_buffer := l_html_buffer;
7600   x_html_clob   := l_html_clob;
7601 
7602 EXCEPTION
7603   WHEN OTHERS THEN
7604     RETURN;
7605 
7606 END ;
7607 
7608 
7609 
7610 /*
7611 update bis_indicators
7612 set comparison_source = 'POA_PMF_PO_DIST.PURCHASE_AMT'
7613 ,increase_in_measure = 'B'
7614 where indicator_id = 24;
7615 
7616 update bis_indicators
7617   2  set comparison_source = 'WIP_BIS_PROD_VAL_EMP_AB1_IDC.FND_APPLY'
7618   3  where indicator_id = 199;
7619 
7620 --===========================================================
7621 FUNCTION getValue(
7622   p_key IN VARCHAR2
7623  ,p_parameters IN VARCHAR2
7624  ,p_delimiter IN VARCHAR DEFAULT c_amp
7625 ) RETURN VARCHAR2
7626 
7627 IS
7628 
7629 BEGIN
7630 
7631 
7632 EXCEPTION
7633   WHEN OTHERS THEN
7634     RETURN NULL;
7635 
7636 END getValue;
7637 */
7638 --===========================================================
7639 -- end of change by juwang
7640 --===========================================================
7641 
7642 --===========================================================
7643 PROCEDURE append(
7644   p_string  IN VARCHAR2
7645  ,x_clob    IN OUT NOCOPY CLOB
7646  ,x_buffer  IN OUT NOCOPY VARCHAR2
7647 )
7648 IS
7649 
7650   v_buffer_length PLS_INTEGER := nvl(length(x_buffer), 0);
7651   v_string_length PLS_INTEGER := nvl(length(p_string), 0);
7652 
7653 BEGIN
7654 
7655   IF (x_clob IS NULL) THEN
7656     IF ((v_buffer_length + v_string_length) <= 32000) THEN
7657       x_buffer := x_buffer || p_string;
7658     ELSE
7659       -- create the CLOB object
7660       dbms_lob.createtemporary(x_clob, true);
7661 
7662       -- append the buffer and the new string to the created CLOB
7663       dbms_lob.writeappend(x_clob, v_buffer_length, x_buffer);
7664       dbms_lob.writeappend(x_clob, v_string_length, p_string);
7665     END IF;
7666   ELSE
7667     -- append the new string to the existing CLOB
7668     dbms_lob.writeappend(x_clob, v_string_length, p_string);
7669   END IF;
7670 
7671 EXCEPTION
7672   WHEN OTHERS THEN
7673     null;
7674 
7675 END append;
7676 
7677 --===========================================================
7678 
7679 
7680 PROCEDURE get_pm_portlet_html(
7681   p_plug_id   IN INTEGER
7682  ,p_reference_path  IN VARCHAR2
7683  ,x_html_buffer   OUT NOCOPY VARCHAR2
7684  ,x_html_clob   OUT NOCOPY CLOB
7685 )
7686 IS
7687 
7688   l_html_buffer         VARCHAR2(32000) := NULL;
7689   l_html_clob           CLOB := NULL;
7690 
7691 BEGIN
7692 
7693   draw_portlet_content(
7694     p_plug_id => p_plug_id
7695    ,p_reference_path => p_reference_path
7696    ,x_html_buffer => l_html_buffer
7697    ,x_html_clob => l_html_clob
7698   );
7699 
7700   IF (l_html_clob IS NOT NULL) THEN
7701     x_html_clob := l_html_clob;
7702     x_html_buffer := NULL;
7703 
7704     free_clob(
7705       x_clob => l_html_clob
7706     );
7707 
7708   ELSE
7709     x_html_clob := NULL;
7710     x_html_buffer := l_html_buffer;
7711   END IF;
7712 
7713 EXCEPTION
7714   WHEN OTHERS THEN
7715     x_html_buffer := 'error in get_pm_portlet_html';
7716 
7717     IF (l_html_clob IS NOT NULL) THEN
7718       free_clob(
7719   x_clob => l_html_clob
7720       );
7721       x_html_clob := NULL;
7722     END IF;
7723 
7724 END get_pm_portlet_html;
7725 
7726 --===========================================================
7727 
7728 PROCEDURE free_clob(
7729   x_clob IN OUT NOCOPY CLOB
7730 )
7731 IS
7732 
7733 BEGIN
7734 
7735   dbms_lob.freetemporary(x_clob);
7736 
7737 EXCEPTION
7738   WHEN OTHERS THEN
7739     null;
7740 
7741 END free_clob;
7742 
7743 --==========================================================================+
7744 
7745 END BIS_PORTLET_PMREGION;