Showing posts with label SQL QUERIES. Show all posts
Showing posts with label SQL QUERIES. Show all posts

Tuesday, January 2, 2018

Find Responsibility Name attached with Profile

SELECT DISTINCT tr.responsibility_name,

  r.RESPONSIBILITY_KEY,
  r.end_date,
  fpotl.user_profile_option_name,
  fpov.profile_option_value,
  psp.SECURITY_PROFILE_NAME
FROM applsys.fnd_responsibility_tl tr,
  applsys.fnd_responsibility r,
  hr.per_security_profiles psp,
  apps.per_business_groups pbg,
  fnd_profile_options_vl fpovl,
  applsys.fnd_profile_option_values fpov,
  applsys.fnd_profile_options fpo,
  applsys.fnd_profile_options_tl fpotl
WHERE r.responsibility_id          = tr.responsibility_id
AND r.application_id               = tr.application_id
AND fpov.PROFILE_OPTION_ID         = fpovl.PROFILE_OPTION_ID
AND fpov.level_value               = r.responsibility_id
AND psp.BUSINESS_GROUP_ID          = pbg.BUSINESS_GROUP_ID (+)
AND fpov.profile_option_value      = TO_CHAR(psp.SECURITY_PROFILE_id)
AND fpov.level_id                  = 10003
AND fpo.profile_option_id          = fpov.profile_option_id
AND fpotl.profile_option_name      = fpo.profile_option_name
AND fpotl.user_profile_option_name = 'HR: Security Profile'
AND psp.security_profile_name      ='US Federal Government';

Wednesday, August 2, 2017

Global Temporary Table

Global Temporary Tables (GTT)

Applications often use some form of temporary data store for processes that are to complicated to complete in a single pass. Often, these temporary stores are defined as database tables or PL/SQL tables. From Oracle 8i onward, the maintenance and management of temporary tables can be delegated to the server by using Global Temporary Tables.
Related articles.

Creation of Global Temporary Tables

The data in a global temporary table is private, such that data inserted by a session can only be accessed by that session. The session-specific rows in a global temporary table can be preserved for the whole session, or just for the current transaction.
The ON COMMIT DELETE ROWS clause indicates that the data should be deleted at the end of the transaction, or the end of the session.
CREATE GLOBAL TEMPORARY TABLE my_temp_table (
  id           NUMBER,
  description  VARCHAR2(20)
)
ON COMMIT DELETE ROWS;

-- Insert, but don't commit, then check contents of GTT.
INSERT INTO my_temp_table VALUES (1, 'ONE');

SELECT COUNT(*) FROM my_temp_table;

  COUNT(*)
----------
         1

SQL>

-- Commit and check contents.
COMMIT;

SELECT COUNT(*) FROM my_temp_table;

  COUNT(*)
----------
         0

SQL>
In contrast, the ON COMMIT PRESERVE ROWS clause indicates that rows should persist beyond the end of the transaction. They will only be removed at the end of the session.
CREATE GLOBAL TEMPORARY TABLE my_temp_table (
  id           NUMBER,
  description  VARCHAR2(20)
)
ON COMMIT PRESERVE ROWS;

-- Insert and commit, then check contents of GTT.
INSERT INTO my_temp_table VALUES (1, 'ONE');
COMMIT;

SELECT COUNT(*) FROM my_temp_table;

  COUNT(*)
----------
         1

SQL>

-- Reconnect and check contents of GTT.
CONN test/test

SELECT COUNT(*) FROM my_temp_table;

  COUNT(*)
----------
         0

SQL>

Global Temporary Tables and Undo

Although the data in a GTT is written to the temporary tablespace, the associated undo is still written to the normal undo tablespace, which is itself protected by redo, so using a GTT does not reduce undo and the redo associated with protecting the undo tablespace.
The following code creates a conventional table, populates it and checks the amount of undo used by the transaction.
DROP TABLE my_temp_table PURGE;

-- Create conventional table.
CREATE TABLE my_temp_table (
  id           NUMBER,
  description  VARCHAR2(20)
);

-- Populate table.
INSERT INTO my_temp_table
WITH data AS (
  SELECT 1 AS id
  FROM   dual
  CONNECT BY level < 10000
)
SELECT rownum, TO_CHAR(rownum)
FROM   data a, data b
WHERE  rownum <= 1000000;

