Saturday 21 March 2015

Introduction to Oracle ADF

              The Oracle Application Development Framework (Oracle ADF) is an end-to-end application framework that builds on Java Platform, Enterprise Edition (Java EE) standards and open-source technologies. Oracle ADF simplifies development by allowing developers to focus on the logic of application creation rather than coding details.

             Oracle JDeveloper 11g and Oracle ADF give you an environment that covers the full development lifecycle from design to deployment, with drag-and-drop data binding, visual UI design, and team development features built in.

       Oracle ADF is based on Model-View-Controller(MVC) Design patterns. MVC Architecture Cleanly Separates UI, Business Logic and Page Navigation.






















• The model layer represents the data values related to the current page.
• The view layer contains the UI pages used to view or modify that data.
• The controller layer processes user input and determines page navigation.
• The business service layer handles data access and encapsulates business logic.

The Oracle ADF Architecture.













     
       The Architecture illustrates where each ADF Module fits in the fusion web application architecture. The ADF Model layer enables a unified approach to bind any user interface to any business service, without the need to write code. The other modules that make up a Fusion web application technology stack are:
• ADF Business Components, which simplifies building business services.
• ADF Faces rich client, which offers a rich library of ajax-enabled UI components
for web applications built with JavaServer Faces (JSF). 
• ADF Controller, which integrates JSF with ADF Model
In addition to ADF Faces, Oracle ADF also supports using the Swing, JSP, and standard JSF view technologies.

The key features of ADF are :
• Full model-view-controller implementation
• Rich web, mobile and desktop UIs
• Focus on reusability
• Visual and declarative development
• Integrated security and customization
• Based on industry standards

Key Benefits of ADF are:
• Speeds up application development
• Protects from technology shifts
• Increase re-usability across applications
• Create open and standard based applications

The final keyword in Java

 This article explains the usage of final keyword with simple example.
  The final keyword in java is used to restrict the user .There are mainly 3 uses of the keyword final.
1)final can be used to define constants.
2)final can be used to prevent inheritance.
3)final can be used to prevent method overriding.

Let us discuss one by one with example
1) final can be used to define constants.

Syntax :
final data_type variable_name=value;



Output:





  In the example the variable a is declared with final i.e constant . If you try to assign a value to the variable it will not accept and will error out. Please refer the below example .



Error:





2)final can be used to prevent inheritance
 

Error:





We have created class FinalConst as final and tried to inherit that class in the class FinalEx.

3)final can be used to prevent method overriding.


Error:





We have tried to override the method FinalDisplay() in child class which is final method in parent class.



Friday 20 March 2015

The super keyword in Java

This article explains the usage of super keyword with simple example.

    The super keyword in java is an instance variable or method that is used to refer immediate parent class object.

Syntax:
super.member;

Lets discuss with an example:


Output:






1)In the superclass and subclass we have declared a variable a and b .
2)Both the class consists the method PrintMethod() .
3)We have created an object of subclass .
4)Here our intention is to print the variables which are in both super and subclass and need to call the method of super class.
5) From the above logic we cannot print the superclass variables and call the super class method.

If you see the output it printed only the variables in the subclass.
Using super keyword we can call the instance variable or method of super class . See the below example.


Output:







Here we have printed the super class instance variables and methods.
Another usage of super() is to invoke immediate parent class constructor. We will discuss this later.




                                                                                  

Thursday 19 March 2015

The this Keyword in Java

         this keyword in java is a reference variable which refers to the current object which invoked it. 

Syntax:
this.variable_name=variable_name;

    In this article you can see the usage of this keyword to refer current class instance variable. Lets discuss with an example. The below example is to calculate the Area of triangle. 



Output:






In the example
1) b,h are the variable of the class TriangleArea.
2)g,k are the formal parameters of the method SetValue.
3)Once you call the method SetValue with Object and actual parameters the values of g,k will be assigned to b.h respectively.
4) If both the class variable name and formal parameter name in the method are same then what will happen. See the below example . (The formal parameter name g,h is replaced with the name b,h )



Output:

 



Why So?
Here the formal parameter value is not assigned to the class variable b,h. It has been assigned to itself . Because the scope of the class variable has been replaced by the formal parameter. (Will discuss more about ‘scope’ later)

