R12 Change sysadmin password from sqlplus

Oracle Apps R12 Change sysadmin password from sqlplus

Two methods to change the sysadmin password:
1- CPASS tool: This is an Oracle tool that allow change system and database user password's
like SYSADMIN, APPLSYSPUB, APPS, GL, AR.

FNDCPASS apps/appspwd 0 Y system/manager USER SYSADMIN newspassword

2- fnd_user_pkg tool: This package maintains oracle application user accounts
To change the sysadmin password execute the following script:

declare
   l_flag  boolean;
begin
  l_flag = fnd_user_pkg.change_password('sysadmin','newpassword');
end;

To check if the new password take place run the following:
select   fnd_web_sec.validate_login('sysadmin','newpassword')    from dual;

The expected result would be Y.

Change Application user password on R12

R12: Change Application user password and end date from sqlplus

DECLARE
  v_user_name     VARCHAR2(80) := 'GFMISDBA';
  v_new_password  VARCHAR2(80) := 'oracle123';
  v_hard_password VARCHAR2(1) := fnd_profile.VALUE('SIGNON_PASSWORD_HARD_TO_GUESS');
BEGIN
  fnd_profile.put(NAME => 'SIGNON_PASSWORD_HARD_TO_GUESS'
                 ,val  => 'N');
  -- Call the procedure
  fnd_user_pkg.updateuser(x_user_name            => v_user_name
                         ,x_owner                => 'CUST'
                         ,x_unencrypted_password => v_new_password
                         ,x_end_date             => SYSDATE + 10000);
  fnd_profile.put(NAME => 'SIGNON_PASSWORD_HARD_TO_GUESS'
                 ,val  => v_hard_password);
COMMIT ;
EXCEPTION
  WHEN OTHERS THEN
    fnd_profile.put(NAME => 'SIGNON_PASSWORD_HARD_TO_GUESS'
                   ,val  => v_hard_password);
    RAISE;
END;



How to change APPS Server Date & Time


Linux Set Date and Time From a Command Prompt

How can I set the system date and time from the command prompt (bash shell)? I don't have GUI installed and I am login over ssh session. How can I set date under Linux operating systems?

Use the date command to display the current date and time or set the system date / time over ssh session. You can also run the date command from X terminal as root user.
This is useful if the Linux server time and/or date is wrong, and you need to set it to new values from the shell prompt.
You must login as root user to use date command.

Linux Set Date

Use the following syntax to set new data and time:
date --set="STRING"
For example, set new data to 2 Oct 2006 18:00:00, type the following command as root user:
# date -s "2 OCT 2006 18:00:00"
OR
# date --set="2 OCT 2006 18:00:00"
You can also simplify format using following syntax:
# date +%Y%m%d -s "20081128"

Linux Set Time

To set time use the following syntax:
# date +%T -s "10:13:13"
Where,
  • 10: Hour (hh)
  • 13: Minute (mm)
  • 13: Second (ss)
Use %p locale’s equivalent of either AM or PM, enter:
# date +%T%p -s "6:10:30AM"
# date +%T%p -s "12:10:30PM"


[oracle@ebs602 scripts]$ su - root
Password:
[root@ebs602 ~]# date
Tue Apr 21 12:07:45 IST 2009

[root@ebs602 ~]# date -s "21 sep 2012 12:00:00"

Fri Sep 21 12:00:00 IST 2012

[root@ebs602 ~]# date

Fri Sep 21 12:00:08 IST 2012
 
**************************************************END******************************************

How to Clean 11i Apps Concurrent Manager Tables

This can be used as a method to clear the errors upon bringing the internal manager back up.

Use this method for 11.5.7+ instances provided the managers are down and no FNDLIBR processes are
still running.
 
FIRST
Update process status codes to TERMINATED
Updating invalid process status codes in FND_CONCURRENT_PROCESSES

SELECT  concurrent_queue_name manager,
      concurrent_process_id pid,
      process_status_code pscode
FROM    fnd_concurrent_queues fcq, fnd_concurrent_processes fcp
WHERE   process_status_code not in ('K', 'S')
AND     fcq.concurrent_queue_id = fcp.concurrent_queue_id
AND     fcq.application_id = fcp.queue_application_id;
UPDATE  fnd_concurrent_processes
SET     process_status_code = 'K'
WHERE   process_status_code not in ('K', 'S');
commit;
SECOND
Set all managers to 0 processes
Updating running processes in FND_CONCURRENT_QUEUES
Setting running_processes = 0 and max_processes = 0 for all managers

