Pages

OracleEBSpro is purely for knowledge sharing and learning purpose, with the main focus on Oracle E-Business Suite Product and other related Oracle Technologies.

I'm NOT responsible for any damages in whatever form caused by the usage of the content of this blog.

I share my Oracle knowledge through this blog. All my posts in this blog are based on my experience, reading oracle websites, books, forums and other blogs. I invite people to read and suggest ways to improve this blog.


Showing posts with label APEX - Oracle Application Express. Show all posts
Showing posts with label APEX - Oracle Application Express. Show all posts

Saturday, March 9, 2013

Build a customized report using Oracle APEX


Introduction

Oracle Application Express (Oracle APEX) is a rapid web application development tool for the Oracle database. It works exceptionally well for CRUD applications that consist mostly of Create, Read, Update, and Delete operations. In this article, I will introduce the steps to create a customized report using Oracle APEX.
Oracle APEX provides a web-based UI to create reports. Basically, it allows you to create Classic reports and Interactive reports. By creating an Interactive report, you can allow the end user to filter the data interactively as in the following sample reports.
Default Interactive Report
However, in order to use these interactive functions, end users must have some knowledge about Oracle APEX and I don’t think it is appropriate for high level managers in an organization. In addition, the built-in filter doesn’t work efficiently for the date data type. Hence, in the next sections, I will introduce the steps to create an interaction report then apply the custom filter area into it. Below is the screenshot of the custom filter that will be created:
Default Interactive Report

Create a standard interactive report

I assume that you have already created an Oracle APEX application. In case you have not, click on the Application Builder menu and click on the Create Application button, then follow its directions all the way to the Finish step. The steps below are for creating a report.
  • Step 1: Click on your application to open it.
  • Step 2: Click the Create Page button.
  • Step 3: Select the Report radio button. Click Next.
  • Step 4: Select the Interactive radio button. Click Next.
  • Step 5: Enter “Customer Report” to both Page Name and Region Name text boxes. Click Next.
  • Step 6: Select Do not use tabs. Click Next.
  • Step 7: Enter the following SQL to the text area. Select No in Link to Single Row View list. Click Next.
  • select 
    c.CUSTOMER_ID,
    CUST_FIRST_NAME || ' ' || CUST_LAST_NAME as NAME,
    CUST_STATE as STATE_ID,
    STATE_NAME as STATE,
    PHONE_NUMBER1 as PHONE,
    CUST_EMAIL as EMAIL,
    ORDER_ID,
    ORDER_TIMESTAMP
    from DEMO_CUSTOMERS c
     join DEMO_ORDERS o on c.CUSTOMER_ID = o.CUSTOMER_ID
     join DEMO_STATES s on c.CUST_STATE = s.ST
  • Step 8: Click Finish.
Now you’ve created a standard interactive report.

Turn off the default Search bar

The first step to customize the search area is to turn off the default filter function of the report by following these steps:
  • Step 1: Click on the report under the application.
  • Step 2: On the page rendering area, expand Customer Report > Regions > Body nodes. Then right lick on the Customer Report region and select the Edit Report Attributes menu on the context menu.
  • Step 3: Click on the Search Bar tab then select No in the Include Search Bar list.
After this step, you have turned off the default Search bar.

Create the custom filter area

Now, we are ready to create our own filter area with these criteria: Customer Name (text box), State (drop down list), and Order Date (from date – to date). Here are the steps:
  • Step 1: Click on the report under the application.
  • Step 2: On the Page Rendering area, expand the Customer Report node. Right click on the Regions node and select the Create menu on the context menu.
  • Step 3: Select the HTML radio button. Click Next.
  • Step 4: Select the HTML radio button again. Click Next.
  • Step 5: Enter “Search” in the Title text box. Select Report Filter – Single Row in Region Template drop down list. Enter “5” in the Sequence text box (so that this filter area will be displayed before the data area whose sequence is 10). Click Next.
  • Step 6: Leave the HTML Text Region text area empty. Click Create Region.