How to overcome this?
See the below example . The class variable is used with the keyword ‘this’.



Output:

 



Here this.b and this.h refers the current class instance variable instead the formal parameter.

Other usage of this keyword
this() keyword can be used to invoke current class constructor .
this keyword can be used to invoke current class method.
this keyword can be used to pass as argument in the constructor call.
this keyword can be used to return the current class instance.
this keyword can be used to pass an argument in the method call .

We will discuss each of the usage in detail later.



Tuesday 17 March 2015

Exception Handling in Java

       An Exception is an abnormal condition that arises in a code sequence at runtime. In simple way an exception is a runtime error.

Eg: If you use division operator i.e (a/b) in your code . if the value of b is zero then at run time the exception occurs as ‘divide by Zero’.

If you not handled the exception in your code the program will be error out . You can handle the exception using try-catch-finally method for safe completion of the program.

Syntax:


Example With out Exception Handling:


Output:






Example with Exception Handling:


Output:





Example of Finally block:
 

Output If the exception raises:




Output if there is no Exception:
Changed the value of b to 2




Will discuss more on Exception handling in later parts

Sunday 15 March 2015

Interview Questions on SQL Queries

          Normally in SQL/PLSQL Interviews they ask for the logic to write some sql queries. You could find 30 such type of queries here. 

1) To fetch ALTERNATE records from a table. (EVEN NUMBERED)
select * from emp where rowid in (select decode(mod(rownum,2),0,rowid, null) from emp);

2) To select ALTERNATE records from a table. (ODD NUMBERED)
select * from emp where rowid in (select decode(mod(rownum,2),0,null ,rowid) from emp);

3) Find the 3rd MAX salary in the emp table.
select distinct sal from emp e1 where 3 = (select count(distinct sal) from emp e2 where e1.sal <= e2.sal);

4) Find the 3rd MIN salary in the emp table.
select distinct sal from emp e1 where 3 = (select count(distinct sal) from emp e2where e1.sal >= e2.sal);

5) Select FIRST n records from a table.
select * from emp where rownum <= &n;

6) Select LAST n records from a table
select * from emp minus select * from emp where rownum <= (select count(*) - &n from emp);

7) List dept no., Dept name for all the departments in which there are no employees in the department.

select * from dept where deptno not in (select deptno from emp);
alternate solution: select * from dept a where not exists (select * from emp b where a.deptno = b.deptno);
altertnate solution: select empno,ename,b.deptno,dname from emp a, dept b where a.deptno(+) = b.deptno and empno is null;

8) How to get 3 Max salaries ?
select distinct sal from emp a where 3 >= (select count(distinct sal) from emp b where a.sal <= b.sal) order by a.sal desc;

9) How to get 3 Min salaries ?
select distinct sal from emp a where 3 >= (select count(distinct sal) from emp b where a.sal >= b.sal);

10) How to get nth max salaries ?
select distinct hiredate from emp a where &n = (select count(distinct sal) from emp b where a.sal >= b.sal);

11) Select DISTINCT RECORDS from emp table.
select * from emp a where rowid = (select max(rowid) from emp b where a.empno=b.empno);

12) How to delete duplicate rows in a table?
delete from emp a where rowid != (select max(rowid) from emp b where a.empno=b.empno);

13) Count of number of employees in department wise.
select count(EMPNO), b.deptno, dname from emp a, dept b where a.deptno(+)=b.deptno group by b.deptno,dname;

14) Suppose there is annual salary information provided by emp table. How to fetch monthly salary of each and every employee?
select ename,sal/12 as monthlysal from emp;

15) Select all record from emp table where deptno =10 or 40.
select * from emp where deptno=30 or deptno=10;

16) Select all record from emp table where deptno=30 and sal>1500.
select * from emp where deptno=30 and sal>1500;

17) Select all record from emp where job not in SALESMAN or CLERK.
select * from emp where job not in ('SALESMAN','CLERK');

18) Select all record from emp where ename in 'BLAKE','SCOTT','KING'and'FORD'.
select * from emp where ename in('JONES','BLAKE','SCOTT','KING','FORD');

