Saturday, August 7, 2010

System Administrator


How to complete Host(Unix Shell Script) Concurrent Program with Warning

If we have a concurrent program as of type host(Unix Shell Script), then the program by default either completes Normal or in Error.
If we return from shell script using text exit 0, program completes in normal and if we use any value other value e.g. exit 1, exit 2, exit 10 etc then the program completes in error.
Below is the code that can be used if requirement is to complete it in warning.
sqlplus -s $p_usr_pwd <<-EOF
  set feedback off
  declare
    l_stat Boolean;
    l_session_id Number;
  begin
    fnd_global.initialize(session_id => l_session_id
                        , user_id => fnd_global.user_id
                        , resp_id => fnd_global.resp_id
                        , resp_appl_id => fnd_global.resp_appl_id
                        , security_group_id => null
                        , site_id => null
                        , login_id => null
                        , conc_login_id => null
                        , prog_appl_id => null
                        , conc_program_id => null
                        , conc_request_id => $p_req_id
                        , conc_priority_request => null);
    l_stat := fnd_concurrent.set_completion_status('WARNING','Completed in Warning. Review log for details.');
    commit;
  end;
/
  exit;
EOF

In the example above $p_usr_pwd stores database username/password, $p_req_id stores the request ID for concurrent request that needs to complete in warning.

Related Post:
Concurrent program parameter in Unix Shell Script
Calling SQLPLUS from unix shell script

Query to find locked objects in Oracle

Sometimes program takes a little longer time then expected, one of the reason to this could be that the table/object you are trying to manipulate is locked by other program and hence it is waiting for the resource to be released.
Below query can be handy to find the objects that are locked 
SELECT   c.owner
       , c.object_name
       , c.object_type
       , b.SID
       , b.serial#
       , b.status
       , b.osuser
       , b.machine
       , b.program
       , b.module
       , b.action
FROM     v$locked_object a
       , v$session b
       , dba_objects c
WHERE    b.SID = a.session_id 
AND a.object_id = c.object_id
ORDER BY module


If you want to forcefully kill any session then it can be done using
alter system kill session 'sid,serial#'

e.g. 
altery system kill session '123,5325'

Restart or Bounce Apache Server

Following command can be used to bounce apache. An apache bounce is needed to reflect any changes in the self service pages.

To Stop
$COMMON_TOP/admin/scripts/$TWO_TASK*/adapcctl.sh stop


To Start
$COMMON_TOP/admin/scripts/$TWO_TASK*/adapcctl.sh start

Profile Option to View Output of Request submitted by other User

Set the value of profile Concurrent:Report Access Level to Responsibility.
The output submitted by other users can now be viewed from the responsibility through which the request was submitted.
The other option available is User,which restricts the output only to the user who submitted the request.

Concurrent Program Name with Parameter, Value set

On request here is the query to list concurrent program name with its parameter, values set and default value/type
SELECT fcpl.user_concurrent_program_name
      , fcp.concurrent_program_name
      , par.column_seq_num      
      , par.end_user_column_name
      , par.form_left_prompt prompt
      , par.enabled_flag
      , par.required_flag
      , par.display_flag
      , par.flex_value_set_id
      , ffvs.flex_value_set_name
      , flv.meaning default_type
      , par.DEFAULT_VALUE
 FROM   fnd_concurrent_programs fcp
      , fnd_concurrent_programs_tl fcpl
      , fnd_descr_flex_col_usage_vl par
      , fnd_flex_value_sets ffvs
      , fnd_lookup_values flv
 WHERE  fcp.concurrent_program_id = fcpl.concurrent_program_id
 AND    fcpl.user_concurrent_program_name = :conc_prg_name
 AND    fcpl.LANGUAGE = 'US'
 AND    par.descriptive_flexfield_name = '$SRS$.' || fcp.concurrent_program_name
 AND    ffvs.flex_value_set_id = par.flex_value_set_id
 AND    flv.lookup_type(+) = 'FLEX_DEFAULT_TYPE'
 AND    flv.lookup_code(+) = par.default_type
 AND    flv.LANGUAGE(+) = USERENV ('LANG')
 ORDER BY par.column_seq_num

