<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Lichen  
    $Date: 2012-2-17 下午02:49:13  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            select * from (select v.*, fcv.company_code, fcv.company_short_name
  from (select eou.*
          from exp_org_unit_vl eou
         where eou.company_id in
               (select fc.parent_company_id
                  from fnd_companies fc
                 where fc.parent_company_id is not null
                 start with fc.company_id = ${/session/@company_id}
                connect by fc.company_id =prior fc.parent_company_id)
            or eou.company_id = ${/session/@company_id}) v,
       fnd_companies_vl fcv
 where v.company_id = fcv.company_id) vl
         #WHERE_CLAUSE# 
         order by company_code,unit_code
         ]]></bm:query-sql>
            <bm:parameters>
                <bm:parameter inputPath="/session/@company_id"/>
            </bm:parameters>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="unit_code" displayWidth="150" fordisplay="true" forquery="true" prompt="EXP_ORG_UNIT.UNIT_CODE"/>
        <bm:field name="description" displayWidth="150" fordisplay="true" forquery="true" prompt="EXP_ORG_UNIT.ORG_UNIT_DESCRIPTION"/>
        <bm:field name="company_code" displayWidth="150" fordisplay="true" prompt="COMPANY_CODE"/>
        <bm:field name="company_short_name" displayWidth="150" fordisplay="true" prompt="COMPANY_SHORT_NAME"/>
        <bm:field name="unit_id"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field name="unit_code" queryExpression="unit_code like &apos;%&apos;|| ${@unit_code} ||&apos;%&apos;"/>
        <bm:query-field name="description" queryExpression="description like &apos;%&apos;|| ${@description} ||&apos;%&apos;"/>
    </bm:query-fields>
</bm:model>
