FORM调用FORM(标准调客户化&客户化调标准)并执行查询的实现研究

一.先来个比较简单的,标准FORM调用客户话FORM并执行查询

1.修改CUSTOM.PLL,使用 fnd_function.execute实现打开和传递参数

参考例子如下

PROCEDURE event(event_name VARCHAR2) IS
  -- 
  -- This procedure allows you to execute your code at specific events 
  -- including: 
  -- 
  --    ZOOM 
  --    WHEN-NEW-FORM-INSTANCE 
  --    WHEN-NEW-BLOCK-INSTANCE 
  --    WHEN-NEW-RECORD-INSTANCE 
  --    WHEN-NEW-ITEM-INSTANCE 
  --    WHEN-VALIDATE-RECORD 
  -- 
  -- Additionally, product-specific events will be passed via this 
  -- interface (see the Applications Technical Reference manuals for  
  -- a list of events that are available).  
  -- 
  -- By default this routine must perform 'null;'. 
  -- 
  -- Oracle Corporation reserves the right to change the events  
  -- available through this interface at any time. 
  -- 
  /* Sample code:
  
    form_name      varchar2(30) := name_in('system.current_form'); 
    block_name     varchar2(30) := name_in('system.cursor_block');  
    param_to_pass1 varchar2(255); 
    param_to_pass2 varchar2(255); 
  begin 
    -- Zoom event opens a new session of a form and 
    -- passes parameter values to the new session.  The parameters
    -- already exist in the form being opened.
    if (event_name = 'ZOOM') then   
      if (form_name = 'DEMXXEOR' and block_name = 'ORDERS') then 
        param_to_pass1 := name_in('ORDERS.order_id'); 
        param_to_pass2 := name_in('ORDERS.customer_name'); 
        fnd_function.execute(FUNCTION_NAME=>'DEM_DEMXXEOR',  
                             OPEN_FLAG=>'Y',  
                             SESSION_FLAG=>'Y',  
                             OTHER_PARAMS=>'ORDER_ID="'||param_to_pass1|| 
                               '" CUSTOMER_NAME="'||param_to_pass2||'"'); 
    -- all the extra single and double quotes account for 
    -- any spaces that might be in the passed values 
      end if; 
  
    -- This is an example of a product-specific event.  Note that as
    -- of Prod 15, this event doesn't exist.
    elsif (event_name = 'OE_LINES_PRICING') then 
      get_custom_pricing('ORDERS.item_id', 'ORDERS.price'); 
  
    -- This is an example of enforcing a company-specific business
    -- rule, in this case, that all vendor names must be uppercase.
    elsif (event_name = 'WHEN-VALIDATE-RECORD') then
      if (form_name = 'APXVENDR') then
        if (block_name = 'VENDOR') then
          copy(upper(name_in('VENDOR.NAME')), 'VENDOR.NAME');       
        end if;
      end if;
    else 
      null; 
    end if; 
  end event; 
  */
  -- 
  -- Real code starts here 
  -- 
  form_name          VARCHAR2(30) := name_in('system.current_form');
  block_name     varchar2(30) := name_in('system.cursor_block');
  special_menu_name13 VARCHAR2(2000);
  special_menu_name14 VARCHAR2(2000);
  special_menu_name15 VARCHAR2(2000);
  param_to_pass1     NUMBER := NULL;
  param_to_pass2     NUMBER := NULL;
  param_to_pass3     varchar2(200) := NULL;
  param_to_pass4     number := NULL;--invoiec_id
  param_to_pass5     number := NULL;--ccid
  param_to_pass6		 date := NULL;--gl_date
  param_to_pass7		 number := NULL;--set_of_books_id
  V_PROPERTY VARCHAR2(30);
  V_COUNT NUMBER;
  V_INVOICE_ID NUMBER;
  V_TERM_ID  NUMBER;
  v_date     date;
    CURSOR rec_invoice_line(p_invoice_id IN NUMBER) IS
    SELECT l.invoice_id,
           l.org_id,
           l.inventory_item_id,
           l.item_description,
           l.po_header_id,
           l.po_line_id,
           l.po_release_id,
           l.po_line_location_id,
           l.po_distribution_id
      FROM ap_invoice_lines_all l
     WHERE l.invoice_id = p_invoice_id
       AND l.po_line_id IS NOT NULL
       AND l.amount <> 0;
       
    CURSOR rec_invoice_lok(p_invoice_id IN NUMBER) IS
    SELECT l.terms_id
      FROM ap_invoices_all l
     WHERE l.invoice_id = p_invoice_id
       FOR UPDATE NOWAIT;
  