UPDATE  fnd_concurrent_queues
SET     running_processes = 0, max_processes = 0;
commit;
THIRD
Reset control codes
Updating invalid control_codes in FND_CONCURRENT_QUEUES
SELECT  concurrent_queue_name manager,
      control_code ccode
FROM    fnd_concurrent_queues
WHERE   control_code not in ('E', 'R', 'X')
AND     control_code IS NOT NULL;

UPDATE  fnd_concurrent_queues
SET     control_code = NULL
WHERE   control_code not in ('E', 'R', 'X')
AND     control_code IS NOT NULL;
commit;
FOURTH
Also null out target_node for all managers
UPDATE  fnd_concurrent_queues
SET     target_node = null;
commit;
FIFTH
Set all 'Terminating' requests to Completed/Error
Also set Running requests to completed, since the managers are down
Updating any Running or Terminating requests to Completed/Error
SELECT  request_id request,
      phase_code pcode,
      status_code scode
FROM    fnd_concurrent_requests
WHERE   status_code = 'T' OR phase_code = 'R'
ORDER BY request_id;
    
UPDATE  fnd_concurrent_requests
SET     phase_code = 'C', status_code = 'E'
WHERE   status_code ='T' OR phase_code = 'R';
commit;
SIXTH
Set all Runalone flags to 'N'Updating any Runalone flags to 'N'
set serveroutput on
set feedback off
declare
      c         pls_integer := dbms_sql.open_cursor;
      upd_rows  pls_integer;
      vers      varchar2(50);
      tbl       varchar2(50);
      col       varchar2(50);
      statement varchar2(255);
begin

      select substr(release_name, 1, 2)
      into   vers
      from fnd_product_groups;

      if vers >= 11 then
         tbl := 'fnd_conflicts_domain';
         col := 'runalone_flag';
      else
         tbl := 'fnd_concurrent_conflict_sets';
         col := 'run_alone_flag';
      end if;


      statement := 'update ' || tbl || ' set ' || col || '=''N'' where ' || col || ' = ''Y''';
      dbms_sql.parse(c, statement, dbms_sql.native);
      upd_rows := dbms_sql.execute(c);
      dbms_sql.close_cursor(c);
      dbms_output.put_line('Updated ' || upd_rows || ' rows of ' || col || ' in ' || tbl || ' to ''N''');
end;
/
commit;
Now you can start with your Concurrent Managers...!!!!!!!!
 
 
**************************************************************************************************** 

Copy Database Schemas To A New Database With Same Login Password ?



How to copy database users from one database to another new database and keep the
login password and granted roles, privileges ?

1. Oracle10g and above: Use Data Pump.
In Oracle10g you can use the Export DataPump and Import DataPump utilities. Example:
-- Step 1: In source database, run a schema level Export Data Pump
-- job and connect with a user who has the EXP-FULL_DATABASE role:

% expdp system/manager DIRECTORY=my_dir DUMPFILE=exp_scott.dmp \
LOGFILE=exp_scott.log SCHEMAS=scott

-- Step 2: In target database, run a schema level Import Data Pump
-- job which will also create the user in the target database:

% impdp system/manager DIRECTORY=my_dir DUMPFILE=exp_scott.dmp \
LOGFILE=imp_scott.log SCHEMAS=scott
Or you can create a logfile (SQLFILE) with all relevant statements. E.g.:
impdp system/manager directory=my_dir dumpfile=exp_scott.dmp logfile=imp_scott.log schemas=scott sqlfile=imp_user.sql

