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.

Sunday 1 May 2016

ADF Interview Questions - Set 11

Question: How to connect standalone weblogic instance from jdeveloper? How to deploy application to standalone weblogic instance from jdeveloper?

Answer: To demonstrate deployment directly from JDeveloper, let's create a sample Fusion Web Application (Web) based on the HR schema. Let's create an Employee entity from the EMPLOYEES table and an Employees view based on the Employee entity. Finally, let's bundle the Employees view in the HrAppModule application module.

For the ViewController let’s create a View Activity called Employees directly in the unbounded adfc-config task flow and anEmployees.jspx JSF page for the Employees View Activity. Finally, let’s drag the Employees view from theHrAppModuleDataControl in the Data Controls and drop it onto the Employees.jspx JSF page as an ADF Form.

In order to deploy our application, we first need to create an Application Server Connection to the standalone WebLogic server. First let’s start WebLogic if not yet started. Then, in the Resource Palette (View Resource Palette) let’s create a new Application Server connection. 



In the Create Application Server Connection wizard Name and Type page specify the Connection Name, ensure that the Connection Type is set to WebLogic 10.3 and click Next


  
In the Authentication page specify the WebLogic server Username and Password


  
In the Configuration page specify the WebLogic Hostname – localhost for our development machine, the server Port – defaults to 7001 - and the Weblogic Domain name that we will be deploying on. 

  

  
In the Test page click on the Test Connection button to test the connection and verify that all tests are successful. 
  
Click Finish to save the connection which will appear in the IDE Connections in the Resource Palette
  
Now we are ready to deploy our application. From the Application Menu – at the top left next to the application selection – select Deploy… and then the name of the deployment. 

  
The first time around a Deployment wizard will be displayed. In the Deployment Action page select Deploy to Application Server and click Next.

In the Select Server page select the application server connection we created earlier from the listed Application Servers. Uncheck the Deploy to all server instances in the domain option if you want to deploy on a specific server instance. Leave the Deploy as a standalone Application option selected and press Next.


If you unchecked the Deploy to all server instances in the domain option in the previous page, a Server Instances page will be displayed. Select the Server instance that you will be deploying – ensure that the status of the server instance is RUNNING– and click Next.

In the Summary page verify the Deployment Summary details and click Finish to start the deployment process. The status of the deployment process is displayed in the Deployment – Log window. The deployment process first creates the Web Application Module (war), then the Enterprise Application Module (ear) and finally deploys the application onto the server instance(s). If all goes well the message Application Deployed Successfully is shown in the log window.
  

That’s it. Our application has been deployed into the standalone WebLogic server. To verify that this is the case, log in into the WebLogic administrator console – http://localhost:7001/console - and click Deployments in the Domain Structure tree. In the Summary of Deployments you should see the application we’ve just deployed.



We can access our deployed application by entering the application URL –http://127.0.0.1:7001/JDeveloperFAQNo3/faces/Employees - on the browser. At this point the application won't initialize and the Employees page won’t load until we enable security in our application. We will see how to do that some other time.

Conclusion: Once we install and configure the standalone WebLogic server in our development machine, deploying an ADF application directly onto it from JDeveloper is a piece of cake. Just make a connection to the server in JDeveloper and deploy! 



ADF Interview Questions - Set 10

Question: How to run application with -Djbo.debugoutput=console enabled in JAVA options?
Answer: Right click on project -> open project properties -> Select Run/Debug/Profile option and click on Edit -> Give -Djbo.debugoutput=console  in Java Options -> Click Ok.

Question: Can you use view object inside custom component definition?
Answer: Use of datamodel inside the Declarative components is not allowed by adf. But there is work around for that you can pass you iterator to Declarative component. You have to write the logic to get data from iterator and display on component same logic you can use to retrieve data from component and set that to iterator.

Question: What is view object?
Answer: A view object is a model object used specifically in the presentation tier. It contains the data that must display in the view layer and the logic to validate user input, handle events, and interact with the business-logic tier. The backing bean is the view object in a JSF-based application. Backing bean and view object are interchangeable terms

Question: What is a view scope?
Answer: A view-state allocates a new viewScope when it enters. This scope may be referenced within the view-state to assign variables that should live for the duration of the state. This scope is useful for manipulating objects over a series of requests from the same view.

Question: What do you mean by Bean Scope?
Answer: Bean Scope typically holds beans and other objects that need to be available in the different components of a web application.

Question: Can you use view object inside custom component definition?
Answer: Use of data model inside the Declarative components is not allowed by adf. But there is work around for that you can pass you iterator to Declarative component. You have to write the logic to get data from iterator and display on component same logic you can use to retrieve data from component and set that to iterator.

Question: Which file holds the details of users and groups in adf?
Answer: Users and Groups we usually create in Security part at the time of enabling security on your application by default some of the files gets created inside Application Resources, Inside that we will find jazn-data.xml file, once we open that file we can have access to create the user profiles, Application Roles and Enterprise roles, So your application level roles is assigned to the users whomever are created in your user profile, So each and everything from user roles to enterprise roles you are giving inside your jazn-data.xml file.

Question: Explain about JSF lifecycle.
Answer: A typical JSF lifecycle flows as follows:
1.     JSF interrogates the request to extract the incoming parameters.
2.     JSF converts these parameters from strings to their corresponding data types.
3.     JSF validates the presence of required parameters, the correctness of entered values, etc.
4.     JSF uses the incoming URL to determine who should process the request. This is usually done using post-backs.
5.     JSF will execute any custom logic that you provide it. Your logic will store work products (or Transfer Objects for the view) in the appropriate scope. JSF defines interfaces for event handlers and clear guidelines as to when a particular handler will be invoked.
6.     JSF determines the view that will display the response to the user. JSF uses the return value of your application handler to look up the desired view in a mapping file that you provide.
7.     JSF will execute any custom logic that you provide to render your response, or will forward to the desired view.

During all of this, JSF provides utilities for errors to be exposed to the user, for internationalization using resource bundles, etc. JSF does not provide a native composition facility - so you'll need to include Tiles or Facelets.


Question: How to declare the page navigation (navigation rules) in faces-config.xml file in ADF 10g?
Answer: Navigation rules tells JSF implementation which page to send back to the browser after a form has been submitted. We can declare the page navigation as follows:
<naviagation-rule>
<from-view-id>/index.jsp</from-view-id>
<navigation-case>
<from-outcome>login</from-outcome>
<to-view-id>/welcome.jsp</to-view-id>
</navigation-case>
</naviagation-rule>
This declaration states that the login action navigates to /welcome.jsp, if it occurred inside /index.jsp.

Question: How to set the range of a table?
Answer: <af:table rows=”#{bindings.LoggedInUserServiceRequests.rangeSize}”…/>

Question: What is region in Task Flow?
Answer: You can render a bounded task flow in a JSF page or page fragment (.jsff) by using an ADF region. An ADF region comprises the following. You create an ADF region by dragging and dropping a bounded task flow that contains at least one view activity or one task flow call activity to the page where you want to render the ADF region. This makes sure that the ADF region you create has content to display at runtime

Question: What is Backing Bean?
Answer: Backing beans are JavaBeans components associated with UI components used in a page. Backing-bean management separates the definition of UI component objects from objects that perform application-specific processing and hold data.
Backing beans are those managed beans which have 1:1 mapping with a page. They have getters and setters for all the components in the related page.

Backing bean is about the role a particular managed bean plays. This is a role to be a server-side representation of the components located on the page. Usually, the backing beans have a request scope, but it is not a restriction.
The backing bean defines properties and handling-logics associated with the UI components used on the page. Each backing-bean property is bound to either a component instance or its value. A backing bean also defines a set of methods that perform functions for the component, such as validating the component’s data, handling events that the component fires and performing processing associated with navigation when the component activates.