Sunday, November 24, 2019

FND_PROFILE & FND_GLOBAL values

Following are the FND_PROFILE values that can be used in the PL/SQL code:

   fnd_profile.value('PROFILEOPTION');
   fnd_profile.value('MFG_ORGANIZATION_ID');
   fnd_profile.value('ORG_ID');
   fnd_profile.value('LOGIN_ID');
   fnd_profile.value('USER_ID');
   fnd_profile.value('USERNAME');
   fnd_profile.value('CONCURRENT_REQUEST_ID');
   fnd_profile.value('GL_SET_OF_BKS_ID');
   fnd_profile.value('SO_ORGANIZATION_ID');
   fnd_profile.value('APPL_SHRT_NAME');
   fnd_profile.value('RESP_NAME');
   fnd_profile.value('RESP_ID');

Following are the FND_GLOBAL values that can be used in the PL/SQL code:

   FND_GLOBAL.USER_ID;
   FND_GLOBAL.APPS_INTIALIZE;
   FND_GLOBAL.LOGIN_ID;
   FND_GLOBAL.CONC_LOGIN_ID;
   FND_GLOBAL.PROG_APPL_ID;
   FND_GLOBAL.CONC_PROGRAM_ID;
   FND_GLOBAL.CONC_REQUEST_ID;

For example, I almost always use the following global variable assignments in my package specification to use throughout the entire package body:

   g_user_id      PLS_INTEGER  :=  fnd_global.user_id;
   g_login_id     PLS_INTEGER  :=  fnd_global.login_id;
   g_conc_req_id  PLS_INTEGER  :=  fnd_global.conc_request_id;
   g_org_id       PLS_INTEGER  :=  fnd_profile.value('ORG_ID');
   g_sob_id       PLS_INTEGER  :=  fnd_profile.value('GL_SET_OF_BKS_ID');

And initialize the application environment as follows:

   v_resp_appl_id  := fnd_global.resp_appl_id;
   v_resp_id       := fnd_global.resp_id;
   v_user_id       := fnd_global.user_id;
   
   FND_GLOBAL.APPS_INITIALIZE(v_user_id,v_resp_id, v_resp_appl_id);

Thursday, November 21, 2019

Query to find all responsibilities of a user

SELECT fu.user_name                "User Name",
       frt.responsibility_name     "Responsibility Name",
       furg.start_date             "Start Date",
       furg.end_date               "End Date",     
       fr.responsibility_key       "Responsibility Key",
       fa.application_short_name   "Application Short Name"
  FROM fnd_user_resp_groups_direct        furg,
       applsys.fnd_user                   fu,
       applsys.fnd_responsibility_tl      frt,
       applsys.fnd_responsibility         fr,
       applsys.fnd_application_tl         fat,
       applsys.fnd_application            fa
 WHERE furg.user_id             =  fu.user_id
   AND furg.responsibility_id   =  frt.responsibility_id
   AND fr.responsibility_id     =  frt.responsibility_id
   AND fa.application_id        =  fat.application_id
   AND fr.application_id        =  fat.application_id
   AND frt.language             =  USERENV('LANG')
   AND UPPER(fu.user_name)      =  UPPER('xxuser')
 ORDER BY frt.responsibility_name;

Saturday, November 16, 2019

Supplier Conversion in Oracle Apps R12

In My scenario it is a conversion. Just one time loading Suppliers in Oracle Apps.
In short I will explain and attached the code below:

This is only one file having Supplier Headers, Sites and Supplier Contacts.
Based on the file developed one Stage table to store till Import into Interface Tables:

/* Stage Table */
create table XX_SUPP_INT_STG
(
  vendor_name                VARCHAR2(240),
  vendor_name_alt            VARCHAR2(320),
  legacy_vendor_num          VARCHAR2(30),
  vendor_type                VARCHAR2(30),
  organization_name          VARCHAR2(240),
  country                    VARCHAR2(25),
  address_line1              VARCHAR2(240),
  address_line2              VARCHAR2(240),
  address_line3              VARCHAR2(240),
  address_line4              VARCHAR2(240),
  city                       VARCHAR2(60),
  state                      VARCHAR2(60),
  province                   VARCHAR2(60),
  postal_code                VARCHAR2(20),
  vendor_site_code           VARCHAR2(15),
  purchasing_site            VARCHAR2(1),
  pay_site                   VARCHAR2(1),
  phone_area_code            VARCHAR2(10),
  phone_number               VARCHAR2(15),
  fax_area_code              VARCHAR2(10),
  fax                        VARCHAR2(15),
  site_email                 VARCHAR2(2000),
  allow_wht_tax_header_level VARCHAR2(1),
  invoice_wht_tax_group_hdr  NUMBER(15),
  allow_wht_tax_site_level   VARCHAR2(1),
  invoice_wht_tax_group_site NUMBER(15),
  calc_tax_site_level        VARCHAR2(1),
  vat_reg_number             VARCHAR2(20),
  vat_code                   VARCHAR2(30),
  hold_all_pay_hdr           VARCHAR2(1),
  hold_unmatch_inv_hdr       VARCHAR2(1),
  hold_unvali_inv_hdr        VARCHAR2(1),
  hold_reason_hdr            VARCHAR2(240),
  hold_all_pay_site          VARCHAR2(1),
  hold_unmatch_inv_site      VARCHAR2(1),
  hold_unvali_inv_site       VARCHAR2(1),
  hold_reason_site           VARCHAR2(240),
  pay_group                  VARCHAR2(25),
  prefix                     VARCHAR2(60),
  title                      VARCHAR2(30),
  first_name                 VARCHAR2(15),
  middle_name                VARCHAR2(15),
  last_name                  VARCHAR2(15),
  contact_email              VARCHAR2(2000),
  department                 VARCHAR2(60),
  contact_fax                VARCHAR2(40),
  contact_phone              VARCHAR2(40),
  contact_alt_phone          VARCHAR2(40)
) ;

We have interface tables for Supplier Headers, Sites and Contacts:

AP_SUPPLIERS_INT
AP_SUPPLIER_SITES_INT
AP_SUPPLIER_SITES_INT

Base Tables:

AP_SUPPLIERS / PO_VENDORS
AP_SUPPLIER_SITES / PO_VENDOR_SITES_ALL
AP_SUPPLIER_CONTACTS / PO_VENDOR_CONTANCTS