-- Check undo used by transaction.
SELECT t.used_ublk,
       t.used_urec
FROM   v$transaction t,
       v$session s
WHERE  s.saddr = t.ses_addr
AND    s.audsid = SYS_CONTEXT('USERENV', 'SESSIONID');

 USED_UBLK  USED_UREC
---------- ----------
       302       6237

SQL>
We now repeat the previous test, but this time using a GTT.
DROP TABLE my_temp_table PURGE;

-- Create GTT.
CREATE GLOBAL TEMPORARY TABLE my_temp_table (
  id           NUMBER,
  description  VARCHAR2(20)
)
ON COMMIT PRESERVE ROWS;

-- Populate GTT.
INSERT INTO my_temp_table
WITH data AS (
  SELECT 1 AS id
  FROM   dual
  CONNECT BY level < 10000
)
SELECT rownum, TO_CHAR(rownum)
FROM   data a, data b
WHERE  rownum <= 1000000;

-- Check undo used by transaction.
SELECT t.used_ublk,
       t.used_urec
FROM   v$transaction t,
       v$session s
WHERE  s.saddr = t.ses_addr
AND    s.audsid = SYS_CONTEXT('USERENV', 'SESSIONID');

 USED_UBLK  USED_UREC
---------- ----------
       303       6238

SQL>

TRUNCATE TABLE my_temp_table;
We can see, there is no significant difference in the undo used.
 Oracle 12c introduced the concept of Temporary Undo, allowing the undo for a GTT to be written to the temporary tablespace, thereby reducing undo and redo.

Global Temporary Tables and Redo

If you've read the previous section, you will already know the relationship between global temporary tables and redo. The data in a GTT is written to the temporary tablespace, which is not directly protected by redo, so using a GTT improves performance by reducing redo generation. Unfortunately, prior to Oracle 12c, all undo associated with DML against a GTT is written to the normal undo tablespace, which is itself protected by redo. As a result, using a GTT reduces the amount of redo generation, but does not eliminate it. Another why of describing this is, using a GTT removes direct redo generation, but not indirect redo generation cause by undo.
The following code creates a conventional table, populates it and checks the amount of redo generated by the transaction.
DROP TABLE my_temp_table PURGE;

-- Create conventional table.
CREATE TABLE my_temp_table (
  id           NUMBER,
  description  VARCHAR2(20)
);

SET AUTOTRACE ON STATISTICS;

-- Populate table.
INSERT INTO my_temp_table
WITH data AS (
  SELECT 1 AS id
  FROM   dual
  CONNECT BY level < 10000
)
SELECT rownum, TO_CHAR(rownum)
FROM   data a, data b
WHERE  rownum <= 1000000;

1000000 rows created.

Statistics
----------------------------------------------------------
        106  recursive calls
      20119  db block gets
       2603  consistent gets
         16  physical reads
   23039396  redo size
        853  bytes sent via SQL*Net to client
        987  bytes received via SQL*Net from client
          3  SQL*Net roundtrips to/from client
          6  sorts (memory)
          0  sorts (disk)
    1000000  rows processed

SQL>
We now repeat the previous test, but this time using a GTT.
DROP TABLE my_temp_table PURGE;

-- Create GTT.
CREATE GLOBAL TEMPORARY TABLE my_temp_table (
  id           NUMBER,
  description  VARCHAR2(20)
)
ON COMMIT PRESERVE ROWS;

SET AUTOTRACE ON STATISTICS;

-- Populate GTT.
INSERT INTO my_temp_table
WITH data AS (
  SELECT 1 AS id
  FROM   dual
  CONNECT BY level < 10000
)
SELECT rownum, TO_CHAR(rownum)
FROM   data a, data b
WHERE  rownum <= 1000000;

1000000 rows created.

Statistics
----------------------------------------------------------
         45  recursive calls
      15333  db block gets
       2381  consistent gets
         16  physical reads
    2944180  redo size
        862  bytes sent via SQL*Net to client
        987  bytes received via SQL*Net from client
          3  SQL*Net roundtrips to/from client
          5  sorts (memory)
          0  sorts (disk)
    1000000  rows processed

SQL>

TRUNCATE TABLE my_temp_table;
We can see we have created an order of magnitude less redo when using the GTT, but we have not eliminated it.

