67% found this document useful (6 votes)
5K views

Oracle CRM Service Contracts Queries

This document provides queries to retrieve data from Oracle CRM Service Contracts tables for contract headers, lines, sublines, and billing information. It includes queries for the OKC_K_HEADERS_ALL_B table to retrieve header level contract data, and describes other key tables like OKC_K_LINES_B, OKS_BILL_SUB_LINES, and tables in other schemas that interact with service contracts data. Sections include contract header data, contract line data, contract billing data, and more.

Uploaded by

ata_rehman70
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
67% found this document useful (6 votes)
5K views

Oracle CRM Service Contracts Queries

This document provides queries to retrieve data from Oracle CRM Service Contracts tables for contract headers, lines, sublines, and billing information. It includes queries for the OKC_K_HEADERS_ALL_B table to retrieve header level contract data, and describes other key tables like OKC_K_LINES_B, OKS_BILL_SUB_LINES, and tables in other schemas that interact with service contracts data. Sections include contract header data, contract line data, contract billing data, and more.

Uploaded by

ata_rehman70
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 55

Oracle CRM Service Contracts Queries

SERVICE CONTRACTS QUERIES..................................................................3


SERVICE CONTRACT HEADER TABLE OKC_K_HEADERS_ALL_B................7
SERVICE CONTRACT HEADER ITEM VALIDATION ORGANIZATION............8
SERVICE CONTRACT HEADER OKS_K_HEADERS_B..................................9
SERVICE CONTRACT HEADER PARTY INFORMATION..............................11
SERVICE CONTRACT HEADER BILL TO / SHIP TO INFORMATION............12
SERVICE CONTRACT HEADER CUSTOMER CONTACT INFORMATION......13
SERVICE CONTRACT HEADER VENDOR CONTACT INFORMATION..........14
SERVICE CONTRACT HEADER PRICING / BILLING INFORMATION...........15
SERVICE CONTRACT HEADER RENEWAL TAB........................................19
SERVICE CONTRACT HEADER RENEWAL TAB........................................21
SERVICE CONTRACT HEADER RENEWAL TAB........................................22
SERVICE CONTRACT HEADER ADMIN TAB.............................................24
SERVICE CONTRACT LINES INFORMATION.............................................25
SERVICE CONTRACT LINES COVERAGE INFORMATION..........................27
SERVICE CONTRACT LINES COVERAGE INFORMATION..........................28
SERVICE CONTRACT LINES HOW TO IDENTIFY COVERAGE FOR A LINE. 29
SERVICE CONTRACT LINES RELATIONSHIP BETWEEN COVERAGE HEADER AND
LINE.........................................................................................................30
SERVICE COVERAGE; COMPLEX COVERAGE QUERY.................................31
SERVICE COVERAGE; COMPLEX COVERAGE QUERY.................................32
SERVICE CONTRACT LINES ACCOUNTS TAB (ITEM NAME).....................34
SERVICE CONTRACT LINES ACCOUNTS TAB (BILL TO / SHIP TO)...........35
SERVICE CONTRACT LINES EFFECTIVITIES TAB (INVOICE TEXT)............36
SERVICE CONTRACT LINES ACCOUNTS TAB (CONTACT INFORMATION).37
SERVICE CONTRACT LINES ACCOUNTS TAB (CONTACT INFORMATION).38
SERVICE CONTRACT LINES ACCOUNTS TAB (CONTACT INFORMATION).39
SERVICE CONTRACT SUBLINES (COVERED) PRODUCT INFORMATION...40
SERVICE CONTRACT LINES BILLING STREAM.........................................44
SERVICE CONTRACT LINES BILLING STREAM.........................................45
SERVICE CONTRACT LINES BILLING SCHEDULE.....................................46
SERVICE CONTRACT LINES STREAM / SCHEDULE QUERY......................47
SERVICE CONTRACT LINES STREAM / SCHEDULE QUERY......................48
SERVICE CONTRACT BILLING TABLES......................................................50
SERVICE CONTRACT BILLING TABLES......................................................51
SERVICE CONTRACT BILLING TABLES......................................................52
SERVICE CONTRACT BILLING TABLES......................................................53
E. Receivables Interface Data..................................................................55
G. Order Details for Contracts Created from Order Management............56

Oracle CRM Service Contracts Queries

SERVICE CONTRACTS QUERIES


We will create a Service Agreement. In each step of the process we will examine the
rows that are created in each table and pertinent columns that are frequently
referenced.
How to query service contracts tables and tables from other schemas to find
underlying data about contract headers, lines, sublines and contract billing in
11.5.10. (For R12 queries please see Note 816374.1).
This note gives a variety of queries which can be used to find the required data for a
particular contract.
In the SQL statements given, <xxx> represents text that needs to be replaced with
the actual values indicated between the brackets. For example, if you want to
execute a query for a contract with number Test1, then whenever you see <contract
number> in the SQL below, replace it with Test1.

Sections in this note are:


A. Contract Header Data
B. Contract Line Data
C. Contract Subline Data
D. Contract Billing Data
E. Receivables Interface Data
F. Subscription Contracts

Table: OKC_K_HEADERS_B
Product: OKC - Contracts Core
Description: Top level of a contract structure and groups all the lines and terms and
conditions of a contract.
Implementation/DBA Data: OKC.OKC_K_HEADERS_B
Table: OKC_K_ITEMS
Product: OKC - Contracts Core
Description: Contract items
Implementation/DBA Data: OKC.OKC_K_ITEMS
Table: OKC_K_LINES_B
Product: OKC - Contracts Core

Oracle CRM Service Contracts Queries

Description: Deliverable ITEMS grouped into a logical set usually defined by unitary
price, delivery or some other classification.
Implementation/DBA Data: OKC.OKC_K_LINES_B
Table: OKS_BILL_SUB_LINES
Product: OKS - Service Contracts
Description: Related to a lower level contract line eg. coverage level or product.
Implementation/DBA Data: OKS.OKS_BILL_SUB_LINES
Table: OKS_BILL_CONT_LINES
Product: OKS - Service Contracts
Description: Records which are sent to AR.
Implementation/DBA Data: OKS.OKS_BILL_CONT_LINES
Table: OKS_BILL_SUB_LINE_DTLS
Product: OKS - Service Contracts
Description: The detail of quantities and monetary amounts either regular or
adjustment.
Implementation/DBA Data: OKS.OKS_BILL_SUB_LINE_DTLS
Table: OKS_BILL_TRANSACTIONS
Product: OKS - Service Contracts
Description: The transaction (invoice, credit etc.) which is eventually received from
AR.
Implementation/DBA Data: OKS.OKS_BILL_TRANSACTIONS
Table: OKS_BILL_TXN_LINES
Product: OKS - Service Contracts
Description: Holds the actual transaction amount and tax returned from AR.
Implementation/DBA Data: OKS.OKS_BILL_TXN_LINES
Table: OKS_STREAM_LEVELS_B
Product: OKS - Service Contracts
Description: Service Contracts Billing Stream Levels
Implementation/DBA Data: OKS.OKS_STREAM_LEVELS_B
Table: OKS_REV_DISTRIBUTIONS
Product: OKS - Service Contracts
Description: Database table used for storing revenue distribution information for
service
contract lines.

Oracle CRM Service Contracts Queries

Implementation/DBA Data: OKS.OKS_REV_DISTRIBUTIONS


Further information on these tables can be found on eTRM Technical Reference
available via My Oracle Support.
The eTRM contains also the following information of the tables and ERD Diagrams:
- OKS - Service Contracts
- R11510 Service Contracts ERD.pdf
- sub_erd_billing.pdf
- sub_erd_billing_profile.pdf
- sub_erd_defaults.pdf
- sub_erd_order_details.pdf
- sub_erd_sales_credit.pdf
When AutoInvoice has been run program RAXTRX takes transactions that are on table
RA_INTERFACE_LINES_ALL, validates them and if valid, passes the information into
the AR tables,
- RA_CUSTOMER_TRX_ALL
- RA_CUSTOMER_TRX_LINES_ALL
- RA_CUST_TRX_LINE_GL_DIST_ALL
- RA_SALESCREDITS_ALL
- AR_PAYMENT_SCHEDULES_ALL
For terminations, transactions also create records on
AR_RECEIVABLE_APPLICATIONS_ALL.
An example of a query can be:
SELECTrcta.trx_numberinvoice_no,
rctla.line_numberinvoice_line_no,
txn.bill_instance_number,
rctla.inventory_item_id,
oks_hd.contract_number,
oks_hd.contract_number_modifier,
oks_ln.line_numbercont_line_no,
cii_oks.instance_id,
cii_oks.serial_numbersn
FROMokc_k_headers_boks_hd,
okc_k_lines_boks_ln,
oks_k_lines_boks_ln_sub,
okc_k_itemsoki,
oks_bill_txn_linestxn,
oks_bill_sub_linesbsl,