19) Select all records where ename starts with ‘S’ and its lenth is 6 char.
select * from emp where ename like'S____';

20) Select all records where ename may be any no of character but it should end with ‘R’.
select * from emp where ename like'%R';

21) Count MGR and their salary in emp table.
select count(MGR),count(sal) from emp;

22) In emp table add comm+sal as total sal .
select ename,(sal+nvl(comm,0)) as totalsal from emp;

23)Count the totalsa deptno wise where more than 2 employees exist.
SELECT deptno, sum(sal) As totalsal
FROM emp
GROUP BY deptno
HAVING COUNT(empno) > 2;

 
 24) How can I retrive all records of emp1 those should not present in emp2?
(Select * from emp) Minus (Select * from emp1)


 25) Select all the employee group by deptno and sal in descending order.
select ename,deptno,sal from emp order by deptno,sal desc;


26) How can I create an empty table emp1 with same structure as emp?
Create table emp1 as select * from emp where 1=2;


27) How to retrive record where sal between 1000 to 2000?
Select * from emp where sal>=1000 And sal<2000;


28) Select all records where dept no of both emp and dept table matches.
select * from emp where exists(select * from dept where emp.deptno=dept.deptno)


29) If there are two tables emp1 and emp2, and both have common record. How can I fetch all the recods but common records only once?
(Select * from emp) Union (Select * from emp1)


30) How to fetch only common records from two tables emp and emp1?
(Select * from emp) Intersect (Select * from emp1)



Author: Jagadekara
     Forum Guru 
     Club Oracle

Friday 13 March 2015

Migrate Descriptive Flex Fields (DFF) from one instance to another using FNDLOAD

         The oracle apps Descriptive Flex Fields (DFF) in one instance can be migrated/moved to another instance using FNDLOAD. You can follow the below steps for the same.

Step 1:
Edit the below FNDLOAD script.
To Copy select+ctrl+C


Note: You need to enter 1) *.ldt file name
                                        2)Application short name
                                        3)DFF Name
                                        4)Context code

You can find the p_context_code from below navigation

 








Step 2: Execution of FNDLOAD script
                         • Log into unix as application user
                         • Enter apps password
                         • Execute the modified script in the step 1
                         • The *.ldt file will be generated on the same directory i.e pwd

Step 3:Modify the below script


Note: You need to enter the *.ldt file name which you have exported and apps credential

Step 4:Execution of FNDLOAD script
                      • Log into destination instance from unix as application user
                      • Place the *.ldt file to the directory i.e pwd
                      • Enter the apps password.
                      • Execute the modified script.

Note:  Step 2 and Step4 are DBA tasks

Thursday 12 March 2015

Migrate Form Personalization from one instance to another using FNDLOAD

       The oracle apps form personalization in one instance can be migrated/moved to another instance using FNDLOAD. You can follow the below steps for the same.

Step 1: Edit the below FNDLOAD script.

To copy code select+ctrl+C


Note: You need to enter a) Apps Credential
                                        b)ldt file name
                                        c) function name

Step 2: Execution of FNDLOAD script
              * Log into unix as application user
              * Enter apps password
              * Execute the modified script in the step 1
              * The *.ldt file will be generated on the same directory i.e pwd

Step 3:Modify the below script

To copy code select+ctrl+C
 

Note: You need to enter the *.ldt file name which you have exported and apps credential

Step 4:
              • Log into destination instance from unix as application user
              • Place the *.ldt file to the directory i.e pwd
              • Enter the apps password.
              • Execute the modified script.

Important Note:
       • The form personalization migration using FNDLOAD will delete the existing   personalization on destination form.
       • If you would like to keep the existing personalization in destination there are 2 Alternatives
                      1) You need to enter/create the personalization manually on destination
                      2) Export the *.ldt file from both source and destination. Change the sequence numbers if it is conflicting and merge both *.ldt file to single *.ldt file and Migrate to destination .

Wednesday 11 March 2015

Migrate form and functions from one instance to another using FNDLOAD

     The oracle apps form and functions in one instance can be migrated/moved to another instance using FNDLOAD. You can follow the below steps for the same.

