Download as pdf or txt
Download as pdf or txt
You are on page 1of 34

Customizing Templates and Data Definition Template for

iReceivables Customer Statement

OBJECTIVE:
How to create custom templates and modify data definition template
for Oracle iReceivables Customers Statement Download?

PRE-REQUISITES:
1. Access to iReceivables and XML Publisher Administrator
responsibilities.
2. BI Publisher Desktop installed– for customizing the downloaded
templates
Steps to identify the Template to be cloned

• Step 1 – Login to iReceivables. Search for any customer with account Balance.

• Step 2 – Navigate to Account Summary page for that customer. In the Account Summary page under
“Statement Download” region, the “Template” LOV would list all the available templates.

• Step 3 – Select the Template to be customized in the LOV, then press download, will launch the report. Ensure that this is
the correct report that needs customization. Note down the Report name that you have selected in the Template LOV.
Download and Copy the Template to be cloned

• Step 4 – Navigate to Home. Select “XML Publisher Administrator” Responsibility.


Select Home >> Templates under this responsibility. This will launch the search screen.

• Step 5 – In the search screen, type the name of the template, as selected in the LOV, in the “NAME” field and click on
Go Button. This templates uses the same Data Definition “iReceivables Customers Statement Data Definition”. If a new
template is created use the same Data Definition to view the template created as LOV in Account Summary page.
• Step 6 – From the search results, click on the NAME link for the appropriate template. This would launch the view
template screen. The bottom of this screen would show the attached file name (as some RTF format file). Select
the DOWNLOAD option against this file and download and save this to the local machine. The data definition name
is also noted.
Identify the attributes used from the Data Template

• Step 7 – Open the downloaded template. The data fields in the template would appear as “grayed out”. Select the FIRST
column’s text that is “grayed out” text in the template and Right Click on the mouse. From the list, select PROPERTIES.
The first column will always have a “F” prefixed to the text. Select only this “F” and click on Properties. Even when new
columns are added, ensure that the first column is prefixed with “F”. This “F” indicates that from this point onwards, the
data is to be repeated for each row. Each row will end with a column name that is suffixed with “E”.
Identify the attributes used from the Data Template

• Step 8 – In the properties window, click on “Add on Help” Text Button. The help text for this “F” would reveal the data
source for this template. Note down this source.
Select the Data Definition

• Step 9 – Navigate to Home. Select “XML Publisher Administrator” Responsibility. Select Home >> Data Definition. This
will open the default search screen. Search for the Data Definition “iReceivables Customers Statement Data Definition”
used by the templates shown above.
Identify the Data template and attributes for the Template

• Step 10 – From the search results, click on the NAME link for the appropriate Data Definition. This would launch the
view screen. The bottom of this screen would show the attached file name (as some xml format file). Select the
Name Link on file to download and save this to the local machine. After making changes to the file click on upload
button highlighted below to upload the changed Data Template file.
Data Template with a sample Example
Data Template with a sample Example

The tags in the above example as described below:

1. dataTemplate: This is the starting tag defining the data template. The name attribute is used as the starting/parent tag of the
output xml. In this case CustomerStatement. So, the output of this data template would be enclosed between
<CustomerStatement> and </CustomerStatement>.

2. properties: There are many properties which define the outcome of the data template. The properties used in the above
example

a. xml_tag_case: The value for which is “as_are”. This defines that the elements mentioned in the dataStructure needs to be in
the same case in the output of this template. By default if this property is not set the element names are converted to upper
case.

b. include_rowsettag: The value for which is either “true” or “false”. The default value for this is true. The purpose of this
property is when we have a sqlStatement may return multiple rows. So when this property is set to true the output xml will
include a row set tag with the name as LIST_<group name mentioned> in this case <LIST_Customers>. If this property is set to
false this tag is not included in the output.

3. dataQuery: All the queries which are defined in the template must be enclosed between this tag. The dataQuery tag can
contain one or more sqlStatement tags where we define the queries.

4. sqlStatement: This tag holds a single sql query which can be either a select statement/ procedure call. This has an attribute
name which is used in the group tag in source attribute. The query may contain bind parameters which are as shown in the
above example. The bind parameters are passed by iReceivables code. The parameters passed are created as tags in the output
xml.
Data Template with a sample Example
5. dataStructure: This tag holds one or more groups based on the number of sqlStatement in the dataQuery tag.

6. group: This tag contains the elements defined in the group. The group has two attributes name and source. The name
attribute is used as the tag in the output xml and source is where the sqlStatement name is defined. A group is always formed
based on a source which is either query/procedure. In the above example the source is “Query1”

7. element: The element defines the name of the element which is seen in the output xml. The element tag has two attributes
name- the name which it should display in the output xml, value is the value from the query which is defined in the source of
the group.

Below is the output after processing the above template using XDO Data Template processor.
Identify the Data Template and attributes for the Template
Seeded Data Template looks like below

<?xml version = '1.0' encoding = 'UTF-8'?>


<!-- $Header: ARI_CUST_STMT_DataTemplate.xml 120.0.12010000.1 2012/01/17 09:02:23 parln noship $ -->
<!-- dbdrv: exec java oracle/apps/xdo/oa/util XDOLoader.class java &phase=dat checkfile:~PROD:patch/115/publisher/defs:ARI_CUST_STMT_DataTemplate.xml
UPLOAD -DB_USERNAME &un_apps -DB_PASSWORD &pw_apps -JDBC_CONNECTION &jdbc_db_addr -LOB_TYPE DATA_TEMPLATE -APPS_SHORT_NAME
~PROD -LOB_CODE ARI_CUST_STMT -LANGUAGE 00 -XDO_FILE_TYPE XML-DATA-TEMPLATE -FILE_NAME
&fullpath:~PROD:patch/115/publisher/defs:ARI_CUST_STMT_DataTemplate.xml -->
<!-- GSCC_Category="Xdo Data Definition" -->

<dataTemplate name="CustomerStatement" description="export the data" version="1.0">