Oracle CRM Service Contracts Queries

okx_install_items_vocsi,
csi_item_instancescii_oks,
ra_customer_trx_allrcta,
ra_customer_trx_lines_allrctla
WHERErctla.customer_trx_id=rcta.customer_trx_id
ANDrctla.interface_line_attribute1=oks_hd.contract_number(+)
ANDNVL(rctla.interface_line_attribute2,'')=NVL
(oks_hd.contract_number_modifier(+),'')
ANDrctla.interface_line_attribute3=txn.bill_instance_number(+)
ANDbsl.cle_id=oks_ln.ID
ANDNVL(txn.bsl_id,999)=DECODE(txn.bsl_id,NULL,999,bsl.ID)
ANDtxn.bcl_id=bsl.bcl_id
ANDoks_ln.ID=oks_ln_sub.cle_id(+)
ANDoks_ln.ID=oki.cle_id(+)
ANDoki.object1_id1=ocsi.id1(+)
ANDoki.object1_id2=ocsi.id2(+)
ANDocsi.instance_id=cii_oks.instance_id(+)
ANDrcta.trx_number='&your_trans_num'
ANDoks_hd.contract_number='&your_contr_num'

Oracle CRM Service Contracts Queries

SERVICE CONTRACT HEADER TABLE OKC_K_HEADERS_ALL_B


NAV: Contract Administration / Launchpad using the Service Contracts Manager
responsibility.
Enter the header information and nothing more.

This query provides some of the header level information:


R12
select * from OKC_K_HEADERS_ALL_B
where contract_number = '23572';
11i
select * from OKC_K_HEADERS_B
where contract_number = '23572';
Two important columns in OKC_K_HEADERS_ALL_B are the authoring_org_id and the
inv_organization_id. The authoring_org_id will always be the org id that matches the
Vendor name. The inv_organization_id is the inventory validation org, a value that
can be seen in Order Management.
Note: In release 11.5.10, the table name is OKC_K_HEADERS_B. In R12, the table
name is OKC_K_HEADERS_ALL_B. This was done so that Service Contracts can use
the MO: Security Profile to control which organizations are accessible from a given
responsibility. There is a synonym from OKC_K_HEADERS_B to
OKC_K_HEADERS_ALL_B. Queries in R12 should reference OKC_K_HEADERS_ALL_B
unless client_info is set to the appropriate organization.
A. Contract Header Data
SELECT*
FROMokc_k_headers_b
WHEREcontract_number='&contract_number'
ANDcontract_number_modifier='&contract_modifier';

Oracle CRM Service Contracts Queries

SERVICE CONTRACT HEADER ITEM VALIDATION ORGANIZATION


NAV: Setup / System Parameters / Values. All services and products must be
defined / assigned to this organization.
Use this method to identify the Item Validation organization for an operating unit.
The Operating Unit that appears in this form is the profile setting MO: Operating Unit.

Oracle CRM Service Contracts Queries

SERVICE CONTRACT HEADER OKS_K_HEADERS_B


OKS_K_HEADERS_B has information that was once stored in the rules tables in early
product releases. Rule Groups had one or more rules. Information such as credit
card numbers, tax codes, invoicing rules, etc. were stored in individual rows in
OKC_RULES_B. Similar rules were consolidated in OKC_RULE_GROUPS_B. Due to
performance issues, this information was moved to OKS_K_HEADERS_B (and
OKS_K_LINES_B at the line level).
It is a good idea to run queries from both tables and save them in a spreadsheet so
that changes can be observed as additional information is entered in the contract.
selectoks.*
fromOKC_K_HEADERS_ALL_Bk,
OKS_K_HEADERS_Boks
wherecontract_number='23572'
andk.id=oks.chr_id;
In most tables, the column dnz_chr_id maps to the column id in
OKC_K_HEADERS_ALL_B. In this table, the column is chr_id.
A. Contract Header Data
A1. This SQL takes data from views rather than from actual contracts tables and is
useful for reviewing data but not ideal for verifying if base tables hold correct data.
SELECTCONTRACT_NUMBER"Contract"
,TO_CHAR(id)"Id"
,SHORT_DESCRIPTION"Description"
,INV_ORGANIZATION_ID"OrganizationId"
,STS_CODE"Status",scs_code
,CURRENCY_CODE"Currency"
,TO_CHAR(DATE_TERMINATED,'DDMONYYYY')"DateTerminated"
,TRN_CODE
,TO_CHAR(START_DATE,'DDMONYYYY')"StartDate"
,TO_CHAR(END_DATE,'DDMONYYYY')"EndDate"
,UPG_ORIG_SYSTEM_REF
,PRICE_LIST_ID
,BILL_TO_SITE_USE_ID
,SHIP_TO_SITE_USE_ID
,PAYMENT_TERM_ID
,ACCT_RULE_ID
,INV_RULE_ID
,AR_INTERFACE_YN
,CLASS_MEANING
,TEMPLATE_YN
,HOLD_BILLING
FROMoks_auth_headers_v
WHERECONTRACT_NUMBERlike'<contractnumber>';

Oracle CRM Service Contracts Queries

OKS_AUTH_HEADERS_V is not a table but a view. This view is


comprised of table OKC_K_HEADERS_B , OKC_K_HEADERS_TL , OKC_STATUSES_V and
OKC_SUBCLASSES_V.
SERVICE CONTRACT HEADER PARTY INFORMATION
The vendor party is automatically populated when the cursor is positioned in the
Parties tab. Select the entry for party role = Customer.

Run this query:


selectpty.rle_code,pty.object1_id1
fromOKC_K_HEADERS_ALL_Bk,
OKC_K_PARTY_ROLES_Bpty
wherek.id=pty.dnz_chr_id
andpty.cle_idisnull
andk.contract_number='23572';
This information is returned:
RLE_CODE
OBJECT1_ID1
----------------- -----------------VENDOR
204
CUSTOMER 4429
As you can see, object1_id1 lists the org_id for a vendor and the party number for a
customer.

Oracle CRM Service Contracts Queries

SERVICE CONTRACT HEADER BILL TO / SHIP TO INFORMATION


Run this query before and after entering the Bill To and Ship To Information in your
contract.
selectbill_to_site_use_id,
ship_to_site_use_id
fromOKC_K_HEADERS_ALL_B
wherecontract_number='23572';
As you can see, the information is stored in OKC_K_HEADERS_ALL_B.

Oracle CRM Service Contracts Queries

SERVICE CONTRACT HEADER CUSTOMER CONTACT INFORMATION


Create a customer contact.

Run this query to identify the contact:


selectcro_code"ContactRole",
ct.jtot_object1_code,
object1_id1"ContactID"
fromOKC_CONTACTSct,
OKC_K_HEADERS_ALL_Bk
wherek.id=ct.dnz_chr_id
andjtot_object1_code='OKX_PCONTACT'
andk.contract_number='23572';
This information is returned:
Contact Role jtot_object1_code Contact ID
----------------- ------------------------ -------------BUYER
OKX_PCONTACT
401670
Run this query to get the contact information:
select*fromhz_parties
whereparty_id=401670;

Oracle CRM Service Contracts Queries

SERVICE CONTRACT HEADER VENDOR CONTACT INFORMATION


Now create a contact for the Vendor.

Rerun this query:


selectcro_code"ContactRole",
ct.jtot_object1_code,
object1_id1"ContactID"
fromOKC_CONTACTSct,
OKC_K_HEADERS_ALL_Bk
wherek.id=ct.dnz_chr_id
andk.contract_number='23572';
This information is returned. Notice that the jtot_object1_code for the new entry is
OKX_RESOURCE. The results will be different when you run this query because line
level contacts are created later in this presentation.
Contact Role
----------------BUYER
ADMIN

jtot_object1_code Contact ID
------------------------ -------------OKX_PCONTACT
401670
OKX_RESOURCE
10199

The resource information is located in a table and a view. Either of these queries will
return the information:
select*fromOKX_RESOURCES_V
whereid1=10199;
select*fromJTF_RS_RESOURCE_EXTNS
whereresource_id=10199;

Oracle CRM Service Contracts Queries

SERVICE CONTRACT HEADER PRICING / BILLING INFORMATION


