Sunday, April 28, 2013

Workflow tables and its usage




WF_ITEM_TYPES:
The wf_item_types table contains one record for each item_type created. The eight character name of the item_type represents the “Internal Name” of the item. It also functions as the primary key for this table. Some key columns are:
§  NAME: It is a mandatory field. It represents the internal name of the item type.
§  PROTECT_LEVEL: Level at which the data is protected. A mandatory field.
§  CUSTOM_LEVEL: Level of user who last updated the row. Again a mandatory field.
§  WF_SELECTOR: It stores the name of the PL/SQL procedure which implements selector function. This is an optional field.
§  PERSISTENCE_TYPE: Indicates whether item type is temporary or permanent.
§  PERSISTENCE_DAYS: Number of days until purge if persistence is temporary.
Workflow Item Type Display Name and description can be found in WF_ITEM_TYPES _TL table. 

WF_ITEM_ATTRIBUTES:
This table stores definitions of attributes associated with a process. The entries in this table correspond to the “Attributes” subheading in the Workflow Builder. An item attribute works like a variable which can hold values that are specific to the process instance or which may change at run time. Some key columns are:
§  ITEM_TYPE: Internal name for the item type that owns the attribute. A mandatory field.
§  NAME: Internal name of the attribute. A mandatory field.
§  SEQUENCE: Order of the attribute within the message
§  TYPE: Each item attribute is assigned a datatype, such as “Character”, “Number”, or “Date”.
There are three fields to hold a default value, but only one of them will be populated for any item attribute, depending upon the datatype. For example, if you create an item attribute with a datatype of “Number”, and then supply a default value, that value would be stored in the “number_default” field.
The “format” field stores information about a format mask that should be applied to number or date values, and the “subtype” field contains “SEND” or “RECEIVE”. The Translation table is WF_ITEM_ATTRIBUTES_TL and the related view is WF_ITEM_ATTRIBUTES_VL.

WF_ACTIVITIES:
This table stores the definition of an activity. Activities can be processes, notifications, functions or folders. A process activity is a modeled workflow process, which can be included as an activity in other processes to represent a sub-process. A notification activity sends a message to a performer. A functions activity performs an automated function that is written as a PL/SQL stored procedure. A folder activity is not part of a process, but it provides a means of grouping activities. Some key columns are:
§  ITEM_TYPE: Internal name for the Item Type that owns the message.
§  NAME: Internal name for the activity.
§  VERSION: It is used to support multiple versions of the same process running at the same time. The version number works in concert with the “begin_date” and “end_date” fields, to ensure that only one version of any activity is active at any given time. By versioning, the previously launched processes retain the process definition that was in force at the time they were launched.
§  TYPE: The “type” field is the way that the individual types of activities can be distinguished. There are five valid values found in the “type” field: “FUNCTION”, “NOTICE”, “EVENT”, “PROCESS”, and “FOLDER”.
§  RERUN: Determines if activity is rerun during looping.
§  EXPAND_ROLE: Determines how many roles are required to respond to a notification activity.
§  FUNCTION: For function activities only, the field is used to store the name of the PLSQL procedure that the Workflow Engine should call to implement the function.
§  RESULT_TYPE: If you intend to model transitions in a process based upon values returned by an activity node, then the expected results must be predefined by supplying a lookup type, which is stored in this field.
§  ICON_NAME: Name of activity icon used in process window.
§  MESSAGE: For notification activities only, the field called “message” will be populated. In these cases, it will contain the internal name of the message that the notification will deliver.
§  ERROR_PROCESS: Workflow process to run in case of an error.
§  ERROR_ITEM_TYPE: Name of item type to execute in case of error.
§  RUNNABLE_FLAG: Flag (Y or N) to indicate if activity is runnable.
§  FUNCTION_TYPE: Indicates whether function type is pl/sql or internal.