Query to List all the responsibilities attached to a User

Based on a request from one of the reader here is the query which he was looking for.

He needed query that can list all the responsibilities attached to a user.
select fu.user_name, fr.responsibility_name, furg.START_DATE, furg.END_DATE
from fnd_user_resp_groups_direct furg, fnd_user fu, fnd_responsibility_tl fr
where fu.user_user_name = :user_name
and furg.user_id = fu.user_id
and furg.responsibility_id = fr.responsibility_id
and fr.language = userenv('LANG')

Call Concurrent Program from responsibility Menu

The concurrent programs can be called in one of the following 2 ways
1) From standard concurrent request by attaching the concurrent program to a request group. The request group name can be found from the responsibility. Query for the request group and attach concurrent program to that request group. Now the program will be available from that responsibility.
2) The other option is to call request directly from the Menu.

To assign a concurrent program to a menu follow the steps. I have taken Import Bills and Routings andimport items program as an example.
a) Create a new function of form type and name it as your concurrent program
Bills of Material:


Import Items:


b) In the parameter field enter the request group name(if all programs assigned to the request is to be available) or enter concurrent program name(if only one concurrent program should be available).
Bills of Material:


Import Items:

c) Assign this function to a responsibility menu from which you want to run this concurrent program.

Now go to that responsibility and click on the function. It will directly launch the concurrent program

WEDNESDAY, AUGUST 13, 2008

Increase Session Timeout Time

The session when kept inactive for certain period gets inactive and hence we need to relogin again.
It sometimes become frustating when working on a test instance and makes us login again and again. This can be avoided by setting a profile option.

Profile "ICX_SESSION_TIMEOUT" can be used to increase the session timeout time.

FNDLOAD in a nutshell

In the following links I have discussed on how to migrate
1) Concurrent Programs
2) Value sets
from one instance to another using FNDLOAD.

Now I will try to cover several other objects that can be migrated using FNDLOAD.
The syntax for moving any objects using FNDLOAD is almost the same except few changes. Following is the list of .lct files that are used for different objects
1) Concurrent Program --> afcpprog.lct
2) Value Sets --> afffload.lct
3) Menus --> afsload.lct