Lets progress to the Pricing / Billing tab for the contract. Enter the Price List,
Payment Terms, Accounting Rule, Invoicing Rule, Hold Credits checkbox and
Summary Transactions checkbox.

The information is stored in OKC_K_HEADERS_ALL_B and some is stored in


OKS_K_HEADERS_B.
selectk.price_list_id,
k.payment_term_id,
oks.acct_rule_id,
k.inv_rule_id,
oks.hold_billing"HoldCredits",
oks.summary_trx_yn"SummaryTransactions"
fromOKC_K_HEADERS_ALL_Bk,
OKS_K_HEADERS_Boks
wherecontract_number='23572'
andk.id=oks.chr_id;
The values are the ids in other tables. For example, this query returns the Corporate
price list:
selectname
fromQP_LIST_HEADERS_Bpl,
QP_LIST_HEADERS_TLtl
wherepl.list_header_id=1000
andpl.list_header_id=tl.list_header_id;
This query returns the invoicing and accounting rules:
selectname,
decode(type,'A','AccountingRule','I','InvoicingRule')"Rule
Type"
fromra_rules
whererule_idin(1,2)

Oracle CRM Service Contracts Queries

D. Contract Billing Data


D1. This query shows the billing invoice details. Note that -99 will be shown for
invoice number if the 'Service Contracts Fetch Receivables Info For Billing' concurrent
program has not been run after Autoinvoice has been run.
SELECTDISTINCTd.contract_number
,a.trx_number"InvoiceNumber"
,TO_CHAR(b.date_billed_from,'DDMONYYYYHH24MI')"BillFrom"
,TO_CHAR(b.date_billed_to,'DDMONYYYYHH24MI')"BillTo"
,b.amount
FROMoks_bill_transactionsa
,oks_bill_txn_linesaa
,oks_bill_cont_linesb
,okc_k_lines_bc
,okc_k_headers_bd
WHEREA.ID=AA.BTN_ID
ANDAA.BCL_ID=B.ID
ANDB.CLE_ID=C.CLE_ID
ANDC.DNZ_CHR_ID=D.ID
ANDd.id=<contractidfromqueryA1>;
D2. This query shows the billing transaction details. The data in this table is shown in
the History tab of the Billing Schedule form in the contract.
For the bill_action, the codes have the following meanings:
Regular Invoice -RI,
Termination Credit - TR,
Averaging - AV,
Settlement Invoice - SRI,
Settlement Credit - STR.
SELECThdr.contract_number"Contract"
,hdr.contract_number_modifier"Modifier"
,hdr.id
,TO_CHAR(cont.creation_date,'DDMONYYYYHH24:MI')"CreationDate"
,bill_action
,btn_id"BillingTransactionID"
,amount
,TO_CHAR(DATE_BILLED_FROM,'DDMONYYYY')"DateBilledFrom"
,TO_CHAR(DATE_BILLED_TO,'DDMONYYYY')"DateBilledTo"
FROMoks_bill_cont_linescont
,okc_k_lines_bline
,okc_k_headers_bhdr
WHEREhdr.id=line.dnz_chr_id
ANDcont.cle_id=line.id
ANDhdr.id=<contractidfromqueryA1>
ORDERBYcont.creation_date;

Oracle CRM Service Contracts Queries

D3. This query returns data about the contract Line ids corresponding to each invoice
as well as invoice details.
SELECTBCL.id
,BCL.cle_id
,BCL.btn_id
,BCL.bill_action
,OKL.id"Lineid"
,OKH.id"Contractid"
,BTN.TRX_NUMBER"Invoice"
,bcl.date_billed_from
,bcl.date_billed_to
FROMOKS_BILL_CONT_LINESBCL,
OKC_K_LINES_BOKL,
OKC_K_HEADERS_BOKH,
OKS_BILL_TRANSACTIONSBTN,
OKS_BILL_TXN_LINESBTL
WHEREOKH.contract_number='<contractnumber>'
AndOKH.ID=OKL.DNZ_CHR_ID
AndOKL.CLE_IDISNULL
AndOKL.ID=BCL.CLE_ID
AndBTN.ID=BCL.BTN_ID
AndBTL.BTN_ID=BTN.ID
AndBTL.BILL_INSTANCE_NUMBERISNOTNULL;
D4. This query returns information about what the contract billing schedule for a
contract and can be used to investigate amounts expected to be billed in a billing
period.
SELECTTO_CHAR(bcl.id)
,TO_CHAR(bsl.id)
,TO_CHAR(lvl.id)
,lvl.date_start
,bsl.date_billed_from
,lvl.date_end
,bsl.date_billed_to
,bcl.DATE_NEXT_INVOICE
,lvl.DATE_TRANSACTION
,lvl.DATE_TO_INTERFACE
,lvl.DATE_COMPLETED
,TO_CHAR(RUL_ID)
,TO_CHAR(lvl.PARENT_CLE_ID)
,bsl.amount
FROMoks_bill_sub_linesbsl
,oks_bill_cont_linesbcl
,oks_level_elementslvl

Oracle CRM Service Contracts Queries

,okc_K_LINES_Bkl
,okc_k_headers_bkh
WHEREkh.contract_number='&enter_contract_number'
ANDkl.dnz_chr_id=kh.id
ANDlvl.dnz_chr_id=kh.id
ANDbcl.cle_id=kl.id
ANDbcl.id=bsl.bcl_id
ANDlvl.cle_id=bsl.cle_id;

Oracle CRM Service Contracts Queries

SERVICE CONTRACT HEADER RENEWAL TAB


Lets review the top portion of the Renewals tab.

This query returns the Renewal Process:


selectk.contract_number,fnd.meaning"RenewalType"
fromOKC_K_HEADERS_ALL_Bk,
FND_LOOKUP_VALUESfnd
wherek.renewal_type_code=fnd.lookup_code
andfnd.lookup_type='OKS_RENEWAL_TYPE'
andk.contract_number='23572';
The Approval (Required) is returned by running this query. The value is Y when
approval is required.
selectapproval_type
fromOKC_K_HEADERS_ALL_B
wherecontract_number='23572';
The price list information is stored in QP_LIST_HEADERS_B, but this query will provide
the list header name.
selectpr.name
fromOKC_K_HEADERS_ALL_Bk,
QP_LIST_HEADERS_TLpr
wherek.price_list_id=pr.list_header_id
andpr.source_lang='US'
andk.contract_number='23572';
This query returns the Billing Profile:
selectbp.profile_number"BillingProfile"
fromOKC_K_HEADERS_ALL_Bk,
OKS_K_HEADERS_Boks,
oks_billing_profiles_vbp
wherek.id=oks.chr_id
andoks.billing_profile_id=bp.id
andcontract_number='23572';

Oracle CRM Service Contracts Queries

SERVICE CONTRACT HEADER RENEWAL TAB


Lets review the middle portion of the Renewals tab.

This query returns the desired information.


selectoks.renewal_po_number,
oks.renewal_grace_duration,
oks.renewal_grace_period,
oks.renewal_est_rev_percent,
oks.renewal_est_rev_duration,
oks.renewal_est_rev_period
fromOKC_K_HEADERS_ALL_Bk,
OKS_K_HEADERS_Boks
wherek.id=oks.chr_id
andcontract_number='23572';

Oracle CRM Service Contracts Queries

SERVICE CONTRACT HEADER RENEWAL TAB


Lets review the Quote To portion of the Renewals tab.

This query returns the Quote To information. It is a single query from multiple tables.
The query can be simplified to return specific fields.
selectsubstr(okc.contract_number,1,30)"ContractNumber",
hca.account_number"AccountNumber",
substr(hca.account_name,1,40)"AccountName",
substr(csv.description,1,60)"QuoteToAddress",
substr(hp.party_name,1,40)"ContactPartyName",
substr(cp.email_address,1,30)"EmailAddress",
oks.quote_to_contact_id,
car.cust_account_role_id,
car.party_id,
car.cust_account_id
fromOKS_K_HEADERS_Boks,
OKC_K_HEADERS_ALL_Bokc,
HZ_CUST_ACCOUNT_ROLEScar,
HZ_CUST_ACCOUNTShca,
HZ_CONTACT_POINTScp,
HZ_PARTIEShp,
OKX_CUST_SITES_Vcsv
whereoks.chr_id=okc.id
andoks.quote_to_contact_id=car.cust_account_role_id
andoks.quote_to_email_id=cp.contact_point_id
andhp.party_id=car.party_id
andcar.cust_account_id=hca.cust_account_id
andoks.quote_to_site_id=csv.id1
andokc.contract_number='23572';
Thequote_to_contact_idinOKS_K_HEADERS_Bmapsto
HZ_CUST_ACCOUNT_ROLES,
which then maps to HZ_CONTACT_POINTS.
The quote_to_email_id maps in OKS_K_HEADERS_B maps to HZ_CONTACT_POINTS
The quote_to_site_id in oks_k_headers_b is mapped to OKX_CUST_SITES_V
Refer to Note 471398.1 , How to Find the Quote To Party ID in a Service
Agreement, for additional information.