WF_ACTIVITY_ATTRIBUTES:
This table defines attributes which behave as parameters for an activity. Activity attributes are only used by function activities. Each row includes the associated activity, type of attribute, and the format used by the activity. Examples of valid attribute types are DATE, DOCUMENT, FORM, ITEMATTR, LOOKUP, and VARCHAR2. Notice that the table requires three fields just to identify to which activity the attribute is attached: the item_type, name, and version of the activity. To join this table to the wf_activities tables you must join all three of these fields to their corresponding fields in that table. Some key columns are:
§  ACTIVITY_ITEM_TYPE: Item type the activity is associated with
§  ACTIVITY_NAME: Internal name of the activity
§  ACTIVITY_VERSION: Version of the activity
§  NAME: Internal name of the attribute
§  SEQUENCE: Order of the attribute within the message
§  TYPE: This field refers to the datatype of the values that the attribute will contain.
§  VALUE_TYPE: Defines if the default is a constant or a reference to an item attribute.

WF_ACTIVITY_ATTR_VALUES:
This table used to track values contained in activity attributes. This table is identical in purpose to wf_item_attribute_values except it holds values for activity attributes instead of item attributes. Each row includes the process activity id and the associated value for the attribute. The interesting thing about this table is that it uses the process_activity_id to identify the activity to which the attribute is attached. The same activity can be inserted into a process more than one time, so the only way to uniquely identify the node to which this attribute is attached is to use the process_activity_id.

WF_MESSAGES:
The messages that are associated with notifications are stored in this table. Each message, which is uniquely identified by the combination of item_type and message_name (stored in the fields “type” and “name”) receives a single record in the wf_messages table. The actual text of the message is stored only in its localization table (wf_messages_tl). They can found in the “body” and “html_body” fields.

WF_MESSAGE_ATTRIBUTES:
This table contains message attribute definitions. Each message may have zero or more message attributes. Message attributes define additional information that is to be sent to, or received from the user. These attributes can be used as tokens in the subject or body of a message template to place variables values into the message at runtime.

WF_PROCESS_ACTIVITIES:
A process is a sequence of activities performed in a pre-determined order. When you create a process definition in the Workflow Builder by dragging various notifications and functions into the process window, the records created by the Builder are stored into this table.

WF_ACTIVITY_TRANSITIONS:
The flow of a process from node to node as indicated by the transition arrows is not saved in the wf_process_activities table. Instead this information is stored in this table.
A transition is defined by three discrete pieces of information: the node where the arrow begins, the node toward which the arrow points, and the result which, when returned by the beginning node, causes the transition to be followed. Not surprisingly, it is those three fields which are the most important fields in this table: “from_process_activity”, “to_process_activity”, and “result_code”. The values stored in “from_process_activity” and “to_process_activity” are numbers which represent the instance_id of the records from wf_process_activities from which and to which the transition is moving.

WF_LOOKUP_TYPES_TL & WF_LOOKUPS_TL:
Wf_lookup_types_tl is the table used to set up the types of results expected from Workflow activities like functions and notifications. This table does not contain the actual result values, it holds the groupings of the result_codes – the names you see in the Workflow Builder as the names of the Lookups. Wf_lookups_tl is the table that stores the component values that comprise a lookup_type.

Saturday, April 27, 2013

Overview of workflow background engine and it is statuses


The Workflow Engine manages all automated aspects of a workflow process for each item. The engine is implemented in server-side PL/SQL and is activated whenever a call to a workflow procedure or function is made. Since the engine is embedded inside the Oracle Database, if the Workflow server goes down for any reason, the Oracle Database is able to manage the recovery and transactional integrity of any workflow transactions that were running at the time of the failure.

Additionally, Workflow engines can be set up as background tasks to perform activities that are too costly to execute in real time.
The Workflow Engine performs the following services for a client application:
  • It manages the state of all activities for an item, and in particular, determines which new activity to transition to whenever a prerequisite activity completes.
  • It automatically executes function activities (execution is either immediate or deferred to a background engine) and sends notifications.
  • It maintains a history of an activity's status.
  • It detects error conditions and executes error processes.
Based on the result of a previous activity, the engine attempts to execute the next activity directly. An activity may have the following status:
  • Active - activity is running.
  • Complete - activity completed normally.
  • Waiting - activity is waiting to run.
  • Notified - notification activity is delivered and open.
  • Deferred - activity is deferred.
  • Error - activity completed with error.
  • Suspended - activity is suspended.

