Friday 10 June 2016

Oracle - Global Temporary tables

To create a table named test with column col1 type varchar2 length 10, col2 type number. col3 type clob we can use CREATE TABLE statement as,

CREATE TABLE TEST(col1 VARCHAR2(10), col2 NUMBER, col3 CLOB);

Now if I insert data into the table the data is visible and accessible to all users. In many cases it is needed the data inside a table will be reside temporarily. In that case we can use temporary tables. Temporary tables are useful in applications where a result set is to be buffered. To create temporary table we have to issue CREATE GLOBAL TEMPORARY clause.

Temporary table can be of two types based on ON COMMIT clause settings.
1)ON COMMIT DELETE ROWS specifies temporary table would be transaction specific. Data persist within table up to transaction ending time. If you end the transaction the database truncates the table (delete all rows). Suppose if you issue commit or run ddl then data inside the temporary table will be lost. It is by default option.
Example:
(i)This statement creates a temporary table that is transaction specific:
CREATE GLOBAL TEMPORARY TABLE test_temp(col1 number, col2 number) ON COMMIT DELETE ROWS;
Table created.

(ii)Insert row in to the temporary table.
insert into test_temp values(3,7);
1 row created.

(iii)Look at the data in the table.
select * from test_temp;
COL1 COL2
---------- ----------
3 7

(iv)Issue Commit.
commit;
Commit complete.

(v)Now look at the data in the temporary table. As I created transaction specific temporary table(on commit delete rows) so data is lost after commit.
SQL> select * from test_temp;
no rows selected

2)ON COMMIT PRESERVE ROWS specifies temporary table would be session specific. Data persist within table up to session ending time. If you end the session the database truncates the table (delete all rows). Suppose you type exit in SQL*Plus then data inside the temporary table will be lost.
Example of Session Specific Temporary Tables:

1)Create Session Specific Temporary Table test_temp2.
CREATE GLOBAL TEMPORARY TABLE test_temp2 (col1 number, col2 number)
ON COMMIT PRESERVE ROWS;

(ii)Insert data into it and look at data both before commit and after commit.
insert into test_temp2 values(3,7);
1 row created.

SQL>select * from test_temp2;
COL1 COL2
---------- ----------
3 7

(iii) commit;
Commit Complete

(iv)select * from test_temp2;
COL1 COL2
---------- ----------
3 7

(iv)End the Session.
exit;

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
(v)Connect in a new session and look at data again.
$ sqlplus apps/apps@vis.world
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 – Production
With the Partitioning, OLAP and Data Mining options
SQL> select * from test_temp2;
no rows selected

This is how Global Temporary Tables are used.

Feature of Temporary Table
1.Indexes can be created on temporary tables. They are also temporary and the data in the index has the same session or transaction scope as the data in the underlying table.
2.Unlike permanent tables, temporary tables and their indexes do not automatically allocate a segment when they are created. Instead, segments are allocated when the first INSERT (or CREATE TABLE AS SELECT) is performed. This means that if a SELECT, UPDATE, or DELETE is performed before the first INSERT, the table appears to be empty.
3.DDL operations (except TRUNCATE) are allowed on an existing temporary table only if no session is currently bound to that temporary table.
4.If you rollback a transaction, the data you entered is lost, although the table definition persists.
5.A transaction-specific temporary table allows only one transaction at a time. If there are several autonomous transactions in a single transaction scope, each autonomous transaction can use the table only as soon as the previous one commits.
6.Because the data in a temporary table is, by definition, temporary, backup and recovery of temporary table data is not available in the event of a system failure.
7.It is good to know about that temporary table itself is not temporary, the data within it is temporary.

Restriction of Temporary Table
1.Temporary tables cannot be partitioned, clustered, or index organized.
2.You cannot specify any foreign key constraints on temporary tables.
3.Temporary tables cannot contain columns of nested table.
4.You cannot specify the following clauses of the LOB_storage_clause: TABLESPACE, storage_clause, or logging_clause.
5.Parallel DML and parallel queries are not supported for temporary tables. Parallel hints are ignored. Specification of the parallel_clause returns an error.
6.You cannot specify the segment_attributes_clause, nested_table_col_properties, or parallel_clause.
7.Distributed transactions are not supported for temporary tables.


ADF - Topics for competency building

Below is the initial list of topics which can be covered to build strong competency in ADF –

1.       Worked on unbounded and bounded task flows
2.       ADF search region with View Criteria and Business Services methods
3.       Create /Update new Record
4.       Entity level and attribute level validations
5.       Master details pages with Search  and Insert update functionality in ADF
6.       Use java script in ADF pages
7.       Call PL/SQL Stored procedure
8.       Upload file data in View object.
9.       Implement popup
10.   Print page

11.   Export to excel

OAF - Topics for competency building

Below is the list of topics which can be covered to build strong competency in OAF –