Miscellaneous Features

  • If the TRUNCATE statement is issued against a temporary table, only the session specific data is truncated. There is no affect on the data of other sessions.
  • Data in temporary tables is stored in temp segments in the temp tablespace.
  • Data in temporary tables is automatically deleted at the end of the database session, even if it ends abnormally.
  • Indexes can be created on temporary tables. The content of the index and the scope of the index is the same as the database session.
  • Views can be created against temporary tables and combinations of temporary and permanent tables.
  • Temporary tables can have triggers associated with them.
  • Export and Import utilities can be used to transfer the table definitions, but no data rows are processed.
  • Statistics on temporary tables are common to all sessions. Oracle 12c allows session specific statistics.
  • There are a number of restrictions related to temporary tables but these are version specific.
For more information see:

Hope this helps. Regards Tim...

Monday, July 24, 2017

Package for calling Bursting Program for Data template & reports

create or replace PACKAGE      XXJML_ASN_DOLLARS_20170724 AS
   CUST_NO  VARCHAR2(10);
   SHIPPING_DATE  DATE;
 function AfterReport(p_request_id number) return boolean;
END XXJML_ASN_DOLLARS_20170724;



PACKAGE BODY
==============
create or replace PACKAGE BODY      XXJML_ASN_DOLLARS_20170724 AS
function AfterReport(p_request_id number) return boolean
   is
     l_req_id number;
   begin
     l_req_id := fnd_request.submit_request('XDO', 'XDOBURSTREP', '','', FALSE, 'Y', p_request_id, 'Y', CHR(0));
     commit;
     if l_req_id =0
     then
       return false;
     else
       return true;
     end if ;
   exception
     when others
     then
       return FALSE;
   end AfterReport;
END XXJML_ASN_DOLLARS_20170724;

Thursday, July 13, 2017

Query to get the Request Group for concurrent program

SELECT
  RG.APPLICATION_ID "Request Group Application ID",
  RG.REQUEST_GROUP_ID "Request Group - Group ID",
  RG.REQUEST_GROUP_NAME,
  RG.DESCRIPTION,
  rgu.unit_application_id,
  rgu.request_group_id "Request Group Unit - Group ID",
  rgu.request_unit_id,cp.concurrent_program_id,
  cp.concurrent_program_name,
  cpt.user_concurrent_program_name,
  DECODE(rgu.request_unit_type,'P','Program','S','Set',rgu.request_unit_type) "Unit Type"
FROM
  fnd_request_groups rg,
  fnd_request_group_units rgu,
  fnd_concurrent_programs cp,
  FND_CONCURRENT_PROGRAMS_TL CPT
WHERE rg.request_group_id = rgu.request_group_id
  AND rgu.request_unit_id = cp.concurrent_program_id
  AND cp.concurrent_program_id = cpt.concurrent_program_id
  AND cpt.user_concurrent_program_name ='Packing Slip Report PDF Output';

Tuesday, July 11, 2017

to separate the column data into segments based on -

  SELECT
    rtrim(substr('80409-005-00W', 1, instr('80409-005-00W', '-')),'-') first_name ,
    rtrim(substr(ltrim(substr('80409-005-00W', instr('80409-005-00W', '-')),'-'),1,instr(ltrim(substr('80409-005-00W', instr('80409-005-00W', '-')),'-'),'-')),'-') middle_name,
    SUBSTR('80409-005-00W', Instr('80409-005-00W', '-', -1, 1) +1) part2
     FROM  dual;

Tuesday, June 13, 2017

R12 SLA Tables join conditions to AR, AP, INV,Payments and Receiving

R12 SLA Tables join conditions to AR, AP, INV,Payments and Receiving

R12 SLA (Sub ledger Accounting)
Here I am trying to describe R12 SLA(Sub Ledger Accounting) Procedure.
1) All accounting performed before transfer to the GL. Accounting data generated and stored in "Accounting Events" tables prior to transfer to GL


2) Run "Create Accounting" to populate accounting events (SLA) tables. User can "View Accounting" only after "Create Accounting" is run. Create Accounting process
– Applies accounting rules
– Loads SLA tables, GL tables
– Creates detailed data per accounting rules, stores in SLA "distribution links" table


3) Below are the key tables for SLA in R12


XLA_AE_HEADERS xah
XLA_AE_LINES xal
XLA_TRANSACTION_ENTITIES xte
XLA_DISTRIBUTION_LINKS xdl
GL_IMPORT_REFERENCES gir