You’ve just created an empty search area. If you run the report now, you will see that search icon without any criteria. Follow the next steps to add these criteria to your search area:
  • Step 1: Right click on the Search region. Select the Create Page Item menu on the context menu.
  • Step 2: Select the Text Field radio button. Click Next.
  • Step 3: Enter “P2_Name” into the Item Name text box. Click Next.
  • Step 4: Enter “Name” into the Label text box. Enter “10” in the Field Width text box. Select No in the Begin On New Line drop down list (if your search area has too many items to display in a single row, select Yes to start a search line). Click Next.
  • Step 5: Select the default values and select Next all the way to the end. Click Create Item.
  • You’ve just finished creating the Name criterion. The steps below are for creating the State drop down list:
  • Step 6: Right click on the Search region. Select the Create Page Item menu on the context menu.
  • Step 7: Select the List radio button. Click Next.
  • Step 8: Enter “P2_State” into the Item Name text box. Click Next.
  • Step 9: Enter “State” into the Label text box. Select No in Begin On New Line. Click Next.
  • Step 10: Select the default values. Click Next.
  • Step 11: Enter “--All States --“ to the Null Display Value text box. Enter the following SQL to the List of Values Query text area. Click Next.
  • select ST, STATE_NAME
    from DEMO_STATES
  • Step 12: Click Create Item.
  • You’ve finished creating the State criterion. Follow the steps below to create the From Order Date criterion:
  • Step 13: Right click on the Search region. Select the Create Page Item menu on the context menu.
  • Step 14: Select the Date Picker radio button. Click Next.
  • Step 15: Enter “P2_From” into the Item Name text box. Click Next.
  • Step 16: Enter “Order from” into the Label text box. Enter “10” into Field Width. Select No in Begin On New Line. Click Next.
  • Step 17: Enter “MM-DD-YYYY” into Format Mask. Click Next.
  • Step 18: Click Create Item.
  • Step 19: Repeat steps 13-18 to create Order To criterion.
  • After these steps, you already have all the criteria on place. Let’s create the Run button so we can refresh the data based on these criteria.
  • Step 20: Right click on the Search region. Select the Create Page Item Button menu on the context menu.
  • Step 21: Enter “P2_Run” into the Button Name text box. Enter “Run” into Label. Click the Create button.
  • Now run the report, select some criteria, and click the Run button and … nothing happens. It’s because we have not wired up these criteria to the report query yet. Let’s update the query.
  • Step 22: Open the report page.
  • Step 23: Right click on the Customer Report region and select the Edit menu.
  • Step 23: Enter the following SQL to the Region Source text area. Click Apply Changes.
select 
c.CUSTOMER_ID,
CUST_FIRST_NAME || ' ' || CUST_LAST_NAME as NAME,
CUST_STATE as STATE_ID,
STATE_NAME as STATE,
PHONE_NUMBER1 as PHONE,
CUST_EMAIL as EMAIL,
ORDER_ID,
ORDER_TIMESTAMP
from DEMO_CUSTOMERS c
 join DEMO_ORDERS o on c.CUSTOMER_ID = o.CUSTOMER_ID
 join DEMO_STATES s on c.CUST_STATE = s.ST
where (:P2_Name is null or lower(CUST_FIRST_NAME) || ' ' || 
    lower(CUST_LAST_NAME) like '%' || lower(:P2_Name) || '%') and
(:P2_STATE is null or CUST_STATE = :P2_STATE) and
(:P2_FROM is null or ORDER_TIMESTAMP >= :P2_FROM) and
(:P2_TO is null or ORDER_TIMESTAMP <= :P2_TO)

Some small customizations