Oracle CRM Service Contracts Queries

SERVICE CONTRACT HEADER ADMIN TAB


The contract group is stored in OKC_K_GRPINGS.

This query can be used to obtain the contract group(s) for a contract.
selectsubstr(k.contract_number,1,25)"ContractNumber",
substr(k.contract_number_modifier,1,25)"Modifier",
substr(tl.name,1,25)"GroupName"
fromOKC_K_HEADERS_ALL_Bk,
OKC_K_GRPINGSgp,
OKC_K_GROUPS_TLtl
wheregp.included_chr_id=k.id
andk.contract_number_modifierisnull
andtl.language='US'
ANDgp.cgp_parent_id=tl.id
andk.contract_number='23572';
Contract Number
----------------------23572

Modifier Group Name


------------- -----------------AL

Oracle CRM Service Contracts Queries

SERVICE CONTRACT LINES INFORMATION


The contract line information is stored in OKC_K_LINES_B and OKS_K_LINES_B. Create
a service line.

selectls.lty_code,
l.bill_to_site_use_id,
l.ship_to_site_use_id
fromokc_k_headers_all_bk,
OKC_K_LINES_Bl,
OKS_K_LINES_Bokls,
OKC_LINE_STYLES_Bls
wherek.id=l.dnz_chr_id
andl.id=okls.cle_id
andl.lse_id=ls.id
andk.contract_number='23572';
From this query you can see that the relationship between OKC_K_LINES_B and
OKS_K_LINES_B is similar to the relationship for the corresponding tables at the
header level.
The cle_id in OKS_K_LINES_B points to the id in OKC_K_LINES_B.
A new table is introduced, OKC_LINE_STYLES_B. This table has descriptions for the
lse_id, an important identifier in a contract line. From this query you see that the
lse_id indicates that this is a service line.
LTY_CODE BILL_TO_SITE_USE_ID SHIP_TO_SITE_USE_ID
-------------- ----------------------------- ---------------------SERVICE
3731
6798
B. Contract Line Data
Note: in OKC_K_LINES_B the chr_id field is only populated with the contract header id
for contract lines. For contract sublines, this value is NULL. Dnz_chr_id is populated
with the contract header id for both lines and sublines.
B1. This SQL takes data from views rather than from actual contracts tables and is
useful for reviewing data but not ideal for verifying if base tables hold correct data
SELECTDISTINCToal.LINE_NUMBER
,oll.lse_name
,oal.STS_CODE"Status"
,oal.TRN_CODE,oal.LSE_ID,old.service_name
,oal.CURRENCY_CODE"Currency|Code"
,TO_CHAR(oal.START_DATE,'DDMONYYYY')"StartDate"
,TO_CHAR(oal.END_DATE,'DDMONYYYY')"EndDate"

Oracle CRM Service Contracts Queries

,qpl.NAME"PriceListName"
,CUST_ACCT_ID
,BILL_TO_SITE_USE_ID
,INV_RULE_ID
,SHIP_TO_SITE_USE_ID
,SHIP_TO_SITE_USE_ID
,ACCT_RULE_ID
,USAGE_PERIOD
,USAGE_TYPE
,UOM_QUANTIFIED
,BILLING_SCHEDULE_TYPE
,INVOICE_TEXT
FROMoks_auth_lines_voal
,okc_launch_lgrid_voll
,qp_pricelists_lov_vqpl
,oks_line_details_vold
WHEREoal.id=oll.id
ANDcle_idISNULL
ANDqpl.PRICE_LIST_ID=oal.PRICE_LIST_ID
ANDold.CONTRACT_ID=oll.chr_id
ANDoll.chr_id='<valueofidtakenfromqueryA1>'
ORDERBYto_number(line_number);
B2. Data taken directly from contract table. (Note that this query may appear to
return duplicate lines, as the query on okc_k_headers_b will return more than one
contract if the contract has been renewed).
select*
fromOKC_K_LINES_B
whereCHR_IDIN(selectid
fromokc_k_headers_b
wherecontract_number='<contractnumber>');

Oracle CRM Service Contracts Queries

SERVICE CONTRACT LINES COVERAGE INFORMATION


Lets examine the coverage for this line. Open the Effectivities tab for the line and
press the Details button. Use Help / Diagnostics / Examine to get the id for the
coverage header.

Exit the contract and navigate to Setup / Contract / Standard Coverage. Search for
the Gold coverage. Again use Help / Diagnostics / Examine to review the id. Notice
that the values are the same. This is a new feature in R12. The coverages for all
contract lines reference a standard coverage. This allows users to change all
contract coverages simply by modifying the standard coverage.

Oracle CRM Service Contracts Queries

SERVICE CONTRACT LINES COVERAGE INFORMATION


To illustrate the difference, modify the coverage for this line, changing it to a custom
coverage. Open the coverage Details and press the Customize button. Use Help /
Diagnostics / Examine again.
Generating a custom coverage causes the application to create a new coverage
record, one that is specific to this contract.

Oracle CRM Service Contracts Queries

SERVICE CONTRACT LINES HOW TO IDENTIFY COVERAGE FOR A LINE


So how does the application know which coverage to use? Where is the information
likely to be located? My guess is OKS_K_LINES_B. Why? Because this is the type of
information that was probably placed in a rules table at one time. My next guess
would be OKC_K_LINES_B.
Use Help / Diagnostics / Examine from the contract line to get the ID:

Now run this query:


selectcoverage_id,standard_cov_yn
fromOKS_K_LINES_B
wherecle_id=224040514744789738490100474035657399323;
This is returned:
COVERAGE_ID
STANDARD_COV_YN
------------------------------------------------224040514744793365267559317923181517851 N
For reference purposes, run a similar query for a contract line that uses a standard
coverage. You will see that the coverage_id is the id for the standard coverage.

Oracle CRM Service Contracts Queries

SERVICE CONTRACT LINES RELATIONSHIP BETWEEN COVERAGE HEADER


AND LINE
In a previous page we found that the id for the coverage is
224040514744793365267559317923181517851. This query demonstrates how the
cle_id can be used to find the parent. Notice that OKC_K_LINES_B is queried twice.
This is because the coverage information and the line information are stored in the
same table.
selectto_char(coverage.id),
covls.lty_code,
to_char(topline.id),
toplinels.lty_code
fromOKC_K_LINES_Bcoverage,
OKC_K_LINES_Btopline,
OKC_LINE_STYLES_Bcovls,
OKC_LINE_STYLES_Btoplinels
wherecoverage.id=224040514744793365267559317923181517851
andcoverage.lse_id=covls.id
andcoverage.cle_id=topline.id
andtopline.lse_id=toplinels.id;
The first two columns in the result are from the coverage record. The cle_id in the
coverage points to its parent, in this case, the top line.
TO_CHAR(COVERAGE.ID)
LTY_CODE
TO_CHAR(TOPLINE.ID)
LTY_CODE
----------------------------------------------------------------------------------------224040514744793365267559317923181517851 COVERAGE
224040514744789738490100474035657399323 SERVICE
The same pattern can be seen throughout the coverage template.
Position the cursor in the Time Zone. Use Help / Diagnostics / Examine to get the
cle_id.
Now position the cursor in the Business Process. The id for this line is the cle_id for
the child Time Zone record. The cle_id for the Business Process is the id for its
parent, the Coverage (Name).
Later, we will see the same relationship between a contract subline and its parent, a
contract line.

Oracle CRM Service Contracts Queries

SERVICE COVERAGE; COMPLEX COVERAGE QUERY


Now that we know how to identify the coverage id, lets expand the query to show
much of the information that appears in the Coverage Details form. This is a
complicated query, one that accesses the table okc_k_lines_b many times. We first
obtain the coverage_id for the contract line from oks_k_lines_b. This leads us to the
coverage in okc_k_lines_b. The id for this record allows us to identify the business
processes (via business process cle_id); the id for the business processes allows us to
identify the reaction times (again, via cle_id).
The full query is on the next page.

Oracle CRM Service Contracts Queries

SERVICE COVERAGE; COMPLEX COVERAGE QUERY