Below are the possible joins between these XLA Tables


xah.ae_header_id = xal.ae_header_id
xah.application_id = xal.application_id
xal.application_id = xte.application_id
xte.application_id = xdl.application_id
xah.entity_id = xte.entity_id
xah.ae_header_id = xdl.ae_header_id
xah.event_id = xdl.event_id
xal.gl_sl_link_id = gir.gl_sl_link_id
xal.gl_sl_link_table = gir.gl_sl_link_table
xah.application_id = (Different value based on Module)


xte.entity_code =
'TRANSACTIONS' or
'RECEIPTS' or
'ADJUSTMENTS' or
'PURCHASE_ORDER' or
'AP_INVOICES' or
'AP_PAYMENTS' or
'MTL_ACCOUNTING_EVENTS' or
'WIP_ACCOUNTING_EVENTS'


xte.source_id_int_1 =
'INVOICE_ID' or
'CHECK_ID' or
'TRX_NUMBER'


XLA_DISTRIBUTION_LINKS table join based on Source Distribution Types


xdl.source_distribution_type = 'AP_PMT_DIST'
and xdl.source_distribution_id_num_1 = AP_PAYMENT_HIST_DISTS.payment_hist_dist_id
---------------
xdl.source_distribution_type = 'AP_INV_DIST'
and xdl.source_distribution_id_num_1 = AP_INVOICE_DISTRIBUTIONS_ALL.invoice_distribution_id
---------------
xdl.source_distribution_type = 'AR_DISTRIBUTIONS_ALL'
and xdl.source_distribution_id_num_1 = AR_DISTRIBUTIONS_ALL.line_id
and AR_DISTRIBUTIONS_ALL.source_id = AR_RECEIVABLE_APPLICATIONS_ALL.receivable_application_id
---------------
xdl.source_distribution_type = 'RA_CUST_TRX_LINE_GL_DIST_ALL'
and xdl.source_distribution_id_num_1 = RA_CUST_TRX_LINE_GL_DIST_ALL.cust_trx_line_gl_dist_id
---------------
xdl.source_distribution_type = 'MTL_TRANSACTION_ACCOUNTS'
and xdl.source_distribution_id_num_1 = MTL_TRANSACTION_ACCOUNTS.inv_sub_ledger_id
---------------
xdl.source_distribution_type = 'WIP_TRANSACTION_ACCOUNTS'
and xdl.source_distribution_id_num_1 = WIP_TRANSACTION_ACCOUNTS.wip_sub_ledger_id
---------------
xdl.source_distribution_type = 'RCV_RECEIVING_SUB_LEDGER'
and xdl.source_distribution_id_num_1 = RCV_RECEIVING_SUB_LEDGER.rcv_sub_ledger_id.

          Hope this will help you.

Monday, March 13, 2017

Release hold from sales order


CREATE OR REPLACE PROCEDURE Release_Hold_prc (
   p_order_number      IN     NUMBER,
   p_header_id         IN     NUMBER,
   x_hold_rel_status      OUT VARCHAR2)
IS
   ---------------------------
   -- PRIVATE VARIABLES
   ---------------------------
   l_msg_count             NUMBER := 0;
   l_msg_data              VARCHAR2 (500) := NULL;
   l_result_out            VARCHAR2 (50) := NULL; -- Pass or Fail Credit Check
   l_return_status         VARCHAR2 (500) := NULL;
   l_order_tbl             OE_HOLDS_PVT.order_tbl_type;
   l_order_tbl_init        OE_HOLDS_PVT.order_tbl_type;
   g_release_reason_code   VARCHAR2 (50) := 'XX_VALIDATION_PASS';