Important: The Workflow Engine traps errors produced by function activities by setting a savepoint before each function activity. If an activity produces an unhandled exception, the engine performs a rollback to the savepoint, and sets the activity to the ERROR status. For this reason, you should never commit within the PL/SQL procedure of a function activity. The Workflow Engine never issues a commit as it is the responsibility of the calling application to commit.
For environments such as database triggers or distributed transactions that do not allow savepoints , the Workflow Engine automatically traps "Savepoint not allowed" errors and defers the execution of the activity to the background engine.
Oracle Workflow components that continue workflow processing asynchronously, such as background engines and the Notification System, do issue commits when appropriate on behalf of the calling application.

how to check the workflow status from back end in oracle applications


SELECT wat1.display_name "process name", wat.display_name "activity name",
       wa.FUNCTION "function",wa.*
  FROM wf_process_activities wpa,
       wf_activities_tl wat,
       wf_activities_tl wat1,
       wf_activities wa,
       wf_item_activity_statuses wias_h
WHERE wpa.activity_item_type = wa.item_type
   AND wpa.instance_label = wa.NAME
   AND wat.item_type = wa.item_type
   AND wat.version = wa.version
   AND wat.LANGUAGE = 'US'
   AND wat.NAME = wa.NAME
   AND wat1.NAME = wpa.process_name
   AND wat1.item_type = wat.item_type
   AND wat1.version = wat.version
   AND wat1.LANGUAGE = wat.LANGUAGE
   AND wat1.version = wpa.process_version
   AND wias_h.item_type = 'OEOL'
   AND wias_h.process_activity = wpa.instance_id
   AND wias_h.item_key = :item_key

Tuesday, April 23, 2013

how to kill the session in oracle 11g


The alter system kill session command requires two unique arguments that uniquely identify the Oracle session, the session identifier and serial number.
First you have to identify the session to be killed with alter system kill session.

select SID,SERIAL# from v$session where sid = 666

SID   SERIAL#
-------------------
666 34409

The SID and SERIAL# values of the Oracle session to be killed can then be substituted and the alter system kill session command issued.

alter system kill session '130,620,@1';
                                                                     SID , SERIAL#,inst_id

inst_id can get it from gv$session for the session id which you want to kill.

Friday, April 12, 2013

How to Migrate DFF from one instance to another instance


Run the below download command in home directory of Instance1, the ldt file descript_flex.ldt is created in the same directory.

FNDLOAD apps/<password> 0 Y DOWNLOAD @FND:patch/115/import/afffload.lct descript_flex.ldt desc_flex_application DESCRIPTIVE_FLEXFIELD_NAME=description_flexfield_name

desc_flex_application - is the shortname of the Application of the DFF.
description_flexfield_name - This is not title of the DFF.

To get description_flexfield_name:
Open the DFF in Application DeveloperàFlexfieldàDescriptiveàSegments

click help->diagnostics->examine->
block=table, field=DESCRIPTIVE_FLEXFIELD_NAME.
The value in the field “Value” is the description_flexfield_name.

For Example, The description_flexfield_name of the DFF “Additional Information” in the above screenshot is: CS_INCIDENTS_ALL_B_EXT.
Application is: Service.
Short name of Service is: CS
And the download command is:

FNDLOAD apps/<password> 0 Y DOWNLOAD @FND:patch/115/import/afffload.lct descript_flex.ldt CS DESCRIPTIVE_FLEXFIELD_NAME=CS_INCIDENTS_ALL_B_EXT



/*Upload description flexfield*/
Transfer the ldt file descript_flex.ldt from Instance1 to the home directory of the Instance2 and run the below upload command in the same directory.

FNDLOAD apps/apps 0 Y UPLOAD @FND:patch/115/import/afffload.lct descript_flex.ldt


/*Compiling description flexfield*/
After migration, run the below compilation command to compile the flexfield in the Instance2.