selectsubstr(hdr.contract_number,1,20)"ContractNumber",
substr(hdr.contract_number_modifier,1,25)"Contract
Modifier",
substr(line.line_number,1,15)"LineNumber",
substr(mtl.segment1,1,20)"ServiceName",
substr(covtl.name,1,15)"CoverageName",
substr(bproc.name,1,25)"BusinessProcessName",
css.name"SeverityName",
at.uom_code"ReactionUOM",
at.mon_duration"MondayDuration",
at.tue_duration"TuesdayDuration",
at.wed_duration"WednesdayDuration",
at.thu_duration"ThursdayDuration",
at.fri_duration"FridayDuration",
at.sat_duration"SaturdayDuration",
at.sun_duration"SundayDuration"
fromOKC_K_HEADERS_ALL_Bhdr,
OKC_K_LINES_Bline,
OKS_K_LINES_Boksline,
OKC_K_ITEMSit,
MTL_SYSTEM_ITEMS_Bmtl,
OKC_K_LINES_Bcovline,
OKC_K_LINES_TLcovtl,
OKC_K_LINES_Bbpline,
OKS_K_LINES_Breactoksline,
OKC_K_ITEMSitbp,
CS_BUSINESS_PROCESSESbproc,
OKC_K_LINES_Breactline,
OKS_ACTION_TIMESat,
OKS_ACTION_TIME_TYPESatt,
CS_INCIDENT_SEVERITIEScss
wherehdr.contract_number='23572'
andhdr.id=line.dnz_chr_id
andline.lse_id='1'
andline.id=it.cle_id
andit.object1_id1=mtl.inventory_item_id
andhdr.inv_organization_id=mtl.organization_id
andline.id=oksline.cle_id
andcovline.id=oksline.coverage_id
andcovline.lse_id='2'
andcovline.id=covtl.id
andcovtl.language='US'
andbpline.cle_id=covline.id
andbpline.lse_id='3'
andbpline.id=itbp.cle_id

Oracle CRM Service Contracts Queries

anditbp.object1_id1=bproc.business_process_id
andreactline.cle_id=bpline.id
andreactline.lse_id=4
andreactline.id=at.cle_id
andreactline.id=reactoksline.cle_id
andat.cov_action_type_id=att.id
andatt.cle_id=reactline.id
andatt.action_type_code='RCN'
andreactoksline.incident_severity_id=css.incident_severity_id;

Oracle CRM Service Contracts Queries

SERVICE CONTRACT LINES ACCOUNTS TAB (ITEM NAME)

Lets examine several of the fields at the line level. How do you identify the item
name? The item information for a contract topline is stored in okc_k_items. The
column object1_id1 has the inventory_item_id, a value that is mapped to the table
mtl_system_items_b. The column object1_id2, is the org_id. The org_id is also stored
in okc_k_headers_all_b.
selectsubstr(k.contract_number,1,25)"ContractNumber",
substr(k.contract_number_modifier,1,25)"ModifierNumber",
substr(mtl.segment1,1,30)"ServiceName",
it.jtot_object1_code"ObjectCode"
fromOKC_K_HEADERS_ALL_Bk,
OKC_K_LINES_Bokc,
MTL_SYSTEM_ITEMS_Bmtl,
OKC_K_ITEMSit
wherek.contract_number='23572'
andk.id=okc.dnz_chr_id
andokc.lse_id='1'
andokc.id=it.cle_id
andit.object1_id1=mtl.inventory_item_id
andit.object1_id2=mtl.organization_id;
Contract Number Modifier Number Service Name Object Code
------------------------ ------------------------ ------------------- ----------------23572
WRTEST
OKX_SERVICE
The value for object_code isnt that important for this query, but we will see other
object_code values are used to identify the line or subline type.

Oracle CRM Service Contracts Queries

SERVICE CONTRACT LINES ACCOUNTS TAB (BILL TO / SHIP TO)

You may see similarities to a previous header level query. The Bill To and Site
information are stored in OKC_K_LINES_B.
selectsubstr(k.contract_number,1,25)"ContractNumber",
substr(okc.line_number,1,10)"LineNumber",
okc.bill_to_site_use_id"BillTo",
okc.ship_to_site_use_id"ShipTo"
fromOKC_K_HEADERS_ALL_Bk,
OKC_K_LINES_Bokc,
OKS_K_LINES_Boks
wherek.contract_number='23572'
andk.id=okc.dnz_chr_id
andokc.id=oks.cle_id
andokc.lse_id='1';
Why did I restrict the query to lse_id = 1? The top line lse_id for a Service Line in a
Service Agreement is 1. When in doubt about the values, remember to check the
values in OKC_LINE_STYLES_B.

Oracle CRM Service Contracts Queries

SERVICE CONTRACT LINES EFFECTIVITIES TAB (INVOICE TEXT)

This query displays the invoice text. The text is located in OKS_K_LINES_TL a
translation table for OKS_K_LINES_B. To obtain the information, join the contract
header to the line, the line to the oks line and then the oks line to the translation
table.
selectsubstr(k.contract_number,1,25)"ContractNumber",
substr(okc.line_number,1,10)"LineNumber",
substr(tl.invoice_text,1,30)"InvoiceText"
fromOKC_K_HEADERS_ALL_Bk,
OKC_K_LINES_Bokc,
OKS_K_LINES_Boks,
OKS_K_LINES_TLtl
wherek.contract_number='23572'
andk.id=okc.dnz_chr_id
andokc.lse_id='1'
andokc.id=oks.cle_id
andoks.id=tl.id;

Oracle CRM Service Contracts Queries

SERVICE CONTRACT LINES ACCOUNTS TAB (CONTACT INFORMATION)

The contact information is in okc_contacts. Two main okc tables retain the data. The
cle_id (contract line id) is in OKC_K_PARTY_ROLES_B.
selectcle_id,rle_code,object1_id1
fromOKC_K_PARTY_ROLES_B
wherecle_id=224040514744789738490100474035657399323;
This query returns the party_id, a link to hz_parties for the customer record.
CLE_ID
RLE_CODE
OBJECT1_ID1
---------------------------------------------------------------- --------------------------------------------------------------------224040514744789738490100474035657399323 CUSTOMER
4429
Use the cle_id to find the entry in okc_contacts:
selectcontact.cro_code,contact.object1_id1
fromOKC_K_PARTY_ROLES_Bpr,
OKC_CONTACTScontact
wherecontact.cpl_id=pr.id
andpr.cle_id=224040514744789738490100474035657399323
CRO_CODE
OBJECT1_ID1
------------------------------ -----------------CUST_BILLING
56854
CUST_SHIPPING
3736

Oracle CRM Service Contracts Queries

SERVICE CONTRACT LINES ACCOUNTS TAB (CONTACT INFORMATION)


The object1_id1 links to hz_cust_account_roles, which then links to hz_parties. The
query actually references tables, but this is one way to identify the contacts.
selectcontact.cro_code,
substr(hp.party_name,1,25),
hz.party_id,hz.cust_account_id
fromOKC_K_PARTY_ROLES_Bpr,
OKC_CONTACTScontact,
HZ_CUST_ACCOUNT_ROLEShz,
HZ_PARTIEShp
wherepr.id=contact.cpl_id
andcontact.object1_id1=hz.cust_account_role_id
andhp.party_id=hz.party_id
andpr.cle_id=224040514744789738490100474035657399323;
CRO_CODE
SUBSTR(HP.PARTY_NAME,1,25) PARTY_ID CUST_ACCOUNT_ID
------------------------ -------------------------- ------------------------------------------CUST_BILLING
Ray Adams-Business World- 4554
3347
CUST_SHIPPING Nicole Burg-Business Worl 4452
3347

Oracle CRM Service Contracts Queries

SERVICE CONTRACT LINES ACCOUNTS TAB (CONTACT INFORMATION)


The tax information is in OKS_K_LINES_B. This is a sample query, but it will return no
information because the tax information is not entered in this contract.
selecttax_code,
tax_exemption_id
fromOKS_K_LINES_B
wherecle_id=224040514744789738490100474035657399323;

The payment information is also stored in OKS_K_LINES_B. Refer to Note 459982.1,


Where Is Commitment, Purchase Order and Credit Card Information Stored in the
Service Contracts Tables? The Note describes the location in
OKS_K_HEADERS_ALL_B. The same information is stored at the line level in
OKS_K_LINES_B.

Oracle CRM Service Contracts Queries

SERVICE CONTRACT SUBLINES (COVERED) PRODUCT INFORMATION


Lets create a contract subline, one for a covered product.

To identify the product name, we again need to establish a link to


MTL_SYTEM_ITEMS_B.
selectsubstr(okc.line_number,1,15)"SublineNumber",
substr(ks.NAME,1,15)"CoveredLevel",
mtl.segment1"ItemName",
csi.instance_number
fromOKC_K_HEADERS_ALL_Bk,
OKC_K_LINES_Bokc,
OKC_K_ITEMSki,
OKC_LINE_STYLES_Vks,
CSI_ITEM_INSTANCEScsi,
MTL_SYSTEM_ITEMS_Bmtl
wherek.contract_number_modifierISNULL
andk.ID=okc.dnz_chr_id
andk.ID=ki.dnz_chr_id
andokc.ID=ki.cle_id
andokc.lse_id=ks.id
andki.jtot_object1_codeIN('OKX_CUSTPROD')
andcsi.last_vld_organization_id=mtl.organization_id
andTO_NUMBER(ki.object1_id1)=csi.instance_id
andcsi.inventory_item_id=mtl.inventory_item_id
andk.contract_number='23572';
Lets review this query in detail:
OKC_K_ITEMS is referenced again. This time the object1_id1 has the instance_id
Jtot_objecdt1_code has the value OKX_CUSTPROD. This is used to identify the
subline type. Modifications in the query are needed to obtain the information for
covered item, covered customer, etc.
The query does not need to access CSI_ITEM_INSTANCES, but the table is included in
case other columns from that table are needed.
Run this query to get a general idea of the type of content in OKC_K_ITEMS. You will
see the object codes that are used to identify usage items, covered system, etc.
selectdistinctjtot_object1_code
fromOKC_K_ITEMS;
C. Contract Subline Data
Note: When you add a subline to a contract OKC_K_LINES_B is populated with data,

Oracle CRM Service Contracts Queries