Download
FNDLOAD apps/APPS_PWD O Y DOWNLOAD $FND_TOP/patch/115/import/afsload.lct file_name.ldt MENU MENU_NAME='XXXX'
Upload
FNDLOAD apps/APPS_PWD O Y UPLOAD $FND_TOP/patch/115/import/afsload.lct file_name.ldt
4) Lookups --> aflvmlu.lct
Download
FNDLOAD apps/APPS_PWD O Y DOWNLOAD $FND_TOP/patch/115/import/aflvmlu.lct file_name.ldt FND_LOOKUP_TYPE APPLICATION_SHORT_NAME='XXXX' LOOKUP_TYPE='XXXX'
Upload
FNDLOAD apps/APPS_PWD O Y UPLOAD $FND_TOP/patch/115/import/aflvmlu.lct file_name.ldt
5) Flexfield --> afffload.lct
Descriptive Flexfield
Download
FNDLOAD apps/APPS_PWD 0 Y DOWNLOAD $FND_TOP/patch/115/import/afffload.lct file_name.ldt DESC_FLEX APPLICATION_SHORT_NAME='XXXX' DESCRIPTIVE_FLEXFIELD_NAME='XXXX'
Upload
FNDLOAD apps/APPS_PWD 0 Y UPLOAD $FND_TOP/patch/115/import/afffload.lct file_name.ldt
Key Flexfield
Download
FNDLOAD apps/APPS_PWD 0 Y DOWNLOAD $FND_TOP/patch/115/import/afffload.lct file_name.ldt KEY_FLEX APPLICATION_SHORT_NAME='XXXX' DESCRIPTIVE_FLEXFIELD_NAME='XXXX'
Upload
FNDLOAD apps/APPS_PWD 0 Y UPLOAD $FND_TOP/patch/115/import/afffload.lct file_name.ldt
6) Profile Options --> afscprof.lct
Download
FNDLOAD apps/APPS_PWD O Y DOWNLOAD $FND_TOP/patch/115/import/afscprof.lct file_name.ldt PROFILE PROFILE_NAME='XXXX' APPLICATION_SHORT_NAME='XXXX'
Upload
FNDLOAD apps/APPS_PWD O Y UPLOAD $FND_TOP/patch/115/import/afscprof.lct file_name.ldt
7) Responsibility --> afscursp.lct
FNDLOAD apps/APPS_PWD O Y DOWNLOAD $FND_TOP/patch/115/import/afscursp.lct file_name.ldt FND_RESPONSIBILITY RESP_KEY='XXXX'
Upload
FNDLOAD apps/APPS_PWD O Y UPLOAD $FND_TOP/patch/115/import/afscursp.lct file_name.ldt
8) Request Groups --> afcpreqg.lct
Download
FNDLOAD apps/APPS_PWD O Y DOWNLOAD $FND_TOP/patch/115/import/afcpreqg.lct file_name.ldt REQUEST_GROUP REQUEST_GROUP_NAME='XXXX' APPLICATION_SHORT_NAME='XXXX' REQUEST_GROUP_UNIT UNIT_NAME='XXXX'
Upload
FNDLOAD apps/APPS_PWD O Y UPLOAD $FND_TOP/patch/115/import/afcpreqg.lct file_name.ldt
9) Menus --> afsload.lct
Download
FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/afsload.lct file_name.ldt MENU MENU_NAME='XXXX'
Upload
FNDLOAD apps/apps O Y UPLOAD $FND_TOP/patch/115/import/afsload.lct file_name.ldt
10) Forms Personalization --> affrmcus.lct
Download
FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/affrmcus.lct file_name.ldt FND_FORM_CUSTOM_RULES FUNCTION_NAME='XXXX'
Upload
FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/affrmcus.lct file_name.ldt

FNDLOAD to create value sets

Download a Value Set:
FNDLOAD apps/APPS_PWD 0 Y DOWNLOAD $FND_TOP/patch/115/import/afffload.lct VALUE_SET_XXXX.ldt VALUE_SET FLEX_VALUE_SET_NAME='XXXX'

Download Value Set Values:
FNDLOAD apps/APPS_PWD 0 Y DOWNLOAD $FND_TOP/patch/115/import/afffload.lct VALUE_SET_XXXX.ldt VALUE_SET_VALUE FLEX_VALUE_SET_NAME='XXXX'

Upload a Value Set:
FNDLOAD apps/APPS_PWD 0 Y UPLOAD $FND_TOP/patch/115/import/afffload.lct VALUE_SET_XXXX.ldt 


Related Post: Create Concurrent Program using FNDLOAD

FNDLOAD to create concurrent programs

The FNDLOAD can be used to create several oracle objects like Menu, Concurrent program, request sets, DFF, Responsibility, Messages, forms personaliztion etc. from one instance to another.
Here I will discuss how to create concurrent program using FNDLOADS

Download the program definition
FNDLOAD apps/APPS_PWD O Y DOWNLOAD $FND_TOP/patch/115/import/afcpprog.lct FNDLOAD_CONC_PRG_NAME.ldt PROGRAM APPLICATION_SHORT_NAME='XXXX' CONCURRENT_PROGRAM_NAME='CONC_PRG_NAME'


FNDLOAD_CONC_PRG_NAME.ldt is the file where concurrent program information is extracted. This file will be used to create same definition in any other instance.

Upload the Program definition
FNDLOAD apps/APPS_PWD O Y UPLOAD $FND_TOP/patch/115/import/afcpprog.lct FNDLOAD_CONC_PRG_NAME.ldt