fdfcmp apps/<password> 0 Y D desc_flex_application description_flexfield_name

Tuesday, April 9, 2013

Read only tables in Oracle 11g

Oracle 11g database categorizes tables based on their transactional behavior; they can be READ ONLY or READ WRITE. A READ ONLY table remains passive against all DML operations, selective DDL operations, and flashback activities. The permissible actions on a READ ONLY table includes selection, indexing, enforce constraints, rename, and dropping.

With the addition of this category, Oracle added another obvious category as READ WRITE. A table, which is open for all transactional activities, falls under this category. The category can be toggled over at any point of time in the session using ALTER TABLE command.

A table would be created in conventional manner but it can be altered to READ ONLY mode.

Example

ALTER TABLE [TABLE NAME] [READ ONLY | READ WRITE]

Example

SQL> ALTER TABLE EMPLOYEES READ ONLY;
Table altered.

The below ALTER TABLE statement switches back the table mode to READ WRITE.


SQL> ALTER TABLE EMPLOYEES READ WRITE;
Table altered.
READ ONLY tables are extremely useful in tightening the security at user level. Earlier, the same objective was achieved by a statement level DML trigger or a check constraint in ‘disable validate’ state. But READ ONLY table provides a simple and reliable technique to impose DML restriction on a table.

Thursday, April 4, 2013

How do I calculate the table space size in oracle


SELECT   /* + RULE */
         df.tablespace_name "Tablespace",
         df.bytes / (1024 * 1024 * 1024) "Size(GB)",
         SUM (fs.bytes) / (1024 * 1024 * 1024) "Free(GB)",
         NVL (
            ROUND (
               SUM (fs.bytes) * 100 / df.bytes
            ),
            1
         ) "%Free",
         ROUND (
            (  df.bytes
             - SUM (fs.bytes)
            ) * 100 / df.bytes
         ) "%Used"
    FROM dba_free_space fs,
         (SELECT   tablespace_name, SUM (bytes) bytes
              FROM dba_data_files
             WHERE tablespace_name LIKE 'ONTD%'
          GROUP BY tablespace_name) df
   WHERE fs.tablespace_name(+) = df.tablespace_name
GROUP BY df.tablespace_name, df.bytes
ORDER BY 3 DESC

Tuesday, March 26, 2013

FND Tables in Oracle Application


Here there are few key FND tables that we use in our AOL queries.

FND_APPLICATION:
Stores applications registered with Oracle Application Object Library.
FND_APPLICATION_TL:
 Stores translated information about all the applications registered with Oracle Application Object Library.
FND_APP_SERVERS:
 This table will track the servers used by the E-Business Suite system.
FND_ATTACHED_DOCUMENTS:
 Stores information relating a document to an application entity.
FND_CONCURRENT_PROCESSES:
 Stores information about concurrent managers.
FND_CONCURRENT_PROCESSORS:
 Stores information about immediate (subroutine) concurrent program libraries.
FND_CONCURRENT_PROGRAMS:
 Stores information about concurrent programs. Each row includes a name and description of the concurrent program.
FND_CONCURRENT_PROGRAMS_TL:
 Stores translated information about concurrent programs in each of the installed languages.
FND_CONCURRENT_QUEUES:
 Stores information about concurrent managers.
FND_CONCURRENT_QUEUE_SIZE:
 Stores information about the number of requests a concurrent manager can process at once, according to its work shift.
FND_CONCURRENT_REQUESTS:
 Stores information about individual concurrent requests.
FND_CONCURRENT_REQUEST_CLASS:
 Stores information about concurrent request types.
FND_CONC_REQ_OUTPUTS:
 This table stores output files created by Concurrent Request.
FND_CURRENCIES:
 Stores information about currencies.
FND_DATABASES:
 It tracks the databases employed by the eBusiness suite. This table stores information about the database that is notinstance specific.
FND_DATABASE_INSTANCES:
 Stores instance specific information. Every database has one or more instance.
FND_DESCRIPTIVE_FLEXS:
 Stores setup information about descriptive flexfields.
FND_DESCRIPTIVE_FLEXS_TL:
 Stores translated setup information about descriptive flexfields.
