Thursday, 21 April 2011

AIM Documents

AIM Documents



BARCODE in XML Reports


BARCODE in XML Reports

For generating reports with barcodes

1) You should have barcode font in your system i.e. Font name FREE3OF9 (Find as attachment)

2) Copy and paste the attached “Free 3of9” font in your machine directories “C:\WINDOWS\Fonts” and $JAVA_HOME\ lib\fonts

Example Java path “C:\Program Files\Java\j2re1.4.2_10\lib\fonts”

3) There is one configuration file i.e. file name is “xdo” as attachment)

4) Copy and paste the configuration file in your “XML Publisher Desktop\Template Builder for Word\config”

Example “C:\Program Files\Oracle\XML Publisher Desktop\Template Builder for Word\config”
?xml version = '5.5.0' encoding = 'UTF-8'?
config version="1.0.0" xmlns="http://xmlns.oracle.com/oxp/config/"
fonts
font family="Free 3 of 9" style="normal" weight="normal"
truetype path="C:\Program Files\Java\j2re1.4.2_12\lib\fonts\FREE3OF9.TTF"/
/font
/fonts
/config

include the tags..i removed the tags.as some problems when posting..check the configuration file once..

5) Once you have done the above setups, you can see the “Free 3of 9” font type under your MSWORD font.

6) Which column you have to display as barcode, just put this font to that column.


One thing to take care is convert the data to upper case before generating the XML
do it at the SQL level only..

White Paper on Oracle Apps Migration Project


White Paper on Oracle Apps Migration Project

Things to take care in a migration project..
These are all my personal observations if any one has anything new to add plz put out a mail i will incorporate them also..

Now a days we are coming across many migration projects..comparitviely these are supposed to be easy and straight forward..
But if we take care of few more things..it would be even smoother...

What is a migration project.??
It is moving from a product of lower version to a product of higher version(the other way is also called migration only)

What will the customer expect??
He expects a higer performance from the system
Added new Functionality
Better support from oracle
The system is supposed to work the same way as it operates..But look and feel might be a bit different..Functionality should remain intact

What are the major challenges for it?
1.The amout of customization in the legacy system
2.Type of Customization--whether custom built modules /Standard process customised
3.Integration with other systems
4.Support of new environments
5.Amount of change in the product from old to new version
6.Whether Standards Followed while customising the standard obejcts like (standard reports,standard forms,workflow..)

What are different phases in it?
1.MIgration phase..First we will take a clone of the instance migrate the applications to the new version with the old data)
Oracle provide the scripts to migrate the data and the software will install the new application objects.
2.Optimised migration--We redo the migration phase again in short span of time to calculate the exact cut over time
3.MTP--Movement to production

What all we need to take care???

Environmental change: some time the old systems might be in a different environment and new system will be on a different environment.
like old one in AIX and new ones in red hat linux.
One of the problem to expect is some commands in AIX might not work in Linux environments.
So if we have shell scripts in or host script files..those need to be checked and changed for the new environment

Database Layer Change:As the product is migrated there might be a database change happend like new not null columns getting added up
so incase you have any direct inserts happening into the oracle tables even interfaces they might need to be corrected
and values need to be populated to the new not null columns

Standard Report Modifications:Because the upgrade will get new application objects any modification done to the standard report objects will be lost.
it is better to rename those objects and re-register them to keep intact the object for future migration

Custom reports migration :For reports we need to just open the report in the new version of the report builder in case the report builder version difference exists
use shift+cntrl+k to compile the objects and save it.This should make the reports work.
But from my personal experience we need to run all the reports and data validation should be done for all..
This might be tedious task if there are huge number of reports ,But it has to be done.
Project plan should include the testing of each and every report(Just data level validation)
One more important thing i heard the compilation of the report builder will not validate the query ..
so any column changes will not get reflected at migration time they can only be find out at run time
Standard Form object migration: Migration will take care of the upgradation of standard objects. Hope that there are no customisation at
the code level for the standard objects.In case if there are any try to redo the customisation using the new feautures
like forms personalizations,custom.pll.One more important thing is before doing the customisation check whether those are really required
in the new system also..Even the customer process also might have changed ..so check with the customer
also before redoiing them .

Custom Form Objects Migration:This is not as simple as the reports..There is a FLINT60(upto 11.5.10.2) or Corresponding utility available to
upgrade the forms from the previous version to the new version.The major road block is if the forms are not developed
as per oracle application standards.Like property paletter not defined,seperate button to popup lov's
and other..In that case the form has to migrated using the flint60 utility and manually changes need to be made to have
the same look and feel of the new version.
For detailed steps of using flint60 and custom form migration check my blog http://oracleappstechnicalworld.blogspot.com/

Legacy Sytem Integration:This will be one of the big task..The first step we need to do is figure out how the legacy systems are integrated
1.Through File system
2.Through DB Links
3.Third party softwares
1.For file system integration check the directory permission and UTL_DIR_PATH variables in the legacy and new system
2.For dblinks one check whether the dblinks can be created between the new database version and the database version of the legacy system.Better to confirm at the assesment stage itself in case not, time need to be allocated for alternative solution implementation
3.Check througthly the compatabilities in case some thing like this exists

Pro*c Programs : The pro*c files need to be recompiled on the new instance.Pro*C Environment need to be set on the new application .If there any custom pro*c programs Pro*c enviromental
setup should be a task in the migration.process.


General Observations: One important thing to remember is the migration will get overwrite all the standard objects and standard application data ex:FND Messages.Suppose in the old instance you have changed the standard message text , then that change will be lost in the migration process.Those changes has to be redone.

Saturday, February 16, 2008

Migrating Custom Forms--4.5 to 6i

Hi,
Currently i am doing a migration project ..and migrating forms...
But for migrating forms there is oracle standard process to do..but unfortunately many people didn't do that way...But this process is the recommended one.
Currently i am facing some issues with FLint60 utility...i will post them also here

1."ERROR ? Item BLOCKNAME.RADIO_BUTTON81 (Radio Group) requires Hint Text "
"ERROR ? Library Location 'APPCORE.pll' for Attached Library APPCORE must not contain a path or extension
ERROR ? Library Location 'APPDAYPK.pll' for Attached Library APPDAYPK must not contain a path or extension
Any problems like above or with the libraries just delete the libraries in the older version form
and then reattach and use the flint60 untility

2.Error like radio group hint text can be ignored

3.One important thing is check how the forms are desinged and see that they are upgraded to the 11.5.10 feautures like lov and others..This is really important make sure that your custom forms look and feel match with oracle latest apps version standards

Upgrading Custom Forms to Release 11i