I have above stage table columns in my excel data file, it is in .xls ( we can have in .csv also. if not in these two types, we need to format the file as per our process.

Dump the excel file Data into Stage table directly ( I have done this step using PL/SQL Developer).

After I have data in my stage table: I run the below code. Because of I have done this conversion one time only, it will never use in future, but if it is multi time process (Interface), just you can create the package or procedure, register in application as per your requirement you can go ahead and you can add more validations before importing into interface table and stage table with respect your business need.

======================================================================
DECLARE

  CURSOR C_SUPP_DATA is(
    SELECT distinct VENDOR_NAME,
                  VENDOR_NAME_ALT,
          LEGACY_VENDOR_NUM,
          VENDOR_TYPE,
          PAY_GROUP,
          ALLOW_WHT_TAX_HEADER_LEVEL,
          INVOICE_WHT_TAX_GROUP_HDR,
          HOLD_ALL_PAY_HDR,
          HOLD_UNMATCH_INV_HDR,
          HOLD_UNVALI_INV_HDR,
          HOLD_REASON_HDR
      FROM XX_SUPP_INT_STG);

  CURSOR C_SITE_DATA(P_VENDOR_NAME varchar2) is(
    SELECT distinct COUNTRY,
                    ADDRESS_LINE1,
                    ADDRESS_LINE2,
                    ADDRESS_LINE3,
                    ADDRESS_LINE4,
                    CITY,
                    STATE,
                    PROVINCE,
                    POSTAL_CODE,
                    VENDOR_SITE_CODE,
                    PURCHASING_SITE,
                    PAY_SITE,
                    PHONE_AREA_CODE,
                    PHONE_NUMBER,
                    FAX_AREA_CODE,
                    FAX,
                    SITE_EMAIL,
                    ALLOW_WHT_TAX_HEADER_LEVEL,
                    INVOICE_WHT_TAX_GROUP_HDR,
                    ALLOW_WHT_TAX_SITE_LEVEL,
                    INVOICE_WHT_TAX_GROUP_SITE,
                    CALC_TAX_SITE_LEVEL,
                    VAT_REG_NUMBER,
                    VAT_CODE,
                    HOLD_ALL_PAY_HDR,
                    HOLD_UNMATCH_INV_HDR,
                    HOLD_UNVALI_INV_HDR,
                    HOLD_REASON_HDR,
                    HOLD_ALL_PAY_SITE,
                    HOLD_UNMATCH_INV_SITE,
                    HOLD_UNVALI_INV_SITE,
                    HOLD_REASON_SITE,
                    PAY_GROUP,
ORGANIZATION_NAME
      FROM XX_SUPP_INT_STG
     where VENDOR_NAME = P_VENDOR_NAME);

  CURSOR C_CONTACT_DATA(P_VENDOR_NAME varchar2, P_VENDOR_SITE varchar2) is(
    select distinct PREFIX,
                    TITLE,
                    FIRST_NAME,
                    MIDDLE_NAME,
                    LAST_NAME,
                    CONTACT_EMAIL,
                    DEPARTMENT,
                    CONTACT_FAX,
                    CONTACT_PHONE,
                    CONTACT_ALT_PHONE
      from XX_SUPP_INT_STG
     where VENDOR_NAME = P_VENDOR_NAME
       and VENDOR_SITE_CODE = P_VENDOR_SITE);

  lc_site_org_id                 po_vendor_sites_all.org_id%type; -- := 50168; /* this need to remove*/
  lc_vendor_interface_id         ap_suppliers_int.vendor_interface_id%type;
  lc_vendor_site_interface_id    ap_supplier_sites_int.vendor_site_interface_id%type;
  lc_vendor_contact_interface_id ap_sup_site_contact_int.vendor_contact_interface_id%type;
  lc_vendor_cnt                  NUMBER := 0;
  lc_user_id                     NUMBER;

BEGIN

  FOR i IN C_SUPP_DATA LOOP
    /* Main Loop */

    lc_vendor_interface_id := ap_suppliers_int_s.nextval;
 
    begin
      INSERT INTO ap.ap_suppliers_int
        (vendor_interface_id,
         vendor_name,
         vendor_name_alt,
         vendor_type_lookup_code,
         allow_awt_flag,
         awt_group_id,
         hold_all_payments_flag,
         hold_unmatched_invoices_flag,
         hold_future_payments_flag,
         hold_reason,
         pay_group_lookup_code,
         attribute10)
      VALUES
        (lc_vendor_interface_id,
         i.vendor_name,
         i.vendor_name_alt,
         i.vendor_type,
         i.allow_wht_tax_header_level,
         i.invoice_wht_tax_group_hdr,
         i.hold_all_pay_hdr,
         i.hold_unmatch_inv_hdr,
         i.hold_unvali_inv_hdr,
         i.hold_reason_hdr,
         i.pay_group,
         i.legacy_vendor_num );
 
    EXCEPTION
      WHEN OTHERS THEN
        DBMS_OUTPUT.PUT_LINE(i.vendor_name ||
                             ' Error occured occured at Supplier Header ' ||
                             SQLCODE || ' - ' || SQLERRM);
   
    end;

    FOR j IN C_SITE_DATA(i.vendor_name) LOOP
 
BEGIN
       SELECT organization_id
       INTO lc_site_org_id
       FROM hr_operating_units
       WHERE NAME = j.organization_name ;
     
     EXCEPTION
       WHEN OTHERS
       THEN
       DBMS_OUTPUT.PUT_LINE(j.organization_name, 'invalid Organization');
    END;

      begin
        lc_vendor_site_interface_id := ap_supplier_sites_int_s.nextval;
   
        INSERT INTO ap.ap_supplier_sites_int
          (vendor_site_interface_id,
           vendor_interface_id,
           vendor_site_code,
           address_line1,
           address_line2,
           address_line3,
           address_line4,
           city,
           state,
           country,
           zip,
           phone,
           org_id,
           province,
           purchasing_site_flag,
           pay_site_flag,
           area_code,
           fax_area_code,
           fax,
           email_address,
           allow_awt_flag,
           awt_group_id,
           auto_tax_calc_flag,
           vat_registration_num,
           vat_code,
           hold_all_payments_flag,
           hold_future_payments_flag,
           HOLD_REASON)
        VALUES
          (lc_vendor_site_interface_id,
           lc_vendor_interface_id,
           j.vendor_site_code,
           j.address_line1,
           j.address_line2,
           j.address_line3,
           j.address_line4,
           j.city,
           j.state,
           j.country,
           j.postal_code,
           j.phone_number,
           lc_site_org_id,
           j.province,
           j.purchasing_site,
           j.pay_site,
           j.phone_area_code,
           j.fax_area_code,
           j.fax,
           j.site_email,
           j.allow_wht_tax_site_level,
           j.invoice_wht_tax_group_site,
           j.calc_tax_site_level,
           j.vat_reg_number,
           j.vat_code,
           j.hold_all_pay_site,
           j.hold_unvali_inv_site,
           j.HOLD_REASON_SITE);
   
      EXCEPTION
        WHEN OTHERS THEN
          DBMS_OUTPUT.PUT_LINE(i.vendor_name || ' ' || j.vendor_site_code ||
                               ' Error occured occured at Supplier Site ' ||
                               SQLCODE || ' - ' || SQLERRM);
     
      end;
 
      for k in C_CONTACT_DATA(i.vendor_name, j.vendor_site_code) LOOP
     
IF k.last_name IS NULL THEN --last name condition
   DBMS_OUTPUT.PUT_LINE(i.vendor_name||''||j.vendor_site_code||''||'Contact not created because LAST NAME is null ');
        ELSE
        begin
        lc_vendor_contact_interface_id :=ap_sup_site_contact_int_s.nextval ;
   
          INSERT INTO ap.ap_sup_site_contact_int ss
            (vendor_interface_id,
             vendor_contact_interface_id,
             vendor_site_code,
             first_name,
             middle_name,
             last_name,
             area_code,
             phone,
             first_name_alt,
             last_name_alt,
             email_address,
             fax,
             prefix,
             title,
             department,
             alt_phone,
             org_id)
          VALUES
            (lc_vendor_interface_id,
             lc_vendor_contact_interface_id,
             j.vendor_site_code,
             k.first_name,
             k.middle_name,
             k.last_name,
'',--area_code
             k.contact_phone,
             NULL,
             NULL,
             k.contact_email,
             k.contact_fax,
             k.prefix,
             k.title,
             k.department,
             NVL(k.contact_alt_phone,k.contact_phone),
             lc_site_org_id);
     
        EXCEPTION
          WHEN OTHERS THEN
            DBMS_OUTPUT.PUT_LINE(i.vendor_name || ' ' ||
                                 j.vendor_site_code || ' ' || k.first_name ||
                                 ' Error occured at Supplier Contact ' ||
                                 SQLCODE || ' - ' || SQLERRM);
       
        END;

        END IF; --last name condition
      END LOOP; -- Contact Loop
 
    END LOOP; -- Site Loop

  END LOOP; -- Main Loop
  COMMIT;
  DBMS_OUTPUT.PUT_LINE('Interface ID: '||lc_vendor_interface_id);

EXCEPTION
  WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('Unhandled Exception occured at Supplier Header ' ||
                         SQLCODE || ' - ' || SQLERRM);
END;
======================================================================

After data inserted into Interface tables, we need to run the concurrent programs one after another to get the data into base tables, as I said above one time process so, I did not created one package and call everything there, but you can do that, if required.

Supplier Open Interface Import
Supplier Sites Open Interface Import
Supplier Contacts Open Interface Import

Once above programs completed Normal, you can see your migrated data in below base tables based on my legacy_vendor_number i.e

AP_SUPPLIERS / PO_VENDORS (attribute10 in this table )
AP_SUPPLIER_SITES / PO_VENDOR_SITES_ALL
AP_SUPPLIER_CONTACTS / PO_VENDOR_CONTANCTS






Monday, November 4, 2019

SQL Query to Get Vendor (Supplier) details with Supplier Header and Site Payment Methods in Oracle Apps

/* Supplier Detail Query */
SELECT
   pov.vendor_name
   ,pov.vendor_name_alt
   ,pov.segment1 vendor_number
   ,pov.vendor_type_lookup_code "VENDOR TYPE"
   ,pov.creation_date "VENDOR CREATION DATE"
   ,( SELECT
         paym.payment_method_code
      FROM
          ap_suppliers supp,
          iby_external_payees_all payee,
          iby_ext_party_pmt_mthds paym
      WHERE  1 = 1
      AND   supp.party_id = payee.payee_party_id
      AND   payee.ext_payee_id = paym.ext_pmt_party_id
      AND   supplier_site_id IS NULL
      AND   paym.primary_flag = 'Y'
      AND   pov.vendor_id = supp.vendor_id
    ) VENDOR_HDR_PAY_METHOD
   ,pov.end_date_active "VENDOR_END_DATE_ACTIVE"
   ,pov.vat_registration_num "VENDOR REGISTRATION NUMBER"
   ,pvs.vendor_site_code
   ,paym.payment_method_code VENDOR_SITE_PAY_METHOD
   ,pvs.end_date_active "VENDOR_SITE_END_DATE_ACTIVE"
   ,pvs.inactive_date "SITE INACTIVE DATE"
   ,hou.name "ORGANIZATION NAME"
   ,pvs.invoice_currency_code "INVOICE CURRENCY"
   ,pvs.payment_currency_code "PAYMENT CURRENCY"
   ,pvs.address_line1||' '||pvs.address_line2||' '||pvs.address_line1||' '||pvs.city||' '||pvs.state||' '||pvs.zip||' '||pvs.province||' '||pvs.country "VENDOR SITE ADDRESS"
   ,pvs.status "SITE STATUS"
   ,pvs.remittance_email "SITE REMITTANCE EMAIL"
   ,pvs.email_address "SITE EMAIL"
   ,pvs.fax_area_code||' '||pvs.fax "SITE FAX"
   ,pvc.prefix
   ,pvc.title
   ,pvc.first_name
   ,pvc.middle_name
   ,pvc.last_name
   ,pvc.email_address "CONTACT EMAIL"
   ,pvc.DEPARTMENT
   ,pvc.fax_area_code||' '||pvc.fax "CONTACT FAX"
   ,pvc.area_code||' '||pvc.phone "CONTACT PHONE"
   ,pvc.alt_area_code||' '||pvc.alt_phone "CONTACT ALT PHONE"
   ,pvc.inactive_date "CONTACT INACTIVE DATE"
FROM
   po_vendors pov
   ,po_vendor_sites_all pvs
   ,po_vendor_contacts pvc
   ,hr_operating_units hou
   ,ap_suppliers supp
   ,ap_supplier_sites_all sites
   ,iby_external_payees_all payee
   ,iby_ext_party_pmt_mthds paym
WHERE 1 = 1
AND   pov.vendor_id = pvs.vendor_id
AND   pvs.vendor_site_id = pvc.vendor_site_id
AND   pov.vendor_id = pvc.vendor_id
AND   pvs.org_id = hou.organization_id
AND   pvs.status = 'A'
AND   pov.vendor_type_lookup_code !='EMPLOYEE'
AND   ((TO_CHAR(pov.end_date_active,'DD-MM-YYYY') <= TO_CHAR(SYSDATE,'DD-MM-YYYY') ) OR pov.end_date_active IS NULL OR TO_CHAR(pov.end_date_active,'DD-MM-YYYY') = '31-12-4712' )
AND   ((TO_CHAR(pvs.end_date_active,'DD-MM-YYYY') <= TO_CHAR(SYSDATE,'DD-MM-YYYY') ) OR pvs.end_date_active IS NULL OR TO_CHAR(pvs.end_date_active,'DD-MM-YYYY') = '31-12-4712' )
AND   ((TO_CHAR(pvs.inactive_date,'DD-MM-YYYY') <= TO_CHAR(SYSDATE,'DD-MM-YYYY') ) OR pvs.inactive_date IS NULL OR TO_CHAR(pvs.inactive_date,'DD-MM-YYYY') = '31-12-4712' )
AND   ((TO_CHAR(pvc.inactive_date,'DD-MM-YYYY') <= TO_CHAR(SYSDATE,'DD-MM-YYYY') ) OR pvc.inactive_date IS NULL OR TO_CHAR(pvc.inactive_date,'DD-MM-YYYY') = '31-12-4712' )
AND   supp.party_id = payee.payee_party_id
AND   payee.ext_payee_id = paym.ext_pmt_party_id
AND   supp.vendor_id = sites.vendor_id
AND   sites.vendor_site_id = payee.supplier_site_id
AND   paym.primary_flag = 'Y'
AND   pov.vendor_id = supp.vendor_id
AND   pvs.vendor_site_id = sites.vendor_site_id
ORDER BY pov.segment1 ASC

SQL Query to get Open, Approved Blanket Agreement Purchase Orders in Oracle Apps

/* Open Blanket Agreement Query*/
SELECT
   pha.segment1 "BLANKET AGREEMENT NUMBER"
   ,pha.revision_num
   ,pha.creation_date "AGREEMENT CREATION DATE"
   ,plc.displayed_field "AGREEMENT TYPE"
   ,pha.authorization_status "APPROVAL STATUS"
   ,pha.blanket_total_amount "AMOUNT"
   ,pha.approved_date
   ,NVL(INITCAP(pha.closed_code),'Open') "AGREEMENT STATUS"
   ,pla.line_num "PO LINE NUMBER"
   ,pla.creation_date "LINE CREATION DATE"
   ,NVL(pla.closed_code,'Open') "LINE STATUS"
   ,hou.name "ORGANIZATION NAME"
   ,pov.segment1 "VENDOR NUMBER"
   ,pov.VENDOR_NAME
   ,pov.VENDOR_TYPE_LOOKUP_CODE "VENDOR TYPE"
   ,pvs.VENDOR_SITE_CODE
   ,pha.currency_code
   ,ppf.full_name "BUYER NAME"
   ,pha.attribute_category "CATEGORY"
   ,pha.attribute1
   ,msi.segment1 "LINE ITEM"
   ,msi.description "ITEM DESCRIPTION"
   ,mcb.segment1||'.'||mcb.segment2||'.'||mcb.segment3||'.'||mcb.segment1 "ITEM CATEGORY"
   ,pla.quantity "BA QUANTITY"
   ,pla.unit_meas_lookup_code "UOM"
   ,pla.unit_price
FROM
   apps.po_headers_all pha
   ,apps.po_lines_all pla
   ,apps.po_lookup_codes plc
   ,apps.po_vendors pov
   ,apps.po_vendor_sites_all pvs
   ,apps.per_all_people_f ppf
   ,apps.hr_operating_units hou
   ,apps.mtl_system_items_b msi 
   ,apps.mtl_categories_b mcb
WHERE 1 = 1
AND   pha.po_header_id = pla.po_header_id
AND   pha.type_lookup_code = plc.lookup_code
AND   pha.vendor_id = pov.vendor_id
AND   pov.vendor_id = pvs.vendor_id
AND   pha.vendor_site_id =pvs.VENDOR_SITE_ID
AND   pha.agent_id = ppf.person_id
AND   (SYSDATE BETWEEN ppf.effective_start_date AND ppf.effective_end_date  )
AND   pha.org_id = hou.organization_id
AND   pla.item_id = msi.inventory_item_id
AND   msi.organization_id = 63
AND   pla.category_id = mcb.category_id
AND   plc.lookup_type = 'AGREEMENT_TYPE'
AND   pha.type_lookup_code = 'BLANKET'
AND   NVL(pha.closed_code,'OPEN') = 'OPEN'
AND   pha.authorization_status = 'APPROVED'
ORDER BY pha.segment1

Tuesday, October 15, 2019

AP Invoice Approval Status Tracking:

AP Invoice Approval Status Tracking:

Invoice Validation
Invoice Approval Workflow

select a.invoice_id,a.invoice_num, a.invoice_amount, a.approval_ready_flag, a.approval_iteration, a.wfapproval_status
from
ap_invoices_all a
where invoice_num = 'INV_TEST_2' ;

select * from
ap_inv_aprvl_hist_all
where invoice_id = 53931065 ;

select * from
wf_notifications
where item_key like '53931065%'
and message_type = 'APINVAPR';

Saturday, September 28, 2019

SQL Query to get Oracle Value Set definition

Query 1:

select b.flex_value_set_name,a.additional_where_clause from FND_FLEX_VALIDATION_TABLES a, fnd_flex_value_sets b
where a.application_table_name = 'MTL_SECONDARY_INVENTORIES'
and a.value_column_name ='SECONDARY_INVENTORY_NAME'
and a.flex_value_set_id = b.flex_value_set_id



Query 2:

SELECT ffvs.flex_value_set_id ,
       ffvs.flex_value_set_name ,
       ffvs.description set_description ,
       ffvs.validation_type,
       ffvt.value_column_name ,
       ffvt.meaning_column_name ,
       ffvt.id_column_name ,
       ffvt.application_table_name ,
       ffvt.additional_where_clause
FROM   APPS.fND_FLEX_VALUE_SETS FFVS ,
       APPS.FND_FLEX_VALIDATION_TABLES FFVT
WHERE  ffvs.flex_value_set_id = ffvt.flex_value_set_id
   AND ffvs.flex_value_set_name IN ('VALUE SET NAME')

Wednesday, September 25, 2019

Generate Spool for multiple db objects / How to generate Spool for multiple DB objects in oracle

SET PAGES 0

SET TIMING   OFF
SET ECHO     OFF
SET FEEDBACK OFF

SET TERMOUT  OFF

SPOOL C:\Emirates\Assignments\views\manyspools_8.sql


SELECT 'SPOOL C:\Emirates\Assignments\objects\' || object_name || '.sql' || CHR (10) ||
       'SELECT text from dba_source WHERE name = ''' || object_name || ''';' || CHR (10) ||
       'SPOOL OFF'
  from xxtemp_hr_stg where object_type in ('PROCEDURE','PACKAGE','PACKAGE BODY','FUNCTION');

SPOOL OFF

@ C:\Emirates\Assignments\objects\manyspools_8.sql

SET TERMOUT ON


--Note:
-- This script can run from SQL Developer / TOAD / PLSQL Developer
-- In above script, instead of table "dba_source", need to use dba_views for views
--My stage table: where my list of objects stored in stage table
--xxtemp_hr_stg

--Table Script:

create table xxtemp_hr_stg
(
 SNO NUMBER,
 OWNER VARCHAR2(10),
 OBJECT_NAME VARCHAR2(100),
 OBJECT_TYPE VARCHAR2(20),
 REMARKS VARCHAR2(2000),
 MODIFY_YN VARCHAR2(2000),
 ADDITIONAL_COMMENTS VARCHAR2(4000)
);

Generate Spool file for Single (particular DB Object) / How to generate the spool for db objects in oracle

set feedback off
set heading off
set timing off
set termout off
set linesize 1000
set trimspool on
set verify off
spool C:\YADUL\FILES_220519\XX_DB_OBJECT_NAME.sql
prompt set define off
select text
    from dba_source
    where name = upper('XX_DB_OBJECT_NAME')
    order by type, line;
prompt /
prompt set define on
spool off
set feedback on
set heading on
set termout on
set linesize 100
set timing on

--Note:
-- This script can run from SQL Developer / TOAD / PLSQL Developer
-- In above script, instead of this table "dba_source", need to user dba_views for views

Monday, September 23, 2019

SQL Query to find Responsibility for given Request group / Find Request group attached responsibilities

SELECT responsibility_name ,
  request_group_name        ,
  frg.description
   FROM fnd_request_groups frg,
  fnd_responsibility_vl frv
  WHERE frv.request_group_id = frg.request_group_id
AND request_group_name    LIKE 'Request group name'
ORDER BY responsibility_name;

Friday, September 20, 2019

SQL Query to find Concurrent program details with Parameters, status, submitted date and responsibility

SELECT
    cpt.user_concurrent_program_name   "Concurrent Program Name",
    decode(rgu.request_unit_type, 'P', 'Program', 'S', 'Set',
           rgu.request_unit_type) "Unit Type",
    fcr.status_code                    status,
    fcr.request_date                   prog_submitted_date,
    fnr.responsibility_name,
    fcr.argument1
    || '-'
    || fcr.argument2
    || '-'
    || fcr.argument3
    || '-'
    || fcr.argument4
    || '-'
    || fcr.argument5
    || '-'
    || fcr.argument6
    || '-'
    || fcr.argument7
    || '-'
    || fcr.argument8
    || '-'
    || fcr.argument9
    || '-'
    || fcr.argument10
    || '-'
    || fcr.argument11
    || '-'
    || fcr.argument12
    || '-'
    || fcr.argument13
    || '-'
    || fcr.argument14
    || '-'
    || fcr.argument15 parameters,
    cp.concurrent_program_name         "Concurrent Program Short Name",
    rg.application_id                  "Application ID",
    rg.request_group_name              "Request Group Name",
    fat.application_name               "Application Name",
    fa.application_short_name          "Application Short Name",
    fa.basepath                        "Basepath",
    cpt.concurrent_program_id
FROM
    fnd_request_groups           rg,
    fnd_request_group_units      rgu,
    fnd_concurrent_programs      cp,
    fnd_concurrent_programs_tl   cpt,
    fnd_application              fa,
    fnd_application_tl           fat--,
    ,
    fnd_concurrent_requests      fcr,
    fnd_responsibility_tl        fnr
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 rg.application_id = fat.application_id
    AND fa.application_id = fat.application_id
    AND cpt.language = userenv('LANG')
    AND fat.language = userenv('LANG')
    AND cpt.concurrent_program_id = fcr.concurrent_program_id
    AND fcr.responsibility_id = fnr.responsibility_id
    AND cpt.user_concurrent_program_name = 'Concurrent program name'
ORDER BY
    fcr.request_date DESC

SQL Query to find Customer, Customer Account and Customer Sites Information

/****************************************************************************** *PURPOSE: Query to Customer, Customer Account and Customer...