Monday, July 11, 2016

Entity Objects and Entity Association

Entity Objects and Entity Association

Entity Objects
  • The entity objects are used if one wishes to do some insert/update operations.
  • Entity Objects represents a Data Base Row of a table.
  • Entity Objects will be based on the View (Oracle View), Synonyms or snapshots.
  • We need to create Entity Object if we want to perform DML operations on the OAF Page.
  • All the Entity Objects end with the EO.

Example:  employeeEO
  • When we create Entity Object (EO) one subclass will generate.
Employee

We have two types of Entity Objects
  1. PL/SQL based Entity Objects
  2. Java based Entity Objects

Note that we have two types of tables in Oracle Apps they are Custom Tables and Seeded Tables.
If we want to perform the DML operations on the standard (Seeded) table then we go for PL/SQL based Entity Object and if we want to perform the DML operations on the custom table then we go for Java Based Entity Object.

Entity Association
  • Entity Association is the relationship between two Entity Objects having one common column.
  • All the Entity Association ends with the AO (Association Object).
Example:  EmpDeptAO
  • If we want to perform DML operations on Master Detail page then we go for Entity Association.
  • If we want to common know column between two tables then we will go for Entity Association.

About Model..

About Model..

The entire Database related transactions in OAF pages will be taken care by the MODEL.
  • Model is where the application implements business logic.
  • Model will implement all the Data Base transactions.
  • Model component is implemented using BC4J where BC4J is Business Component for Java.
  • BC4J consists of three components:
      • Entity Object and Entity Associations
      • View Objects and View Links
      • Application Module
Model contains six components including BC4J components, additionally the other three components are:
    • Callable Statement
    • Prepare Statement
    • OADB Transactions
Callable statement is used to call a PL/SQL statements, Prepare statements are used if we are using single SELECT statement, and OADB transactions will take care of Oracle APPS related Data Base transactions.
model

Advantages & Disadvantages of OAF

Advantages & Disadvantages of OAF

The advantages of OAF are as follows:
1) End user Productivity
2) Enterprise Grade Performance and Scalability
3) Highly extensible Architecture
4) Browser Look and Feel of all the pages in application.
5) Open Standards such as XML, HTML, Java, JSP, SQL, and Web Services.
6) Application Customizability.
7) Developer Productivity.
The disadvantages of OAF are:
i) Cannot see the layout at design time.
ii) OAF Pages are integrated / compatible only with the Oracle Apps.
iii) Drag and Drop options are not available.
iv)  More R&D is required to design a form layout which is time consuming.

Structure of OAF

Let us discuss about the structure of OAF.
OAF follows J2EE Architecture and J2EE follows MVC architecture so therefore ultimately OAF follows MVC Architecture.
The abbreviation of MVC is Model View Controller.
MVC is the clean design interface between Model, View, and Controller.
Structure of OAF
Model will take care the Data Base related Transactions, Model contains the following:

Entity Object (EO)
View Object (VO)
Callable Statement (PL/SQL Statement)
Prepare Statement (Single Select Statement)
OADB Transactions (Oracle Apps Data Base Transactions)

View is nothing but the OAF Page Output. View is implemented by UIX (User Interface XML).

Controller will take care of web browser activities like HTTP Get and HTTP Post
Controller have got three methods:
Process Request
Process Forms Request (HTTP Get)
Process Form Data (HTTP Post)
HTTP get: While loading the Page we use HTTP Get.
HTTP Post : After Loading the page if we want any changes the we use HTTP Post.
We will discuss in detail about MVC architecture in the next chapters.
The Below figure shows the interaction between Model, View, and Controller.

controller

Onion Structure of OAF
Another structure of OAF is called Onion structure.
The OA Framework can be extracted into a series of concentric layers.
Each layer knows only about the layers below to them.
The below figure shows the Onion Structure, in which AM interacts with the VO and VO interacts with EO and finally EO interacts with Database.

OAF

Difference Between OAF and Oracle Forms

Difference Between OAF and Oracle Forms

Let us discuss some difference in OAF pages and Oracle Forms.  The below table lists out the differences between OAD and Oracle Forms.

OAFOracle FORMS
OAF Follows MVC architecture and Client ServerArchitectureForms Follows only Client Server Architecture
OAF pages are light weight componentsForms are not light weight
OAF Pages can send through mobile devicesCannot send to mobile devices
OAF Pages can connect in Oracle Apps Local MachineCannot (NOT APPLICABLE)
Look and Feel is goodNot better when comparing to OAF
OAF pages are integrated with the Java TopForms are integrated with Application Top
Commit always takes place in the Application Module’s (AM) Java code. When a commit takes place, the data from OA Framework Cache is transferred to the database.The COMMIT_FORM or DO_KEY(‘COMMIT_FORM’) commands can be invoked from any trigger that allows restricted procedures.
A page is divided into regions. Regions contain fields, buttons, tables, and other components.A form is divided into blocks; blocks contain the fields, buttons, and other components

What is OAF

OAF Overview