BEGIN
   l_order_tbl := l_order_tbl_init;

   l_order_tbl (1).header_id := p_header_id;

   DBMS_OUTPUT.put_line (
      'Calling the OE_HOLDS_PUB.Release_Holds API to Relese hold');

   -- Calling the API to release hold on order.
   OE_HOLDS_PUB.Release_Holds (
      p_api_version           => 1.0,
      p_init_msg_list         => FND_API.G_TRUE,
      p_commit                => FND_API.G_FALSE,
      p_validation_level      => NULL,
      p_order_tbl             => l_order_tbl,
      p_hold_id               => NULL,                            --l_hold_id,
      p_release_reason_code   => g_release_reason_code,
      p_release_comment       => 'Order is passed',
      x_return_status         => l_return_status,
      x_msg_count             => l_msg_count,
      x_msg_data              => l_msg_data);

   DBMS_OUTPUT.put_line ('Return Status is :: ' || l_return_status);
   DBMS_OUTPUT.put_line ('Msg Count is     :: ' || l_msg_count);
   DBMS_OUTPUT.put_line ('Msg Data is      :: ' || l_msg_data);

   --If API is Success return 'PASS' or return 'FAIL'.
   IF NVL (l_return_status, 'X') = FND_API.G_RET_STS_SUCCESS
   THEN
      x_hold_rel_status := l_return_status;
   ELSE
      x_hold_rel_status := l_return_status;

      DBMS_OUTPUT.put_line ('hold failure');


      FOR i IN 1 .. l_msg_count
      LOOP
         l_msg_data := oe_msg_pub.get (p_msg_index => i, p_encoded => 'F');

         DBMS_OUTPUT.put_line ('failure:' || l_msg_data);
      END LOOP;
   END IF;

   DBMS_OUTPUT.put_line ('Exiting from Release_Hold_prc');
EXCEPTION
   WHEN OTHERS
   THEN
      l_error := SQLERRM;
      DBMS_OUTPUT.put_line (
            'Error while releasing hold on Header ID :: '
         || p_header_id
         || ' due to : '
         || l_error);
END Release_Hold_prc;

Wednesday, March 8, 2017

Apps General Scripts

Apps General Scripts

List of Contents:

1- Query to get Business Group, Legal Entity Name, Operating Unit Details.
2- Organizations in Oracle Apps
3- P2P & O2C Cycle
4- Inventory Organization and corresponding Operating Unit, Ledger and Legal Entity:
5- Business Group & Legal Entities.
6- Business Group, Legal Entity, Operating Unit, Organizations
7- Business Group, Legal Entity, Operating Unit, Organizations & SubInventories
8- Application ID & Shortname & Name
9- Application Object Libraries (Tables)
10- Script to run before populating ap_invoices_v table data.
11- Script for Application short name, Responsibility_name & Key etc
12- FND Tables
13- In order to get Phone number of supplier/customer site the query will be (HZ Tables)
14- In order to get Phone number of supplier/customer  the query will be (HZ Tables)
15- Inventory items with categories

1- Query to get Business Group, Legal Entity Name, Operating Unit Details

SELECT distinct hrl.country, hroutl_bg.NAME bg, hroutl_bg.organization_id,
       lep.legal_entity_id, lep.NAME legal_entity,
       hroutl_ou.NAME ou_name, hroutl_ou.organization_id org_id,
       hrl.location_id,
       hrl.location_code,
       glev.FLEX_SEGMENT_VALUE
  FROM xle_entity_profiles lep,
       xle_registrations reg,
       hr_locations_all hrl,
       hz_parties hzp,
       fnd_territories_vl ter,
       hr_operating_units hro,
       hr_all_organization_units_tl hroutl_bg,
       hr_all_organization_units_tl hroutl_ou,
       hr_organization_units gloperatingunitseo,
       gl_legal_entities_bsvs glev
 WHERE lep.transacting_entity_flag = 'Y'
   AND lep.party_id = hzp.party_id
   AND lep.legal_entity_id = reg.source_id
   AND reg.source_table = 'XLE_ENTITY_PROFILES'
   AND hrl.location_id = reg.location_id
   AND reg.identifying_flag = 'Y'
   AND ter.territory_code = hrl.country
   AND lep.legal_entity_id = hro.default_legal_context_id
   AND gloperatingunitseo.organization_id = hro.organization_id
   AND hroutl_bg.organization_id = hro.business_group_id
   AND hroutl_ou.organization_id = hro.organization_id
   AND glev.legal_entity_id = lep.legal_entity_id;

2- Organizations in Oracle Apps