<properties>
<property name="xml_tag_case" value="as_are"/>
<!--<property name="include_rowsettag" value="FALSE"/>-->
</properties>
<dataQuery>
<sqlStatement name="Query1"> Query1 gets the customer information
<![CDATA[
SELECT
to_char(sysdate,'YYYY-MM-DD') statementDate, location,
arp_addr_pkg.format_address(hl.address_style,
hl.address1, hl.address2, hl.address3, hl.address4,
hl.city, hl.county, hl.state, hl.province,
hl.postal_code, terr.territory_short_name) concatenated_address,
hp.party_name customer_name,
hca.account_number customer_number,
mo_global.get_ou_name(hcsu.org_id) organization_name
FROM
hz_cust_site_uses hcsu,
hz_cust_acct_sites hcas,
hz_party_sites hps,
hz_locations hl,
fnd_territories_vl terr,
hz_cust_accounts hca,
hz_parties hp
WHERE
:useCustSiteId ='YES'
AND hcsu.site_use_id = :siteUseId
AND hcsu.cust_acct_site_id = hcas.cust_acct_site_id
AND hcas.party_site_id = hps.party_site_id
AND hcas.cust_account_id = hca.cust_account_id
AND hp.party_id = hca.party_id
AND hps.location_id = hl.location_id
AND hl.country = terr.territory_code(+)
UNION

SELECT to_char(sysdate,'YYYY-MM-DD') statementDate, null location, null concatenated_address,


hp.party_name customer_name,
hca.account_number customer_number,
mo_global.get_ou_name(:orgId) organization_name
FROM
hz_cust_accounts hca,
hz_parties hp
WHERE
:useCustId ='YES'
AND hca.cust_account_id = :custId
AND hca.party_id = hp.party_id
]]>
</sqlStatement>
<sqlStatement name="Query2"> Query2 gets the transaction information
<![CDATA[
SELECT
pmt_sch.trx_number,
pmt_sch.trx_type,
ari_utilities.get_lookup_meaning('INV/CM/ADJ', pmt_sch.trx_type) trx_type_meaning,
pmt_sch.TERMS_SEQUENCE_NUMBER,
pmt_sch.trx_date,
to_char(pmt_sch.trx_date, 'YYYY-MM-DD') StrTrxDate,
pmt_sch.due_date,
to_char(pmt_sch.due_date, 'YYYY-MM-DD') StrDueDate,
pmt_sch.AR_LOOKUP_CODE_STATUS_MEANING,
pmt_sch.ct_purchase_order,
pmt_sch.INVOICE_CURRENCY_CODE,
pmt_sch.amount_due_original,
to_char(pmt_sch.amount_due_original, fnd_currency_cache.get_format_mask(INVOICE_CURRENCY_CODE, 30)) AS
Amount_Due_Original_Formatted,
pmt_sch.AMOUNT_DUE_REMAINING,
to_char(pmt_sch.AMOUNT_DUE_REMAINING, fnd_currency_cache.get_format_mask(INVOICE_CURRENCY_CODE, 30)) AS
Amount_due_remaining_Formatted,
pmt_sch.AMOUNT_IN_DISPUTE,
to_char(pmt_sch.AMOUNT_IN_DISPUTE, fnd_currency_cache.get_format_mask(INVOICE_CURRENCY_CODE, 30)) AS
Amount_in_dispute_Formatted,
pmt_sch.disc_amt,
to_char(pmt_sch.disc_amt, fnd_currency_cache.get_format_mask(INVOICE_CURRENCY_CODE, 30)) AS Disc_amt_Formatted,
decode(pmt_sch.disc_amt,0,null,pmt_sch.discount_last_date) discount_last_date,
pmt_sch.customer_number,
pmt_sch.customer_name,
pmt_sch.bill_to_location,
pmt_sch.amount_in_claim,
to_char(pmt_sch.amount_in_claim, fnd_currency_cache.get_format_mask(INVOICE_CURRENCY_CODE, 30)) AS Amount_in_Claim_Formatted,
pmt_sch.ON_ACCOUNT_AMOUNT,
to_char(pmt_sch.ON_ACCOUNT_AMOUNT, fnd_currency_cache.get_format_mask(INVOICE_CURRENCY_CODE, 30)) AS
Amount_on_Account_Formatted,
customerContact,
sales_orders
FROM
(

SELECT
ct.PURCHASE_ORDER AS CT_PURCHASE_ORDER,
ArPaymentSchedulesV.TRX_NUMBER trx_number,
ArPaymentSchedulesV.TRX_DATE trx_date,
ArPaymentSchedulesV.AMOUNT_DUE_ORIGINAL amount_due_original,
ArPaymentSchedulesV.CUSTOMER_ID,
ArPaymentSchedulesV.CUSTOMER_SITE_USE_ID,
ArPaymentSchedulesV.class as trx_type,
ArPaymentSchedulesV.TERMS_SEQUENCE_NUMBER,
DECODE(ArPaymentSchedulesV.CLASS,'PMT',
(SELECT -sum(app.amount_applied)
FROM AR_PAYMENT_SCHEDULES ps, ar_receivable_applications app
WHERE ps.customer_id = ArPaymentSchedulesV.customer_id
AND decode( (ArPaymentSchedulesV.CUSTOMER_SITE_USE_ID),
NULL, nvl(ps.customer_site_use_id,-10), ArPaymentSchedulesV.CUSTOMER_SITE_USE_ID)= nvl(ps.customer_site_use_id,-10)
AND ps.invoice_currency_code = ArPaymentSchedulesV.INVOICE_CURRENCY_CODE
AND app.cash_receipt_id = ps.cash_receipt_id
AND nvl( app.confirmed_flag, 'Y' ) = 'Y'
AND app.status = 'UNAPP'
AND app.cash_receipt_id = ArPaymentSchedulesV.CASH_RECEIPT_ID
),
ArPaymentSchedulesV.AMOUNT_DUE_REMAINING)
AS AMOUNT_DUE_REMAINING,

(SELECT CASE WHEN to_char(:TemplateType)='ARICUSTMTCNTCT' THEN


(SELECT RTRIM (XMLAGG (XMLELEMENT (E,XMLATTRIBUTES (sales_order|| ',' AS "Seg"))
ORDER BY sales_order ASC).EXTRACT ('./E[not(@Seg = preceding-sibling::E/@Seg)]/@Seg'),',')
FROM ra_customer_trx_lines ral where ral.customer_trx_id = ct.customer_trx_id)
ELSE
(select null from dual)
END from dual)
AS sales_orders,
(SELECT CASE WHEN to_char(:TemplateType)='ARICUSTMTCNTCT' THEN
(SELECT party.person_first_name ||' '|| party.person_last_name customerContact
FROM hz_cust_account_roles acct_role,
hz_relationships rel,
hz_parties party
WHERE
acct_role.cust_account_role_id = ct.BILL_TO_CONTACT_ID
AND acct_role.ROLE_TYPE = 'CONTACT'
AND acct_role.party_id = rel.party_id
AND rel.subject_id = party.party_id
AND rel.SUBJECT_TABLE_NAME = 'HZ_PARTIES'
AND rel.OBJECT_TABLE_NAME = 'HZ_PARTIES'
AND rel.DIRECTIONAL_FLAG = 'F')
ELSE
(SELECT null from dual)
END FROM dual)
AS customerContact,

DECODE(ArPaymentSchedulesV.CLASS,'PMT', 0,
nvl(to_number(AR_IREC_PAYMENTS.get_discount_wrapper(ArPaymentSchedulesV.PAYMENT_SCHEDULE_ID,ArPaymentSchedulesV.AMOUNT_DUE_REMAININ
G)),0)) as disc_amt,

(SELECT min(DECODE(TLD.DISCOUNT_DAYS ,NULL ,NVL(TLD.DISCOUNT_DATE, DECODE ( LEAST(TO_NUMBER(TO_CHAR(PS.TRX_DATE,'DD')),


NVL(T.DUE_CUTOFF_DAY,32)) ,T.DUE_CUTOFF_DAY,LAST_DAY(ADD_MONTHS(PS.TRX_DATE, TLD.DISCOUNT_MONTHS_FORWARD) )+
LEAST(TLD.DISCOUNT_DAY_OF_MONTH, TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(PS.TRX_DATE,
TLD.DISCOUNT_MONTHS_FORWARD+1)),'DD'))) ,
LAST_DAY(ADD_MONTHS(PS.TRX_DATE,TLD.DISCOUNT_MONTHS_FORWARD-1)) +
LEAST(TLD.DISCOUNT_DAY_OF_MONTH ,TO_NUMBER(TO_CHAR(LAST_DAY(
ADD_MONTHS(PS.TRX_DATE,TLD.DISCOUNT_MONTHS_FORWARD)),'DD'))) ) ) ,
PS.TRX_DATE + TLD.DISCOUNT_DAYS) +
TO_NUMBER(DECODE(AR_IREC_PAYMENTS.is_grace_days_enabled_wrapper,'Y',
nvl(CUST_SITE_LEVEL.discount_grace_days,
nvl(CUST_ACCT_LEVEL.discount_grace_days,0) ),
0))) last_date
FROM AR_PAYMENT_SCHEDULES ps, RA_TERMS_LINES_DISCOUNTS TLD,
RA_TERMS T,
HZ_CUSTOMER_PROFILES CUST_SITE_LEVEL,
HZ_CUSTOMER_PROFILES CUST_ACCT_LEVEL
WHERE ArPaymentSchedulesV.payment_schedule_id = ps.payment_schedule_id
AND cust_site_level.cust_account_id(+) = ps.customer_id
AND cust_site_level.site_use_id(+) = ps.customer_site_use_id
AND cust_acct_level.cust_account_id = ps.customer_id
AND cust_acct_level.site_use_id IS NULL
AND t.term_id = ps.term_id
AND tld.term_id = t.term_id
AND tld.sequence_num = ps.terms_sequence_number
AND trunc(DECODE(TLD.DISCOUNT_DAYS ,NULL ,NVL(TLD.DISCOUNT_DATE,
DECODE ( LEAST(TO_NUMBER(TO_CHAR(PS.TRX_DATE,'DD')),
NVL(T.DUE_CUTOFF_DAY,32)) ,T.DUE_CUTOFF_DAY,LAST_DAY(
ADD_MONTHS(PS.TRX_DATE, TLD.DISCOUNT_MONTHS_FORWARD) ) +
LEAST(TLD.DISCOUNT_DAY_OF_MONTH,
TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(PS.TRX_DATE,
TLD.DISCOUNT_MONTHS_FORWARD+1)),'DD'))) ,
LAST_DAY(ADD_MONTHS(PS.TRX_DATE,TLD.DISCOUNT_MONTHS_FORWARD-1)) +
LEAST(TLD.DISCOUNT_DAY_OF_MONTH ,TO_NUMBER(TO_CHAR(LAST_DAY(
ADD_MONTHS(PS.TRX_DATE,TLD.DISCOUNT_MONTHS_FORWARD)),'DD'))) ) ) ,
PS.TRX_DATE + TLD.DISCOUNT_DAYS) +
TO_NUMBER(DECODE(AR_IREC_PAYMENTS.is_grace_days_enabled_wrapper,'Y',
nvl(CUST_SITE_LEVEL.discount_grace_days,
nvl(CUST_ACCT_LEVEL.discount_grace_days,0) ),
0)))>=trunc(sysdate) ) AS discount_last_date,
ArPaymentSchedulesV.PAYMENT_SCHEDULE_ID,
ArPaymentSchedulesV.DUE_DATE,