Oracle Application Framework (OAF) is an architecture for creating web based front end pages and J2EE type of applications within the Oracle EBS ERP platform.Oracle Application Framework is the development and deployment platform developed by Oracle to develop the Oracle E-Business Suite “Self-Service” or HTML based Applications.
OA Framework, is based on the industry-standard Model-View-Controller(MVC) design pattern and can be used to develop extensions to existing E-Business Suite functionality. Oracle Application (OA) enables you to personalize the layout of the user interface and the content it displays to suit your business needs. Oracle’s JDeveloper tool with an Oracle Applications extension is used for development for the Oracle Applications Framework and uses Java & XML languages for the same.
Oracle Application Framework (OA Framework or OAF) is a framework developed by Oracle Corporation for application development within the Oracle E-Business Suite (EBS)
Oracle Application Framework (OAF) provides visual and declarative approaches to Java EE development. The OA framework is also available to customers for personalization’s, customizations and custom-application development.
The OA Framework helps to create self Service pages in Oracle EBS.
The OA Framework helps in controlling the flow of the application.
OA Framework works on the basic Java EE principles.
To Learn OAF you must know the Basics of Java like Core Java.
User Interface is Very Interactive in OAF
OA Framework contains inbuilt security
We can view OA Framework pages in mobile phones too which contains Internet browsing feature
OA Framework is J2EE based but it also supports various standards like HTML, XML, SQL, JSP.

Friday, July 8, 2016

Developing XML Publisher Report - using Data Source as PL/SQL Stored Procedure



Background:

Developing sample XML Publisher Report with Executable Method as 'PL/SQL Stored Procedure'

In my previous post https://oracleappscenter.blogspot.com/2016/07/xml-data-template.html i have explained developing XML Publisher Report using Data Template as Data Source

Prerequisite for the below Example:
1. Create a table
CREATE TABLE demo_products
(  product_code   NUMBER,
   product_name   VARCHAR2 (100));
2. Insert Values
INSERT INTO demo_products
     VALUES (569, 'Oracle Cost Management');
3. Issue Commit

1. Create a Package Spec & Body with a single Procedure
Spec:

CREATE OR REPLACE PACKAGE APPS.MY_PACKAGE
AS
   PROCEDURE REPORT (errbuf            OUT VARCHAR2,
                     retcode           OUT VARCHAR2,
                     p_product_id   IN     NUMBER);
END MY_PACKAGE;
/ 
Body:
CREATE OR REPLACE PACKAGE BODY APPS.MY_PACKAGE
AS
   PROCEDURE REPORT (errbuf            OUT VARCHAR2,
                     retcode           OUT VARCHAR2,
                     p_product_id   IN     NUMBER)
   IS
      l_qryCtx      DBMS_XMLGEN.ctxHandle;
      l_query       VARCHAR2 (32000);
      l_length      NUMBER (10);
      l_xmlstr      VARCHAR2 (32765);
      l_offset      NUMBER (10) := 32000;
      l_retrieved   NUMBER (10) := 0;
      l_result      CLOB;
      l_no_rows     NUMBER;
   BEGIN
      l_query := 'SELECT product_code, product_name 
         FROM demo_products 
       WHERE product_code = ' || p_product_id;

      l_qryCtx := DBMS_XMLGEN.newContext (l_query);

      -- set rowset tag to PRODUCTS and row tag to PRO_DETAILS
      DBMS_XMLGEN.setRowSetTag (l_qryCtx, 'PRODUCTS');
      DBMS_XMLGEN.setRowTag (l_qryCtx, 'PRO_DETAILS');

      -- now get the result
      l_result := DBMS_XMLGEN.getXML (l_qryCtx);
      l_no_rows := DBMS_XMLGEN.GETNUMROWSPROCESSED (l_qryCtx);
      FND_FILE.put_line (FND_FILE.LOG, 'No of rows processed= ' || l_no_rows);

      l_length := NVL (DBMS_LOB.getlength (l_result), 0);
      FND_FILE.put_line (FND_FILE.LOG, 'Length= ' || l_length);

      LOOP
         EXIT WHEN l_length = l_retrieved;

         IF (l_length - l_retrieved) < 32000
         THEN
            SELECT SUBSTR (l_result, l_retrieved + 1) INTO l_xmlstr FROM DUAL;

            l_retrieved := l_length;
            fnd_file.put_line (fnd_file.output, l_xmlstr);
         ELSE
            SELECT SUBSTR (l_result, l_retrieved + 1, l_offset)
              INTO l_xmlstr
              FROM DUAL;

            l_retrieved := l_retrieved + l_offset;
            fnd_file.put (fnd_file.output, l_xmlstr);
         END IF;
      END LOOP;

      DBMS_XMLGEN.closeContext (l_qryCtx);
   EXCEPTION
      WHEN OTHERS THEN
         FND_FILE.PUT_LINE (FND_FILE.LOG, SQLERRM);
         raise_application_error (-20001, 'Error in procedure MY_PACKAGE.report');
   END REPORT;
END MY_PACKAGE;
/

2. Define Executable
Navigation: Application Developer > Concurrent > Executable

Provide Executable, Short Name, Application, Description & also
Execution Method: PL/SQL Stored Procedure
Execution File Name: MY_PACKAGE.REPORT

3. Define Concurrent Program
Navigation: Application Developer > Concurrent > Program

Provide Program, Short name, Application, Description & also
- Executable Name as defined in the above step

- Output Format should be XML
- Define a Parameter p_product_id
- Associate Concurrent Program to the Request Group.

4. Create Data Definition
Navigation: XML Publisher Administrator -> Data Definitions -> Create Data Definition
The code should be exactly same as concurrent program short name.

5. Create Template. Register Template with the XML Publisher
Navigation: XML Publisher Administrator -> Templates -> Create Template

6. Run the Concurrent Program to see the output

Note:
If you need any extra help from Step2 refer my previous post

https://oracleappscenter.blogspot.com/2016/07/xml-data-template.html

Oracle Fusion - Cost Lines and Expenditure Item link in Projects

SELECT   ccd.transaction_id,ex.expenditure_item_id,cacat.serial_number FROM fusion.CST_INV_TRANSACTIONS cit,   fusion.cst_cost_distribution_...