or:
2. In Oracle9i and above: query the Data Dictionary in the source database to obtain the required information to pre-create the user in the target database. Example:
2.1. Obtain the CREATE USER statement in the source database. E.g.:
SET long 200000000
SELECT dbms_metadata.get_ddl('USER','SCOTT') FROM dual;
2.2. Run other queries in the source database to determine which privileges, grants, roles, and tablespace quotas are granted to the users. E.g.:
SET lines 120 pages 100
SELECT * FROM dba_sys_privs WHERE grantee='SCOTT';
SELECT * FROM dba_role_privs WHERE grantee='SCOTT';
SELECT * FROM dba_tab_privs WHERE grantee='SCOTT';
SELECT * FROM dba_ts_quotas WHERE username='SCOTT';
2.3. Create a script file that contains the CREATE USER, CREATE ROLE statements, the GRANT statements, and the ALTER USER statements for tablespace quotas.
2.4. Pre-create the tablespaces for this user with SQL*Plus in the target database. Note that the original CREATE TABLESPACE statement can be obtained in the source database with DBMS_METADATA.GET_DDL. E.g.:
SET long 200000000
SELECT dbms_metadata.get_ddl('TABLESPACE','USERS') FROM dual;
2.5. Run the script of step 2.3. to create the user in the target database.
2.6. Run a user level export. E.g.:
exp system/manager file=exp_scott.dmp log=exp_scott.log owner=scott
2.7. Import this export dumpfile into the target database. E.g.:
imp system/manager file=exp_scott.dmp log=imp_scott.log fromuser=scott touser=scott

or:
3. If all users need to be copied into the new target database: use a full database export from the source database and a full database into the target database. Example:
3.1. Run a full database export. E.g.:
exp system/manager file=exp_f.dmp log=exp_f.log full=y
or in Oracle10g:expdp system/manager directory=my_dir dumpfile=expdp_f.dmp logfile=expdp_f.log full=y
3.2. Pre-create the tablespaces with SQL*Plus in that target database if they have a different directory structure on the target server. If the directory structure on the target is the same as on the source, ensure that this directory structure is in place (import does not create directories when creating tablespaces). Note that the original CREATE TABLESPACE statement can be obtained with dbms_metadata.get_ddl (see the example in step 2.4. above).
3.3. Import the data into the target database with:
imp system/manager file=exp_f.dmp log=imp_f.log full=y
or in Oracle10g:
impdp system/manager directory=my_dir dumpfile=expdp_f.dmp logfile=impdp_f.log full=y


****************************************************************************

How to Move a Oracle Database to a Different Platform


Export/Import is the only supported method of moving an existing Oracle database from one hardware platform to another. This is due to the incompatible file structures between
Operating Systems. The only option is to take a logical backup of the database, hence export/import.

The general procedure is as follows:

1.  Gather the necessary information from your source database.  You will need to know the exact name of all TABLESPACES, 
     so perform the following query as a DBA user:

        SQL>  SELECT tablespace_name FROM dba_tablespaces; 

    Or you can use the script given below to generate create tablespace script
---------------------------------------------------------------------------------------------------
set verify off; 
set termout off; 
set feedback off; 
set pagesize 0; 
  
set termout on; 
select 'Creating tablespace build script...' from dual; 
set termout off; 
  
create table ts_temp (lineno number, ts_name varchar2(30), 
                    text varchar2(800)); 
  
DECLARE 
   CURSOR ts_cursor IS select   tablespace_name, 
                             initial_extent, 
                                next_extent, 
                                min_extents, 
       max_extents, 
                                pct_increase, 
                  status 
                        from    sys.dba_tablespaces 
                     where tablespace_name != 'SYSTEM' 
                        and status != 'INVALID' 
                        order by tablespace_name; 
   CURSOR df_cursor (c_ts VARCHAR2) IS select   file_name, 
                    bytes 
                                       from     sys.dba_data_files 
                                       where    tablespace_name = c_ts 
                                         and    tablespace_name != 'SYSTEM' 
                                       order by file_name; 
   lv_tablespace_name   sys.dba_tablespaces.tablespace_name%TYPE; 
   lv_initial_extent    sys.dba_tablespaces.initial_extent%TYPE; 
   lv_next_extent       sys.dba_tablespaces.next_extent%TYPE; 
   lv_min_extents       sys.dba_tablespaces.min_extents%TYPE; 
   lv_max_extents       sys.dba_tablespaces.max_extents%TYPE; 
   lv_pct_increase      sys.dba_tablespaces.pct_increase%TYPE; 
   lv_status            sys.dba_tablespaces.status%TYPE; 
   lv_file_name         sys.dba_data_files.file_name%TYPE; 
   lv_bytes             sys.dba_data_files.bytes%TYPE; 
   lv_first_rec         BOOLEAN; 
   lv_string            VARCHAR2(800); 
   lv_lineno            number := 0; 
  
   procedure write_out(p_line INTEGER, p_name VARCHAR2,  
             p_string VARCHAR2) is 
   begin 
     insert into ts_temp (lineno, ts_name, text) values  
            (p_line, p_name, p_string); 
   end; 
  