(SELECT nvl ((SELECT fnd_message.get_string('AR', 'ARI_STATUS_OVERDUE') FROM dual WHERE ( trunc(sysdate) > ArPaymentSchedulesV.due_date ) AND
ArPaymentSchedulesV.CLASS <> 'PMT'AND ArPaymentSchedulesV.STATUS = 'OP'), ARI_UTILITIES.get_lookup_meaning('PAYMENT_SCHEDULE_STATUS',
ArPaymentSchedulesV.STATUS))
FROM DUAL
) AS AR_LOOKUP_CODE_STATUS_MEANING,
ArPaymentSchedulesV.AMOUNT_IN_DISPUTE,
acct.account_number customer_number,
acct.account_name customer_name,
billto_uses.Location bill_to_location,
shipto_uses.Location ship_to_location,
ArPaymentSchedulesV.CASH_RECEIPT_ID,
ARI_UTILITIES.get_lookup_meaning('INV/CM/ADJ', ArPaymentSchedulesV.class) as ACCT_DTLS_VIEW_TRX_TYPE,
ArPaymentSchedulesV.INVOICE_CURRENCY_CODE,
DECODE(ArPaymentSchedulesV.CLASS,'PMT',
(SELECT -sum(app.amount_applied)
FROM AR_PAYMENT_SCHEDULES ps, ar_receivable_applications app
WHERE ps.customer_id = ArPaymentSchedulesV.customer_id
AND decode( (ArPaymentSchedulesV.CUSTOMER_SITE_USE_ID),
NULL, nvl(ps.customer_site_use_id,-10),
ArPaymentSchedulesV.CUSTOMER_SITE_USE_ID)= nvl(ps.customer_site_use_id,-10)
AND ps.invoice_currency_code =ArPaymentSchedulesV.INVOICE_CURRENCY_CODE
AND app.cash_receipt_id = ps.cash_receipt_id
AND app.applied_payment_schedule_id = -4
AND nvl( app.confirmed_flag, 'Y' ) = 'Y'
AND app.status = 'OTHER ACC'
AND app.cash_receipt_id = ArPaymentSchedulesV.CASH_RECEIPT_ID), null)
AS amount_in_claim,
DECODE(ArPaymentSchedulesV.CLASS,'PMT',
( SELECT -sum(app.amount_applied)
FROM AR_PAYMENT_SCHEDULES ps, ar_receivable_applications app
WHERE ps.customer_id = ArPaymentSchedulesV.customer_id
AND decode( (ArPaymentSchedulesV.CUSTOMER_SITE_USE_ID),
NULL, nvl(ps.customer_site_use_id,-10), ArPaymentSchedulesV.CUSTOMER_SITE_USE_ID)= nvl(ps.customer_site_use_id,-10)
AND ps.invoice_currency_code = ArPaymentSchedulesV.INVOICE_CURRENCY_CODE
AND app.cash_receipt_id = ps.cash_receipt_id
AND nvl( app.confirmed_flag, 'Y' ) = 'Y'
AND app.status = 'ACC'
AND app.cash_receipt_id = ArPaymentSchedulesV.CASH_RECEIPT_ID),null)
AS ON_ACCOUNT_AMOUNT
FROM
AR_PAYMENT_SCHEDULES ArPaymentSchedulesV,
ra_customer_trx ct, hz_cust_accounts acct,ra_terms t,ar_lookups al,
ar_irec_user_acct_sites_all auasa,
hz_cust_site_uses billto_uses,
hz_cust_site_uses shipto_uses
WHERE
ArPaymentSchedulesV.customer_trx_id = ct.customer_trx_id(+)
AND ArPaymentSchedulesV.STATUS = 'OP'
AND billto_uses.site_use_id(+) = ct.bill_to_site_use_id
AND shipto_uses.site_use_id (+)=ct.ship_to_site_use_id
AND shipto_uses.site_use_code(+)='SHIP_TO'
AND (acct.cust_account_id = ArPaymentSchedulesV.customer_id OR (auasa.CUSTOMER_SITE_USE_ID = -1
AND ArPaymentSchedulesV.CUSTOMER_SITE_USE_ID IS NULL))
AND ArPaymentSchedulesV.customer_id =:customerId
AND ArPaymentSchedulesV.INVOICE_CURRENCY_CODE =:CurrencyCode
AND ArPaymentSchedulesV.customer_id = auasa.customer_id
AND ArPaymentSchedulesV.customer_site_use_id = auasa.customer_site_use_id
AND auasa.user_id = FND_GLOBAL.USER_ID
AND auasa.session_id =:sessionId
AND ct.term_id = t.term_id(+)
AND al.lookup_type='ARI_PMT_APPROVAL_STATUS'
AND al.lookup_code=nvl(ArPaymentSchedulesV.PAYMENT_APPROVAL,'PENDING')
AND(TRUNC(ArPaymentSchedulesV.trx_date)) >= trunc(decode( nvl(FND_PROFILE.VALUE('ARI_FILTER_TRXDATE_OLDER'), 0), 0,
ArPaymentSchedulesV.trx_date, (sysdate-FND_PROFILE.VALUE('ARI_FILTER_TRXDATE_OLDER'))))
AND (ct.printing_option = decode(nvl(FND_PROFILE.VALUE('ARI_FILTER_DONOTPRINT_TRX'), 'NOT'), 'Y', 'PRI', ct.printing_option) OR
ArPaymentSchedulesV.CLASS='PMT')
)pmt_sch
]]>
</sqlStatement>
<sqlStatement name="Query3"> Query3 to get aging information.
<![CDATA[
SELECT
:BucketTitlea AS BucketTitle0,
:BucketTitleb AS BucketTitle1,
:BucketTitlec AS BucketTitle2,
:BucketTitled AS BucketTitle3,
:BucketTitlee AS BucketTitle4,
:BucketAmountFormatteda AS BucketAmountFormatted0,
:BucketAmountFormattedb AS BucketAmountFormatted1,
:BucketAmountFormattedc AS BucketAmountFormatted2,
:BucketAmountFormattedd AS BucketAmountFormatted3,
:BucketAmountFormattede AS BucketAmountFormatted4,
:TOTAL_OVERDUE_INVOICES AS TOTAL_OVERDUE_INVOICES,
:Overdue_Invoices_Formatted AS Overdue_Invoices_Formatted,
:Open_Invoices_Formatted AS Open_Invoices_Formatted,
:UNAPPL_PAYMENTS AS UNAPPL_PAYMENTS,
:Payments_Formatted AS Payments_Formatted,
:UNAPPLIED_CM AS UNAPPLIED_CM,
:Unapplied_Cm_Formatted AS Unapplied_Cm_Formatted,
:PENDING_REQUEST AS PENDING_REQUEST,
:Pending_Request_Formatted AS Pending_Request_Formatted,
:CurrencyCode AS CURRENCY_CODE,
:customerId AS CUSTOMER_ID,
:ACCOUNT_BALANCE AS ACCOUNT_BALANCE,
:Account_Balance_Formatted AS Account_Balance_Formatted,
:AS_OF_DATE AS AS_OF_DATE,
:REMAINING_GUARANTEE AS REMAINING_GUARANTEE,
:Remaining_Guarantee_Formatted AS Remaining_Guarantee_Formatted
FROM dual
]]>
</sqlStatement>
</dataQuery>
<dataStructure>
<group name="Customers" source="Query1">
<element name="OrganizationName" value="organization_name"/>
<element name="CustomerHdrName" value="customer_name"/>
<element name="AccountNumber" value="customer_number"/>
<element name="StatementDate" value="statementDate"/>
<element name="Location" value="location"/>
<element name="Address" value="concatenated_address"/>
<group name="CustomerStatementVORow" source="Query2">
<element name="TrxNumber" value="trx_number"/>
<element name="TrxType" value="trx_type"/>
<element name="TrxTypeMeaning" value="trx_type_meaning"/>
<element name="TermsSequenceNumber" value="TERMS_SEQUENCE_NUMBER"/>
<element name="TrxDate" value="trx_date"/>
<element name="Strtrxdate" value="StrTrxDate"/>
<element name="Strduedate" value="StrDueDate"/>
<element name="AmountDueRemainingFormatted" value="Amount_due_remaining_Formatted"/>
<element name="customerContact" value="customerContact"/>
<element name="CtPurchaseOrder" value="ct_purchase_order"/>
<element name="salesOrders" value="sales_orders"/>
<element name="dueDate" value="due_date"/>
<element name="ArLookupCodeStatusMeaning" value="AR_LOOKUP_CODE_STATUS_MEANING"/>
<element name="AmountDueOriginal" value="amount_due_original"/>
<element name="AmountDueOriginalFormatted" value="Amount_Due_Original_Formatted"/>
<element name="DiscAmt" value="disc_amt"/>
<element name="DiscAmtFormatted" value="Disc_amt_Formatted"/>
<element name="CustomerNumber" value="customer_number"/>
<element name="CustomerName" value="customer_name"/>
<element name="BillToLocation" value="bill_to_location"/>
</group>
<group name="PageVORow" source="Query3">
<element name="BucketTitle0" value="BucketTitle0"/>
<element name="BucketTitle1" value="BucketTitle1"/>
<element name="BucketTitle2" value="BucketTitle2"/>
<element name="BucketTitle3" value="BucketTitle3"/>
<element name="BucketTitle4" value="BucketTitle4"/>
<element name="BucketAmountFormatted0" value="BucketAmountFormatted0"/>
<element name="BucketAmountFormatted1" value="BucketAmountFormatted1"/>
<element name="BucketAmountFormatted2" value="BucketAmountFormatted2"/>
<element name="BucketAmountFormatted3" value="BucketAmountFormatted3"/>
<element name="BucketAmountFormatted4" value="BucketAmountFormatted4"/>
<element name="TotalOverdueInvoices" value="TOTAL_OVERDUE_INVOICES"/>
<element name="OverdueInvoicesFormatted" value="Overdue_Invoices_Formatted"/>
<element name="TotalOpenInvoices" value="TOTAL_OPEN_INVOICES"/>
<element name="OpenInvoicesFormatted" value="Open_Invoices_Formatted"/>
<element name="UnapplPayments" value="UNAPPL_PAYMENTS"/>
<element name="PaymentsFormatted" value="Payments_Formatted"/>
<element name="UnappliedCm" value="UNAPPLIED_CM"/>
<element name="UnappliedCmFormatted" value="Unapplied_Cm_Formatted"/>
<element name="PendingRequest" value="PENDING_REQUEST"/>
<element name="PendingRequestFormatted" value="Pending_Request_Formatted"/>
<element name="CurrencyCode" value="CURRENCY_CODE"/>
<element name="CustomerId" value="CUSTOMER_ID"/>
<element name="AccountBalance" value="ACCOUNT_BALANCE"/>
<element name="AccountBalanceFormatted" value="Account_Balance_Formatted"/>
<element name="AsOfDate" value="AS_OF_DATE"/>
<element name="RemainingGuarantee" value="REMAINING_GUARANTEE"/>
<element name="RemainingGuaranteeFormatted" value="Remaining_Guarantee_Formatted"/>
</group>