Step 1:
Find the form and function name which you are going to migrate.
You can refer below 2 tables
select * from fnd_form
select * from fnd_form_functions

Step 2:
Edit the below FNDLOAD script 

Export form:
To Copy code Select+ctrl+C


Export Function:
To Copy code Select+ctrl+C


Note: You need to enter a) Apps Credential
                                        b)ldt file name
                                        c) Application short name
                                        d)form/function name 

Step 3:
Execution of FNDLOAD script
               * Log into unix as application user
               * Enter apps password
               * Execute the modified script in the step 2
              * The *.ldt file will be generated on the same directory i.e pwd

Step 4:
Modify the below script 

Form Import:
To Copy code Select+ctrl+C


Function Import:
To Copy code Select+ctrl+C


Note: You need to enter the *.ldt file name which you have exported and apps credential
Step 5:
* Log into destination instance from unix as application user
* Place the *.ldt file to the directory i.e pwd
* Enter the apps password.
* Execute the modified script.

Note: The step 3 and step 5 are DBA taskes. You can contact your DBA to execute the FNDLOAD scripts

Tuesday 10 March 2015

Script to Register Custom Table using AD_DD Package

             If a custom table is not registered then that table will not be shown in fnd_tables. You have to register your custom table if you are using those tables in AOL like value set creation. Using AD_DD package you can register custom tables,columns,Primary keys. If a table has many columns then you have to register each and every column manually . It is a tedious task.

       You can use below PLSQL block to register the table and all columns and primary key by passing table name and application short name as parameter

To copy code select+ctrl+C

Wednesday 4 March 2015

Oracle Apps Form personalization An Example.

     Requirement: A column Deliver -to in the form purchase order distribution need to make as mandatory.

In the seeded Purchase order form the column Deliver-to is not mandatory .











You can follow below steps to make the column Deliver-To as Mandatory column using Form personalization.

Step 1:
Open the form Purchase Order . Go to Help >>Diagnostics>>Custom Code>>Personalize


Step 2 :
Define the sequence number , Description and select the level as form. Check the enabled box.





Step 3:
Go to condition tab and select the trigger event and processing mode and the Context level as Site/Responsibility/user










Step 4:
Go to action Tab and define the sequence . Select the Type as property and select the target object .










Select the property name as required and Value as True.
Click on Apply Now and Save the Data.
You can see the Deliver-To field is become mandatory.

Tuesday 3 March 2015

Data Abstraction in Java

        Data abstraction is the process of hiding the implementation details and showing only the functionality. In java you can declare the structure of abstract class in parent class and the actual implementation will be defined in their child classes.

Eg: The calculation of area will be the functionality and depending on either it is triangle ,rectangle or square your implementation details will be different.

Abstract class: 
      A class which is declared with abstract keyword will be the abstract class in java. If a class is abstract then you cannot create an instance for that class. You have to inherit the abstract class and need to create the instance for the child class.

Syntax:
abstract class class_name{}

Abstract Method: 
      If a method is created with the abstract keyword and the method does not have any implementation logic in the method body is called abstract method.
If a class has at least one abstract method then the class should be abstract class.

Syntax:
abstract return_type method_name();

Example:
TO copy the code select+ctrl+C


Output:








Monday 2 March 2015

Polymorphism in Java

     Polymorphism is an OOP concept that refers to the ability of a variable,function or object to take on multiple forms. Polymorphism means many forms .

Below are the 2 types which supports polymorphism in Java
1)Method Overloading
2)Method overriding

1) Method Overloading:
       Method overloading is one of the polymorphism concept which allows 2 or more methods within the same class that share the same name and the parameter for those methods are different. 

Depending on the parameter passed at the time of calling the method it will decide which method need to be called. 

Example :
To copy the code select+ctrl+C


Output:








2) Method Overriding
 A subclass has the same method as declared in the parent class is called method overriding. Here the method name and the number of parameters are same . The implementation logic i.e the method body may change than the parent method.
Method overriding is used for runtime polymorphism. If a child class overrides the parent class method then the method in the child class will be executed else the method in the parent class will be executed.

Example:
To copy the code select+ctrl+C


Output: