<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: duanjian 
    $Date: 2012-2-8 下午01:39:46  
    $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 fv.COMPANY_ID, fv.COMPANY_CODE, fv.COMPANY_SHORT_NAME,fv.COMPANY_CODE || '-' || fv.COMPANY_SHORT_NAME code_name
			  from fnd_companies_vl fv
			  #WHERE_CLAUSE#   order by fv.company_code
]]></bm:query-sql>
            <bm:parameters>
                <bm:parameter inputPath="/parameter/@unit_type_id"/>
            </bm:parameters>
        </bm:operation>
    </bm:operations>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="fv.set_of_books_id = ${/parameter/@set_of_books_id} and (fv.end_date_active is null or                                                                                                    sysdate between fv.start_date_active                                                                                                                               and fv.end_date_active)                                                                                                                                                                                and not exists (select c.company_id                                                                                                                                 from exp_org_unit_assign_types c, fnd_companies_vl f                                                                                                                                where c.company_id = fv.company_id                                                                                                                                                                                                and f.company_id = fv.company_id                                                                                                                                   and c.unit_type_code = ${/parameter/@unit_type_code})"/>
    </bm:data-filters>
    <bm:fields>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COMPANY_ID"/>
        <bm:field name="company_code" databaseType="VARCHAR2" datatype="java.lang.String" forDisplay="true" forQuery="true" physicalName="COMPANY_CODE" prompt="FND_COMPANIES.COMPANY_CODE"/>
        <bm:field name="company_short_name" databaseType="VARCHAR2" datatype="java.lang.String" forDisplay="true" forQuery="true" physicalName="COMPANY_SHORT_NAME" prompt="FND_COMPANIES.COMPANY_SHORT_NAME"/>
        <bm:field name="code_name"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field field="company_code" queryOperator="like"/>
        <bm:query-field field="company_short_name" queryOperator="like"/>
        <bm:query-field name="code_name" queryExpression="fv.company_code like ${@code_name} || &apos;%&apos;"/>
        <bm:query-field name="company_code_from" queryExpression="fv.company_code &gt;= ${@company_code_from}"/>
        <bm:query-field name="company_code_to" queryExpression="fv.company_code &lt;= ${@company_code_to}"/>
    </bm:query-fields>
</bm:model>