1- org_organization_definitions (All orgs & corresponding OU's & SOB's & LE)
2- hr_organization_units ( All Orgs including OU's & Names of orgs with Business Group)
3- mtl_parameters  (All Organizations not OU's)
4- hr_all_organization_units_tl      (All details of OP & Orgs)

3- P2P & O2C Cycle

http://www.slideshare.net/venugopalram/p2-p-and-o2c


4- Inventory Organization and corresponding Operating Unit, Ledger and Legal Entity:

Select a.organization_id, a.organization_code, a.organization_name,
a.operating_unit, b.name OU, a.set_of_books_id,d.name LEDGER,
a.legal_entity,c.name LE_NAME
From  apps. ORG_ORGANIZATION_DEFINITIONS a,
apps. HR_OPERATING_UNITS b,
apps. xle_entity_profiles c,
apps. gl_ledgers d
Where a.operating_unit=b.organization_id
AND c.legal_entity_id=a.legal_entity
AND d.ledger_id=a.set_of_books_id;

5- Business Group & Legal Entities

SELECT pg.business_group_name, pg.working_hours_frequency,
       pg.business_group_short_name, pg.default_currency_code,
       pg.enabled_flag, pg.competence_structure, pg.business_group_id,
       pg.location_id, le.organization_id, le.NAME
  FROM hrfv_business_groups pg, hr_legal_entities le
 WHERE pg.business_group_id = le.business_group_id
   AND pg.business_group_id =81;

6- Business Group, Legal Entity, Operating Unit, Organizations

SELECT PG.BUSINESS_GROUP_ID, pg.business_group_name, pg.working_hours_frequency,
       pg.business_group_short_name, pg.default_currency_code,
       pg.enabled_flag, pg.competence_structure, pg.business_group_id,
       pg.location_id, le.organization_id, le.NAME,
       ORGS.ORGANIZATION_iD ORGS, orgs.organization_code, ORG_ORG_NAMES.NAME ORGANIZATION_NAME,
        ORGS.OPERATING_UNIT OU, ORG_OU_NAME.NAME OPERATING_UNIT_NAME
  FROM hrfv_business_groups pg, hr_legal_entities le, hr_organization_units  ORG_ORG_NAMES,
        hr_organization_units ORG_OU_NAME ,
       (select business_group_id , organization_id , organization_code,  operating_unit from org_organization_definitions
       where business_group_id=81) Orgs
 WHERE pg.business_group_id = le.business_group_id
   AND pg.business_group_id =81
   AND PG.BUSINESS_GROUP_ID = ORGS.BUSINESS_GROUP_ID
   AND PG.BUSINESS_GROUP_ID = ORG_ORG_NAMES.BUSINESS_GROUP_ID
   AND ORGS.ORGANIZATION_ID = ORG_ORG_NAMES.ORGANIZATION_ID
   AND PG.BUSINESS_GROUP_ID = ORG_OU_NAME.BUSINESS_GROUP_ID
   AND ORGS.OPERATING_UNIT = ORG_OU_NAME.ORGANIZATION_ID;

7- Business Group, Legal Entity, Operating Unit, Organizations & Sub Inventories

SELECT PG.BUSINESS_GROUP_ID, pg.business_group_name, pg.working_hours_frequency,
       pg.business_group_short_name, pg.default_currency_code,
       pg.enabled_flag, pg.competence_structure, pg.business_group_id,
       pg.location_id, le.organization_id, le.NAME,
       ORGS.ORGANIZATION_iD ORGS, orgs.organization_code, ORG_ORG_NAMES.NAME ORGANIZATION_NAME,
        ORGS.OPERATING_UNIT OU, ORG_OU_NAME.NAME OPERATING_UNIT_NAME,
        msi.SECONDARY_INVENTORY_NAME, msi.DESCRIPTION
  FROM hrfv_business_groups pg, hr_legal_entities le, hr_organization_units  ORG_ORG_NAMES,
        hr_organization_units ORG_OU_NAME , MTL_SECONDARY_INVENTORIES msi,
       (select business_group_id , organization_id , organization_code,  operating_unit from org_organization_definitions
       where business_group_id=81) Orgs
 WHERE pg.business_group_id = le.business_group_id
   AND pg.business_group_id =81
   AND PG.BUSINESS_GROUP_ID = ORGS.BUSINESS_GROUP_ID
   AND PG.BUSINESS_GROUP_ID = ORG_ORG_NAMES.BUSINESS_GROUP_ID
   AND ORGS.ORGANIZATION_ID = ORG_ORG_NAMES.ORGANIZATION_ID
   AND PG.BUSINESS_GROUP_ID = ORG_OU_NAME.BUSINESS_GROUP_ID
   AND ORGS.OPERATING_UNIT = ORG_OU_NAME.ORGANIZATION_ID
   AND ORGS.ORGANIZATION_ID = MSI.ORGANIZATION_ID;

8- Application ID & Shortname & Name

SELECT fa.application_id           "Application ID",
       fat.application_name        "Application Name",
       fa.application_short_name   "Application Short Name",
       fa.basepath                 "Basepath"
  FROM fnd_application     fa,
       fnd_application_tl  fat
 WHERE fa.application_id = fat.application_id
   AND fat.language      = 'US';

9- AOL (Application Object Libraries) Tables

FND_APPLICATION Applications registered with Oracle Application Object Library
FND_CONCURRENT_PROGRAMS Concurrent programs
FND_CONCURRENT_REQUESTS Concurrent requests information
FND_CURRENCIES Currencies enabled for use at your site
FND_DATA_GROUPS Data groups registered with Oracle Application Object Library
FND_FLEX_VALUES Valid values for flexfield segments
FND_FLEX_VALUE_HIERARCHIES Child value ranges for key flexfield segment values
FND_FLEX_VALUE_SETS Value sets used by both key and descriptive flexfields
FND_FORM Application forms registered with Oracle Application Object Library
FND_FORM_FUNCTIONS Functionality groupings
FND_ID_FLEXS Registration information about key flexfields
FND_ID_FLEX_SEGMENTS Key flexfield segments setup information and correspondences between table columns and key flexfield segments
FND_ID_FLEX_STRUCTURES Key flexfield structure information
FND_LOOKUP_TYPES Oracle Application Object Library QuickCodes
FND_LOOKUP_VALUES QuickCode values
FND_MENUS New menu tabl for Release 10SC
FND_PROFILE_OPTIONS User profile options
FND_PROFILE_OPTION_VALUES Values of user profile options defined at different profile levels
FND_REQUEST_SETS Reports sets
FND_REQUEST_SET_PROGRAMS Reports within report sets
FND_REQUEST_SET_STAGES Stores request set stages
FND_RESPONSIBILITY Responsibilities
FND_RESP_FUNCTIONS Function Security
FND_USER Application users

10 - Script to run before query view ap_invoices_v


begin 
MO_GLOBAL.SET_ORG_CONTEXT('101',NULL,'SQLAP'); 

end; 

101 is operating unit which data will be populated in it.

11 - Script for Application short name, Responsibility_name & Key etc


SELECT A.APPLICATION_ID, A.APPLICATION_SHORT_NAME , A.PRODUCT_CODE, AA.APPLICATION_NAME,
       R.RESPONSIBILITY_ID, R.RESPONSIBILITY_KEY , RR.RESPONSIBILITY_NAME
FROM
FND_APPLICATION A , FND_APPLICATION_TL AA ,
FND_RESPONSIBILITY R,  FND_RESPONSIBILITY_TL RR
WHERE
A.APPLICATION_ID = AA.APPLICATION_ID AND
A.APPLICATION_ID = R.APPLICATION_ID AND
R.RESPONSIBILITY_ID = RR.RESPONSIBILITY_ID AND
R.APPLICATION_ID = RR.APPLICATION_ID
    AND AA.LANGUAGE='US';

12 - FND Tables 

FND_APPLICATION: 
 Stores applications registered with Oracle Application Object Library.
FND_APPLICATION_TL: 
Stores translated information about all the applications registered with Oracle Application Object Library.
FND_APP_SERVERS: 
This table will track the servers used by the E-Business Suite system.
FND_ATTACHED_DOCUMENTS: 
Stores information relating a document to an application entity.
FND_CONCURRENT_PROCESSES: 
Stores information about concurrent managers.
FND_CONCURRENT_PROCESSORS: 
Stores information about immediate (subroutine) concurrent program libraries.
FND_CONCURRENT_PROGRAMS: 
Stores information about concurrent programs. Each row includes a name and description of the concurrent program.
FND_CONCURRENT_PROGRAMS_TL: 
Stores translated information about concurrent programs in each of the installed languages.
FND_CONCURRENT_QUEUES: 
Stores information about concurrent managers.

FND_CONCURRENT_QUEUE_SIZE: 
Stores information about the number of requests a concurrent manager can process at once, according to its work shift.
FND_CONCURRENT_REQUESTS: 
Stores information about individual concurrent requests.
FND_CONCURRENT_REQUEST_CLASS: 
Stores information about concurrent request types.
FND_CONC_REQ_OUTPUTS: 
This table stores output files created by Concurrent Request.
FND_CURRENCIES: 
Stores information about currencies.
FND_DATABASES: 
It tracks the databases employed by the eBusiness suite. This table stores information about the database that is not instance specific.
FND_DATABASE_INSTANCES: 
Stores instance specific information. Every database has one or more instance.
FND_DESCRIPTIVE_FLEXS: 
Stores setup information about descriptive flexfields.
FND_DESCRIPTIVE_FLEXS_TL: 
Stores translated setup information about descriptive flexfields.
FND_DOCUMENTS: 
Stores language-independent information about a document.
FND_EXECUTABLES: 
Stores information about concurrent program executables.
FND_FLEX_VALUES: 
Stores valid values for key and descriptive flexfield segments.
FND_FLEX_VALUE_SETS: 
Stores information about the value sets used by both key and descriptive flexfields.
FND_LANGUAGES: 
Stores information regarding languages and dialects.
FND_MENUS: 
It lists the menus that appear in the Navigate Window, as determined by the System Administrator when defining responsibilities for function security.
FND_MENUS_TL: 
Stores translated information about the menus in FND_MENUS.
FND_MENU_ENTRIES: 
Stores information about individual entries in the menus in FND_MENUS.
FND_PROFILE_OPTIONS: 
Stores information about user profile options.
FND_REQUEST_GROUPS: 
Stores information about report security groups.
FND_REQUEST_SETS: 
Stores information about report sets.
FND_RESPONSIBILITY: 
Stores information about responsibilities. Each row includes the name and description of the responsibility, the application it belongs to, and values that identify the main menu, and the first form that it uses.
FND_RESPONSIBILITY_TL: 
Stores translated information about responsibilities.
FND_RESP_FUNCTIONS: 
Stores security exclusion rules for function security menus. Security exclusion rules are lists of functions and menus inaccessible to a particular responsibility.
FND_SECURITY_GROUPS: 
Stores information about security groups used to partition data in a Service Bureau architecture.
FND_SEQUENCES: 
Stores information about the registered sequences in your applications.
FND_TABLES: 
Stores information about the registered tables in your applications.
FND_TERRITORIES: 
Stores information for countries, alternatively known as territories.
FND_USER: 
Stores information about application users.
FND_VIEWS: 
Stores information about the registered views in your applications.

13- In order to get Phone number of supplier/Customer site the query will be (HZ Tables)

Select hz.party_id, hz.party_name, hps.party_site_name, hcp.phone_number
from      hz_contact_points hcp,
    hz_party_sites hps,
hz_parties hz
where
hz.party_id=77042 and
hz.party_id = hps.party_id(+) and
hps.party_site_id = hcp.owner_table_id(+) and
hcp.owner_table_name='HZ_PARTY_SITES' and
 hz.application_id=200;

* If you replace application_id to 222 then you can get the detail of Customer

14- In order to get Phone number of supplier/Customer  the query will be (HZ Tables)


Select hz.party_id, hz.party_name,  hcp.phone_number
from   hz_contact_points hcp,
hz_parties hz,
hz_relationships hr
where 
hz.party_id=77042 and
    hz.party_id = hr.object_id(+) and
    hr.party_id = hcp.owner_table_id(+) and
hcp.owner_table_name='HZ_PARTIES' 
 hz.application_id=200;

* If you replace application_id to 222 then you can get the detail of Customer

14- Inventory items with categories

SELECT I.INVENTORY_ITEM_ID, I.SEGMENT1 ITEM_CODE, I.DESCRIPTION ITEM_DETAIL,
i.PRIMARY_UNIT_OF_MEASURE
, C.CATEGORY_ID, CD.DESCRIPTION
FROM MTL_SYSTEM_ITEMS_B I , MTL_ITEM_CATEGORIES C, MTL_CATEGORIES CD
WHERE I.ORGANIZATION_ID=127 AND I.ORGANIZATION_ID = C.ORGANIZATION_ID AND

I.INVENTORY_ITEM_ID = C.INVENTORY_ITEM_ID  AND C.CATEGORY_ID = CD.CATEGORY_ID;

Oracle Fusion - Cost Lines and Expenditure Item link in Projects

SELECT   ccd.transaction_id,ex.expenditure_item_id,cacat.serial_number FROM fusion.CST_INV_TRANSACTIONS cit,   fusion.cst_cost_distribution_...