1.                   Result page with jump ahead LOV (like 20 of 200 records)
2.                   Advance table
3.                   Show/Hide function
4.                   Select All - checkbox  --
5.                   Different ways of passing Parameters
6.                   PPR functionality
7.                   Navigator search - type ahead search
8.                   Handling Single or Multiple Exceptions
9.                   Displaying error messages in Popup windows --
10.               Tree Table --
11.               Drop-down Menu --
12.               External LOVs
13.               Poplist
14.               Attachments
15.               Inline add or view attachment Window
16.               Print Attachment dialog window
17.               Export Result table
18.               Print Result table
19.               Emailing
20.               Embedded OBIEE Report
21.               Personalization, Extension, Substitutions
22.               New VO Creation through personalization
23.               Entity - Defaulting Primary Key
24.               VO – Initializing Query
25.               Implement FTP page for BCT
26.               OAF Page Internationalization
27.               Web ADI Customization
28.               Java Concurrent program for upload file from Application server to Database server.
29.               View Object and Controller extension.
30.               Dependent list of values.
31.               Multi select list of value.
32.               Use Bound values.
33.               OAF Integration with XML publisher
34.               Prepare OAF component installation script.
35.               Create printable page in OAF.
36.               Generate flat files from application and upload flat file through OAF pages.
37.               Master detail insert page.
38.               Master detail search page.
39.               Attach custom CSS with OAF beans
40.               OAF page debugging.
41.               Create processing page.
42.               ** Range based list of values.
43.               ** Implement Bilingual OAF pages
44.               ** Calling SRS window through OAF Page
45.               ** Switcher functionality
46.               ** Navigator tree
47.               **Inline Popup Windows  -- http://oracleanil.blogspot.in/2010/09/popup-in-oaf-r1212-part-ii.html
48.               **Call forms from OAF pages.
49.               **Dynamically creation of Application module and View Object inside controller.
50.               **Add dynamic attribute in view object.

Sunday 5 June 2016

OAF - Account Generator Implementation (PAAPINVW examples)

To begin with, Account Generator Workflow needs to be customized as per the business requirement. Below is an example of PAAPINVW workflow customization - 




Once Workflow is customized, below PLSQL Code is required initiate the Customized PAAPINVW Workflow and update the generated account back in database - 


SELECT fa.application_short_name,
  fifs.id_flex_code,
  fifs.id_flex_num
INTO v_application_short_name,
  v_id_flex_code,
  v_id_flex_num
FROM fnd_id_flex_segments fifs,
  fnd_application fa
WHERE fifs.application_id = 101
AND fifs.application_id   = fa.application_id
AND id_flex_code          = 'GL#'
AND enabled_flag          = 'Y';

Pass the above retrieved variables into the below initialize procedure - 

v_seq_num := FND_FLEX_WORKFLOW.INITIALIZE(v_application_short_name, v_id_flex_code, v_id_flex_num, 'PAAPINVW');

Above process internally calls 'wf_engine.CreateProcess' process as well. 
Next steps, involves initializing the variables to be passed to workflow - 

wf_engine.setitemattrtext (
        itemtype      => 'PAAPINVW' ,
        itemkey       => v_seq_num  ,
        Aname         => 'PROJECT_ID'  ,
        avalue        => v_project_id);
    
wf_engine.setitemattrtext (
        itemtype      => 'PAAPINVW' ,
        itemkey       => v_seq_num  ,
        Aname         => 'TASK_ID'  ,
        avalue        => v_task_id);
    
wf_engine.setitemattrtext (
        itemtype      => 'PAAPINVW' ,
        itemkey       => v_seq_num  ,
        Aname         => 'AWARD_ID'  ,
        avalue        => v_award_id);   
    
wf_engine.setitemattrtext (
        itemtype      => 'PAAPINVW' ,
        itemkey       => v_seq_num  ,
        Aname         => 'EXPENDITURE_TYPE',
        avalue        => v_expenditure_type);

After initializing the variables to be passed to the Workdlow, StartProcess is called to initiate the process -

wf_engine.StartProcess('PAAPINVW', v_seq_num );

Once the process is completed, account generation status and generated account is retrieved using below commands - 

v_account_status := wf_engine.getitemattrtext ('PAAPINVW', x_seq_num, 'FND_FLEX_STATUS'); 
v_account_ccid := wf_engine.getitemattrtext('PAAPINVW', x_seq_num, 'FND_FLEX_CCID'); 
v_account_segment := wf_engine.getitemattrtext('PAAPINVW', x_seq_num, 'FND_FLEX_SEGMENTS'); 
v_account_data := wf_engine.getitemattrtext('PAAPINVW', x_seq_num, 'FND_FLEX_DATA'); 
v_account_desc := wf_engine.getitemattrtext('PAAPINVW', x_seq_num, 'FND_FLEX_DESCRIPTIONS');

Below SQL statement can be used to update the generated account - 

UPDATE Ap_Invoice_Distributions_All
SET Dist_Code_Combination_Id = V_Account_Ccid
WHERE Invoice_Id             = V_Invoice_Id
AND invoice_line_number      = v_inv_line_num
AND distribution_line_number = v_distribution_line_number;

Below is the link to the details document on Account Generator.

Reference Document for Account Generator Implementation

OAF - GL Diistribution DFF field on OAF page

This post will details the steps required for enabling the functionality of GL DFF as below - 



First step, create a field on OAF page with item type as 'Flex' in a table or region. Attributes of this Flex item needs to be set as below - 




Segment List property value need to setup as below - 



** Here ACCOUNTING_FLEXFIELD is the name of the accounting flexfield defined for GL and can be obtained using below query - 

select id_flex_structure_code, id_flex_code from fnd_id_flex_structures where id_flex_code = 'GL#';

Above field is created in a Advanced table. If you are using a normal OAF table then you will need to populate the VO Instance name of the flex item as well.


Second step, which needs to be performed is adding following code in the processRequest method of the Controller java file - 

OAApplicationModule am = pageContext.getApplicationModule(webBean);

OAKeyFlexBean kffId = (OAKeyFlexBean)webBean.findIndexedChildRecursive("AccountCol");

// Set the code combination lov
kffId.useCodeCombinationLOV(true);

// Set the structure code for the item key flex
kffId.setStructureCode("ACCOUNTING_FLEXFIELD");

// Set the attribute name to the item
kffId.setCCIDAttributeName("DistCodeCombinationId");

Performing the above mentioned steps will help meet the requirement of creating and displaying the GL DFF field on an OAF page.