As can be seen in the current report, there will be two columns for State and we should hide the State Code column by using these steps:
  • Step 1: Right click on Customer Report region and select the Edit Report Attributes menu.
  • Step 2: In the column attributes area, click on Edit (pencil) icon right before the STATE_ID column.
  • Step 3: Select Hidden in the Display Type list.
If you run the report now, this column has disappeared.
One more thing you should do to the report is to update the date format of ORDER_TIMESTAMP. In order to do this, follow the first and second steps of the State Code column. Then on the Column Definition page, enter ‘MM-DD-YYYY’ to the Number/Date Format text box.
Finally, your report will look like this:
Default Interactive Report
Credit goes to the below website(s) :

Tuesday, February 26, 2013

Oracle Application Express 4.2 - New Features


The top 3 biggest things for me are arround:
Mobile development
HTML5 (themes, items, charts)
Packaged applications

  • Application Builder for Mobile

    Release 4.2 provides declarative support for building mobile Web applications. Mobile pages use jQuery Mobile to render content on the vast majority of mobile devices. Each application can include both desktop and mobile user interfaces.
  • Mobile and Responsive Themes

    To support the development of mobile pages, a new theme has been introduced which is based on jQuery Mobile. This theme supports mobile page transitions and gestures such as swipe, tap, and pinch. You can also declaratively specify JavaScript and CSS files for use within the mobile templates and pages.
    Another new theme introduced, Theme 25, incorporates reponsive design principles. Reponsive design automatically adjusts to the screen dimensions. Such themes work well on desktop, tablet and mobile devices.
  • HTML5 Charts

    Release 4.2 now includes HTML5 charts. Charts can now be rendered as either HTML5 or Flash, where Flash charts have automatic fallback to HTML5 when Flash is not detected.
  • HTML5 Item Types

    New item types have been introduced including Slider, HTML5 Date Picker, and Yes/No Flip Toggle Switch. Incorporating such HTML5 attributes as sub-types for Email, Phone, and URL together with Placeholders will allow you to improve your end user experience.
  • Mobile Calendars

    A new "mobile-friendly" calendar template has been introduced along with a new List View calendar option.
  • Packaged Applications

    Release 4.2 includes a suite of business productivity applications, easily installed with only a few clicks. These solutions can be readily used as production applications to improve business processes and are fully supported by Oracle. Packaged Applications also include a collection of sample applications which demonstrate some of the major features of Oracle Application Express.
  • RESTful Web Services*

    RESTful Services in Release 4.2 provides stateless access to data and logic, through the use of SQL and PL/SQL. RESTful Services are accessed through the use of Uniform Resource Identifiers (URIs), defined within Oracle Application Express. Data can be easily served in JSON or CSV format, or additional formats by choosing PL/SQL as the source.
    * This feature requires APEX Listener 2.0 or later.

Thursday, February 21, 2013

APEX - Oracle Application Express

http://apps2fusion.com/apps-training/oracle-application-express-apex

This article is Introduction to APEX.

What is Application Express?It is formerly called HTML-DB, a web-based RAD tool which resides in Oracle database. Using browser based user interface and limited programming experience, you can build a complete data-centric web application in a very fast development cycle. 

From the end user’s perspective, the deployed applications require only a browser and
access to an Oracle database running Application Express.

What are the uses of APEX?
1. Builds professional looking web applications that are both fast and secure.
2. Runs on and lives in Oracle database. APEX framework and meta data are stored in Oracle tables.
3. It is FREE. No licensing required.
4. Fast learning curve for developers to build application.
5. Deployment of application is as simple as 'Export and Import' if hard coded references of values that change between environments are avoided.
6. Lot of scope for customization of application look and feel.
7. Scalable for high user volume. AskTom, former Oracle Metalink (before migrated to Flash version) and many applications are built using APEX.
8. Can be configured to use Oracle SSO and EBS fnd user repository.

Who uses APEX?If you are running on oracle database and you want to build rich web application with reports, forms, charts, drill downs and dashboards with limited Java experienced developers in a short time frame, Oracle APEX is the most likely candidate for consideration.

How APEX Architecture works?APEX is installed on Oracle database (above 9.2 version), starting from Oracle 11g it comes pre-installed with the database. It is comprised of meta data in tables, pl/sql code and extensive JavaScript APIs.

The URL request from the browser is translated into appropriate APEX PL/SQL call by either Oracle HTTP Server (Apache) with mod_plsql plugin or Embedded PL/SQL Gateway. This varies by the type of APEX installation on oracle database. After the data is processed, results are relayed back to browser as HTML. This cycle happens each time user request or submit a page. The application session state is maintained in database tables.

APEX installation can be done in two ways. DBAs are more concerned about it than developers. But this determines how the URL is translated. I will talk about it in next article.

Oracle HTTP ServerIn this three-tier configuration, mod_plsql in Oracle HTTP Server acts a broker between client web browser and server database. 


For each URL that is processed, mod_plsql either uses a database session from its connection pool, or creates a new session on the fly and pools it. For mod_plsql to invoke the appropriate database PL/SQL procedure in a URL-processing session, you must first configure a virtual path and associate that path with a Database Access Descriptor (DAD).

A DAD is a named set of configuration values that specify the information necessary to create a session for a specific database and a specific database user/password. This includes the database service name and the Globalization Support setting (for example, language) for the session.

Embedded PL/SQL GatewayThis is a classic client-server architecture where embedded PL/SQL gateway provides the Oracle database with a Web server and also the necessary infrastructure to create dynamic applications. The embedded PL/SQL gateway runs in the XML DB HTTP server in the Oracle database and includes the core features of mod_plsql, but does not require the Oracle HTTP Server powered by Apache. Inclusion of the embedded PL/SQL gateway simplifies the
architecture and eliminates the middle tier entirely.




Oracle HTTP Server is known and proven technology, it has been used for Self Service applications.
Does APEX works with non-Oracle databases?
No.

What is current version available? 
APEX 4.2 is released a couple of weeks back.

What are skills required for APEX Developers?SQL, PL/SQL are essential. HTML, CSS and JavaScript are good to have skills to understand and customize look and feel (themes, templates, .... ). 

Where to learn and get hands on APEX?There are multitude of sites dedicated to APEX. apex.oracle.com allows anyone to request for  free APEX account to build applications or run packaged applications. 

Follow the below steps for creating account in apex.oracle.com
  • Go to apex.oracle.com and click 'sign up for account' link below Login button.
  • Fill administrator information. This user will have all rights to create new users and manage their accounts.
  • Enter workspace name (For Ex: XX-APEX). Workspace is dedicated area where you develop applications. A workspace is attached to one or more database schemas. In a typical development environment, you might create a single workspace for all
    your developers to share.
  • Enter name of database schema and its space allocation.
  • Fill justification and complete by confirming the request.
  • You will get email once the request is approved. Oracle administrator do great job to approve your request as soon as they can. (Usually few hours ... latest a day).
  • After clicking on approval link, you get another email with userid/password.
  • Then you are set on login on apex.oracle.com  and run sample application under Application Builder.

I will cover different aspects of APEX in next article.   

Finally APEX or OAF or ADF?Some healthy debates are going on choice of these existing new technologies. APEX embeds business logic and presentation together in oracle database. It has bunch of bugs to be fixed ... for that matter every technology evolves over time. APEX is fast growing platform for RAD. The number of OTN threads and APEX developers in APEX OTN discussion forum gives a fair idea of amount of work going in APEX. Though a quarter of them use APEX with EBS.

If you want to follow Model-View-Controller (MVC) design pattern and have Java / J2EE resources at hand, OAF or ADF is a better choice. With OAF, you can use EBS security model, DFFs etc. 

APEX doesn't replace OAF, it's highly productive, wizard driven development and deployment and easy to use navigation cannot go unnoticed.