<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Harry
	$Date: 2018/11/16 14:26
	$Revision: 1.0
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" accessControlMode="false" needAccessControl="false">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    hd.sap_belnr BELNR,
                    hd.period_year GJAHR,
                    ln.sap_buzei BUZEI,
                    ln.reference4 ZTERM,
                    to_char(trunc(to_date(ln.reference14,'YYYY-MM-DD hh24:mi:ss')),'YYYYMMDD') ZFBDT,
                    null ZLSPR,
                    'T' ZLSCH,
                    (select h.INTERFACE_URL
                    from hls_interface_parameter h
                    where h.interface_code = ${@interface_code}) INTERFACE_URL,
                    (select h.INTERFACE_USERNAME
                    from hls_interface_parameter h
                    where h.interface_code = ${@interface_code}) INTERFACE_USERNAME,
                    (select h.INTERFACE_PASSWORD
                    from hls_interface_parameter h
                    where h.interface_code = ${@interface_code}) INTERFACE_PASSWORD,
                    (select h.ATTRIBUTE_1
                    from hls_interface_parameter h
                    where h.interface_code = ${@interface_code}) ATTRIBUTE_1
                FROM
                    hls_journal_header hd, hls_journal_detail ln
                WHERE
                    hd.journal_header_id = ln.journal_header_id and
                    ln.reference4 = '2901' and
                    nvl(ln.sap_payment_flag, 'N') <> 'Y' and
                    hd.sap_belnr is not null and
                    ln.sap_payment_status is null and
                    ln.reference14 is not null
                ]]>
            </bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                BEGIN
                    update
                        hls_journal_detail t
                    set
                        t.sap_payment_flag = decode(${@e_type}, 'S', 'Y', 'N'),
                        t.sap_e_msg        = ${@e_msg}
                    where
                        (select
                            h.sap_belnr
                        from
                            hls_journal_header h
                        where
                            h.journal_header_id = t.journal_header_id) = ${@belnr}
                        and t.sap_buzei = ${@buzei};
                END;
                ]]>
            </bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>