Friday 23 February 2018

Script to update salespersons customer site wise in oracle apps R12

SELECT * FROM HZ_PARTIES
WHERE PARTY_NAME LIKE 'DEENA VISION%';

SELECT * FROM HZ_CUST_ACCOUNTS_ALL
WHERE PARTY_ID =94043 ;

SELECT * FROM HZ_CUST_ACCT_SITES_ALL
WHERE CUST_ACCOUNT_ID =62040;

SELECT * FROM HZ_CUST_SITE_USES_ALL
WHERE CUST_ACCT_SITE_ID = 62041;

==============================================================================

select * from jtf_rs_salesreps
where SALESREP_ID =100004040 ;

SELECT SALESREP_ID,A.RESOURCE_NAME,B.ORG_ID
FROM JTF_RS_RESOURCE_EXTNS_TL A,
               jtf_rs_salesreps B
WHERE 1=1
--AND SALESREP_ID =100004040
AND  A.RESOURCE_ID = B.RESOURCE_ID
AND A.RESOURCE_NAME LIKE 'D SENTHIL%';

==================================================

SELECT HCSUA.CUST_ACCT_SITE_ID,HCSUA.ORG_ID,AC.CUSTOMER_ID,AC.CUSTOMER_NAME,CUSTOMER_NUMBER,HCSUA.PRIMARY_SALESREP_ID,
(SELECT  A.RESOURCE_NAME FROM JTF_RS_RESOURCE_EXTNS_TL A,
               jtf_rs_salesreps B
WHERE SALESREP_ID =HCSUA.PRIMARY_SALESREP_ID  --100004040
AND  A.RESOURCE_ID = B.RESOURCE_ID) SALESREP_NAME
FROM AR_CUSTOMERS AC,
              HZ_CUST_ACCOUNTS_ALL HCAA,
              HZ_CUST_ACCT_SITES_ALL HCASA,
              HZ_CUST_SITE_USES_ALL HCSUA
WHERE AC.CUSTOMER_ID = HCAA.CUST_ACCOUNT_ID
AND   HCAA.CUST_ACCOUNT_ID = HCASA.CUST_ACCOUNT_ID
AND   HCASA.CUST_ACCT_SITE_ID = HCSUA.CUST_ACCT_SITE_ID
AND  AC.CUSTOMER_NUMBER = 'RDD1078';

UPDATE THE TABLE:-

UPDATE HZ_CUST_SITE_USES_ALL
SET PRIMARY_SALESREP_ID = 100018070
WHERE ORG_ID = 182
AND CUST_ACCT_SITE_ID= 62041;

commit;

Tuesday 20 February 2018

sql query for list all users who have not logged on in oracle apps r12

We can use this query for your requirement.

SELECT pap.full_name,user_name,to_char(last_logon_date,'DD-MON-YYYY HH24:MI:SS AM') last_logon_date,
to_char(end_date,'DD-MON-YYYY HH24:MI:SS AM') end_date
FROM fnd_user fu,
     per_all_people_f pap
WHERE fu.employee_id = pap.person_id
AND fu.user_name NOT IN (SELECT user_name
                                         FROM   fnd_user
                                         WHERE  1=1
                                          AND end_date IS NULL
                                           AND  last_logon_date >= TRUNC(sysdate)-2)

ORDER BY pap.full_name

Wednesday 10 January 2018

hr_operating_units table data in oracle apps is not coming in windows 10-Oracle Views return no data due to NLS LANGUAGE Settings

I faced some issues when I query the below table data is not fetching in my query:
SELECT * FROM hr_operating_units
SELECT * FROM MTL_CATEGORIES

Solution:

You just need to check the USER ENV Language from the below query.

SELECT USERENV('LANGUAGE') Language FROM DUAL;

After that run the below query(alter language)
ALTER session SET nls_language='AMERICAN'

then check in your table query output:

ex: SELECT * FROM hr_operating_units

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

SELECT USERENV('LANG') FROM DUAL;
                         USERENV(‘LANG’)
                        ------------------------------
                         S
     
SELECT * FROM V$NLS_PARAMETERS
where parameter in('NLS_LANGUAGE','NLS_TERRITORY');   
PARAMETER                   VALUE
--------------------------------------------------                                  
NLS_LANGUAGE SWEDISH
NLS_TERRITORY   SWEDEN
            
b.      Set NLS_LANG value in client (This is permanent Solution)
Windows:
                                                  i.      Go to Start-> run
                                                ii.      Type regedit and click ok
                                              iii.      Drill Down to HKEY_LOCAL_MACHINE->SOFTWARE->ORACLE-> KEY_OraClientxxx_homeX (xxx is the oracle client version and X is the currently used home)
                                              iv.      Double click NLS_LANG and change Value data. For example in the example scenario updated NLS_LANG value to SWEDISH_SWEDEN.WE8MSWIN1252
                                                v.      Close regedit
Make sure you have backup windows registry before modifying it.     
Or
                                                      i.      Click on Computer, select Properties.
                                                      ii.      Select Advance system settings
                                                     iii.      In the Advance tab, select Environment Variables
                                                      iv.      Select New
                                                        v.      Set variable name NLS_LANG and variable value SWEDISH_SWEDEN.WE8MSWIN1252
                                                       vi.      Select ok and you should now see the new environment variable that you just created.
 Linux:
 setenv NLS_LANG <NLS_LANG>
Example: setenv NLS_LANG SWEDISH_SWEDEN. WE8MSWIN1252
3.       Restart the client. Examples, if you are using Toad restart TOAD for the changes to take effect.


http://www.nazmulhuda.info/setting-nls_lang-environment-variable-for-windows-and-unix-for-oracle-database

Friday 15 December 2017