Note: Any value set that needs to be created along with concurrent program is downloaded and created automatically by FNDLOAD.

Date List of Value(LOV) for Concurrent Request Parameter

We are aware that it is not possible to display calendar window for concurrent request parameter. Here I am discussing on an alternative to create Date List of values.
This is addition to my earlier post Calender in Concurrent program. 
Create a table value set as shown in the screenshot below.


click on Edit Information and Enter following in the table name field
(SELECT (TO_DATE (SYSDATE - 1 + LEVEL, 'DD-MON-RRRR')) date_range
           , (TO_CHAR (SYSDATE - 1 + LEVEL, 'Month, DD RRRR')) date_word 
      FROM DUAL CONNECT BY LEVEL <= 1000)




This is how concurrent program looks when a value is attached to it.


Related Post: Calender in Concurrent program.

MONDAY, JUNE 9, 2008

Basics of Value Sets in Oracle Applications

Explained below is the basics of Value Set.

What is a value set and where is it used?
Value set is primarily the List of Values(LOV) to restrict and mantain consistencies in entering or selecting the values. It is also the place holders to allow user enter a value. Oracle Application Object Library uses value sets as important components of key flexfields, descriptive flexfields, and Concurrent Request Submission.

What are the Format Types the value set have?
* Character
* Number
* Time
* Standard Date, Standard Date Time
* Date, Date Time
Note that Date and Date Time value set formats are obsolete and are provided for backward compatibility only. For new value sets, use the the format types Standard Date and Standard Date Time.

What are the validation types?
None:

* There is no validation done for this type of value set, hence allows user to enter any value.
Independent:

* It provides a list of pre-defined values. The predefined values are entered seperately.
Dependent:

* Same like Independent Value Set, except the List of Values shown to you will depends on which the Independent value you have selected in the Prior Segment.
* Must define your independent value set before you define the dependent value set that depends on it.
* Must create at least one dependent value for each independent value.
Table:

* The list of value is created based on database tables
* Allows to write simple queries, joins, order by etc
* The value, meaning and ID can be used to display a value, description to the value but return ID to the calling program or screen.
* Additional columns can also be displayed. The syntax is column "column title(size)",.... e.g. order_type "SO Order Type(40)"
* Can also create dependent values to filter LOV data based on parameter value selected earlier. This can be done using :$FLEX:.value_set_name in the where clause.
Special & Pair:
Pair validation value set allows to select a range of concatenated Flex field segments as parameters to the report. The special value set is used to perform special validation. This is used to enter the entire key flexfield segment in the single parameter of the report/calling entity.
Translatable Independent & Translatable Dependent:

* This is similar to Independent and Dependent value set except that translated values can be displayed to the user.

APIs to create value set
The FND_FLEX_VAL_API package can be used to create different types of value sets.
* VALUESET_EXISTS - To check if value set exists
* DELETE_VALUESET - To delete value set. The value set can only be deleted if it is not being referenced by any program or entity.
* CREATE_VALUESET_NONE
* CREATE_VALUESET_INDEPENDENT
* CREATE_VALUESET_DEPENDENT
* CREATE_VALUESET_TABLE
* CREATE_VALUESET_SPECIAL
* CREATE_VALUESET_PAIR

What are the oracle tables that store value set information?
* FND_FLEX_VALUE_SETS
* FND_ID_FLEX_SEGMENTS
* FND_FLEX_VALUE
* FND_FLEX_VALIDATION_EVENTS
* FND_FLEX_VALUE_RULE_LINES
* FND_FLEX_VALUE_RULE
* FND_FLEX_VALUE_RULE_USAGE
* FND_FLEX_VALIDATION_TABLES

Display Distinct Value in Value Set

