How can you set a calendar on oracle forms 6i
============================== =======
Step 1: Download forms 6i demos with library from
https://googledrive.com/host/0B5DZvtSmSXRITmREUTQ1ZmxYb0U/forms6idemos.zip
copy the stndrd20.olb and calendar.pll file from forms6idemos\win32\pmbf\6_0_8_ 8\demo\forms location and past it
Desired forms directory
Step 2: Add stndrd20.olb desired form module and expand the library then duble click into the COMPONENTS tab
drag and drop the calendar into the module.When a message arise then press copy.
Step 3: In the programm unit Add a package spacification named date_lov and write the following code:
============================== ============================== ====================
package date_lov is
last_lov_date number(2);
current_lov_date date;
date_lov_return_item varchar2(80);
lov_title varchar2(80);
lov_auto_confirm boolean;
lov_auto_skip boolean;
weekend_highlight boolean;
weekend_day1 number;
weekend_day2 number;
procedure display_cal(display_date in date);
procedure date_click;
procedure get_date (display_date in date,
return_item in varchar2,
v_x_pos in number := 0,
v_y_pos in number := 0,
v_title in varchar2 := 'Date List of Values',
v_ok in varchar2 := 'OK',
v_cancel in varchar2 := 'Cancel',
v_highlight in boolean := TRUE,
v_autoconfirm in boolean := FALSE,
v_autoskip in boolean := FALSE);
end;
Step 4: In the programm unit Add a package body named date_lov and write the following code:
============================== ============================== ==============
package body date_lov is
procedure set_day_labels
is
begin
-- if November 8, 1996 is the fifth day of the week, then
-- display the labels in ISO style with Monday as
-- the first day of the week
-- else November 8, 1996 is the sixth day of the week, then
-- display the labels in American style with Sunday as
-- the first day of the week
if to_char(to_date('11/08/ 1996','mm/dd/yyyy'),'d') = '5' then
weekend_day1 := 6;
weekend_day2 := 7;
copy(to_char(to_date('11/04/ 1996','mm/dd/yyyy'),'Dy'),
'date_control_block.day_label1 ');
copy(to_char(to_date('11/05/ 1996','mm/dd/yyyy'),'Dy'),
'date_control_block.day_label2 ');
copy(to_char(to_date('11/06/ 1996','mm/dd/yyyy'),'Dy'),
'date_control_block.day_label3 ');
copy(to_char(to_date('11/07/ 1996','mm/dd/yyyy'),'Dy'),
'date_control_block.day_label4 ');
copy(to_char(to_date('11/08/ 1996','mm/dd/yyyy'),'Dy'),
'date_control_block.day_label5 ');
copy(to_char(to_date('11/09/ 1996','mm/dd/yyyy'),'Dy'),
'date_control_block.day_label6 ');
copy(to_char(to_date('11/10/ 1996','mm/dd/yyyy'),'Dy'),
'date_control_block.day_label7 ');
else
weekend_day1 := 1;
weekend_day2 := 7;
copy(to_char(to_date('11/03/ 1996','mm/dd/yyyy'),'Dy'),
'date_control_block.day_label1 ');
copy(to_char(to_date('11/04/ 1996','mm/dd/yyyy'),'Dy'),
'date_control_block.day_label2 ');
copy(to_char(to_date('11/05/ 1996','mm/dd/yyyy'),'Dy'),
'date_control_block.day_label3 ');
copy(to_char(to_date('11/06/ 1996','mm/dd/yyyy'),'Dy'),
'date_control_block.day_label4 ');
copy(to_char(to_date('11/07/ 1996','mm/dd/yyyy'),'Dy'),
'date_control_block.day_label5 ');
copy(to_char(to_date('11/08/ 1996','mm/dd/yyyy'),'Dy'),
'date_control_block.day_label6 ');
copy(to_char(to_date('11/09/ 1996','mm/dd/yyyy'),'Dy'),
'date_control_block.day_label7 ');
end if;
end set_day_labels;
procedure display_cal(display_date in date)
is
first_date date;
first_dow number;
last_dom number;
loop_begin number;
loop_end number;
current_date number;
day_label number := 1;
BEGIN
current_lov_date := display_date;
current_date := to_number(to_char(display_date ,'dd'));
first_date := to_date('01-'||to_char(display _date,'mon-yyyy'),'dd-mon-yyyy ');
first_dow := to_number(to_char(first_date,' d'));
last_dom := to_number(to_char(last_day(dis play_date),'dd'));
copy(to_char(display_date,'fmM onth YYYY'),
'date_control_block.display_mo n_year');
loop_end := first_dow - 1;
for i in 1..loop_end loop
set_item_property('date_button '||to_char(i), displayed, property_false);
end loop;
loop_end := last_dom + first_dow - 1;
for i in first_dow..loop_end loop
if get_item_property('date_button '||to_char(i), displayed) = 'FALSE' then
set_item_property('date_button '||to_char(i), displayed, property_true);
end if;
copy(to_char(day_label), 'date_button'||to_char(i));
if day_label = current_date then
set_item_property('date_button '||to_char(i), visual_attribute, 'date_selected_va');
last_lov_date := i;
elsif to_char(to_date(to_char(day_la bel)||'-'||
to_char(display_date,'mon-yyyy '),'dd-mon-yyyy'),'d')
in (weekend_day1,weekend_day2) and weekend_highlight = TRUE then
set_item_property('date_button '||to_char(i), visual_attribute, 'date_weekend_va');
else
set_item_property('date_button '||to_char(i), visual_attribute, 'date_normal_va');
end if;
day_label := day_label + 1;
end loop;
if last_dom + first_dow < 37 then
loop_begin := last_dom + first_dow;
loop_end := 37;
for i in loop_begin..loop_end loop
set_item_property('date_button '||to_char(i), displayed, property_false);
end loop;
end if;
end display_cal;
procedure get_date (display_date in date,
return_item in varchar2,
v_x_pos in number := 0,
v_y_pos in number := 0,
v_title in varchar2 := 'Date List of Values',
v_ok in varchar2 := 'OK',
v_cancel in varchar2 := 'Cancel',
v_highlight in boolean := TRUE,
v_autoconfirm in boolean := FALSE,
v_autoskip in boolean := FALSE)
is
date_window window;
begin
date_window := find_window('date_lov_window') ;
-- set date lov window position
set_window_property(date_windo w, position, v_x_pos, v_y_pos);
-- set date lov window title
set_window_property(date_windo w, title, v_title);
-- set OK button label
set_item_property('date_contro l_block.ok_button',label,v_ok) ;
-- set Cancel button label
set_item_property('date_contro l_block.cancel_button',label,v _cancel);
-- set date lov auto confirm flag
lov_auto_confirm := v_autoconfirm;
-- set date lov auto skip flag
lov_auto_skip := v_autoskip;
-- set weekend highlight flag
weekend_highlight := v_highlight;
date_lov_return_item := return_item;
set_day_labels;
display_cal(display_date);
go_item('date_control_block.OK _BUTTON');
end get_date;
procedure date_click
is
begin
if to_char(date_lov.current_lov_d ate,'d') in (date_lov.weekend_day1, date_lov.weekend_day2) and
weekend_highlight = TRUE then
set_item_property('date_button '||to_char(date_lov.last_lov_d ate),
visual_attribute, 'date_weekend_va');
else
set_item_property('date_button '||to_char(date_lov.last_lov_d ate),
visual_attribute, 'date_normal_va');
end if;
set_item_property(name_in('sys tem.trigger_item'),
visual_attribute, 'date_selected_va');
date_lov.last_lov_date := substr(name_in('system.trigger _item'),
instr(name_in('system.trigger_ item'),'.')+12);
date_lov.current_lov_date := to_date(name_in(name_in('syste m.trigger_item')) || '-' ||
to_char(date_lov.current_lov_d ate,'mon-yyyy'),'dd-mon-yyyy') ;
if date_lov.lov_auto_confirm = TRUE then
copy(to_char(date_lov.current_ lov_date), date_lov.date_lov_return_item) ;
go_item(date_lov.date_lov_retu rn_item);
if date_lov.lov_auto_skip = TRUE then
next_item;
end if;
end if;
end date_click;
end;
Step 5: Create a text item(if needed) and push button in the form that will execute the calendar.
in the push button write the following code in WHEN-BUTTON-PRESSED trigger
============================== ============================== ============================== ============================== ===
declare
xp number;
yp number;
begin
xp:=get_item_property('from_da te',x_pos);
yp:=get_item_property('from_da te',y_pos);
date_lov.get_date(sysdate,'EMP LOYEE.from_date',240,60,'From Date','OK','Cancel',TRUE,FALSE ,FALSE);
END;
[note:change block name like here employee is block and item name like from_date;]
compile the form and run...........
If you want to see a video tutorial click the following link
https://www.youtube.com/watch?v=oDua6VQQJpo
==============================
Step 1: Download forms 6i demos with library from
https://googledrive.com/host/0B5DZvtSmSXRITmREUTQ1ZmxYb0U/forms6idemos.zip
copy the stndrd20.olb and calendar.pll file from forms6idemos\win32\pmbf\6_0_8_
Desired forms directory
Step 2: Add stndrd20.olb desired form module and expand the library then duble click into the COMPONENTS tab
drag and drop the calendar into the module.When a message arise then press copy.
Step 3: In the programm unit Add a package spacification named date_lov and write the following code:
==============================
package date_lov is
last_lov_date number(2);
current_lov_date date;
date_lov_return_item varchar2(80);
lov_title varchar2(80);
lov_auto_confirm boolean;
lov_auto_skip boolean;
weekend_highlight boolean;
weekend_day1 number;
weekend_day2 number;
procedure display_cal(display_date in date);
procedure date_click;
procedure get_date (display_date in date,
return_item in varchar2,
v_x_pos in number := 0,
v_y_pos in number := 0,
v_title in varchar2 := 'Date List of Values',
v_ok in varchar2 := 'OK',
v_cancel in varchar2 := 'Cancel',
v_highlight in boolean := TRUE,
v_autoconfirm in boolean := FALSE,
v_autoskip in boolean := FALSE);
end;
Step 4: In the programm unit Add a package body named date_lov and write the following code:
==============================
package body date_lov is
procedure set_day_labels
is
begin
-- if November 8, 1996 is the fifth day of the week, then
-- display the labels in ISO style with Monday as
-- the first day of the week
-- else November 8, 1996 is the sixth day of the week, then
-- display the labels in American style with Sunday as
-- the first day of the week
if to_char(to_date('11/08/
weekend_day1 := 6;
weekend_day2 := 7;
copy(to_char(to_date('11/04/
'date_control_block.day_label1
copy(to_char(to_date('11/05/
'date_control_block.day_label2
copy(to_char(to_date('11/06/
'date_control_block.day_label3
copy(to_char(to_date('11/07/
'date_control_block.day_label4
copy(to_char(to_date('11/08/
'date_control_block.day_label5
copy(to_char(to_date('11/09/
'date_control_block.day_label6
copy(to_char(to_date('11/10/
'date_control_block.day_label7
else
weekend_day1 := 1;
weekend_day2 := 7;
copy(to_char(to_date('11/03/
'date_control_block.day_label1
copy(to_char(to_date('11/04/
'date_control_block.day_label2
copy(to_char(to_date('11/05/
'date_control_block.day_label3
copy(to_char(to_date('11/06/
'date_control_block.day_label4
copy(to_char(to_date('11/07/
'date_control_block.day_label5
copy(to_char(to_date('11/08/
'date_control_block.day_label6
copy(to_char(to_date('11/09/
'date_control_block.day_label7
end if;
end set_day_labels;
procedure display_cal(display_date in date)
is
first_date date;
first_dow number;
last_dom number;
loop_begin number;
loop_end number;
current_date number;
day_label number := 1;
BEGIN
current_lov_date := display_date;
current_date := to_number(to_char(display_date
first_date := to_date('01-'||to_char(display
first_dow := to_number(to_char(first_date,'
last_dom := to_number(to_char(last_day(dis
copy(to_char(display_date,'fmM
'date_control_block.display_mo
loop_end := first_dow - 1;
for i in 1..loop_end loop
set_item_property('date_button
end loop;
loop_end := last_dom + first_dow - 1;
for i in first_dow..loop_end loop
if get_item_property('date_button
set_item_property('date_button
end if;
copy(to_char(day_label), 'date_button'||to_char(i));
if day_label = current_date then
set_item_property('date_button
last_lov_date := i;
elsif to_char(to_date(to_char(day_la
to_char(display_date,'mon-yyyy
in (weekend_day1,weekend_day2) and weekend_highlight = TRUE then
set_item_property('date_button
else
set_item_property('date_button
end if;
day_label := day_label + 1;
end loop;
if last_dom + first_dow < 37 then
loop_begin := last_dom + first_dow;
loop_end := 37;
for i in loop_begin..loop_end loop
set_item_property('date_button
end loop;
end if;
end display_cal;
procedure get_date (display_date in date,
return_item in varchar2,
v_x_pos in number := 0,
v_y_pos in number := 0,
v_title in varchar2 := 'Date List of Values',
v_ok in varchar2 := 'OK',
v_cancel in varchar2 := 'Cancel',
v_highlight in boolean := TRUE,
v_autoconfirm in boolean := FALSE,
v_autoskip in boolean := FALSE)
is
date_window window;
begin
date_window := find_window('date_lov_window')
-- set date lov window position
set_window_property(date_windo
-- set date lov window title
set_window_property(date_windo
-- set OK button label
set_item_property('date_contro
-- set Cancel button label
set_item_property('date_contro
-- set date lov auto confirm flag
lov_auto_confirm := v_autoconfirm;
-- set date lov auto skip flag
lov_auto_skip := v_autoskip;
-- set weekend highlight flag
weekend_highlight := v_highlight;
date_lov_return_item := return_item;
set_day_labels;
display_cal(display_date);
go_item('date_control_block.OK
end get_date;
procedure date_click
is
begin
if to_char(date_lov.current_lov_d
weekend_highlight = TRUE then
set_item_property('date_button
visual_attribute, 'date_weekend_va');
else
set_item_property('date_button
visual_attribute, 'date_normal_va');
end if;
set_item_property(name_in('sys
visual_attribute, 'date_selected_va');
date_lov.last_lov_date := substr(name_in('system.trigger
instr(name_in('system.trigger_
date_lov.current_lov_date := to_date(name_in(name_in('syste
to_char(date_lov.current_lov_d
if date_lov.lov_auto_confirm = TRUE then
copy(to_char(date_lov.current_
go_item(date_lov.date_lov_retu
if date_lov.lov_auto_skip = TRUE then
next_item;
end if;
end if;
end date_click;
end;
Step 5: Create a text item(if needed) and push button in the form that will execute the calendar.
in the push button write the following code in WHEN-BUTTON-PRESSED trigger
==============================
declare
xp number;
yp number;
begin
xp:=get_item_property('from_da
yp:=get_item_property('from_da
date_lov.get_date(sysdate,'EMP
END;
[note:change block name like here employee is block and item name like from_date;]
compile the form and run...........
If you want to see a video tutorial click the following link
https://www.youtube.com/watch?v=oDua6VQQJpo
Thanks for sharing the useful information about the oracle and for the further information about the oracle training visit
ReplyDeleteOracle Fusion Financials Training
Hi,
ReplyDeleteit is very article. Very interesting and valuable.
Thanks for sharing such a wonderful article.
oracle fusion SCM on line training
million thanx brother...
ReplyDelete