BEGIN 
   OPEN ts_cursor; 
   LOOP 
      FETCH ts_cursor INTO lv_tablespace_name, 
                           lv_initial_extent, 
                           lv_next_extent, 
     lv_min_extents, 
                           lv_max_extents, 
           lv_pct_increase, 
                           lv_status; 
      EXIT WHEN ts_cursor%NOTFOUND; 
      lv_lineno := 1; 
      lv_string := ('CREATE TABLESPACE '||lower(lv_tablespace_name)); 
      lv_first_rec := TRUE; 
      write_out(lv_lineno, lv_tablespace_name, lv_string); 
      OPEN df_cursor(lv_tablespace_name); 
      LOOP 
         FETCH df_cursor INTO lv_file_name, 
        lv_bytes; 
         EXIT WHEN df_cursor%NOTFOUND; 
         if (lv_first_rec) then 
            lv_first_rec := FALSE; 
            lv_string := 'DATAFILE '; 
         else 
            lv_string := lv_string || ','; 
         end if; 
     lv_string:=lv_string||''''||lv_file_name||''''|| 
                    ' SIZE '||to_char(lv_bytes) || ' REUSE'; 
      END LOOP; 
      CLOSE df_cursor; 
   lv_lineno := lv_lineno + 1; 
         write_out(lv_lineno, lv_tablespace_name, lv_string); 
         lv_lineno := lv_lineno + 1; 
         lv_string := (' DEFAULT STORAGE (INITIAL ' || 
                      to_char(lv_initial_extent) || 
                   ' NEXT ' || lv_next_extent); 
         write_out(lv_lineno, lv_tablespace_name, lv_string); 
         lv_lineno := lv_lineno + 1; 
         lv_string := (' MINEXTENTS ' || 
                      lv_min_extents || 
          ' MAXEXTENTS ' || lv_max_extents); 
         write_out(lv_lineno, lv_tablespace_name, lv_string); 
         lv_lineno := lv_lineno + 1; 
         lv_string := (' PCTINCREASE ' || 
                      lv_pct_increase || ')'); 
  write_out(lv_lineno, lv_tablespace_name, lv_string); 
         lv_string := ('   '||lv_status); 
         write_out(lv_lineno, lv_tablespace_name, lv_string); 
         lv_lineno := lv_lineno + 1; 
         lv_string:='/'; 
         write_out(lv_lineno, lv_tablespace_name, lv_string); 
         lv_lineno := lv_lineno + 1; 
         lv_string:='                                                  '; 
   write_out(lv_lineno, lv_tablespace_name, lv_string); 
   END LOOP; 
   CLOSE ts_cursor; 
END; 
/ 
  
spool create_tablespaces.sql 
set heading off 
set recsep off 
col text format a80 word_wrap 
  
  
select   text 
from     ts_temp 
order by ts_name, lineno; 
  
spool off; 
  
drop table ts_temp;
-------------------------------------------------------------------------------------------------
2.  Perform a full export from the source database as a DBA user.  
    For example:

        exp system/manager full=y file=expdat.dmp log=expdat.log
3.  Move the dump file to the target database server via ftp.   (Note:  remember to change to BINARY mode to avoid 
     corrupting the file.  To configure ftp for binary mode, enter 'binary' at the ftp prompt)
4.  Create a database on the target server. 
5.  Before performing the import, you will need to precreate your tablespaces. This is necessary since the import will 
    want to create the corresponding datafiles in the same file structure as was at the source database.  Since your file 
    structure will be different on the target database, precreating the tablespaces will allow you to specify a file structure 
    that will work.
    
6.  Perform a full import with the parameter IGNORE=Y into the target database as a DBA user.  

        imp system/manager full=y ignore=y file=expdat.dmp log=expdat.log

    Using IGNORE=Y will tell Oracle to ignore any creation errors during the import, allowing the import to complete. 
 
 
********************************************************************************************* 

Profile Options in Oracle Apps R12