This section covers upgrading custom forms built with Oracle Forms 4.5, the Oracle Applications coding standards, and Oracle Application Object Library. It applies to custom forms built to integrate with Releases 10SC, 10.7 NCA, and 11.

Upgrading your custom forms to Release 11i consists of the following basic steps:
1. On your developer client machine convert your Oracle Forms 4.5 forms to Oracle Forms 6i using the Oracle Forms 6i Form Generator and make any required changes related to converting to PL/SQL 8

If you have any library files which you attached to your form you must first convert the library files prior to attempting to upgrade your form module. To convert your 4.5 form to a 6i form load a copy of your 4.5 form into 6i form builder and save 'only', DO NOT re-compile it.
By loading the library or form module the developer will perform a number of steps to prepare the files for the new developer environment once successfully saved you may proceed the the next steps outlined below.

2. Move the newly converted 6i form to the Forms server in the $AU_TOP/forms/US directory. Use the Oracle Applications upgrade utility (flint60) on the Oracle Forms 6i .fmb file to apply changes that help your form conform to Release 11i standards.

Release 11i of applications provides an upgrade utility called flint60 which performs a number changes to custom forms previously developed for Oracle Applications 10.7SC/NCA and 11.0.x. The changes include 11i enhancements and applications coding standards verification. The utility may be run multiple times against the custom developed form during the development process.

**** This utility is only for the form module. There
**** is no such utility provide nor needed for custom
**** developed library files.

NOTE: Flint60 is a 32 bit utility that runs on your forms server tier (i.e. it will not run on any machine that is not certified as a forms server like ... Windows95 or Windows 3.11 )

To successfully run the flint60 utility, the flint60.ora file must be created and contain proper values.


Setting Up the Configuration File

The flint60 utility requires a configuration file, flint60.ora, to hold the database username and password and other information. The flint60.ora file is a simple text file that should have the following information:

server_host=your_web_server_name
message_file=location_of_the_message_help_file_on_web_server
connect=[y|n]
userid=database_username_and_password

The web server host name that will be used to access the .html log files the virtual path and filename of the message descriptions file, fnderr.html boolean that indicates whether to verify blocks against the database if database=y, then this is the ORACLE username and password to use to connect to the database.

Note that when attempting to connect to the database, flint60 uses the table ACCESSIBLE_COLUMNS (actually a public synonym for SYS.ALL_TAB_COLUMNS) to determine the constraints (data type, length, null allowed) for a database item?s column. If ACCESSIBLE_COLUMNS is inaccessible, flint60 will generate multiple fatal errors in the log file (if the option to connect to the database is selected).

Example:

server_host=www-apps.us.oracle.com
message_file=/r115/fnderr.html
connect=y
userid=apps/apps@devdb

You must set an environment variable, FLINT60_CONFIG (for Unix) that points to the flint60.ora configuration file. If the FLINT60_CONFIG environment variable is not set then flint60 will search for the file flint60.ora in the current directory. If you see the message
?LRM-00109: could not open parameter file ?? ? when you try to run flint60, then the configuration file could not be loaded. If you run the flint60 utility without the configuration file, the .html log file will not be able to provide context-sensitive links to the help file that describes each of the messages generated by flint60, and the utility may be unable to connect to the database (which would create additional errors in the log file).


Verify Your Environment

It is important to verify that you are pointing to the correct versions of Oracle Forms and Oracle Applications before running the upgrade utility, or you may get spurious or misleading error messages. For example, your environment must point to the correct versions of APPSTAND.fmb and APPCORE.pll. Ensure that the environment is configured properly and is pointing to an Oracle Forms 6i environment.
Verify that the FORMS60_PATH (Unix environment variable, or NT registry setting) points to the directories that hold the correct versions of APPSTAND.fmb and APPCORE.pll.

Ensure the DISPLAY environment variable is set and valid (for Unix only).



To run flint60 utility the command line execution would look like the
following:

Command line switches

The flint60 utility can accept one, two, or no switches on the command line, as shown:

flint60 -u .fmb .fmb ...
flint60 -uc .fmb .fmb ...
flint60 .fmb .fmb ...

-u Parameter: This is the ?upgrade? mode. Include the -u
(?upgrade?) switch if you want the flint60 utility to write a new .fmb file with any required changes.

-c Parameter: Include the -c switch if you want the flint60 utility to not clear out hint text. Use the -c switch when you are running flint60 again after the initial upgrade and you have added hint text that you do not want the utility to clear out (of the new file written by the utility because of the -u switch). If you have not added hint text manually, you do not need to use this switch. The -c switch is ignored if the -u switch is not present.

If no values or switches are passed to the flint60 ultity then this is the ?standards compliance checker? mode.
If you do not use the -u switch, the flint60 utility simply performs various checks on your form and writes out a log file listing any standards compliance errors or warnings.


Form name arguments
The flint60 utility expects form names on the command line:
flint60 -uc .fmb .fmb ...

The filenames can be fully qualified with paths and/or environment variables (for Unix):

flint60 $fnd/forms/US/.fmb
/custgldev/custgl/11.5/forms/US/.fmb ...

To run flint60 for all forms in the current directory (if using an appropriate Unix shell that expands file wildcards, such as tcsh):

flint60 *.fmb

To run flint60 for all forms in a specific directory (if using an appropriate Unix shell that expands file wildcards, such as tcsh):