FND_DOCUMENTS:
     Stores language-independent information about a document.
FND_EXECUTABLES:
 Stores information about concurrent program executables.
FND_FLEX_VALUES:
 Stores valid values for key and descriptive flexfield segments.
FND_FLEX_VALUE_SETS:
 Stores information about the value sets used by both key and descriptive flexfields.
FND_LANGUAGES:
 Stores information regarding languages and dialects.
FND_MENUS:
 It lists the menus that appear in the Navigate Window, as determined by the System Administrator when definingresponsibilities for function security.
FND_MENUS_TL:
 Stores translated information about the menus in FND_MENUS.
FND_MENU_ENTRIES:
 Stores information about individual entries in the menus in FND_MENUS.
FND_PROFILE_OPTIONS:
 Stores information about user profile options.
FND_REQUEST_GROUPS:
 Stores information about report security groups.
FND_REQUEST_SETS:
 Stores information about report sets.
FND_RESPONSIBILITY:
 Stores information about responsibilities. Each row includes the name and description of the responsibility, theapplication it belongs to, and values that identify the main menu, and the first form that it uses.
FND_RESPONSIBILITY_TL:
 Stores translated information about responsibilities.
FND_RESP_FUNCTIONS:
 Stores security exclusion rules for function security menus. Security exclusion rules are lists of functions and menusinaccessible to a particular responsibility.
FND_SECURITY_GROUPS:
 Stores information about security groups used to partition data in a Service Bureau architecture.
FND_SEQUENCES:
 Stores information about the registered sequences in your applications.
FND_TABLES:
 Stores information about the registered tables in your applications.
FND_TERRITORIES:
 Stores information for countries, alternatively known as territories.
FND_USER:
 Stores information about application users.
FND_VIEWS:
 Stores information about the registered views in your applications

WHO COLUMNS in Oracle Apps

WHO columns are used to track the information updated or inserted by the users against the tables. FND_STANDARD package is used for this purpose. FND_STANDARD.SET_WHO Procedure is used to update the WHO columns in aTable when a DML operation s (i.e. INSERT, UPDATE) performed.1) Created by2) Creation date3) Last _updated_by4) last_update_date5) last_update_login

  •  Use fnd_profile.VALUE (‘USER_ID’) for retrieving the user_id   which will be used by created_by column.
  •  Creation date and last_update_date will be normally SYSDATE.
  •  last_updated_by is same as created_by.
  •  Use USERENV (‘SESSIONID’) for getting the last_update_login id



Monday, March 18, 2013

Sales Order Line Status Flow and Meaning


Below are some of the different statuses of Sales Order Line with brief explanation

OM = Order Management Sales order form
SE = Shipping Transactions or execution form

1) Entered (OM): Order is saved but not booked

2) Booked (OM): Order is Booked.

3) Awaiting Shipping (OM): Order is booked but lines are not yet picked.
Navigating to Shipping Execution, the delivery line status flow is:

4) Not Ready to Release (SE): A delivery line may be in this status when it is interfaced manually into Shipping, is not scheduled and has no reservations. When lines are imported automatically from Order Management this status is not used

5) Released to Warehouse (SE): Pick Release has started but not yet completed. One of the reason could be allocation have not been pick confirmed. The Pick Release process creates a Move Order Header & Mover Order Line in Inventory. This is a common status for users that perform a two-step pick release process. This status indicates that inventory allocation has occurred however pick conformation has not yet taken place.

6) Ready to Release (SE): Order Line is booked and passed to shipping execution. The line is now eligible to pick Release.

7) Backordered(SE): The status of Backorderd is assigned to a line under the following circumstances.

·         The Pick Release process attempted to allocate inventory to the line and all or a partial quantity of the item was not available. In this case the system automatically backorders the discrepant quantity.
·         At Ship confirm the user enters a shipped quantity for an item that is less than the original requested quantity.
·         The user manually Backorders the entire delivery.
8) Shipped (SE): The delivery line is shipped confirmed.

9) Confirmed (SE): The delivery line is shipped or backordered and the trip stops are open.

