app_field.clear_dependent_fields

可以调用APP_FIELD.clear_dependent_fields和APP_FIELD.set_dependent_field来将两个(或多个)Item建立关联,当一个为空时,另一个不可录入,反正,可录入,且父Item Field变化时,子Fields清空。
----------------------------------------------------------------------------------------------------------------------------------
APP_FIELD.clear_dependent_fields(
                            master_field VARCHAR2,
                                 field1       VARCHAR2,
                                 field2       VARCHAR2 DEFAULT NULL,
                                 field3       VARCHAR2 DEFAULT NULL,
                                 field4       VARCHAR2 DEFAULT NULL,
                                 field5       VARCHAR2 DEFAULT NULL,
                                 field6       VARCHAR2 DEFAULT NULL,
                                 field7       VARCHAR2 DEFAULT NULL,
                                 field8       VARCHAR2 DEFAULT NULL,
                                 field9       VARCHAR2 DEFAULT NULL,
                                 field10      VARCHAR2 DEFAULT NULL)
实现:如果master_field为空,则清空后续所有fieldn.
----------------------------------------------------------------------------------------------------------------------------------
APP_FIELD.set_dependent_field(
                              even                   VARCHAR2,
                              master_field        VARCHAR2,
                              dependent_field  VARCHAR2,
                              invalidate            BOOLEAN DEFAULT FALSE)
实现:如果master_field为空,则dependent_Field的ENTERABLE为PROPERTY_OFF;
          反之, 如果master_field不空,则dependent_Field的ENTERABLE为PROPERTY_ON。
          event可以为'..VALIDATE..','INIT','PRE-RECORD', 'WHEN-NEW-RECORD-INSTANCE','POST-QUERY'。
这个Procedure其实调用了另外一个Procedure
APP_FIELD.set_dependent_field(
                           event                   VARCHAR2,
                           condition             BOOLEAN,
                           dependent_field  VARCHAR2,
                           invalidate            BOOLEAN DEFAULT FALSE)
条件condition为(name_in(master_field) is not null)
----------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------
附Procedure原码:
  PROCEDURE clear_dependent_fields(master_field VARCHAR2,
                                   field1       VARCHAR2,
                                   field2       VARCHAR2 DEFAULT NULL,
                                   field3       VARCHAR2 DEFAULT NULL,
                                   field4       VARCHAR2 DEFAULT NULL,
                                   field5       VARCHAR2 DEFAULT NULL,
                                   field6       VARCHAR2 DEFAULT NULL,
                                   field7       VARCHAR2 DEFAULT NULL,
                                   field8       VARCHAR2 DEFAULT NULL,
                                   field9       VARCHAR2 DEFAULT NULL,
                                   field10      VARCHAR2 DEFAULT NULL) IS
  BEGIN
    COPY('Entering app_field.clear_dependent_fields.','global.frd_debug');
    if (name_in(master_field) is null) then
      clear_fields(field1, field2, field3, field4, field5,
                   field6, field7, field8, field9, field10);
    end if;
    COPY('Completed app_field.clear_dependent_fields.','global.frd_debug');
  END clear_dependent_fields;

  PROCEDURE set_dependent_field(event           VARCHAR2,
                                master_field    VARCHAR2,
                                dependent_field VARCHAR2,
        invalidate  BOOLEAN DEFAULT FALSE) IS
  BEGIN
    COPY('Entering app_field.set_dependent_field.  Event is '||event||'.','global.frd_debug');
    set_dependent_field(event,
                        (name_in(master_field) is not null),
                        dependent_field,
      invalidate);
    COPY('Completed app_field.set_dependent_field.  Event is '||event||'.','global.frd_debug');
  END set_dependent_field;

  PROCEDURE set_dependent_field(event           VARCHAR2,
                                condition       BOOLEAN,
                                dependent_field VARCHAR2,
        invalidate  BOOLEAN DEFAULT FALSE) IS
    value    NUMBER;
    itemtype VARCHAR2(32);
  BEGIN
    COPY('Entering app_field.set_dependent_field.  Event is '||event||'.','global.frd_debug');
    if (condition) then
      value := PROPERTY_ON;
    else
      value := PROPERTY_OFF;
    end if;

    if ((instr(event, 'VALIDATE') <> 0) or (event = 'INIT')) then
      app_item_property.set_property(dependent_field, ENTERABLE, value);
      itemtype := get_item_property(dependent_field, item_type);
      if invalidate then
        set_item_property(dependent_field, ITEM_IS_VALID, PROPERTY_FALSE);
      elsif not(itemtype = 'CHECKBOX' or
               (itemtype = 'LIST' and
                get_item_property(dependent_field, required) = 'TRUE')) then
        if (name_in(dependent_field) is not null) then
          copy('', dependent_field);
        end if;
      end if;

    elsif (event in ('PRE-RECORD', 'WHEN-NEW-RECORD-INSTANCE')) then
      app_item_property.set_property(dependent_field, ENTERABLE, value);

    elsif (event = 'POST-QUERY') then
      --
      -- In R11 this set the visual attribute. Now we get the coloring
      -- by setting the enterable property
      --
      app_item_property.set_property(dependent_field, ENTERABLE, value);
    else
      fnd_message.debug('DEVELOPER ERROR: Invalid arg '||
        event||' to set_dependent field');
    end if;
    COPY('Completed app_field.set_dependent_field.  Event is '||event||'.','global.frd_debug');
  EXCEPTION
    when OTHERS then
      app_debug.setpoint('app_field.set_dependent_field',
                         event||', '||dependent_field);
      RAISE;
  END set_dependent_field;

 

posted @ 2014-04-16 10:38  我不卖豆腐  阅读(3809)  评论(1编辑  收藏  举报