flint60 $fnd/forms/US/*.fmb

If you are running the flint60 utility on Windows NT, you may need to create a .bat script to run multiple commands because NT does not support expanding command line wildcards.

Reviewing flint60 Log File Output

The flint60 utility provides a detailed log file of messages as it goes through your form. The log file is called form_filename.fmb.html, and you can read it using any standard browser. The utility provides one log file for each form, located in the current directory.

The message types are:
Status: an informational message
Action: each action taken by the flint60 utility, such as changing a
piece of boilerplate to an associated prompt

3. Correct any errors found by the upgrade utility, and run the utility again to verify your changes

When utilizing the forms upgrade utility an HTML output file is created which provides detail of the changes made to the form module. Additionally, the output file provides warning and suggested changes that should be considered for custom form development which if followed will ensure custom form is 11i Oracle look and feel.

4. Perform any required manual changes that may be necessary, such as changes to internal menu names

Performing Required Manual Changes on Your Forms


Menu calls

If you have hardcoded calls in your form that modify the default
(pulldown) menu, such as calls that enable or disable menu entries, you may need to modify your menu calls because the internal names of the menu names have changed to be consistent with the rearranged menu.
Changes to Internal Menu Names from Release 11 to Release 11i (See page 27 - 42)

You can typically find these calls by using the ?Find and Replace PL/SQL? feature in the Oracle Forms 6i Form Builder (under the Program menu choice) to search for the following strings (do not search as case sensitive):

SET_MENU_ITEM_PROPERTY
GET_MENU_ITEM_PROPERTY
FIND_MENU_ITEM
APP_SPECIAL.ENABLE

These calls must be evaluated and changed if necessary.


Toolbar block calls

If you have code in your form that calls anything in the pre-11i toolbar, such as calls to enable or disable toolbar buttons, you must modify your code. Behind the scenes, the toolbar has been reimplemented to not use a distinct TOOLBAR block. It is now part of the menu, and toolbar icons are now enabled and disabled automatically when you programmatically enable or disable menu entries using the APP_SPECIAL routines.

Changes to Internal Menu Names from Release 11 to Release 11i (See page 27 - 42)

APP_SPECIAL: Menu and Toolbar Control (See page 10 - 15)

You can typically find these calls by using the ?Find and Replace PL/SQL? feature in the Oracle Forms 6i Form Builder (under the Program menu choice) to search for the string (including the single quote and the period):

?TOOLBAR.

Note that the TOOLBAR canvas has not been removed, because it serves as a holding area for certain Oracle Applications fields (such as switcher fields).

5. Perform optional manual changes, such as converting alternative regions to tabbed regions and enhancing special menus, as desired

6. Use the Oracle Forms 6i generator to generate the .fmx file for your upgraded form

Ctrl-T will compile and generate your form. Should first be performed on you development environment to ensure that all the code compiles and has been resolved prior to loading the form into the production environment.

7. Test your upgraded form within Oracle Applications 11i To test your form you will need to run the form within the applications environment only. It is possible to run the form stand alone using the forms server and the static login html file whereas the following line in the html file would initially look like:

serverArgs="module=Q:\oa\appltst\fnd\11.0.28\forms\US\FNDSCSGN
userid=applsyspub/pub@VD11 fndnam=apps"

serverArgs="module=Q:\oa\appltst\fnd\11.0.28\forms\US\FNDSCSGN
userid=apps/apps@VD11"


Note: While it is technically possible to skip the first step and go directly to the Oracle Applications upgrade utility step, we recommend that you do the first step separately to better isolate the changes to your form should there be any problem with either upgrade step.

Multiple oraganizations Access control(MOAC)-R12--Part1


Multiple oraganizations Access control(MOAC)-R12--Part1

Hi ALL,
Here i am trying to put the MOAC techical architecture in simple terms..

we are might have heard the term multi organization till 11.5.10 prior it is only one organization

what does multiorganization mean??
Managing multiple organizations data in a single system...putting it in lay man terms
For example lets take GEfinancial
It is headquarted in US and operations in india also..assume it declares the Profit and loss results in both the countries..
Indian accounting rules, financial Calendar is different between the US and India..
since it belongs to same company with in one system I define two operating units one for us and one for India
different ledgers and calendars...if I want I can have different chart of accounts also..

to manage data for both the organizations with in single instance oracle introduced the column org_id in all table which holds organization specific data..

For data security purpose people of a organization should able to see their own data to achieve this
they created view on the base table like _all _B which restricts the data of the organization to which the user/user responsibility is attached.
for this purpose they defined a profile MO:operating unit which is set at the responsibility/user level
based on this value the system context org_id is set to the operating unitid set at the profile level
and a additional conditiion is added to the where clause of the views like

'org_id = substrb(userenv(''CLIENT_INFO''),1,10)'

By this way they are able to restrict data to the one organization in all the forms,reports,concprograms

fnd_global.apps_intialize--will set the applciation context org_id

thats the resason when ever we try to access the data from toad/sql plus for single org specific views we will not get any results..

select * from po_headers--no data found

if we set the application context we will able to see data for that org_id

execute dbms_Application_info.set_client_info('101');
or
fnd_global.apps_intialize(userid,responsibilityid,applicationid) --this inturn will get the org_id and set the context




From R12:Multiple organization access control

Till 11.5.10.2 one responsibility is able to see data of only one operating unit..
when ever we want to see another operating unit data we need to change resposnsibility..
From R12 oracle introduced the concept of Multiple organization access control(MOAC) so that being in the same responsibility the user should
be able to see the data for which he is give access..
let see how they achieved it..

1.First we will define a policy which will have access for different operating units
2.they attach that policy to the responsibility/user at profile option level

technically..till 11.5.10 the query is getting chagned as org_id=101
if we have to access multiple organization it should changed to org_id in (101,102) or exits...

for achieving this oracle used the concept of Virtual Private Database (VPD)..
VPD:
The Virtual Private Database (VPD) feature allows developers to enforce security by attaching a security policy to database objects such as tables, views and synonyms. It attaches a predicate function to every SQL statement to the objects by applying security policies. When a user directly or indirectly accesses the secure objects, the database rewrites the user's SQL statement to include conditions set by security policy that are visible to the user.

First lets decide whethere the access mode to a responsibility is single or multiple or all.Based on the security policy oracle decides the access mode
let assume our security policy which is attached to our respobility has access to the two operating units.
now oracle will populate the global temporary table(session controlled) mo_glob_org_access_tmp with all the operating units attached to the security policy
of yours..

based on the vpd a concept from oracle 9i onwards they defined a policy 'ORG_SEC' which call the function 'MO_GLOBAL.ORG_SECURITY' for all the objects to which the policy is attached..



MO_GLOBAL.Org_Security function:

FUNCTION org_security(obj_schema VARCHAR2
obj_name VARCHAR2)RETURN VARCHAR2
IS
BEGIN
--
-- Returns different predicates based on the access_mode
-- The codes for access_mode are
-- M - Multiple OU Access
-- A - All OU Access
-- S - Single OU Access
-- Null - Backward Compatibility - CLIENT_INFO case
--
IF g_access_mode IS NOT NULL THEN
IF g_access_mode = 'M' THEN
RETURN 'EXISTS (SELECT 1
FROM mo_glob_org_access_tmp oa
WHERE oa.organization_id = org_id)';
ELSIF g_access_mode = 'A' THEN -- for future use
RETURN NULL;
ELSIF g_access_mode = 'S' THEN
RETURN 'org_id = sys_context(''multi_org2'',''current_org_id'')';
END IF;
ELSE
RETURN 'org_id = substrb(userenv(''CLIENT_INFO''),1,10)';
END IF;
END org_security;


let see what happend po_headers view(11.5.10.2) in R12

1.Dropped the view po_headers
2.Created a synonym for the base table
create synnonym for po_headers for po_headers_all

3.attach the security policy org_sec to this synonym


so when ever we access this synonym from any where the policy will call the mo_global.org_Security funcion to all a condition to the select statement we isssued

select * from po_headers will be changed as

select * from po_headerS_all where exists 'EXISTS (SELECT 1
FROM mo_glob_org_access_tmp oa
WHERE oa.organization_id = org_id)'

By this they are able to access all data of all organizations assigned to the security policy.



RETCODE & ERRBUFF

Hi ALL,
As we all know there are two mandatory parameters that need to be pased for all the procedures called
1.ERRBUFF
2.RETCODE..
They are very useful parameters if used properly..like setting the status of the conucrrent program and putting the log messages...
i think it is better we make some rule like we make the program end in Error when ever there is a unidentified exception occurs based on your business rule...

define ERRBUFF as the first parameter and Retcode as the second one...Dont forget to specify the out variable type in it...

CREATE PROCEDURE SAMPLE_PROC (ERRBUF OUT VARCHAR2,
RETCODE OUT VARCHAR2,
p_1 varchar2)

The retcode has three values returned by the concurrent manager
0--Success
1--Success & warning
2--Error

we can set our concurrent program to any of the three status by using these parameters...
for example
Begin
.....
Exception
when others then
fnd_File.put_line(fnd_file.log,'Unhandled exception occurred in package.procedure'||SQLERRM);
retcode='2';
end;
Even you can use fnd_concurrent.set_completion_Status to send the concurrent program to more status than success,error and warning.....



FND_GLOBAL PACKAGE

Recently i come accross a requirement to capture the requestidof the concurrent with in the concurrent program session...Even i am aware of the FND_GLOBAL package...But it didnt strike'at first go.....so i am writing this article for people who are not even awarethat this package exists..
FND_GLOBAL package gives the most of the enviroment values
THis package should be used in database side only...use FND_PROFILE package to get these values in Forms.
1.FND_GLOBAL.USERID --Returns userid
2.FND_GLOBAL.APPS_INTIALIZEprocedure APPS_INITIALIZE(user_id in number,resp_id in number,resp_appl_id in number);
This is used to set the values userid and responsibilityid for a session
3.FND_GLOBAL.LOGIN_ID -Gives login id
4.FND_GLOBAL.CONC_LOGIN_ID--Not sure how to use this
5.FND_GLOBAL.PROG_APPL_ID--Concurrent program application id
6.FND_GLOBAL.CONC_PROGRAM_ID--Concurrent program id
7.FND_GLOBAL.CONC_REQUEST_ID (Server)This will give the concurrent request id of the program which is calling the plsql package..
ln_Request_id:=FND_GLOBAL.CONC_REQUEST_ID;



Adding Concurrent Program to a request group from backend

This one of the common requirements of adding adding the new concurrent program to the request group in production environment...
The critical comes when we dont have access to the sysadmin responsibility and guide the DBA to do it...
Actually there is API's for adding the concurrent program from backend.. it is better to create that script and askt he DBA to run the script which will add the concurrent program to the request group.
The API is given in the Application Developer the only thing is knowing that it exists and remembering it at the right movement...

FND_PROGRAM.ADD_TO_GROUP
FND_PROGRAM.ADD_TO_GROUP
(program_short_name IN VARCHAR2,
program_application IN VARCHAR2,
request_group IN VARCHAR2,
group_application IN VARCHAR2);

Description Use this procedure to add a concurrent program to a
request group. This procedure corresponds to the "Requests" region in the "Request Groups" window in System Administration.
Arguments (input):
program_short_ name The short name used as the developer name of the
concurrent program.
program_ application The application that owns the concurrent program.
request_group The request group to which to add the concurrent program.
group_ application The application that owns the request group.

Sample:

begin
FND_PROGRAM.ADD_TO_GROUP(program_short_name=>'XX_TEST',
program_=>'Application Object Library',
request_group=>'Application Developer Reports',
group_application=>'Application Object Library');
Commit;
Exception
when others then
Dbms_output.put_line('Exception while adding'SQLERRM);
End;
You need to commit the trasaction to get things effected

Attachment Functionality in Oracle Applications

why do i need a attachment functionality?
The attachments feature enables users to link unstructured data, such as images, wordprocessing documents, spreadsheets, or text to their application data. For example,users can link images to items or video to operations as operation instructions.
Can i enable it to any form i want?
For most of the standar you can do that..i hope custom form done in standard way can also have this feauture enabled
where should i start???
Lets Define the terms first
1.Entity:An entity is an object within Oracle Applications data, such as an item, an order, or anorder line. The attachments feature must be enabled for an entity before users can link attachments to the entity.
2.Category:A document category is a label that users apply to individual attachments anddocuments. Document categories provide security by restricting the documents that canbe viewed or added via a specific form or form function.
In the below example i am tryign to enable the attachment funcionality for the USer form..I want to upload the approval copy for creating a user or attaching new responsibility
what are the steps to do that??
Step1:First Define a Entity for which you are creating the attachments.In my case it is users.
define the base table and entityid and others things


Step2:Define a category(optional).if the attachments belongs logically to different group.
In this example i am addding to the miscellenous category.

Make the assignments of the Function once you define it.
step3:Find the Form Name,Function Name and block name to which the attachment feauture need to be enabled.
Step4:Define the Attachment Function .Seelct the type either you want the attachmetn feature at form level or Function level


Press the Blocks Button. and Enter the Block name you want to enable the attachment feauture.

Press the Entities Button

Enter the entity and other settings and see what fuctionalties are required for this form.like query,insert,update and delete allowed can be done or not from this form
Enter the primary Key so that it show the document based on the primary key.

If it a common document like across users then primary key should not be given.

Press the categories button to select the caegories

Press the Assignments Button in document categories and attach the Function.

Now the attache button is enabled..press the button and upload the document..




uploading document is self explainable
for developing some complex one..read tthe application developer for more info..
more or less it depends on the entity definition and the primary key for the document..
you can have more than one primary key...just play aroud with the primary key..you will be able to get any requirement...

Special Validation type Valuesets

How do you validate the parameter value of a concurrent program submitted through SRS window?

This is one of the recent requirement i come across..after some research i came to know it can be done using special valueset.

1.create a valueset of specail validation type

2.create a validate Event.you can write the PLSQL COde to validate

FND PLSQL "declare
l_email VARCHAR2(2000) := :!VALUE;
BEGIN
IF NVL(UPPER(substr(l_email,-9,9)),'INVALID')<>'GMAIL.COM' THEN
fnd_message.set_name('FND','INVALID_EMAIL');
fnd_message.raise_error;
end if;
end;"

3.attach it to the parameter in ..you will get a warning while saving the program ..ignore it..


As far i checked it is validation only when you enter...

THis is another sample available in one of the forums..but didn't work for me..

FND PLSQL "declare
l_payroll VARCHAR2(20) := ':$FLEX$.VALSET_TST5';
l_input DATE := :!VALUE;
BEGIN
if l_payroll is null and l_input is not null then
fnd_message.set_name('XXPAY','ONLY_ENTER_DATE_WITH_PAYROLL');
fnd_message.raise_error;
end if;
end;"

Just try to experiment around..this might meet your requirement....



Useful Information about LOG & OUT Files

Recently we came around a scenario whether the naming convention of the out files need to be changed.After some R&D we find some good document regarding this..

Where do concurrent request or manager logfiles and output files go?
The concurrent manager first looks for the environment variable
$APPLCSF. If this is set, it creates a path using two other
environment variables: $APPLLOG and $APPLOUT
It places log files in $APPLCSF/$APPLLOG, output files go in
$APPLCSF/$APPLOUT

So for example, if you have this environment set:
$APPLCSF = /u01/appl/common
$APPLLOG = log
$APPLOUT = out

The concurrent manager will place log files in /u01/appl/common/log,
and output files in /u01/appl/common/out
Note that $APPLCSF must be a full, absolute path, and the other two
are directory names.

If $APPLCSF is not set, it places the files under the product top of
the application associated with the request. For example, a PO report
would go under $PO_TOP/$APPLLOG and $PO_TOP/$APPLOUT
Logfiles go to: /u01/appl/po/9.0/log
Output files to: /u01/appl/po/9.0/out
All these directories must exist and have the correct permissions.

Note that all concurrent requests produce a log file, but not necessarily
an output file.
Concurrent manager logfiles follow the same convention, and will be
found in the $APPLLOG directory



What are the logfile and output file naming conventions?
Request logfiles: l.req


Output files: If $APPCPNAM is not set: .
If $APPCPNAM = REQID: o.out
If $APPCPNAM = USER: .out


Where: = The request id of the concurrent request
And: = The id of the user that submitted the request


Manager logfiles:


ICM logfile: Default is std.mgr, can be changed with the mgrname
startup parameter
Concurrent manager log: w.mgr
Transaction manager log: t.mgr
Conflict Resolution manager log: c.mgr


Where: is the concurrent process id of the manager



OUT & LOG Files

Normally where do you find the out and log files..
i always learnt that they will be in the corresponding top
out and log directories.
But i never checked..
Last week i got a requirement to find the files and when i check i dont find any out files or log files in the corresponding Top.
later after some hard work i find that there is a setting.If that is not specified only then they will be stored in the out and log files.

$APPLCSF The value of this will determine where log and out files

FND LOAD Examples

Hi All,
Plz find the different ways of using fnd load.
Most of time we required for the movement of different objects majorly likelookups,Menus,Concurrent ProgramsAlerts,valueset...
Using FND Load we can load many of the different FND objects from one server to other server.
But Unfortunate i never find all the FND load Examples at one place.
So i thought i put diffrent examples at one point so that in future a single point of reference can be there.
One Important thing is FNDLOAD updates the object if the object alreadys exists...
Check once it is moved as in case of some objects i creates a new one also with a different version
Concurrent Programs:Use the Below Script to download concurrent programs.The best part of it is it downloads all the valuesets attached to the concurrent program.
Download:$FND_TOP/bin/FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/afcpprog.lct XXBOB_EXT_TRNFB_DTL_REP.ldt PROGRAM APPLICATION_SHORT_NAME="XXBOB" CONCURRENT_PROGRAM_NAME="XXBOB_EXT_TRNFB_DTL_REP"UPLOAD:
$FND_TOP/bin/FNDLOAD apps/apps O Y UPLOAD $FND_TOP/patch/115/import/afcpprog.lct XXBOB_EXT_TRNFB_SUM_REP.ldt


Lookups:
Download:$FND_TOP/bin/FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/aflvmlu.lct BOB_OTA_SESSION_FEEDBACK_RESP.ldt FND_LOOKUP_TYPE APPLICATION_SHORT_NAME ='OTA' LOOKUP_TYPE="BOB_OTA_SESSION_FEEDBACK_RESP"
UPLOAD:$FND_TOP/bin/FNDLOAD apps/apps 0 Y UPLOAD $FND_TOP/patch/115/import/aflvmlu.lct BOB_OTA_SESSION_FEEDBACK_RESP.ldt



Menu:

This will download all the menu definitions and the definitions of the functions associtated with it.But it will not download the submenus.
Download:$FND_TOP/bin/FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/afsload.lct BOB_ILEARNING_ADMIN_TOP_MENU.ldt MENU MENU_NAME="BOB_ILEARNING_ADMIN_TOP_MENU"


Upload:$FND_TOP/bin/FNDLOAD apps/apps O Y UPLOAD $FND_TOP/patch/115/import/afsload.lct BOB_ILEARNING_ADMIN_TOP_MENU.ldt


Forms Personalization:

This is one of the important things if the number of personalizations are moreBut for caution check whether the personlaization works properly are not...i experienced some problems with that..
DOWNLOAD:FNDLOAD apps/$CLIENT_APPS_PWD 0 Y DOWNLOAD $FND_TOP/patch/115/import/affrmcus.lct XX_PERWSHRG.ldt FND_FORM_CUSTOM_RULES function_name="PERWSHRG-404"

Upload:FNDLOAD apps/$CLIENT_APPS_PWD 0 Y DOWNLOAD $FND_TOP/patch/115/import/affrmcus.lct


Responsibility:
Check this once if..i need to try if we download responsibility whether it will download and other all depending objects also..Some one can try this...let me know the answer also...

Download:FNDLOAD apps/$CLIENT_APPS_PWD O Y DOWNLOAD $FND_TOP/patch/115/import/afscursp.lct XX_PERSON_RESPY.ldt FND_RESPONSIBILITY RESP_KEY="XX_PERSON_RESPY"

UPLOAD:FNDLOAD apps/$CLIENT_APPS_PWD O Y UPLOAD $FND_TOP/patch/115/import/afscursp.lct XX_PERSON_RESPY.ldt


Messages:
Use to dowload the messages..in case if you want to download all the messages in a application(work when doing big bang implementation) just provide application short name onlyit will donwload all the messages
Download:$FND_TOP/bin/FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/afmdmsg.lct XXBOB_OLM_EXTTRG_FB_CONF.ldt FND_NEW_MESSAGES APPLICATION_SHORT_NAME='XXBOB' MESSAGE_NAME="XXBOB_OLM_EXTTRG_FB_CONF"
Upload:
$FND_TOP/bin/FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/afmdmsg.lct XXBOB_OLM_EXTTRG_FB_CONF.ldt

Valuesets:Try this and let me know if it doesn't work..i have not yet tried this...
Download:$FND_TOP/bin/FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/afffload.lct XXVALUESETNAME.ldt FLEX_VALUE_SET_NAME='XXVALUESETNAME'
Upload:$FND_TOP/bin/FNDLOAD apps/apps 0 Y UPLOAD $FND_TOP/patch/115/import/afffload.lct XXVALUESETNAME.ldt


Alerts:
Most people are not aware that there is a FNDLOAD script for alerts..even me..but i searhced some how find this one..it worked..i tried this by downloading all alertsunsing only application short name..But the other parameter will work..try this out...
Download:
$FND_TOP/bin/FNDLOAD apps/apps 0 Y DOWNLOAD $ALR_TOP/patch/115/import/alr.lct OTA.ldt ALR_ALERTS APPLICATION_SHORT_NAME='OTA' ALERT_NAME= 'URALERT'

UPLOAD:$FND_TOP/bin/FNDLOAD apps/apps 0 Y DOWNLOAD $ALR_TOP/patch/115/import/alr.lct OTA.ldt


Descriptive FLEX FIELDS:Download:$FND_TOP/bin/FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/afffload.lct ADD_EXT_ORG_TRG_DTLS.ldt DESC_FLEX APPLICATION_SHORT_NAME='XXBOB' DESCRIPTIVE_FLEXFIELD_NAME='ADD_EXT_ORG_TRG_DTLS'

UPLOAD:
$FND_TOP/bin/FNDLOAD apps/apps 0 Y UPLOAD $FND_TOP/patch/115/import/afffload.lct ADD_EXT_ORG_TRG_DTLS.ldt



Wednesday, 20 April 2011

R12 - How to link GL data to the subledger data or vice versa


R12 - How to link GL data to the subledger data or vice versa

  • Applications

gl_je_lines (je_header_id, je_line_num)                -> gl_import_references (je_header_id, je_line_num)

gl_import_references (gl_sl_link_table, gl_sl_link_id) -> xla_ae_lines (gl_sl_link_table, gl_sl_link_id)

xla_ae_lines (applicaiton_id, ae_header_id)            -> xla_ae_headers (application_id, ae_header_id)

xla_ae_headers (application_id, event_id)              -> xla_events (application_id, event_id)

xla_events (application_id, entity_id)                 -> xla.xla_transaction_entities (application_id, entity_id)
xla.xla_transaction_entities (source_id_int_1, etc) after filtering by application_id, entity_code and ledger_id     -> subledger's table(its key columns mentioned in xla_entity_id_mappings) for that ledger_id

For Ex:
xla.xla_transaction_entities (source_id_int_1) filtered by application_id 200, entity_code AP_INVOICES and ledger_id -> ap_invoices_all (invoice_id) for that set_of_books_id.
xla.xla_transaction_entities (source_id_int_1) filtered by application_id 200, entity_code AP_PAYMENTS and ledger_id -> ap_checks_all (check_id) for that set_of_books_id.

xla.xla_transaction_entities (source_id_int_1) filtered by application_id 222, entity_code TRANSACTIONS and ledger_id -> ra_customer_trx_all (customer_trx_id) for that set_of_books_id.

DATE FUNCTIONS IN SQL:

DATE FUNCTIONS IN SQL:

Date
Current DateCURRENT_DATE
SYSDATE
SELECT TO_CHAR(CURRENT_DATE, 'DD-MON-YYYY HH:MI:SS') FROM dual;

SELECT TO_CHAR(SYSDATE, 'DD-MON-YYYY HH:MI:SS') FROM dual;
Formats
DayMonthYearFill ModeJulian Date
DMMYYFMJ
DDMONYYYY  
DDTH RR  
DAY RRRR  
 
+ AND -
+<date> + <integer>
SELECT SYSDATE + 1 FROM dual;
-<date> - <integer>
SELECT SYSDATE - 1 FROM dual;
 
ADD_MONTHS

Add A Month To A Date
ADD_MONTHS(<date>, <number of months_integer>
SELECT add_months(SYSDATE, 2) FROM dual;

-- but be aware of what it is doing
SELECT add_months(TO_DATE('27-JAN-2007'), 1) FROM dual;

SELECT add_months(TO_DATE('28-JAN-2007'), 1) FROM dual;

SELECT add_months(TO_DATE('29-JAN-2007'), 1) FROM dual;

SELECT add_months(TO_DATE('30-JAN-2007'), 1) FROM dual;

SELECT add_months(TO_DATE('31-JAN-2007'), 1) FROM dual;

SELECT add_months(TO_DATE('01-FEB-2007'), 1) FROM dual;
 
CURRENT_DATE

Returns the current date in the session time zone, in a value in the Gregorian calendar of datatype DATE
 
col sessiontimezone format a30

SELECT sessiontimezone, current_date
FROM dual;

ALTER SESSION SET TIME_ZONE = '-5:0';

SELECT sessiontimezone, current_date
FROM dual;

ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';

SELECT sessiontimezone, current_date
FROM dual;

ALTER SESSION SET TIME_ZONE = '-7:0';

SELECT sessiontimezone, current_date
FROM dual;

ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';
 
DUMP

Returns a VARCHAR2 value containing the datatype code, length in bytes, and internal representation of a value
DUMP(<value> [,<return_format>[,<start_position>[,<length>]]])

8Octal
10Decimal
16Hexidecimal
17Single Characters
1008octal notation with the character set name
1010decimal notation with the character set name
1016hexadecimal notation with the character set name
1017single characters with the character set name
col drows format a40

SELECT DUMP(SYSDATE) DROWS FROM dual;

SELECT DUMP(SYSDATE, 8) DROWS FROM dual;

SELECT DUMP(SYSDATE, 16) DROWS FROM dual;
 
GREATEST

Return the Latest Date
GREATEST(<date>, <date>, <date>, ...)
CREATE TABLE t (
datecol1 DATE,
datecol2 DATE,
datecol3 DATE)
PCTFREE 0;

INSERT INTO t VALUES (SYSDATE+23, SYSDATE-10, SYSDATE-24);
INSERT INTO t VALUES (SYSDATE-15, SYSDATE, SYSDATE+15);
INSERT INTO t VALUES (SYSDATE-7, SYSDATE-18, SYSDATE-9);
COMMIT;

SELECT * FROM t;

SELECT GREATEST(datecol1, datecol2, datecol3)
FROM t;
 
INTERVAL

Interval to adjust date-time
INTERVAL '<integer>' <unit>
SELECT TO_CHAR(SYSDATE, 'HH:MI:SS')
FROM dual;

SELECT TO_CHAR(SYSDATE + INTERVAL '10' MINUTE, 'HH:MI:SS')
FROM dual;

SELECT TO_CHAR(SYSDATE - INTERVAL '10' MINUTE, 'HH:MI:SS')
FROM dual;
 
LAST_DAY
Returns The Last Date Of A MonthLAST_DAY(<date>)
SELECT * FROM t;

SELECT LAST_DAY(datecol1) FROM t;
 
LEAST
Return the Earliest DateLEAST(<date>, <date>, <date>, ...)
SELECT * FROM t;

SELECT LEAST(datecol1, datecol2, datecol3) FROM t;
 
LENGTH
Returns length in charactersLENGTH(<date>)
SELECT LENGTH(last_ddl_time) FROM user_objects;
 
LENGTHB
Returns length in bytesLENGTHB(<date>)
SELECT LENGTHB(last_ddl_time) FROM user_objects;
Note: Additional forms of LENGTH (LENGTHC, LENGTH2, and LENGTH4) are also available.
 
MAX
Return the Latest DateMAX(<date>)
SELECT * FROM t;

SELECT MAX(datecol1) FROM t;
 
MIN
Return the Earliest DateMIN(<date>)
SELECT * FROM t;

SELECT MIN(datecol1) FROM t;
 
MONTHS_BETWEEN
Returns The Months Separating Two DatesMONTHS_BETWEEN(<latest_date>, <earliest_date>)
SELECT MONTHS_BETWEEN(SYSDATE+365, SYSDATE-365) FROM dual;

SELECT MONTHS_BETWEEN(SYSDATE-365, SYSDATE+365) FROM dual;
 
NEW_TIME

Returns the date and time in time zone zone2 when date and time in time zone zone1 are date
Before using this function, you must set the NLS_DATE_FORMAT parameter to display 24-hour time.
SELECT NEW_TIME(TO_DATE('11-10-99 01:23:45',
'MM-DD-YY HH24:MI:SS'), 'AST', 'PST') "New Date and Time"
FROM dual;

ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';

SELECT NEW_TIME(TO_DATE('11-10-99 01:23:45',
'MM-DD-YY HH24:MI:SS'), 'AST', 'PST') "New Date and Time"
FROM dual;

ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';
 
NEXT_DAY
Date of next specified date following a dateNEXT_DAY(<date>, <day of the week>)

Options are SUN, MON, TUE, WED, THU, FRI, and SAT
SELECT NEXT_DAY(SYSDATE, 'FRI') FROM dual;
 
ROUND
Returns date rounded to the unit specified by the format model. If you omit the format, the date is rounded to the nearest dayROUND(<date_value>, <format>)
SELECT ROUND(TO_DATE('27-OCT-00'),'YEAR') NEW_YEAR
FROM dual;
 
Spelled Out Using TO_CHAR

Spelled Demo
DDSPHH24SPMISPMMSPSSSP
SELECT TO_CHAR(TO_DATE('10:30:18', 'HH24:MI:SS'), 'HH24SP:MISP:SSSP')
FROM dual;

SELECT TO_CHAR(TO_DATE('01-JAN-2008', 'DD-MON-YYYY'), 'DDSP-MONTH-YYYYSP')
FROM dual;

SELECT TO_CHAR(TO_DATE('01-JAN-2008', 'DD-MM-YYYY'), 'DDSP-MMSP-YYYYSP')
FROM dual;

SELECT TO_CHAR(TO_DATE(sal,'J'), 'JSP')
FROM emp;
 
SYSDATE
Returns the current date and time set for the operating system on which the database residesSYSDATE
SELECT SYSDATE FROM dual;
 
TO_DATE

In Oracle/PLSQL, the to_date function converts a string to a date.
TO_DATE(<string1>, [ format_mask ], [ nls_language ])
string1 is the string that will be converted to a date.The format_mask parameter is optional. It is the format that will be used to convert string1 to a date.
nls_language is optional. The nls_language parameter sets the default language of the database. This language is used for messages, day and month names, symbols for AD, BC, a.m., and p.m., and the default sorting mechanism. This parameter also determines the default values of the parameters NLS_DATE_LANGUAGE and NLS_SORT.
The following table shows options for the format_mask parameter. These parameters can be used in various combinations.
ParameterExplanation
YEARYear, spelled out alphabetically
YYYY4-digit year
YYY
YY
Y
Last 3, 2, or 1 digit(s) of year.
IYY
IY
I
Last 3, 2, or 1 digit(s) of ISO year.
IYYY4-digit year based on the ISO standard
RRRRAccepts a 2-digit year and returns a 4-digit year.
A value between 0-49 will return a 20xx year.
A value between 50-99 will return a 19xx year.
QQuarter of year (1, 2, 3, 4; JAN-MAR = 1).
MMMonth (01-12; JAN = 01).
MONAbbreviated name of the month.
MONTHThe name of month, padded with blanks to length of 9 characters.
RMRoman numeral month (I-XII; JAN = I).
WWThe week of the year (1-53) where week 1 starts on the first day of the year and continues to the seventh day of the year.
WThe week of the month (1-5) where week 1 starts on the first day of the month and ends on the seventh.
IWThe week of year (1-52 or 1-53) based on the ISO standard.
DDay of the week (1-7). Sunday is day 1 when nls_territory is set to 'AMERICA' but differs if another nls_territory is set (i.e. 'UNITED KINGDOM' or 'GERMANY' - in these cases Monday is 1.
DAYName of the day.
DDThe day of month (1-31).
DDDThe day of year (1-366).
DYAbbreviated name of the day. (Mon, Tue, Wed, etc)
JJulian day; the number of days since January 1, 4712 BC.
HHHour of day (1-12).
HH12Hour of day (1-12).
HH24Hour of day (0-23).
MIMinute (0-59).
SSSecond (0-59).
SSSSSNumber of seconds past midnight (0-86399).
FFFractional seconds. Use a value from 1 to 9 after FF to indicate the number of digits in the fractional seconds. For example, 'FF5'.
AM, A.M., PM, or P.M.Meridian indicator
AD or A.DAD indicator
BC or B.C.BC indicator
TZDDaylight savings identifier. For example, 'PST'
TZHTime zone hour.
TZMTime zone minute.
TZRTime zone region.
TRUNC

Convert a date to the date at midnight
TRUNC(<date_time>)
CREATE TABLE t (
datecol DATE);

INSERT INTO t (datecol) VALUES (SYSDATE);

INSERT INTO t (datecol) VALUES (TRUNC(SYSDATE));

INSERT INTO t (datecol) VALUES (TRUNC(SYSDATE, 'HH'));

INSERT INTO t (datecol) VALUES (TRUNC(SYSDATE, 'MI'));

COMMIT;

SELECT TO_CHAR(datecol, 'DD-MON-YYYY HH:MI:SS')
FROM t;

Selectively remove part of the date information

Special thanks to Dave Hayes for reminding me of this.
TRUNC(<date_time>, '<format>')
SELECT TO_CHAR(SYSDATE, 'DD-MON-YYYY HH:MI:SS')
FROM dual;

-- first day of the month
SELECT TO_CHAR(TRUNC(SYSDATE, 'MM'), 'DD-MON-YYYY HH:MI:SS')
FROM dual;

SELECT TO_CHAR(TRUNC(SYSDATE, 'MON'), 'DD-MON-YYYY HH:MI:SS')
FROM dual;

SELECT TO_CHAR(TRUNC(SYSDATE, 'MONTH'), 'DD-MON-YYYY HH:MI:SS')
FROM dual;

-- first day of the year
SELECT TO_CHAR(TRUNC(SYSDATE, 'YYYY'), 'DD-MON-YYYY HH:MI:SS')
FROM dual;

SELECT TO_CHAR(TRUNC(SYSDATE, 'YEAR'), 'DD-MON-YYYY HH:MI:SS')
FROM dual;

Dates in WHERE Clause Joins
SELECT SYSDATE FROM dual;

ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';

SELECT SYSDATE FROM dual;

/

/

ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';

CREATE TABLE t (
datecol DATE);

INSERT INTO t
(datecol)
VALUES
(SYSDATE);

SELECT * FROM t;

ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';

SELECT * FROM t;

ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';

SELECT * FROM t;

SELECT SYSDATE FROM dual;

SELECT * FROM t
WHERE datecol = SYSDATE;

ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';

SELECT * FROM t;

SELECT SYSDATE FROM dual;

SELECT TRUNC(SYSDATE) FROM dual;

SELECT * FROM t
WHERE TRUNC(datecol) = TRUNC(SYSDATE);

ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';
 
VSIZE
Returns The Number Of Bytes Required By A ValueVSIZE(e IN DATE) RETURN NUMBER
SELECT VSIZE(SYSDATE) FROM dual;
 
Date Calculations

Returns A Day A Specified Number Of Days In The Future Skipping Weekends
CREATE OR REPLACE FUNCTION business_date (start_date DATE,
Days2Add NUMBER) RETURN DATE IS
 Counter  NATURAL := 0;
 CurDate  DATE := start_date;
 DayNum   POSITIVE;
 SkipCntr NATURAL := 0;
BEGIN
  WHILE Counter < Days2Add LOOP
    CurDate := CurDate+1;
    DayNum := TO_CHAR(CurDate, 'D');

    IF DayNum BETWEEN 2 AND 6 THEN
      Counter := Counter + 1;
    ELSE
      SkipCntr := SkipCntr + 1;
    END IF;
  END LOOP;
  RETURN start_date + Counter + SkipCntr;
END business_date;
/

Business Date function, above, enhanced by Larry Benton to handle negative values for the days2add parameter.
CREATE OR REPLACE FUNCTION business_date (start_date DATE,
days2add NUMBER) RETURN DATE IS
 Counter NATURAL := 0;
 CurDate DATE := start_date;
 DayNum POSITIVE;
 SkipCntr NATURAL := 0;
 Direction INTEGER := 1;  -- days after start_date
 BusinessDays NUMBER := Days2Add;
BEGIN
  IF Days2Add < 0 THEN
    Direction := - 1; -- days before start_date
    BusinessDays := (-1) * BusinessDays;
  END IF;

  WHILE Counter < BusinessDays LOOP
    CurDate := CurDate + Direction;
    DayNum := TO_CHAR( CurDate, 'D');

    IF DayNum BETWEEN 2 AND 6 THEN
      Counter := Counter + 1;
    ELSE
      SkipCntr := SkipCntr + 1;
    END IF;
  END LOOP;

  RETURN start_date + (Direction * (Counter + SkipCntr));
END business_date;
/

Returns The First Day Of A Month
CREATE OR REPLACE FUNCTION fday_ofmonth(value_in DATE)
RETURN DATE IS
 vMo VARCHAR2(2);
 vYr VARCHAR2(4);
BEGIN
  vMo := TO_CHAR(value_in, 'MM');
  vYr := TO_CHAR(value_in, 'YYYY');
  RETURN TO_DATE(vMo || '-01-' || vYr, 'MM-DD-YYYY');
EXCEPTION
  WHEN OTHERS THEN
    RETURN TO_DATE('01-01-1900', 'MM-DD-YYYY');
END fday_ofmonth;
/
 
Time Calculations

Returns The Number Of Seconds Between Two Date-Time Values
CREATE OR REPLACE FUNCTION time_diff (
DATE_1 IN DATE, DATE_2 IN DATE) RETURN NUMBER IS

NDATE_1   NUMBER;
NDATE_2   NUMBER;
NSECOND_1 NUMBER(5,0);
NSECOND_2 NUMBER(5,0);

BEGIN
  -- Get Julian date number from first date (DATE_1)
  NDATE_1 := TO_NUMBER(TO_CHAR(DATE_1, 'J'));

  -- Get Julian date number from second date (DATE_2)
  NDATE_2 := TO_NUMBER(TO_CHAR(DATE_2, 'J'));

  -- Get seconds since midnight from first date (DATE_1)
  NSECOND_1 := TO_NUMBER(TO_CHAR(DATE_1, 'SSSSS'));

  -- Get seconds since midnight from second date (DATE_2)
  NSECOND_2 := TO_NUMBER(TO_CHAR(DATE_2, 'SSSSS'));

  RETURN (((NDATE_2 - NDATE_1) * 86400)+(NSECOND_2 - NSECOND_1));
END time_diff;
/
Calculating time from seconds

Posted by John K. Hinsdale
12/30/06 to c.d.o.misc
SELECT DECODE(FLOOR(999999/86400), 0, '',
              FLOOR(999999/86400) || ' day(s), ') ||
   TO_CHAR(TO_DATE(MOD(999999, 86400),'SSSSS'), 'HH24:MI:SS') AS elapsed
FROM dual;

Obtain counts per ten minute increment

Posted by Michele Cadot
03/09/08 to c.d.o.misc
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';

SELECT TRUNC(SYSDATE) + dbms_random.value(0,86400)/86400
FROM dual
CONNECT BY LEVEL <= 10;

WITH data AS (
  SELECT TRUNC(SYSDATE)+dbms_random.value(0,86400)/86400 h
  FROM dual
  CONNECT BY LEVEL <= 10)
SELECT TO_CHAR(h,'DD/MM/YYYY HH24:MI:SS') h, TO_CHAR(TRUNC(h)
 + TRUNC(TO_CHAR(h,'SSSSS')/600)/144, 'DD/MM/YYYY HH24:MI:SS') "10m"
FROM data
ORDER BY h;