Extract Employee and Supervisor Based on Position Hierarchy

This SQL will give you employee and Supervisor as per position hierarchy .

/* Formatted on 2009/10/19 15:01 (Formatter Plus v4.8.8) */
SELECT LPAD (‘ ‘, 5 * LEVEL) || has.NAME hierarchy, LEVEL,
hap.NAME parent_name, pse.parent_position_id, has.NAME child_name,
pse.subordinate_position_id
FROM (SELECT NAME, position_id
FROM hr_all_positions_f_tl
WHERE LANGUAGE = USERENV (‘LANG’)) hap,
(SELECT NAME, position_id
FROM hr_all_positions_f_tl
WHERE LANGUAGE = USERENV (‘LANG’)) has,
per_pos_structure_elements pse
WHERE pse.business_group_id = 81
AND hap.position_id = pse.parent_position_id
AND has.position_id = pse.subordinate_position_id
start with pse.parent_position_id = –40979 Base Position Id (like CEO etc)
CONNECT BY PRIOR pse.subordinate_position_id = pse.parent_position_id
AND PRIOR pse.pos_structure_version_id = pse.pos_structure_version_id
AND PRIOR pse.business_group_id = pse.business_group_id
ORDER BY 4

How to Get Approval Group assigned to specific Job and Position in Oracle Purchasing

Remittance Advice by Email to Supplier by Using UTL_SMTP

How can one recover ? If one the apps password changed through FNDCPASS when application and database is running

How to Turn On “About This Page” in Oracle R12 Web Forms

Set Following Profile Options as Required at User or Site

Personalize Self-Service Defn = YES

FND: Personalization Region Link Enabled = YES

Disable Self-Service Personal = NO (Only at Site)

FND: Diagnostics = Yes

Bounce the Apache Server

Login to Application you can see the About This Page Link on all web pages

By Using About This Page link you can have almost all information of technology Stack

How to Get Supplier Bank Detail In R12

In Release 12, Payables Supplier Bank Information is stored somewhere else instead of PO_VENDORS table as in 11i. After going thru the guides, it seems that the bank information (such as bank account numbers, etc) for suppliers may be in TCA or in Cash Management Bank Model. Please provide the tables names where bank account information and other bank related information is stored?

By Using Following Queries you can get Required Information on Basis on Supplier Site Name

/* For Supplier Bank Account Number Use This One */

SELECT bank_account_name, bank_account_num, branch_id

FROM iby_ext_bank_accounts

WHERE ext_bank_account_id IN (

SELECT ext_bank_account_id

FROM iby_account_owners

WHERE account_owner_party_id IN (

SELECT party_id

FROM hz_party_sites

WHERE party_site_name LIKE

‘%UPC%’))

/* USE THIS QUERY TO GET BANK NAME AND BANK BRANCH NAME OF SUPPLIER BANK*/

SELECT BANKORGPROFILE.HOME_COUNTRY BANK_HOME_COUNTRY,

BANKORGPROFILE.PARTY_ID BANK_PARTY_ID,

BANKORGPROFILE.ORGANIZATION_NAME BANK_NAME,

BANKORGPROFILE.BANK_OR_BRANCH_NUMBER BANK_NUMBER,

BRANCHPARTY.PARTY_ID BRANCH_PARTY_ID,

BRANCHPARTY.PARTY_NAME BANK_BRANCH_NAME,

BRANCHPARTY.PARTY_ID

FROM HZ_ORGANIZATION_PROFILES BANKORGPROFILE,

HZ_CODE_ASSIGNMENTS BANKCA,

HZ_PARTIES BRANCHPARTY,

HZ_ORGANIZATION_PROFILES BRANCHORGPROFILE,

HZ_CODE_ASSIGNMENTS BRANCHCA,

HZ_RELATIONSHIPS BRREL,

HZ_CODE_ASSIGNMENTS BRANCHTYPECA,

HZ_CONTACT_POINTS BRANCHCP,

HZ_CONTACT_POINTS EDICP

WHERE SYSDATE BETWEEN TRUNC (BANKORGPROFILE.EFFECTIVE_START_DATE)

AND NVL (TRUNC (BANKORGPROFILE.EFFECTIVE_END_DATE),

SYSDATE + 1

)

AND BANKCA.CLASS_CATEGORY = ‘BANK_INSTITUTION_TYPE’

AND BANKCA.CLASS_CODE IN (‘BANK’, ‘CLEARINGHOUSE’)

