Thursday 14 November 2019

Enable / Disable Field in Oracle Forms

Case Study :

There are multiple columns in Oracle tabular form and they are depend on each other as Numeric sequence. User enter cannot enter value in columns if parent  of current item is null or child of current item is not null.

Add procedure in form and enter your your fields name in array as sequence you want .
after this call this code

begin 
when_New_item_instance;
end;

in When-new-item-instance trigger.


PROCEDURE when_New_item_instance IS

  type Items_List_t is varray(3) of Varchar2(200);

  l_Items_List Items_List_t := Items_List_t('BlockName.Item1',
                                            'BlockName.Item2',
                                            'BlockName.Item3');

  l_triggered_Item varchar2(200) default :system.trigger_item;

  l_item_enabled boolean default true;

  l_triggered_item_ind number;

BEGIN

  for ldx in 1 .. l_Items_List.count loop
 
    if l_triggered_Item = l_Items_List(ldx)
   
     then
   
      l_triggered_item_ind := ldx;
   
    end if;
 
  end loop;


if l_triggered_item_ind  is null then
null;
end;
  ---Note

  -- Exception overriding  is requeired in inner block so Exception when Others is Replaced with if-Else condition.

  Begin
 
    if name_in(l_Items_List(l_triggered_item_ind - 1)) is null
   
     then
   
      l_item_enabled := false;
   
    end if;
 
  exception
    when others
   
     then
      null;
   
      l_item_enabled := true;
   
  end;

  ---Note

  -- Exception overriding  is requeired in inner block so Exception when Others is Replaced with if-Else condition.

  Begin
 
    if name_in(l_Items_List(l_triggered_item_ind + 1)) is not null
   
     then
   
      l_item_enabled := false;
   
    end if;
 
  exception
    when others
   
     then
      null;
   
      l_item_enabled := true;
   
  end;

  if l_item_enabled then
 
    app_item_property.set_property(l_triggered_Item, enabled, property_on);
 
  else
 
    app_item_property.set_property(l_triggered_Item, enabled, property_off);
 
  end if;

END;





Note: 
Incase of non-EBS application 
replace 
app_item_property.set_property(l_triggered_Item, enabled, property_on);
with 
set_item_property(l_triggered_Item, enabled, property_on);


No comments:

Post a Comment

OADBTransactionImpl in Oracle Application Framework (OAF)

OADBTransactionImpl is a class in Oracle Application Framework (OAF), which is a framework for building Oracle E-Business Suite applications...