10) Picked (OM): Pick release is complete, both allocations and pick confirm

11) Picked Partial (OM): This status occurs when a delivery line is not allocated the full quantity during Pick Release and Ship Confirm has not occurred

12) Interfaced (SE): The delivery line is shipped and Inventory interface concurrent process is complete.

13) Awaiting Fulfillment (OM): When fulfillment set is used, Not all shippable lines in a fulfillment set or a configuration are fulfilled

14) Fulfilled (OM): All lines in a fulfillment set are fulfilled.

15) Interfaced to Receivables (OM): The order is linked with Receivables and the invoice is created.

16) Partially Interfaced to Receivables (OM): This status is used in a PTO flow and indicates that the particular PTO item is required for revenue.

17) Closed (OM): Closed indicates that the line is closed.

18) Canceled (OM): Indicates that the line has been completely canceled. No further processing will occur for this line.

Monday, March 11, 2013

Query to find 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_name = user_name
   AND furg.user_id = fu.user_id
   AND furg.responsibility_id = fr.responsibility_id
   AND fr.LANGUAGE = USERENV ('LANG')

Query to find locked objects in Oracle


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

Query to get Customer Related information for a Sales Order


SELECT ooh.order_number
     , hp_bill.party_name
     , hl_ship.address1 ||Decode(hl_ship.address2,NULL,'',chr(10))
      ||hl_ship.address2||Decode(hl_ship.address3,NULL,'',chr(10))
      ||hl_ship.address3||Decode(hl_ship.address4,NULL,'',chr(10))
      ||hl_ship.address4||Decode(hl_ship.city,NULL,'',chr(10))
      ||hl_ship.city    ||Decode(hl_ship.state,NULL,'',',')
      ||hl_ship.state   ||Decode(hl_ship.postal_code,'',',')
      ||hl_ship.postal_code ship_to_address
     , hl_bill.address1 ||Decode(hl_bill.address2,NULL,'',chr(10))
      ||hl_bill.address2||Decode(hl_bill.address3,NULL,'',chr(10))
      ||hl_bill.address3||Decode(hl_bill.address4,NULL,'',chr(10))
      ||hl_bill.address4||Decode(hl_bill.city,NULL,'',chr(10))
      ||hl_bill.city    ||Decode(hl_bill.state,NULL,'',',')
      ||hl_bill.state   ||Decode(hl_bill.postal_code,'',',')
      ||hl_bill.postal_code bill_to_address
     , ooh.transactional_curr_code currency_code
     , mp.organization_code
     , ooh.fob_point_code
     , ooh.freight_terms_code
     , ooh.cust_po_number,
,hcs_ship.site_use_id ship_to_location
, hcs_bill.site_use_id bill_to_location
FROM   oe_order_headers_all ooh
     , hz_cust_site_uses_all hcs_ship
     , hz_cust_acct_sites_all hca_ship
     , hz_party_sites hps_ship
     , hz_parties hp_ship
     , hz_locations hl_ship
     , hz_cust_site_uses_all hcs_bill
     , hz_cust_acct_sites_all hca_bill
     , hz_party_sites hps_bill
     , hz_parties hp_bill
     , hz_locations hl_bill
     , mtl_parameters mp
WHERE  1 = 1
AND    header_id =p_header_id
AND    ooh.ship_to_org_id = hcs_ship.site_use_id
AND    hcs_ship.cust_acct_site_id = hca_ship.cust_acct_site_id
AND    hca_ship.party_site_id = hps_ship.party_site_id
AND    hps_ship.party_id = hp_ship.party_id
AND    hps_ship.location_id = hl_ship.location_id
AND    ooh.invoice_to_org_id = hcs_bill.site_use_id
AND    hcs_bill.cust_acct_site_id = hca_bill.cust_acct_site_id
AND    hca_bill.party_site_id = hps_bill.party_site_id
AND    hps_bill.party_id = hp_bill.party_id
AND    hps_bill.location_id = hl_bill.location_id
AND    mp.organization_id(+) = ooh.ship_from_org_id