AND BANKCA.OWNER_TABLE_NAME = ‘HZ_PARTIES’

AND (BANKCA.STATUS = ‘A’ OR BANKCA.STATUS IS NULL)

AND BANKCA.OWNER_TABLE_ID = BANKORGPROFILE.PARTY_ID

AND BRANCHPARTY.PARTY_TYPE = ‘ORGANIZATION’

AND BRANCHPARTY.STATUS = ‘A’

AND BRANCHORGPROFILE.PARTY_ID = BRANCHPARTY.PARTY_ID

AND SYSDATE BETWEEN TRUNC (BRANCHORGPROFILE.EFFECTIVE_START_DATE)

AND NVL (TRUNC (BRANCHORGPROFILE.EFFECTIVE_END_DATE),

SYSDATE + 1

)

AND BRANCHCA.CLASS_CATEGORY = ‘BANK_INSTITUTION_TYPE’

AND BRANCHCA.CLASS_CODE IN (‘BANK_BRANCH’, ‘CLEARINGHOUSE_BRANCH’)

AND BRANCHCA.OWNER_TABLE_NAME = ‘HZ_PARTIES’

AND (BRANCHCA.STATUS = ‘A’ OR BRANCHCA.STATUS IS NULL)

AND BRANCHCA.OWNER_TABLE_ID = BRANCHPARTY.PARTY_ID

AND BANKORGPROFILE.PARTY_ID = BRREL.OBJECT_ID

AND BRREL.RELATIONSHIP_TYPE = ‘BANK_AND_BRANCH’

AND BRREL.RELATIONSHIP_CODE = ‘BRANCH_OF’

AND BRREL.STATUS = ‘A’

AND BRREL.SUBJECT_TABLE_NAME = ‘HZ_PARTIES’

AND BRREL.SUBJECT_TYPE = ‘ORGANIZATION’

AND BRREL.OBJECT_TABLE_NAME = ‘HZ_PARTIES’

AND BRREL.OBJECT_TYPE = ‘ORGANIZATION’

AND BRREL.SUBJECT_ID = BRANCHPARTY.PARTY_ID

AND BRANCHTYPECA.CLASS_CATEGORY(+) = ‘BANK_BRANCH_TYPE’

AND BRANCHTYPECA.PRIMARY_FLAG(+) = ‘Y’

AND BRANCHTYPECA.OWNER_TABLE_NAME(+) = ‘HZ_PARTIES’

AND BRANCHTYPECA.OWNER_TABLE_ID(+) = BRANCHPARTY.PARTY_ID

AND BRANCHTYPECA.STATUS(+) = ‘A’

AND BRANCHCP.OWNER_TABLE_NAME(+) = ‘HZ_PARTIES’

AND BRANCHCP.OWNER_TABLE_ID(+) = BRANCHPARTY.PARTY_ID

AND BRANCHCP.CONTACT_POINT_TYPE(+) = ‘EFT’

AND BRANCHCP.STATUS(+) = ‘A’

AND EDICP.OWNER_TABLE_NAME(+) = ‘HZ_PARTIES’

AND EDICP.OWNER_TABLE_ID(+) = BRANCHPARTY.PARTY_ID

AND EDICP.CONTACT_POINT_TYPE(+) = ‘EDI’

AND EDICP.STATUS(+) = ‘A’

AND BRANCHCA.OWNER_TABLE_ID = :IBY_BRANCH_ID /*USER BRANCH ID FROM ABOVE QUERY*/

If anyone have a better solution then please update

Join Processing in Oracle

In a query involving more than one table, join processing is involved to determine the most optimal plan to perform the join. This comprises:

  1. Join cardinality
  2. Enumerating join orders
  3. Evaluating the costs associated with each join path under each join method.

Join Cardinality

Join cardinality is the determination of the number of rows that will make up the joined relation. In the worst case, we have no join predicates and the cardinality is the Cartesian product of the two or more tables involved. But typically when two or more tables participate in a join, the join is based on values of some columns. Using the statistical descriptions on the columns and the number of rows in each table, we calculate the cardinality of the joined form.

Join Orders

A “Join Order” is a particular permutation of ordering the access to tables participating in the join to complete the joined relation. Join orders depend on the type of join or the join topology. Depending on the structuring of the join predicates, joins can be classified into various types viz chain, star, cycle, complete graph, etc. For example, consider the query with a three table join -