</group>
</dataStructure>
</dataTemplate>
Identify the Data Template and attributes for the Template
Modifying the Data Template and attributes for the
Template

• Step 11 – Changing the template and the Data Template for a new requirement.

For example if SalesOrder and Customer Contact needs to be added to the Customer Statement.
Modifying the Data Template and attributes for the
Template

• Step 12 – Changing the Data Template to get the values of SalesOrder and Customer Contact. These columns are
added to the template which gets the data from Query2 of Data Template.

So the following highlighted changes are made to Query2

<sqlStatement name="Query2"> Query2 gets the transaction information


<![CDATA[
SELECT
pmt_sch.trx_number,
pmt_sch.trx_type,
ari_utilities.get_lookup_meaning('INV/CM/ADJ', pmt_sch.trx_type) trx_type_meaning,
pmt_sch.TERMS_SEQUENCE_NUMBER,
pmt_sch.trx_date,
to_char(pmt_sch.trx_date, 'YYYY-MM-DD') StrTrxDate,
pmt_sch.due_date,
to_char(pmt_sch.due_date, 'YYYY-MM-DD') StrDueDate,
pmt_sch.AR_LOOKUP_CODE_STATUS_MEANING,
pmt_sch.ct_purchase_order,
pmt_sch.INVOICE_CURRENCY_CODE,
pmt_sch.amount_due_original,
to_char(pmt_sch.amount_due_original, fnd_currency_cache.get_format_mask(INVOICE_CURRENCY_CODE, 30)) AS
Amount_Due_Original_Formatted,
pmt_sch.AMOUNT_DUE_REMAINING,
to_char(pmt_sch.AMOUNT_DUE_REMAINING, fnd_currency_cache.get_format_mask(INVOICE_CURRENCY_CODE, 30)) AS
Amount_due_remaining_Formatted,
pmt_sch.AMOUNT_IN_DISPUTE,
to_char(pmt_sch.AMOUNT_IN_DISPUTE, fnd_currency_cache.get_format_mask(INVOICE_CURRENCY_CODE, 30)) AS
Amount_in_dispute_Formatted,
pmt_sch.disc_amt,
to_char(pmt_sch.disc_amt, fnd_currency_cache.get_format_mask(INVOICE_CURRENCY_CODE, 30)) AS Disc_amt_Formatted,
decode(pmt_sch.disc_amt,0,null,pmt_sch.discount_last_date) discount_last_date,
pmt_sch.customer_number,
pmt_sch.customer_name,
pmt_sch.bill_to_location,
pmt_sch.amount_in_claim,
to_char(pmt_sch.amount_in_claim, fnd_currency_cache.get_format_mask(INVOICE_CURRENCY_CODE, 30)) AS Amount_in_Claim_Formatted,
pmt_sch.ON_ACCOUNT_AMOUNT,
to_char(pmt_sch.ON_ACCOUNT_AMOUNT, fnd_currency_cache.get_format_mask(INVOICE_CURRENCY_CODE, 30)) AS
Amount_on_Account_Formatted,
customerContact,
sales_orders
FROM
( Dynamic Select statements

SELECT
ct.PURCHASE_ORDER AS CT_PURCHASE_ORDER,
ArPaymentSchedulesV.TRX_NUMBER trx_number,
ArPaymentSchedulesV.TRX_DATE trx_date,
ArPaymentSchedulesV.AMOUNT_DUE_ORIGINAL amount_due_original,
ArPaymentSchedulesV.CUSTOMER_ID,
ArPaymentSchedulesV.CUSTOMER_SITE_USE_ID,
ArPaymentSchedulesV.class as trx_type,
ArPaymentSchedulesV.TERMS_SEQUENCE_NUMBER,
DECODE(ArPaymentSchedulesV.CLASS,'PMT',
(SELECT -sum(app.amount_applied)
FROM AR_PAYMENT_SCHEDULES ps, ar_receivable_applications app
WHERE ps.customer_id = ArPaymentSchedulesV.customer_id
AND decode( (ArPaymentSchedulesV.CUSTOMER_SITE_USE_ID),
NULL, nvl(ps.customer_site_use_id,-10), ArPaymentSchedulesV.CUSTOMER_SITE_USE_ID)= nvl(ps.customer_site_use_id,-10)
AND ps.invoice_currency_code = ArPaymentSchedulesV.INVOICE_CURRENCY_CODE
AND app.cash_receipt_id = ps.cash_receipt_id
AND nvl( app.confirmed_flag, 'Y' ) = 'Y'
AND app.status = 'UNAPP'
AND app.cash_receipt_id = ArPaymentSchedulesV.CASH_RECEIPT_ID
),
ArPaymentSchedulesV.AMOUNT_DUE_REMAINING)
AS AMOUNT_DUE_REMAINING,
(SELECT CASE WHEN to_char(:TemplateType)='ARICUSTMTCNTCT' THEN
(SELECT RTRIM (XMLAGG (XMLELEMENT (E,XMLATTRIBUTES (sales_order|| ',' AS "Seg"))
ORDER BY sales_order ASC).EXTRACT ('./E[not(@Seg = preceding-sibling::E/@Seg)]/@Seg'),',') Query for Sales Order We use CASE and check
FROM ra_customer_trx_lines ral where ral.customer_trx_id = ct.customer_trx_id) the Template Code to improve performance as
ELSE this query will not be executed for all the
(select null from dual) templates which does not require sales order.
END from dual)
AS sales_orders,
(SELECT CASE WHEN to_char(:TemplateType)='ARICUSTMTCNTCT' THEN
(SELECT party.person_first_name ||' '|| party.person_last_name customerContact
FROM hz_cust_account_roles acct_role,
hz_relationships rel,
hz_parties party
WHERE
acct_role.cust_account_role_id = ct.BILL_TO_CONTACT_ID
AND acct_role.ROLE_TYPE = 'CONTACT' Query for getting Invoice Contact.
Use CASE and Check for Template Code
‘'ARICUSTMTCNTCT'’to improve
performance
AND acct_role.party_id = rel.party_id
AND rel.subject_id = party.party_id
AND rel.SUBJECT_TABLE_NAME = 'HZ_PARTIES'
AND rel.OBJECT_TABLE_NAME = 'HZ_PARTIES'
AND rel.DIRECTIONAL_FLAG = 'F')
ELSE
(SELECT null from dual)
END FROM dual)
AS customerContact,

DECODE(ArPaymentSchedulesV.CLASS,'PMT', 0,
nvl(to_number(AR_IREC_PAYMENTS.get_discount_wrapper(ArPaymentSchedulesV.PAYMENT_SCHEDULE_ID,ArPaymentSchedulesV.AMOUNT_DUE_REMAININ
G)),0)) as disc_amt,

(SELECT min(DECODE(TLD.DISCOUNT_DAYS ,NULL ,NVL(TLD.DISCOUNT_DATE, DECODE ( LEAST(TO_NUMBER(TO_CHAR(PS.TRX_DATE,'DD')),


NVL(T.DUE_CUTOFF_DAY,32)) ,T.DUE_CUTOFF_DAY,LAST_DAY(ADD_MONTHS(PS.TRX_DATE, TLD.DISCOUNT_MONTHS_FORWARD) )+
LEAST(TLD.DISCOUNT_DAY_OF_MONTH, TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(PS.TRX_DATE,
TLD.DISCOUNT_MONTHS_FORWARD+1)),'DD'))) ,
LAST_DAY(ADD_MONTHS(PS.TRX_DATE,TLD.DISCOUNT_MONTHS_FORWARD-1)) +
LEAST(TLD.DISCOUNT_DAY_OF_MONTH ,TO_NUMBER(TO_CHAR(LAST_DAY(
ADD_MONTHS(PS.TRX_DATE,TLD.DISCOUNT_MONTHS_FORWARD)),'DD'))) ) ) ,
PS.TRX_DATE + TLD.DISCOUNT_DAYS) +
TO_NUMBER(DECODE(AR_IREC_PAYMENTS.is_grace_days_enabled_wrapper,'Y',
nvl(CUST_SITE_LEVEL.discount_grace_days,
nvl(CUST_ACCT_LEVEL.discount_grace_days,0) ),
0))) last_date
FROM AR_PAYMENT_SCHEDULES ps, RA_TERMS_LINES_DISCOUNTS TLD,
RA_TERMS T,
HZ_CUSTOMER_PROFILES CUST_SITE_LEVEL,
HZ_CUSTOMER_PROFILES CUST_ACCT_LEVEL
WHERE ArPaymentSchedulesV.payment_schedule_id = ps.payment_schedule_id
AND cust_site_level.cust_account_id(+) = ps.customer_id
AND cust_site_level.site_use_id(+) = ps.customer_site_use_id
AND cust_acct_level.cust_account_id = ps.customer_id
AND cust_acct_level.site_use_id IS NULL
AND t.term_id = ps.term_id
AND tld.term_id = t.term_id
AND tld.sequence_num = ps.terms_sequence_number
AND trunc(DECODE(TLD.DISCOUNT_DAYS ,NULL ,NVL(TLD.DISCOUNT_DATE,
DECODE ( LEAST(TO_NUMBER(TO_CHAR(PS.TRX_DATE,'DD')),
NVL(T.DUE_CUTOFF_DAY,32)) ,T.DUE_CUTOFF_DAY,LAST_DAY(
ADD_MONTHS(PS.TRX_DATE, TLD.DISCOUNT_MONTHS_FORWARD) ) +
LEAST(TLD.DISCOUNT_DAY_OF_MONTH,
TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(PS.TRX_DATE,
TLD.DISCOUNT_MONTHS_FORWARD+1)),'DD'))) ,
LAST_DAY(ADD_MONTHS(PS.TRX_DATE,TLD.DISCOUNT_MONTHS_FORWARD-1)) +
LEAST(TLD.DISCOUNT_DAY_OF_MONTH ,TO_NUMBER(TO_CHAR(LAST_DAY(
ADD_MONTHS(PS.TRX_DATE,TLD.DISCOUNT_MONTHS_FORWARD)),'DD'))) ) ) ,
PS.TRX_DATE + TLD.DISCOUNT_DAYS) +
TO_NUMBER(DECODE(AR_IREC_PAYMENTS.is_grace_days_enabled_wrapper,'Y',
nvl(CUST_SITE_LEVEL.discount_grace_days,
nvl(CUST_ACCT_LEVEL.discount_grace_days,0) ),
0)))>=trunc(sysdate) ) AS discount_last_date,
ArPaymentSchedulesV.PAYMENT_SCHEDULE_ID,
ArPaymentSchedulesV.DUE_DATE,