TABLE REGISTRATION IN ORACLE APPLICATION WITH EXAMPLE

DECLARE
   vc_appl_short_name   CONSTANT VARCHAR2 (40) := 'XXU';
   vc_tab_name          CONSTANT VARCHAR2 (32) := 'XXU_JOBWORK_LINES';
   vc_tab_type          CONSTANT VARCHAR2 (50) := 'T';
   vc_next_extent       CONSTANT NUMBER        := 512;
   vc_pct_free          CONSTANT NUMBER        := 10;
   vc_pct_used          CONSTANT NUMBER        := 70;
BEGIN   -- Start Register Custom Table
   -- Get the table details in cursor
   FOR table_detail IN (SELECT table_name, tablespace_name, pct_free, pct_used,
                              ini_trans, max_trans, initial_extent,
                              next_extent
                          FROM dba_tables
                         WHERE table_name = vc_tab_name)
   LOOP
      -- Call the API to register table
      ad_dd.register_table (p_appl_short_name => vc_appl_short_name,
                            p_tab_name        => table_detail.table_name,
                            p_tab_type        => vc_tab_type,
                            p_next_extent     => NVL(table_detail.next_extent, vc_next_extent),
                            p_pct_free        => NVL(table_detail.pct_free, vc_pct_free),
                            p_pct_used        => NVL(table_detail.pct_used, vc_pct_used)
                           );
   END LOOP; -- End Register Custom Table

   -- Start Register Columns
   -- Get the column details of the table in cursor
   FOR table_columns IN (SELECT column_name, column_id, data_type, data_length,
                               nullable
                          FROM all_tab_columns
                         WHERE table_name = vc_tab_name)
   LOOP
      -- Call the API to register column
      ad_dd.register_column (p_appl_short_name      => vc_appl_short_name,
                             p_tab_name             => vc_tab_name,
                             p_col_name             => table_columns.column_name,
                             p_col_seq              => table_columns.column_id,
                             p_col_type             => table_columns.data_type,
                             p_col_width            => table_columns.data_length,
                             p_nullable             => table_columns.nullable,
                             p_translate            => 'N',
                             p_precision            => NULL,
                             p_scale                => NULL
                            );
   END LOOP;   -- End Register Columns
   -- Start Register Primary Key
   -- Get the primary key detail of the table in cursor
   FOR all_keys IN (SELECT constraint_name, table_name, constraint_type
                      FROM all_constraints
                     WHERE constraint_type = 'P' AND table_name = vc_tab_name)
   LOOP
      -- Call the API to register primary_key
      ad_dd.register_primary_key (p_appl_short_name      => vc_appl_short_name,
                                  p_key_name             => all_keys.constraint_name,
                                  p_tab_name             => all_keys.table_name,
                                  p_description          => 'Register primary key',
                                  p_key_type             => 'S',
                                  p_audit_flag           => 'Y',
                                  p_enabled_flag         => 'Y'
                                 );
      -- Start Register Primary Key Column
      -- Get the primary key column detial in cursor
      FOR all_columns IN (SELECT column_name, POSITION
                            FROM dba_cons_columns
                           WHERE table_name = all_keys.table_name
                             AND constraint_name = all_keys.constraint_name)
      LOOP
         -- Call the API to register primary_key_column
         ad_dd.register_primary_key_column
                                     (p_appl_short_name      => vc_appl_short_name,
                                      p_key_name             => all_keys.constraint_name,
                                      p_tab_name             => all_keys.table_name,
                                      p_col_name             => all_columns.column_name,
                                      p_col_sequence         => all_columns.POSITION
                                     );
      END LOOP; -- End Register Primary Key Column
   END LOOP;    -- End Register Primary Key

   COMMIT;
END;

Thursday 16 November 2017

What is the difference between 11i and R12 in Oracle Apps

11i
1) Consist of 3C
2) No concept of MOAC.
3) Major table changes like po_vendors.
4) Banks are created in Account Payables.
5) Ap_Invoices_lines_all table in finance is not there.

R12
1) Consist of 4C
2) Introduction of MOAC( Multi org access control)
3) Major table changes (Ap_suppliers)
4) Banks are created in Cash Management.
5) Subledger Accounting is not there.
5) Ap_invoices_lines_all is there.
6) Subledger Accounting is there.

How to know what are the Seeded table,Transactional Tables, Static Data Tables in Oracle Applications

You can tell based on the TABLESPACE the table belongs to - this is the new Oracle Applications Tablespace Model (OATM)

Run the following code to see:

SELECT tablespace_name, table_name
FROM all_tables
WHERE tablespace_name LIKE '%SEED%' -- seeded data
AND table_name LIKE 'FND%'

SELECT tablespace_name, table_name
FROM all_tables
WHERE tablespace_name LIKE '%TX%' -- transaction data
AND table_name LIKE 'FND%'

SELECT tablespace_name, table_name
FROM all_tables
WHERE tablespace_name LIKE '%ARCHIVE%' -- static data
AND table_name LIKE 'FND%'

Friday 27 October 2017

What are the Aggregate Functions in Oracle SQL

Aggregate Functions


MINreturns the smallest value in a given column
MAXreturns the largest value in a given column
SUMreturns the sum of the numeric values in a given column
AVGreturns the average value of a given column
COUNTreturns the total number of values in a given column
COUNT(*)returns the number of rows in a table

Aggregate functions are used to compute against a "returned column of numeric data" from your SELECT statement. They basically summarize the results of a particular column of selected data.

Script to update salespersons customer site wise in oracle apps R12

SELECT * FROM HZ_PARTIES WHERE PARTY_NAME LIKE 'DEENA VISION%'; SELECT * FROM HZ_CUST_ACCOUNTS_ALL WHERE PARTY_ID =94043 ; SE...