SELECT … FROM t1,t2,t3 WHERE

t1.col1 = t2.col1 AND

t2.col1 = t3.col1 ;

Tables t1, t2 and t3 are joined in a chain order.

Tables t1,t2,t3 can be joined in n! i.e n factorial way .

where n is number of tables .

So in This case it will be 3*2*1=6

Possible join orders:

t1->t2->t3, t2->t1->t3, t2->t3->t1, t3->t2->t1

t1->t3->t2, t3->t1->t2

Note the Join orders such as t1->t3->t2, t3->t1->t2 are evaluated using

Cartesian product as there is no join predicate specified between t1 and t3.

Each of the join orders are possible and need to be evaluated for resource usage. As number of tables increase, depending on the join topology, the search space or the possible permutations go up steeply. Several techniques are used to prune the search space and reduce the work involved in identifying the best join order.

Evaluating Join Path Costs

For each join order, the optimizer evaluates the cost of performing the join by breaking the order into pairs. The first part is made of the relations already joined and the second part of the next table to be joined. Costs are considered using both join methods currently implemented in the kernel, the sort-merge join method and the nested-loops join method.

In the sort-merge method, the tables participating in the join are first sorted by the join columns. The sorted relations are then joined. The cost of performing join by this method includes the sorting costs and the cost of retrieving sorted records to perform the join.

In the nested-loops method, we scan the outer table row one at a time and for each row retrieved, we access the inner table based on the join columns. The outer table will actually be a joined relation where more than two tables are joined. The cost of performing the join in this method includes the cost of accessing the outer table and for each row retrieved and the cost of fetching the group of rows from the inner table based on the join columns.

For each table in a particular join order, there is a large number of possible access paths, the table can be accessed using a ROWID or could be accessed by doing a table scan. Alternatively, it may be accessed using a single index or a cluster scan or a merge of several single column no unique indexes.

Several rules are used to narrow down or prune the search space to speed up access path selection. For example, if there is a lookup by ROWID, it is considered the best and we don’t bother to evaluate other access paths open to the table.

Source := US Education Website

How can I unreserved quantity, Reserved against a closed / canceled sale order

Problem

In one of my operating unit sale officer enter order and released to ware house, after that sale officer cancel that sale order. Now it showing me quantity reserved for that sale order in system but actually order is canceled how can I unreserved this quantity

Solution

For 11i – 11.5.7 / INV.G and above
——————————————-

Download and review Patch.3170660 “script i2471362.sql not correcting orders for cancelled qty”

Run i2471362.sql to remove any old reservations

To delete a reservation manually

NAVIGATE to INV/On hand Availability/ Reservations Query up the item and find the associated row for the order Place cursor on the row to be deleted and click on delete icon and save icon.

Reference

Metalink Note Id 150081.1

Price List Bulk Loader Example Scripts

Please apply Patch#4900462 and find the following example scripts under QP_TOP/patch/11.5/sql directory.

QPBLKEX1.sql – Script populates interface tables to insert price list header and price list line.

QPBLKEX2.sql – Script populates interface tables to insert price list header and price list line and pricing attributes.

QPBLKEX3.sql – Script populates interface tables to insert price list header and price break line.

QPBLKEX4.sql – Script populates interface tables to update price list header with qualifiers.

QPBLKEX5.sql – Script populates interface tables to attach secondary price lists to the primary price list.

Serial number is not available when doing a inventory transaction but shows in on hand quantity

Script to Clear Orders Stuck in Workflow @ Releasing

If you have some order lines in booked status and the ship line activity is in error instead of ‘Notified’ then use the following script (But check on Test Environment first). Pass the line_id for one of the line from problematic order and check if this will progress the line to ‘Awaiting Shipping’ and the work flow activity to Notified status.

set serveroutput on
Declare

l_line_id NUMBER := &line_id; /* Order Line Id*/
l_org_id NUMBER; /* Organization Id*/
l_count NUMBER;
l_activity_id NUMBER;
l_result VARCHAR2(30);

Begin

OE_Standard_WF.OEOL_SELECTOR
(p_itemtype => ‘OEOL’
,p_itemkey => to_char(l_line_id) /* Order Line Id*/
,p_actid => 12345
,p_funcmode => ‘SET_CTX’
,p_result => l_result
);

select activity_id
into l_activity_id
from wf_item_activity_statuses_v
where item_type = ‘OEOL’
and activity_name = ‘SHIP_LINE’
and item_key = to_char(l_line_id)
and activity_status_code = ‘ERROR’;

wf_item_activity_status.create_status(‘OEOL’,to_char(l_line_id),l_activity_id,wf_engine.eng_notified,wf_engine.eng_null,SYSDATE,null);
commit;
End;
/

What Notification Types are available in Oracle Service

The following Notifications are available:”You can set up the application to automatically notify the service request owner and customer contacts associated with the service request whenever a certain event occurs, for example, whenever a service request is created, closed, or reassigned. Notifications can be sent via Oracle Workflow notifications or by e-mail.

Oracle TeleService includes a notification workflow and notification templates suitable for different types of events, but implementers must set up the rules that trigger the workflow. The rules make it possible to selectively notify users only about events of interest to the organization. This notification functionality enhances and replaces notifications through the Call Support Process workflow which can be associated with Service Request Types. The Call Support Process notifies users each and every time a service request is updated. This release includes one seeded notification rule: If service request status changes to closed, then notify the primary contacts of related service requests.

The following table describes the events that can trigger a notification message to be sent and the scope of the rule you can create.

1. Contact Added to Service Request

2. Published Solution Added to Service Request

3. Service Request Status Changed

4. Service Request Created

5. Service Request Owner Changed

6. Relationship Created

7. Relationship Removed

8. Service Request Updated

The Notifications that are available in Oracle Service can be set up via the Customer Support -> Setup -> Service Requests -> Notification Rules form.

Reference

Metalink

Oracle® TeleService Implementation Guide

How to Delete Stock Locators by Using API

How to Create Stock Locators By using API

How to Exract Service Activity LOV Detail

SELECT cs_txn_billing_oetxn_all.org_id, cs_transaction_types_vl.NAME,
cs_transaction_types_vl.description,
cs_txn_billing_types.billing_type,
cs_transaction_types_vl.revision_flag,
cs_transaction_types_vl.new_cp_return_required,
cs_transaction_types_vl.new_cp_status_code,
cs_transaction_types_vl.installed_cp_return_required,
cs_transaction_types_vl.installed_status_code,
cs_txn_billing_types.txn_billing_type_id,
cs_transaction_types_vl.no_charge_flag,
cs_txn_billing_oetxn_all.order_type_id, csd_repairs.repair_line_id,
cs_txn_billing_oetxn_all.line_type_id,
cs_transaction_types_vl.line_order_category_code line_category_code,
cs_bus_process_txns.transaction_type_id
FROM csd_repairs,
csd_repair_types_b,
cs_bus_process_txns,
cs_transaction_types_vl,
cs_txn_billing_types,
cs_txn_billing_oetxn_all
WHERE csd_repair_types_b.repair_type_id = csd_repairs.repair_type_id
AND cs_bus_process_txns.business_process_id =
csd_repair_types_b.business_process_id
AND cs_transaction_types_vl.transaction_type_id =
cs_bus_process_txns.transaction_type_id
AND (TO_DATE (SYSDATE) BETWEEN NVL
(cs_bus_process_txns.start_date_active,
TO_DATE (SYSDATE)
)
AND NVL (cs_bus_process_txns.end_date_active,
TO_DATE (SYSDATE)
)
)
AND cs_transaction_types_vl.transaction_type_id =
cs_txn_billing_types.transaction_type_id
AND cs_txn_billing_types.billing_type = ‘M’
AND cs_txn_billing_oetxn_all.txn_billing_type_id =
cs_txn_billing_types.txn_billing_type_id
– AND cs_transaction_types_vl.line_order_category_code = ‘RETURN’
AND NVL (cs_transaction_types_vl.depot_repair_flag, ‘N’) = ‘Y’
ORDER BY cs_transaction_types_vl.NAME

How to Check Order In Workflow Error and Not Bookable

By Using Following Query you can extract Order Number and Other Details which are in Work flow Error

SELECT h.order_number, h.org_id “Operating Unit ID”, h.ordered_date,
h.header_id, h.cancelled_flag, h.open_flag, h.flow_status_code,
h.creation_date, h.last_update_date,
(SELECT COUNT (1)
FROM oe_order_lines_all l
WHERE l.header_id = h.header_id AND open_flag = ‘Y’) “Order Open”
FROM oe_order_headers_all h, wf_items wi
WHERE wi.item_type = ‘OEOH’
AND wi.item_key = TO_CHAR (h.header_id)
AND h.open_flag = ‘Y’
AND NOT EXISTS (
SELECT ‘WF is pending’
FROM wf_item_activity_statuses wias
WHERE wias.item_key = TO_CHAR (h.header_id)
AND wias.item_type = ‘OEOH’)