(SELECT nvl ((SELECT fnd_message.get_string('AR', 'ARI_STATUS_OVERDUE') FROM dual WHERE ( trunc(sysdate) > ArPaymentSchedulesV.due_date ) AND
ArPaymentSchedulesV.CLASS <> 'PMT'AND ArPaymentSchedulesV.STATUS = 'OP'), ARI_UTILITIES.get_lookup_meaning('PAYMENT_SCHEDULE_STATUS',
ArPaymentSchedulesV.STATUS))
FROM DUAL
) AS AR_LOOKUP_CODE_STATUS_MEANING,
ArPaymentSchedulesV.AMOUNT_IN_DISPUTE,
acct.account_number customer_number,
acct.account_name customer_name,
billto_uses.Location bill_to_location,
shipto_uses.Location ship_to_location,
ArPaymentSchedulesV.CASH_RECEIPT_ID,
ARI_UTILITIES.get_lookup_meaning('INV/CM/ADJ', ArPaymentSchedulesV.class) as ACCT_DTLS_VIEW_TRX_TYPE,
ArPaymentSchedulesV.INVOICE_CURRENCY_CODE,
DECODE(ArPaymentSchedulesV.CLASS,'PMT',
(SELECT -sum(app.amount_applied)
FROM AR_PAYMENT_SCHEDULES ps, ar_receivable_applications app
WHERE ps.customer_id = ArPaymentSchedulesV.customer_id
AND decode( (ArPaymentSchedulesV.CUSTOMER_SITE_USE_ID),
NULL, nvl(ps.customer_site_use_id,-10),
ArPaymentSchedulesV.CUSTOMER_SITE_USE_ID)= nvl(ps.customer_site_use_id,-10)
AND ps.invoice_currency_code =ArPaymentSchedulesV.INVOICE_CURRENCY_CODE
AND app.cash_receipt_id = ps.cash_receipt_id
AND app.applied_payment_schedule_id = -4
AND nvl( app.confirmed_flag, 'Y' ) = 'Y'
AND app.status = 'OTHER ACC'
AND app.cash_receipt_id = ArPaymentSchedulesV.CASH_RECEIPT_ID), null)
AS amount_in_claim,
DECODE(ArPaymentSchedulesV.CLASS,'PMT',
( SELECT -sum(app.amount_applied)
FROM AR_PAYMENT_SCHEDULES ps, ar_receivable_applications app
WHERE ps.customer_id = ArPaymentSchedulesV.customer_id
AND decode( (ArPaymentSchedulesV.CUSTOMER_SITE_USE_ID),
NULL, nvl(ps.customer_site_use_id,-10), ArPaymentSchedulesV.CUSTOMER_SITE_USE_ID)= nvl(ps.customer_site_use_id,-10)
AND ps.invoice_currency_code = ArPaymentSchedulesV.INVOICE_CURRENCY_CODE
AND app.cash_receipt_id = ps.cash_receipt_id
AND nvl( app.confirmed_flag, 'Y' ) = 'Y'
AND app.status = 'ACC'
AND app.cash_receipt_id = ArPaymentSchedulesV.CASH_RECEIPT_ID),null)
AS ON_ACCOUNT_AMOUNT
FROM
AR_PAYMENT_SCHEDULES ArPaymentSchedulesV,
ra_customer_trx ct, hz_cust_accounts acct,ra_terms t,ar_lookups al,
ar_irec_user_acct_sites_all auasa,
hz_cust_site_uses billto_uses,
hz_cust_site_uses shipto_uses
WHERE
ArPaymentSchedulesV.customer_trx_id = ct.customer_trx_id(+)
AND ArPaymentSchedulesV.STATUS = 'OP'
AND billto_uses.site_use_id(+) = ct.bill_to_site_use_id
AND shipto_uses.site_use_id (+)=ct.ship_to_site_use_id
AND shipto_uses.site_use_code(+)='SHIP_TO'
AND (acct.cust_account_id = ArPaymentSchedulesV.customer_id OR (auasa.CUSTOMER_SITE_USE_ID = -1
AND ArPaymentSchedulesV.CUSTOMER_SITE_USE_ID IS NULL))
AND ArPaymentSchedulesV.customer_id =:customerId
AND ArPaymentSchedulesV.INVOICE_CURRENCY_CODE =:CurrencyCode
AND ArPaymentSchedulesV.customer_id = auasa.customer_id
AND ArPaymentSchedulesV.customer_site_use_id = auasa.customer_site_use_id
AND auasa.user_id = FND_GLOBAL.USER_ID
AND auasa.session_id =:sessionId
AND ct.term_id = t.term_id(+)
AND al.lookup_type='ARI_PMT_APPROVAL_STATUS'
AND al.lookup_code=nvl(ArPaymentSchedulesV.PAYMENT_APPROVAL,'PENDING')
AND(TRUNC(ArPaymentSchedulesV.trx_date)) >= trunc(decode( nvl(FND_PROFILE.VALUE('ARI_FILTER_TRXDATE_OLDER'), 0), 0,
ArPaymentSchedulesV.trx_date, (sysdate-FND_PROFILE.VALUE('ARI_FILTER_TRXDATE_OLDER'))))
AND (ct.printing_option = decode(nvl(FND_PROFILE.VALUE('ARI_FILTER_DONOTPRINT_TRX'), 'NOT'), 'Y', 'PRI', ct.printing_option) OR
ArPaymentSchedulesV.CLASS='PMT')
)pmt_sch
]]>
</sqlStatement>
Bind Parameters available in Data Template
Below is the list of parameters passed by iReceivables:
<TemplateType>ARICUSTMT</TemplateType> --- The template Code which is selected
<useCustId>YES</useCustId> ---
<custId>1002</custId> --- The Customer Id for which the statement is required
<orgId>204</orgId> --- The organization ID of the particular customer
<useCustSiteId>NO</useCustSiteId> --- Boolean value whether to useCustSiteId.
<currencyCode>USD</currencyCode> --- The currency code in which the amounts needs to be displayed
<sessionId>XXXX</sessionId> --- Session Id for this particular transaction
<BucketAmountFormattede>XXXX</BucketAmountFormattede>
<BucketAmountFormattedd> XXXX </BucketAmountFormattedd>
<BucketAmountFormattedc> XXXX </BucketAmountFormattedc>
<BucketAmountFormattedb> XXXX </BucketAmountFormattedb>
<BucketAmountFormatteda> XXXX </BucketAmountFormatteda>
<BucketTitlea> XXXX </BucketTitlea>
<BucketTitleb> XXXX </BucketTitleb>
<BucketTitlec> XXXX </BucketTitlec>
<BucketTitled> XXXX </BucketTitled>
<BucketTitlee> XXXX </BucketTitlee>
<Open_Invoices_Formatted> XXXX </Open_Invoices_Formatted>
<Pending_Request_Formatted> XXXX /Pending_Request_Formatted> Parameters
<Remaining_Guarantee_Formatted>XXX</Remaining_Guarantee_Formatted> used in Query3
<ACCOUNT_BALANCE> XXXX</ACCOUNT_BALANCE>
<UNAPPL_PAYMENTS> XXXX </UNAPPL_PAYMENTS>
<Account_Balance_Formatted> XXXX </Account_Balance_Formatted>
<PENDING_REQUEST> XXXX </PENDING_REQUEST>
<TOTAL_OVERDUE_INVOICES> XXXX </TOTAL_OVERDUE_INVOICES>
<Payments_Formatted> XXXX </Payments_Formatted>
<UNAPPLIED_CM> XXXX </UNAPPLIED_CM>
<Overdue_Invoices_Formatted> XXXX </Overdue_Invoices_Formatted>
<Unapplied_Cm_Formatted> XXXX </Unapplied_Cm_Formatted>
<AS_OF_DATE> XXXX </AS_OF_DATE>
<REMAINING_GUARANTEE> XXXX </REMAINING_GUARANTEE>
<TOTAL_OPEN_INVOICES> XXXX </TOTAL_OPEN_INVOICES>
Adding Available Data Template Attributes to Template