BEGIN
  special_menu_name13 := '返利';
  special_menu_name14 := '订单';
  special_menu_name15 := '更新';
  --FND_MESSAGE.DEBUG('CUSTOM.PLL');
  IF form_name = 'APXINWKB' AND event_name = 'WHEN-NEW-FORM-INSTANCE' THEN
    --SET_MENU_ITEM_PROPERTY('SPECIAL.MENU15',LABEL,'自动创建'); 
    --FND_MESSAGE.DEBUG('WHEN-NEW-FORM-INSTANCE');
    set_menu_item_property('FILE.SAVE', enabled, PROPERTY_ON);-- able save menu
    app_special2.instantiate('SPECIAL13', special_menu_name13, NULL, TRUE); --添加菜单API
    app_special2.instantiate('SPECIAL14', special_menu_name14, NULL, TRUE); --添加菜单API
    app_special2.instantiate('SPECIAL15', special_menu_name15, NULL, TRUE); --添加菜单API
   
    RETURN;
  END IF;
  
  IF form_name = 'APXINWKB' AND event_name = 'WHEN-NEW-ITEM-INSTANCE' /*AND
     block_name = 'INV_SUM_FOLDER'*/ THEN
     IF name_in('INV_SUM_FOLDER.QUICK_PO_NUMBER') IS NULL THEN
    set_item_property('INV_SUM_CONTROL.MATCH', enabled, property_false);
     ELSE
     	set_item_property('INV_SUM_CONTROL.MATCH', enabled, property_true);
     END IF;
     --FND_MESSAGE.DEBUG('WHEN-NEW-ITEM-INSTANCE');
    V_INVOICE_ID :=  NAME_IN('INV_SUM_FOLDER.INVOICE_ID');
    SELECT COUNT(*)
    INTO V_COUNT
    FROM AP_INVOICE_LINES_ALL L
    WHERE l.invoice_id = V_INVOICE_ID
    AND   L.PO_LINE_ID IS NOT NULL
    AND   L.amount <> 0;
    --FND_MESSAGE.DEBUG(V_INVOICE_ID||'---'||V_COUNT);
    IF V_COUNT = 0 THEN
    	app_special.enable('SPECIAL15', property_OFF);
    ELSE
    	app_special.enable('SPECIAL15', property_on);
    END IF;
    RETURN;
  
  END IF;
  
  IF form_name = 'APXINWKB' AND event_name = 'WHEN-NEW-BLOCK-INSTANCE' THEN
  
    --SET_MENU_ITEM_PROPERTY('SPECIAL.MENU15',LABEL,'自动创建'); 
    app_special.enable('SPECIAL13', property_on);
    app_special.enable('SPECIAL14', property_on);
    app_special.enable('SPECIAL15', property_on);
     
    RETURN;
  END IF;
  
  IF ((form_name = 'APXINWKB') /*and (Block_Name = 'LINES')*/
     AND (event_name = 'SPECIAL13')) THEN
    param_to_pass1 := name_in('INV_SUM_FOLDER.ORG_ID');
    param_to_pass2 := name_in('INV_SUM_FOLDER.VENDOR_ID');
    param_to_pass4 := name_in('INV_SUM_FOLDER.INVOICE_ID');
    param_to_pass5 := name_in('INV_SUM_FOLDER.ACCTS_PAY_CODE_COMBINATION_ID');
    param_to_pass6 := name_in('INV_SUM_FOLDER.GL_DATE');
    param_to_pass7 := name_in('INV_SUM_FOLDER.SET_OF_BOOKS_ID');
    --FND_MESSAGE.DEBUG('CUSTOM.PLL');
    --FND_MESSAGE.DEBUG('param_to_pass4  '||param_to_pass4);
    --FND_MESSAGE.DEBUG('param_to_pass5  '||param_to_pass5);
    --FND_MESSAGE.DEBUG('param_to_pass6  '||param_to_pass6);
    --FND_MESSAGE.DEBUG('param_to_pass7  '||param_to_pass7);
    V_PROPERTY := Get_Menu_Item_Property('FILE.SAVE',enabled);
    --FND_MESSAGE.DEBUG('V_PROPERTY  '||V_PROPERTY);
    --set_menu_item_property('FILE.SAVE', enabled, PROPERTY_OFF);-- disable save menu 
    
    fnd_function.execute(function_name => 'CUXAPREBATE',
                         open_flag     => 'Y',
                         session_flag  => 'Y',
                         other_params  => 'G_ORG_ID="' || param_to_pass1 ||
                                          '" G_VENDOR_ID="' ||
                                          param_to_pass2 || /*'"'||*/
                                          '" G_INVOICE_ID="' ||
                                          param_to_pass4 || 
                                          '" G_CCID="' ||
                                          param_to_pass5 ||
                                          '" G_GL_DATE="' ||
                                          param_to_pass6 || 
                                          '" G_SET_OF_BOOKS_ID="' ||
                                          param_to_pass7 || '"');
                                          


  ELSIF ((form_name = 'APXINWKB') /*and (Block_Name = 'LINES')*/
        AND (event_name = 'SPECIAL14')) THEN
    param_to_pass3 := name_in('INV_SUM_FOLDER.QUICK_PO_NUMBER');
   fnd_function.execute(function_name => 'CUXAPPOINFOR',
                         open_flag     => 'Y',
                         session_flag  => 'Y',
                         other_params  => 'G_PO_NUMBER="' || param_to_pass3 ||
                                          '"' );                         


  ELSIF ((form_name = 'APXINWKB') /*and (Block_Name = 'LINES')*/
        AND (event_name = 'SPECIAL15')) THEN
    fnd_message.debug('XXXXXXXX:'||NAME_IN('INV_SUM_FOLDER.VENDOR_ID'));
    V_INVOICE_ID :=  NAME_IN('INV_SUM_FOLDER.INVOICE_ID');
    FOR REC_INVOICE IN rec_invoice_line(p_invoice_id => V_INVOICE_ID) LOOP
    	
    	open rec_invoice_lok(p_invoice_id => REC_INVOICE.INVOICE_ID);
   
    	SELECT H.TERM_ID
		  INTO   V_TERM_ID
		  FROM   CUX_OMS_PO_HEADERS H,PO_HEADERS_ALL PH
			WHERE  H.PO_NUMBER = PH.SEGMENT1
			AND    H.PROCESS_STATUS = 'COMPLETE'
			AND    PH.PO_HEADER_ID = REC_INVOICE.PO_HEADER_ID;
			
			SELECT rt.transaction_date
			into   v_date
      FROM rcv_transactions rt
      WHERE rt.po_header_id = REC_INVOICE.PO_HEADER_ID;
			
			UPDATE AP_INVOICES_ALL 
			SET    TERMS_ID = V_TERM_ID,
			       TERMS_DATE = v_date
			WHERE  INVOICE_ID = REC_INVOICE.INVOICE_ID;
			
			close rec_invoice_lok;
    END LOOP;
  ELSE
    RETURN;
  END IF;