Profile Options in Oracle Apps R12 - Overview (FND PROFILE)


Definition:

 

  • Profiles are the changeable options which affect the way Oracle Applications run. 
  • The profile option acts like a Global Variable in Oracle, to provide the flexibility in Oracle Applications.

Types:

 

The profiles are of two types those are given below.
  1. System Profile and
  2. User Profile.

Different Levels a Profile value can be set:

 
The Profile values will be set in different levels as given below.
  1. Site
  2. Application
  3. Responsibility
  4. User
  5. Server
  6. Organization
  •  Site: This field displays the current value, if set, for all users at the installation site. 
  • Application: This field displays the current value, if set, for all users working under responsibilities owned by the application identified in the Find Profile Values block. 
  • Responsibility: This field displays the current value, if set, for all users working under the responsibility identified in the Find Profile Values block.  
  • User: This field displays the current value, if set, for the application user identified in the Find Profile Values block.  
  • Profile: Enter the name of the profile option whose values you wish to display.
 

Navigation to set Profile Values

  • SYSTEM PROFILE: 
Responsibility SYSTEM ADMINISTRATOR -->


You may search for profile options using character strings and the wildcard symbol (%). For example, to find all the profile options prefixed by "Concurrent:” you could enter "Conc%" and press the Find button.


  
  • PERSONAL PROFILE:

Responsibility SYSTEM ADMINISTRATOR -->

To view personal profiles enter into the query mode and enter the profile name which we have already then we get profile value details.



To check the validation done against the Profile value while setting:

 

Responsibility APPLICATION DEVELOPER -->




Use of the API FND_PROFILE

 

It is used to perform various actions related to profile values through PL/SQL. Some of the important ones are listed below

1. FND_PROFILE.GET(‘Name of the Profile’, variable name);
Example
SELECT 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')
  FROM DUAL;


2. variable name := FND_PROFILE.VALUE(‘Name of the profile’);
3. FND_PROFILE.PUT(‘Name of the profile’, value of the profile);

Example
SET SERVEROUTPUT ON;
DECLARE
   v_conc_login_id      NUMBER;
BEGIN
   FND_PROFILE.put ('CONC_LOGIN_ID',1425);
   fnd_profile.get ('CONC_LOGIN_ID', v_conc_login_id);
   DBMS_OUTPUT.put_line (v_conc_login_id);
END;
Output:
1425
PL/SQL procedure successfully completed

The 1st and 2nd are same but, the only difference is FND_PROFILE.GET is the procedure and FND_PROFILE.VALUE is the function so, it return a value.  

Apart from the above procedures we have another important one named FND_PROFILE.SAVE used to set the profile values from backend. A detail regarding this API is as below. 
 

Changing Profile Options from Backend

The table fnd_profile_options_tl, profile options names are kept.  Now find the corresponding the Profile option name for which you need to update from backend. For this example I took my favorite “ORG_ID”
 
SELECT profile_option_name
 FROM fnd_profile_options_tl
 WHERE user_profile_option_name LIKE 'MO%'


It returns more than one row but i can make out that "ORG_ID" is the PROFILE_OPTION_NAME for MO: Operating Unit. Now I need to know the Org_ID of the Org whose value is to be set in MO: Operating Unit. SO I use the simple select as below
SELECT organization_id, NAME
  FROM hr_all_organization_units;

From the organization name I find the one which will be the default Operating Unit, and I note the ID. In my case the ID for my default Operating Unit is 286. Now with the code below I set the profile option value using fnd_profile.save.

DECLARE
   stat   BOOLEAN;
BEGIN
   DBMS_OUTPUT.DISABLE;
   DBMS_OUTPUT.ENABLE (100000);
   stat := fnd_profile.SAVE ('ORG_ID', 286, 'SITE');
   IF stat
   THEN
      DBMS_OUTPUT.put_line ('Stat = TRUE - profile updated');
   ELSE
      DBMS_OUTPUT.put_line ('Stat = FALSE - profile NOT updated');
   END IF;
   COMMIT;
END;
 
 *********************************************************END*******************************************

ERROR 1396 (HY000): Operation ALTER USER failed for 'Mysql'@'%'

 This MySQL error — ERROR 1396 (HY000): Operation ALTER USER failed for 'Mysql'@'%' — means that MySQL cannot find the user ...