• Step 13 – Now, open the previously saved template file and use File >> Save As and give a new name and save the
same file

• Step 14 – Open the newly saved template (Which in effect is the same template that was downloaded from XML
Publisher). Modify the template to include the customer ID, in the appropriate position, as required. Copy any of the
already grayed-out data and past the same against the newly added field, as shown in the picture below: Please note
that a new field called “Customer ID” has been added in the template. An existing data source named “Customer
Name” has been copied from the template and pasted against the newly added field:
Adding Available Data Template Attributes to Template

• Step 15 – Select the “Customer Name” against the newly added “Customer ID” field. Right Click and select Properties as
done previously. In the “Text Form Field Options” Window – against the Default Text field – the data will appear as
Customer Name. Change this to “CustomerID”. Now, click on the “Add Help Text” button. This will launch the “Form
Field Help Text” window. This would by default appear as “<?CustomerName?>”. Type the exact name of the
“Attribute” selected from the list of attributes. Since the “Attribute” name we are using in this example is “CustomerID”,
modify the same in the “Form Field Help Text” window, as shown. Click on OK and again OK in the “Text Form Field
Options” window. Please note that the data in the Form Field Help Text is Case-Sensitive.
Adding Available Data Template Attributes to Template

• Step 16 – Now, with the above steps, a new field has been added to the customized template. Repeat Steps 13 and 14,
to include as many new attributes in the new template, as required. Be sure to start the first column with a “F” prefix
and end the last column with an “E” suffix. The attributes for “F” and “E” should be the same as the one given in the
original downloaded template. This is most important, for the data to loop against a given header context. Save the final
template. Be sure that the file format is RTF.
Uploading the Modified Template and using the same

• Step 17 – Now, the new template is ready. Navigate to “XML Publisher Administrator” Responsibility and Click on
templates. Click on “Create Template” button. Give a new Template Name and Code, as desired. Under Applications,
select the appropriate application, in this example – IReceivables. In the Data Definition, use the help option and select
the correct data definition for which we are creating this template. In our example the template is created for
“IReceivables Customers Statement Data Definition”. Use the “Browse” button to select the saved version of the
customized template. Please select the Type as “RTF” in the dropdown. Click on “Apply” button.
Uploading the Modified Template and using the same

• Step 18 –On successful upload of file, the same can be found under “Localized Templates” of the “View Template”
page.

• Step 19 – Now, navigate to IReceivables Responsibility >> Customer Search >> Account Summary page. The Template
LOV will now contain the newly created template as well. The newly created template can be used for statement
download and IReceivables will generate the output.

PDF to Word

You might also like