END event;


2.在客户化FORM里创建参数,接收传过来的,如上面程序中的G_ORG_ID,G_VENDOR_ID等等

3.在客户化FORM里根据传过来的参数执行查询即可实现

二.客户化FORM调用标准FORM并执行查询

1.利用个性化来实现具体如下

客户化Form A 调用标准 Form B;在Form A上定义一个全局参数,B 获取这个参数,作为查询条件,B上设置个性化

FORM调用FORM(标准调客户化&客户化调标准)并执行查询的实现研究_第1张图片

FORM调用FORM(标准调客户化&客户化调标准)并执行查询的实现研究_第2张图片

Form B获取Form A过来的参数,把参数的值赋给Form B的ITEM

2.利用CUSTOM.PLL实现

例子如下

打开PO

PROCEDURE BTN_OPEN_PO IS 
  BEGIN 
  
       fnd_function.Execute(Function_Name => 'PO_POXPOEPO',
                             Open_Flag     => 'Y',
                             Session_Flag  => 'Y',
                             Other_Params  => 'PO_HEADER_ID=' || :Po.Po_Header_Id || ' ' 
                              ||' ACCESS_LEVEL_CODE="MODIFY"' 
                              ||' POXPOEPO_CALLING_FORM="POXSTNOT"',
                             Activate_Flag => 'ACTIVATE');
   
  END ;

打开SO

PROCEDURE BTN_OPEN_SO IS 
  BEGIN 
   
       fnd_function.Execute(Function_Name => 'ONT_OEXOEORD',
                             Open_Flag     => 'Y',
                             Session_Flag  => 'Y',
                             Other_Params  => 'DESKTOP_HEADER_ID="' || :So.So_Header_Id || '"',
                             Activate_Flag => 'ACTIVATE'); 
   
  END ;


 

你可能感兴趣的:(form,查询,ebs,FORM调用FORM)