Now there are 3 ways to create distinct values value set
1) Write distinct statement in the field where table name is entered, but this has a limitation to the number of characters that can be entered. so if query is long then you cannot make use of this feature
2) Create a view based on your query and use that view in the value set
3) Write your query in such a way that it gives you a distinct value. You can make use of ROWID to meet the requirement.
ex. SELECT ooh.order_number
      FROM   oe_order_lines_all ool, oe_order_headers_all ooh
      WHERE  ool.header_id = ooh.header_id
      AND    ool.ROWID = (SELECT MAX(ROWID)
                          FROM   oe_order_lines_all oo11
                          WHERE  oo11.header_id = ooh.header_id)

Note that the above query is just an example and needs to be changed as per your need. In the above query I purposely joined lines and header to display duplicate order_numbers and then supressed it by using MAX(ROWID).

Enable/Disable Concurrent program parameter based on Other Parameter

Based on a request, here is the details on how parameter can be enabled/disabled based another parameter value.
Below is the requirement
There are 2 valuesets parameter. If for parameter 1 user selects Yes then the other paramter should be enabled whereas if No is selected then the parameter should remain disabled. This can be achieved by using a hidden parameter as explained below.

Step1: Need 3 value sets for 3 parameter.
Value set1 = BOM_SRS_YES_NO (Oracle Defined)
Value Set2 = AMS_SRS_CHAR1 (Oracle Defined)
Value Set3 = SV_DEPENDENT_VS (User Defined)




Step2: Create Concurrent program as displayed in the screenshot below
Parameter1: Main Parameter

Parameter2: Hidden PArameter

Parameter3: Dependent Parameter

Step3: Assign concurrent program to a request group and test your program.

MONDAY, MAY 5, 2008

FAQ: Common Tracing Techniques for Oracle Apps

1) How to enable trace in the Oracle Application screens / forms?
Below is the navigation to enable trace for forms
Help Menu --> Diagnostics --> Trace(Select appropriate trace as needed)

Most commonly if debugging an error, you may select trace with binds.
When debugging a performance issue, you may consider using trace with binds and waits.

Remember to disable trace as this will keep generating the file.

2) How to enable trace for a concurrent program?
Refer to post Create Trace File for Concurrent Program

3) How to enable trace for a concurrent program INCLUDING bind variables and waits?
The above method can be used to generate a trace file, but this does not includes bind variables and wait times.
Download and review the script, bde_system_event_10046.sql, from Metalink Note 179848.1.
The above script is used to turn on the trace with binds and wait(Level 12).
Run Script and press enter when prompted.
Return to application and submit your concurrent program.
The moment status changes to running, switch to SQL*PLUS and press enter again to turn tracing off.
Important: Note that the tracing is set at global level and any program that runs during time when trace is kept on will be traced. Hence it is very important to immediately turn trace off after your programs status changes to running.