How to Get Detail of Locks with Object Locked

SELECT VLO.OS_USER_NAME “OS USERNAME”, VLO.ORACLE_USERNAME “DB USER”,
VP.SPID “SPID”, AO.OWNER “OWNER”, AO.OBJECT_NAME “OBJECT LOCKED”,AO.OBJECT_TYPE,
DECODE (VLO.LOCKED_MODE,
1, ‘NO LOCK’,
2, ‘ROW SHARE’,
3, ‘ROW EXCLUSIVE’,
4, ‘SHARE’,
5, ‘SHARE ROW EXCL’,
6, ‘EXCLUSIVE’,
NULL
) “MODE OF LOCK”,
VS.STATUS “CURRENT STATUS”
FROM V$LOCKED_OBJECT VLO, ALL_OBJECTS AO, V$SESSION VS, V$PROCESS VP
WHERE VLO.OBJECT_ID = AO.OBJECT_ID
AND VS.STATUS <> ‘KILLED’
AND VLO.SESSION_ID = VS.SID
AND VS.PADDR = VP.ADDR;

How to Call Customized Function in Personalization

Add Responsibility to your USER without having Application System Administrator Rights

By following procedure you can add responsibility to your USER with out having Application System Administrator Rights

begin
fnd_user_pkg.addresp(
‘&User_Name’, /*Application User Name */
‘&Responsablity_Application_Short_Name’, /*get from Query Below */
‘&Responsibility_Key’,/*get from Query Below */
‘&Security_Group’, /* Most of cases it is ‘STANDARD’ so you can hard code it */
‘&Description’, /* Any comments you want */
‘&Start_Date’, /* Sysdate From Today */
‘&End_Date’ ); /* Sysdate + 365 Rights for Next One Year*/
commit;

dbms_output.put_line(‘Responsibility Added Successfully’);
exception
when others then
dbms_output.put_line(‘ Responsibility is not added due to ‘ || SQLCODE || substr(SQLERRM, 1, 100));
Rollback;

end;

To get value for ‘Responsablity_Application_Short_Name’ and ‘Responsibility_Key’ Parameters you need to run following sql Statement by Using APPS User Name

SELECT FAV.APPLICATION_SHORT_NAME, FAV.APPLICATION_NAME,FRV.RESPONSIBILITY_KEY, FRV.RESPONSIBILITY_NAME

FROM FND_APPLICATION_VL FAV, FND_RESPONSIBILITY_VL FRV
WHERE FRV.APPLICATION_ID=FAV.APPLICATION_ID
ORDER BY FRV.RESPONSIBILITY_NAME

@Advanced Supply Chain Planner

EXAMPLE CODE 

To add Responsibility of @Advanced Supply Chain Planner to User Ahmad Bilal

BEGIN
fnd_user_pkg.addresp (‘AHMADBILAL’,
‘MSC’,
‘ADV_SUPPLY_CHAIN_PLANNING’,
‘STANDARD’,
‘Test By Script’,
SYSDATE,
SYSDATE + 100
);
COMMIT;
DBMS_OUTPUT.put_line (‘Responsibility Added Successfully’);
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (   ‘ Responsibility is not added due to ‘
|| SQLCODE
|| SUBSTR (SQLERRM, 1, 100)
);
ROLLBACK;
END;

Sub Queries in Oracle SQL and their types

What is a Sub Query?

A query nested inside another query and it is used when a query is based on an unknown value. A sub query is a complete query nested in the SELECT, FROM, HAVING, or WHERE clause of another query the sub query must be enclosed in parentheses and have a SELECT and a FROM clause, at a minimum.

What are the types of Sub Queries?

Single Row Sub Query

Return the outer query one row of results that consists of one column

Multiple Row Sub Query

Return to the outer query more then one row of the results it Require use of IN, ANY, ALL, or EXISTS operators

Multiple Column Sub Query

Return to the outer query more then one row of the results in this type of query Column list on the left side of operator must be in parentheses it use the IN operator for WHERE and HAVING clauses

Correlated Sub Query

Reference a column in the outer query and execute the sub query once for every row in outer query

Uncorrelated Sub Query

Execute the sub query first and passes the value to outer query

 

Source Oracle Introduction to Database