some of the data created there for each subline is internal data. Use the LSE_ID to
restrict the data returned when querying.
C1. Query for all the sublines on a contract with a Level type that can be seen when
authoring the contract (i.e. restricts to lines which have Level of Product, Site, Item,
System, Customer or Site). (Note that this query may appear to return duplicate
lines, as the query on okc_k_headers_b will return more than one contract if the
contract has been renewed).
select
id
,line_number
,cle_id
,sts_code
,hidden_ind
,decode(lse_id,
8,'Party',
7,'Item',
9,'Product',
10,'Site',
11,'System',
35,'Customer')"Level"
,object_version_number
,price_negotiated
,price_level_ind
,price_unit
,price_unit_percent
,price_type
,currency_code
,price_list_id
,price_list_line_id
,item_to_price_YN
,pricing_date
,date_terminated
,start_date
,end_date
fromOKC_K_LINES_B
whereDNZ_CHR_IDIN(selectid
fromokc_k_headers_b
wherecontract_number='<contractnumber>')
andlse_idIN(8,7,9,10,11,35);
C2. Query for contract sublines for a given contract line only. Replace <parent line
number> with the line number of the required contract line (e.g. 1, 2. 3), taken either
from the contract form, or from query B2. (Note that this query may appear to return

Oracle CRM Service Contracts Queries

duplicate lines, as the query on okc_k_headers_b will return more than one contract if
the contract has been renewed).
select
id
,line_number
,cle_id
,sts_code
,decode(lse_id,
8,'Party',
7,'Item',
9,'Product',
10,'Site',
11,'System',
35,'Customer')"Level"
,object_version_number
,price_negotiated
,price_level_ind
,price_unit
,price_unit_percent
,price_type
,currency_code
,price_list_id
,price_list_line_id
,item_to_price_YN
,pricing_date
,date_terminated
,start_date
,end_date
fromOKC_K_LINES_B
whereDNZ_CHR_IDIN(selectid
fromokc_k_headers_b
wherecontract_number='<contractnumber>')
andcle_idIN(selectid
fromokc_k_lines_b
wherechr_idIN(selectid
fromokc_k_headers_b
wherecontract_number='<contract
number>')
andline_number=<parentlinenumber>)
andlse_idIN(8,7,9,10,11,35);
C3. This query returns the inventory item for a given contract subline where the
Level = Product (i.e. the subline is for a particular install base instance).
SELECTkl.line_number,
ks.NAME
,i.segment1

Oracle CRM Service Contracts Queries

FROM
okc_k_headers_bkh,
okc_k_lines_bkl,
okc_k_itemski,
okc_line_styles_vks,
csi_item_instancesc,
mtl_system_items_bi
WHERE
kh.contract_number='<contractnumber>'
ANDkh.contract_number_modifierISNULLcanbepopulated
ANDkh.ID=kl.dnz_chr_id
ANDkh.ID=ki.dnz_chr_id
ANDkl.ID=ki.cle_id
ANDkl.lse_id=ks.ID
ANDki.jtot_object1_codeIN('OKX_CUSTPROD')
ANDc.last_vld_organization_id=i.organization_id
ANDTO_NUMBER(ki.object1_id1)=c.instance_id
ANDc.inventory_item_id=i.inventory_item_id;

Oracle CRM Service Contracts Queries

SERVICE CONTRACT LINES BILLING STREAM


Lets begin with the information that appears at the top of the Billing Schedule. The
invoicing rule (for the line) is stored in OKC_K_HEADERS_B. The accounting rule and
billing schedule type are stored in OKS_K_HEADERS_B.

We know the line id from previous queries. This query returns the information that
appears at the top of the Billing Schedule form.
selectokc.inv_rule_id,
oks.acct_rule_id,
oks.billing_schedule_type
fromOKC_K_LINES_Bokc,
OKS_K_LINES_Boks
whereokc.id=oks.cle_id
and okc.id = 224040514744789738490100474035657399323;
INV_RULE_ID
ACCT_RULE_ID
BILLING_SCHEDULE_TYPE
--------------------------------------------------------------------2
1
T
The unbilled, credit, suppressed credit amount, etc. are also stored in
OKS_K_LINES_B.

Oracle CRM Service Contracts Queries

SERVICE CONTRACT LINES BILLING STREAM

There are two billing streams in this example. This query returns the pertinent
information.
selectsequence_no,
level_periods,
start_date,
end_date,
uom_per_period,
uom_code
fromOKS_STREAM_LEVELS_B
wherecle_id=224040514744789738490100474035657399323;
SEQUENCE_NO
LEVEL_PERIODS
START_DATE
END_DATE
UOM_PER_PERIOD
UOM_CODE
------------------------------------------------------------------------------------------------------------------1
1
11-MAY-10
10-NOV-10
6
MTH
2
2
11-NOV-10
10-MAY-11
1
QRT
Remember that these billing streams exist at the subline level too.

Oracle CRM Service Contracts Queries

SERVICE CONTRACT LINES BILLING SCHEDULE


Press the Schedule button to generate the billing schedules.

This query displays the schedule information. Again, remember that this information
appears at the subline level too.
selectsubstr(sequence_number,1,15)"SequenceNumber",
date_start,
date_end,
amount,
date_completed
fromOKS_LEVEL_ELEMENTS
wherecle_id=224040514744789738490100474035657399323
orderbysequence_number,date_start;
Sequence Number DATE_START
DATE_COMPLETED
------------------------- -----------------------------------------1
11-MAY-10
1
11-NOV-10
2
11-FEB-11

DATE_END

AMOUNT

---------------

--------------

10-NOV-10
10-FEB-11
10-MAY-11

55
27.5
27.5

The date_completed is not populated. This is a critical field in the table. This column
is populated when an invoice is generated for the contract.

Oracle CRM Service Contracts Queries

SERVICE CONTRACT LINES STREAM / SCHEDULE QUERY


Identifying why schedules are corrupt can be difficult. Lets assume that you know
the line id, that you feel there is corruption with one of the streams, but you are not
sure which one. In many cases there are multiple sublines. A query is sometimes
needed to show the information for the top line and all of the subline streams.
This query links the tables OKS_STREAM_LEVELS_B and OKS_LEVEL_ELEMENTS based
on the common column cle_id.
selectstrm.sequence_no"StreamNumber",
substr(lvl.sequence_number,1,15)"SequenceNumber",
to_char(lvl.parent_cle_id)"TopLevelLineID",
to_char(lvl.cle_id)"LevelElementLineID",
lvl.date_start,
lvl.date_end,
lvl.amount,
lvl.date_completed
fromOKS_STREAM_LEVELS_Bstrm,
OKS_LEVEL_ELEMENTSlvl
wherestrm.cle_id=lvl.cle_id
andstrm.cle_id=224040514744789738490100474035657399323;
This is insufficient though because it does not show the information for the sublines.
The level elements table also has a column parent_cle_id, one that is populated with
224040514744789738490100474035657399323 for all of the sublines. A minor
change in the query allows us to display the information for all of the sublines.
selectstrm.sequence_no"StreamNumber",
substr(lvl.sequence_number,1,15)"SequenceNumber",
to_char(lvl.parent_cle_id)"TopLevelLineID",
to_char(lvl.cle_id)"LevelElementLineID",
lvl.date_start,
lvl.date_end,
lvl.amount,
lvl.date_completed
fromOKS_STREAM_LEVELS_Bstrm,
OKS_LEVEL_ELEMENTSlvl
wherestrm.cle_id=lvl.cle_id
andlvl.parent_cle_id=224040514744789738490100474035657399323;

Oracle CRM Service Contracts Queries

SERVICE CONTRACT LINES STREAM / SCHEDULE QUERY


Lets combine the two and sort them so that the topline schedule is followed
immediately by all of the subline schedule entries for that line.
selectstrm.sequence_no"StreamNumber",
substr(lvl.sequence_number,1,15)"SequenceNumber",
to_char(lvl.parent_cle_id)"TopLevelLineID",
to_char(lvl.cle_id)"LevelElementLineID",
lvl.date_start,
lvl.date_end,
lvl.amount,
lvl.date_completed
fromOKS_STREAM_LEVELS_Bstrm,
OKS_LEVEL_ELEMENTSlvl
wherestrm.cle_id=lvl.cle_id
andstrm.cle_id=224040514744789738490100474035657399323
UNION
selectstrm.sequence_no"StreamNumber",
substr(lvl.sequence_number,1,15)"SequenceNumber",
to_char(lvl.parent_cle_id)"TopLevelLineID",
to_char(lvl.cle_id)"LevelElementLineID",
lvl.date_start,
lvl.date_end,
lvl.amount,
lvl.date_completed
fromOKS_STREAM_LEVELS_Bstrm,
OKS_LEVEL_ELEMENTSlvl
wherestrm.cle_id=lvl.cle_id
andlvl.parent_cle_id=224040514744789738490100474035657399323
orderby1,2,5;
Stream Number
Sequence Number Top Level Line ID
Level Element Line ID
DATE_START
AMOUNT
DATE_COMPLETED
---------------------------------------------- ------------------------------------------------------------------------------------------------------1
1
224040514744789738490100474035657399323
224040514744789738490100474035657399323 11-MAY-10
55
1
1
224040514744789738490100474035657399323
224654994456990219633500215272306024339 11-MAY-10
55
1
1
224040514744789738490100474035657399323

DATE_END
---------------

10-NOV-10

10-NOV-10

Oracle CRM Service Contracts Queries

224040514744789738490100474035657399323 11-NOV-10
27.5
1
1
224040514744789738490100474035657399323
224654994456990219633500215272306024339 11-NOV-10
27.5

10-FEB-11

10-FEB-11

The first entry is for the top line. Notice that the Top Level Line ID and Level Element
Line ID have the same value. The second entry is for the subline, the schedule entry
for May 11 to Nov 10.

Oracle CRM Service Contracts Queries

Lines 3 and 4 are for the next schedule entry for stream 1, the billing schedule for
Nov 11 to Feb 11, 2011.SERVICE CONTRACT BILLING TABLES
Lets run Main Billing for the first Billing Period. One invoice has been generated.

See what happens to the level elements when this query is rerun after billing.
selectsubstr(sequence_number,1,15)"SequenceNumber",
date_start,
date_end,
amount,
date_completed
fromOKS_LEVEL_ELEMENTS
wherecle_id=224040514744789738490100474035657399323
orderbysequence_number,date_start;
Sequence Number DATE_START
DATE_COMPLETED
------------------------- -----------------------------------------1
11-MAY-10
10-NOV-10
1
11-NOV-10
2
11-FEB-11

DATE_END

AMOUNT

---------------

--------------

10-NOV-10
10-FEB-11
10-MAY-11

55
27.5
27.5

The date_completed is now populated. We know from this query that an invoice has
been generated for schedule entry 1.

Oracle CRM Service Contracts Queries

SERVICE CONTRACT BILLING TABLES


Now, lets examine other billing tables.
selectsubstr(hdr.contract_number,1,15)"ContractNumber",
substr(hdr.contract_number_modifier,1,15)"Modifier",
to_char(bcl.creation_date,'MM/DD/YYYYHH24:MI:SS')
"CreationDate",
to_char(bcl.btn_id),
to_char(bcl.cle_id),
bill_action,amount
fromOKC_K_HEADERS_ALL_Bhdr,
OKC_K_LINES_Bline,
OKS_BILL_CONT_LINESbcl
wherebcl.cle_id=line.id
andline.dnz_chr_id=hdr.id
andcontract_number='23572'
orderbyhdr.contract_number;
Contract Number Modifier
Creation Date
TO_CHAR(BCL.BTN_ID)
TO_CHAR(BCL.CLE_ID)
BILL_ACTION AMOUNT
----------------------- -------------------------------------------------------------------------------------------------------------------- -------------23572
05/19/2010 17:29:24
224763666759272367907400019617050675714
224040514744789738490100474035657399323 RI
55
What to look for in this table:
The btn_id is populated when Main Billing has processed the transaction. The btn_id
will be -44 under two circumstances. The value is -44 when a contract line is
terminated and the credits are suppressed. It also has this value when the entry is
created a Sales Order. Services for sales order lines are invoiced via integration from
OM to Receivables; this value tells Main Billing to ignore the entry.
The bill_action is generally RI, for regular invoice, and TR, for termination.

Oracle CRM Service Contracts Queries

SERVICE CONTRACT BILLING TABLES


Lets terminate the contract subline and run Main Billing again.

Run the same query again. Notice that there is another entry, a termination, TR,
transaction. The btn_id is not populated. Because it is not yet populated, I know that
Main Billing has not picked up the transaction.
Contract Number Modifier
Creation Date
TO_CHAR(BCL.BTN_ID)
TO_CHAR(BCL.CLE_ID)
BILL_ACTION AMOUNT
----------------------- -------------------------------------------------------------------------------------------------------------------- -------------23572
05/19/2010 17:29:24
224763666759272367907400019617050675714
224040514744789738490100474035657399323 RI
55
23572
05/19/2010 17:57:30
224040514744789738490100474035657399323 TR
-52.61

Oracle CRM Service Contracts Queries

SERVICE CONTRACT BILLING TABLES


As a final action, run this query again.
selectstrm.sequence_no"StreamNumber",
substr(lvl.sequence_number,1,15)"SequenceNumber",
to_char(lvl.parent_cle_id)"TopLevelLineID",
to_char(lvl.cle_id)"LevelElementLineID",
lvl.date_start,
lvl.date_end,
lvl.amount,
lvl.date_completed
fromOKS_STREAM_LEVELS_Bstrm,
OKS_LEVEL_ELEMENTSlvl
wherestrm.cle_id=lvl.cle_id
andstrm.cle_id=224040514744789738490100474035657399323
UNION
selectstrm.sequence_no"StreamNumber",
substr(lvl.sequence_number,1,15)"SequenceNumber",
to_char(lvl.parent_cle_id)"TopLevelLineID",
to_char(lvl.cle_id)"LevelElementLineID",
lvl.date_start,
lvl.date_end,
lvl.amount,
lvl.date_completed
fromOKS_STREAM_LEVELS_Bstrm,
OKS_LEVEL_ELEMENTSlvl
wherestrm.cle_id=lvl.cle_id
andlvl.parent_cle_id=224040514744789738490100474035657399323
orderby1,2,5;
Stream Number
Sequence Number Top Level Line ID
Level Element Line ID
DATE_START
AMOUNT
DATE_COMPLETED
---------------------------------------------- ------------------------------------------------------------------------------------------------------1
1
224040514744789738490100474035657399323
224040514744789738490100474035657399323 11-MAY-10
55
1
1
224040514744789738490100474035657399323
224654994456990219633500215272306024339 11-MAY-10
55
1
1
224040514744789738490100474035657399323

DATE_END
---------------

10-NOV-10

10-NOV-10

Oracle CRM Service Contracts Queries

224040514744789738490100474035657399323 11-NOV-10
0

10-FEB-11

If you compare this result to the one that was run earlier you will see that the Nov 11
entry for the subline, cle_id 224654994456990219633500215272306024339, no
longer exists. The termination process truncated all of the schedule entries if the
date_start is greater than the termination date. The entry still exists at the line level,
only because the subline was terminated, not the line.

Oracle CRM Service Contracts Queries

E. Receivables Interface Data


E1. Query to return all the data in the RA interface table for a given service contract.
This will return the data populated into the table by Service Contracts Main Billing.
Note that this query will not return any data if Autoinvoice has been run since the
records are deleted from this table once they have been successfully processed by
Autoinvoice.
SELECT*
FROMra_interface_lines_all
WHEREsales_order='<contractnumber>';
F. Subscription Contracts
F1. How to find the install base instance created for the subscription line item.
(Note that when you enter a subscription line, the application automatically creates
an Oracle Install Base item instance. This is what this query is retrieving).
SELECTosh.instance_id,
okh.contract_number,
okh.contract_number_modifier,
okl.line_number
FROMoks_subscr_header_bosh,
okc_k_headers_bokh,
okc_k_lines_bokl
WHEREosh.dnz_chr_id=okh.id
ANDosh.cle_id=okl.id
ANDokl.chr_id=okh.id
ANDokh.contract_number='<contractnumber>'
ANDNVL(okh.contract_number_modifier,'')=NVL('<contract
modifier>','');
F2. Query to find the install base instances created by a Subscription Contract as a
result of subscription fulfillment.
SELECTcsi.instance_number
FROMoks_subscr_elementsose,
csi_item_instancescsi
WHEREose.dnz_chr_idIN(SELECTid
FROMokc_k_headers_b
WHEREcontract_number='<contractnumber>'
ANDNVL(contract_number_modifier,'')=Nvl('<contractmodifier>',''))
ANDose.order_line_id=csi.last_oe_order_line_id;
F3. Query to find which subscription contract line created the install base instance,
for a subscription fulfillment.
SELECTokh.contract_number,
okh.contract_number_modifier,
okl.line_number
FROMoks_subscr_elementsose,
csi_item_instancescsi,

Oracle CRM Service Contracts Queries

okc_k_headers_bokh,
okc_k_lines_bokl
WHEREcsi.instance_number='<InstanceNumber>'
ANDose.order_line_id=csi.last_oe_order_line_id
ANDokh.id=ose.dnz_chr_id
ANDokl.chr_id=okh.id
ANDokl.id=ose.dnz_cle_id;
G. Order Details for Contracts Created from Order Management
G1. Query which retrieves the order header id and order line id for a given contract.
object1_id1 gives the order header id where jtot_object1_code = OKX_ORDERHEAD
and the order line id where jtot_object1_code = OKX_ORDERLINE
selectokl.idSubline
,okl.cle_idService_Line
,okl.dnz_chr_id
,obj.object1_id1
,obj.jtot_object1_code
fromokc_k_lines_bokl
,okc_k_rel_objs_vobj
whereokl.dnz_chr_id=obj.chr_id
andokl.dnz_chr_id=<contractidfromqueryA1>
andlse_idin(7,8,9,10,11,18,25,35);
G2. The table OKS_K_ORDER_DETAILS captures service contract details when a
service is ordered in Order Management.
SELECT*
FROMOKS_K_ORDER_DETAILS
WHERE
CHR_ID=<contractidfromqueryA1>

Oracle CRM Service Contracts Queries

Service Contract Coverage and Price Information


The hardest part in Service Contract module is that it is pretty new relative to the
other modules such as the Order Management, Inventory, Receivables, etc. The
result of this is being not too familiar on how the tables are related and how to come
up with information.
An example of a requirement is to produce an active contracts with price and
covered item information. This is a sample script. There could be an enhancement
to this but this can be a good basis to extract information which is Install Baseddriven.
select/*+INDEX(grpings,OKC_K_GRPINGS_N1)
INDEX(k,OKC_K_HEADERS_B_N4)
INDEX(okc,OKC_K_LINES_B_N6)
INDEX(kiOKC_K_ITEMS_N2)*/
k.contract_number,
k.start_date,
k.end_date,
hp.party_namecustomer_name,
hcsu.location,
hl.address1,
hl.address2,
hl.address3,
hl.city,
hl.state,
hl.postal_code,
hl.country,
csi.serial_number,
mtl.segment1item,
mtl.descriptionitem_des,
okct.line_number||'.'||okc.line_number
line_number,
okc.price_negotiated
fromOKC_K_HEADERS_Bk,
OKC_K_LINES_Bokc,
OKC_K_LINES_Bokct,
OKC_K_ITEMSki,
okc_k_groups_tlgroups1,
okc_k_grpingsgrpings,
CSI_ITEM_INSTANCEScsi,
MTL_SYSTEM_ITEMS_Bmtl,
hz_cust_accounts_allhca,
hz_partieshp,
hz_cust_site_uses_allhcsu,
hz_locationshl,
hz_party_siteshps,

Oracle CRM Service Contracts Queries

hz_cust_acct_sites_allhcas
where1=1
andgroups1.name='GROUPNAME'
andgroups1.language='US'
andgroups1.id=grpings.cgp_parent_id
andgrpings.included_chr_id=k.id
andk.ship_to_site_use_id=hcsu.site_use_id
andhcsu.site_use_code='SHIP_TO'
andhca.party_id=hp.party_id
andhps.party_id=hp.party_id
andhps.location_id=hl.location_id
andhcsu.cust_acct_site_id=hcas.cust_acct_site_id
andhcas.party_site_id=hps.party_site_id
andk.ID=okc.dnz_chr_id
andk.ID=ki.dnz_chr_id
andokc.lse_id=9
andokc.ID=ki.cle_id
andokct.ID=okc.cle_id
andokc.start_date<=SYSDATE
andokc.end_date>SYSDATE
ANDk.start_date<=SYSDATE
aNDk.end_Date>=SYSDATE
andokct.start_date<=SYSDATE
andokct.end_Date>=SYSDATE
andNVL(okc.date_terminated,SYSDATE+1)>SYSDATE
andNVL(k.date_terminated,SYSDATE+1)>SYSDATE
andki.jtot_object1_codeIN('OKX_CUSTPROD')
andcsi.last_vld_organization_id=mtl.organization_id
andTO_NUMBER(ki.object1_id1)=csi.instance_id
andcsi.inventory_item_id=mtl.inventory_item_id
Another option without considering the termination date as the filter but just select
the termination date would be:
SELECTk.contract_number,k.start_date,k.end_date,hp.party_name
customer_name,hcsu.location,hl.address1,hl.address2,hl.address3,
hl.city,hl.state,hl.postal_code,hl.country,
cii.serial_number,mtl.segment1item,mtl.description
item_des,okct.line_number||'.'||okc.line_number,ocl.service_name,
k.date_terminated
FROM
csi_item_instancescii,
OKC_K_ITEMSki,
OKC_K_LINES_Bokc,
apps.OKS_AUTH_LINES_Vokct,
apps.OKS_LINE_DETAILS_Vocl,
OKC_K_HEADERS_Bk,

Oracle CRM Service Contracts Queries

mtl_system_itemsmtl,
okc_k_grpingsgrpings,
hz_cust_accounts_allhca,hz_partieshp,
hz_cust_site_uses_allhcsu,hz_locationshl,
hz_party_siteshps,hz_cust_acct_sites_allhcas
WHERE1=1
ANDTO_NUMBER(ki.object1_id1)=cii.instance_id
ANDki.jtot_object1_codeIN('OKX_CUSTPROD')
ANDcii.inv_master_organization_id=104ParentOrganizationID
ANDokct.ID=okc.cle_id
ANDokct.id=ocl.line_id(+)
ANDokc.lse_id=9
ANDokc.ID=ki.cle_id
ANDk.ID=okc.dnz_chr_id
ANDk.start_date<=TO_DATE('31DEC2011','DDMONYYYY')
ANDk.start_date>=TO_DATE('01JAN2011','DDMONYYYY')
ANDcii.inventory_item_id=mtl.inventory_item_id
ANDmtl.organization_id=last_vld_organization_id
ANDgrpings.cgp_parent_id=10000oryoucanreplacethiswitha
listofGroupIDsorallIDs
ANDgrpings.included_chr_id=k.id
ANDk.ship_to_site_use_id=hcsu.site_use_id
ANDhcsu.site_use_code='SHIP_TO'
ANDhca.party_id=hp.party_id
ANDhps.party_id=hp.party_id
ANDhps.location_id=hl.location_id
ANDhcsu.cust_acct_site_id=hcas.cust_acct_site_id
ANDhcas.party_site_id=hps.party_site_id
ANDhcsu.org_id=116

You might also like