4) How to enable trace for all actions that occur for a user?
Use profile option Initialization SQL Statement - Custom
Set the value at user level 
BEGIN FND_CTL.FND_SESS_CTL('','', '', 'TRUE','','ALTER SESSION SET TRACEFILE_IDENTIFIER='||''''||'4269824.999' ||''''||' EVENTS ='||''''||' 10046 TRACE NAME CONTEXT FOREVER, LEVEL 12 '||''''); END;


Reference: Metalink Note 296559.1

Related Post:
SQL Trace and TKPROF
Various options with TKPROF
Create Trace File for Concurrent Program

FRIDAY, MAY 2, 2008

Various options with TKPROF

The post is in continuation to SQL Trace and TKPROF

Syntax of TKPROF
tkprof [filename1] [filename2] [WAITS] [SORT] [PRINT]
There are few more but these are more commonly used.

Argument Description
filename1 : The trace file name
filename2 : Filename to which TKPROF writes formatted output
WAITS : Flag to record summary for any wait events found in the trace file. Values are YES or NO
SORTS : Sorts traced SQL statements in descending order of specified sort option before listing them into the output file
PRSCNT Number of times parsed.
PRSCPU CPU time spent parsing.
PRSELA Elapsed time spent parsing.
PRSDSK Number of physical reads from disk during parse.
PRSQRY Number of consistent mode block reads during parse.
PRSCU Number of current mode block reads during parse.
PRSMIS Number of library cache misses during parse.
EXECNT Number of executes.
EXECPU CPU time spent executing.
EXEELA Elapsed time spent executing.
EXEDSK Number of physical reads from disk during execute.
EXEDSK Number of physical reads from disk during execute.
EXEQRY Number of consistent mode block reads during execute.
EXECU Number of current mode block reads during execute.
EXEROW Number of rows processed during execute.
EXEMIS Number of library cache misses during execute.
FCHCNT Number of fetches.
FCHCPU CPU time spent fetching.
FCHELA Elapsed time spent fetching.
FCHDSK Number of physical reads from disk during fetch.
FCHQRY Number of consistent mode block reads during fetch.
FCHCU Number of current mode block reads during fetch.
FCHROW Number of rows fetched.

PRINT : Number of SQL statements to be displayed

Example 1
If you are processing a large trace file using a combination of SORT parameters and the PRINT parameter, then you can produce a TKPROF output file containing only the highest resource-intensive statements. For example, the following statement prints the 10 statements in the trace file that have generated the most physical I/O:

tkprof abcd53269.trc abcd53269.txt SORT = (PRSDSK, EXEDSK, FCHDSK) PRINT = 10


Example 2
Print the SQL Query taking maximum CPU Usage
tkprof abcd53269.trc abcd53269.txt SORT = (EXECPU,FCHCPU) PRINT = 1

SQL Trace and TKPROF

Understanding SQL Trace
Times when program is performing poorly, creating and examining a trace file is one of the best way to find what is causing the problem for poor performance.
Following is the list of some of the SQL Trace statictics that are generated in the trace file.
Parse, execute, and fetch counts
CPU and elapsed times
Physical reads and logical reads
Number of rows processed
Commits and Rollback

There are several ways by which you can turn on/off SQL Trace
Turn on
DBMS_SESSION.SET_SQL_TRACE(TRUE);
ALTER SESSION SET SQL_TRACE = TRUE;

Turn off
DBMS_SESSION.SET_SQL_TRACE(FALSE);
ALTER SESSION SET SQL_TRACE = FALSE;

Click here to set SQL Trace on a concurrent program.
The trace file is created in the udump directory.

Understanding TKPROF
The TKPROF program can be used to format the contents of the trace file and convert it into a readable output file.
TKPROF can also be used to generate Explain Plan for the queries.
I will create a seperate post to discuss various options available with TKPROF.

Create Trace File for Concurrent Program

If your program is taking time to complete, then the best way to know what is causing the problem is by creating a trace file.

Navigation:
System Administrator(R) --> Concurrent --> Program --> Define

Query for the concurrent program and check enable trace button.


Now when the concurrent program is executed the trace file is created in the udump directory. The path of udump directory can be found by executing following query.
select * from v$parameter
where name like '%user_dump_dest%'


The trace file can be converted to a readable format by running a tkprof command over the trace file.
Syntax:
tkprof [trace_file_name] [new_file_name]


Click for more info on TKPROF

FRIDAY, APRIL 4, 2008

Password Policy and profile options

On apps there are a lot of profile options that are useful in making apps passwords difficult to guess, the profiles are

1-Signon password failure limit
2-Signon Password Length
3-Signon Password No Reuse
4-Signon Password Hard to Guess

For the first one it means how many time can I try to access the system using wrong password. It is recommended to change this value to 3. The default value is null.

The second one to allow minimum password length. The default value is 5, it is recommended to make it 6 or 7.

The 3rd profile is for not allowing using same password again for specified number of days.

The default value for 4th profile option is No. Following are the password rules if the value is set to Yes
1) The password contains at least one letter and at least one number.
2) The password does not contain the username.
3) The password does not contain consecutively repeating characters.

Reference: Metalink Note 362663.1

No comments:

Post a Comment