you got your apex in my e-business...

80
You Got Your APEX In My E-Business Suite Chad Johnson Polk County BoCC

Upload: truonglien

Post on 06-Sep-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

You Got Your APEX

In My E-Business Suite

Chad Johnson

Polk County BoCC

Why APEX?

■ Rapid Application Development

▪ Shorter learning curve than OAF, ADF, Java

■ Avoid customizations

■ No impact on patching and upgrading

■ Fun and Free! But check with Oracle

▪ EBS limited use database license does not allow for an additional schema

■ Fully supported by Oracle

■ Force Multiplier – users can do a lot without code changes

Possible Use Cases

Real time access to EBS data Additional reporting and analysis

Simple and customized export of data

Graphical representation of EBS data

Deliver new business functionality Custom ordering system

Searchable personnel directory

Custom data collection

APEX can NOT be used to customize EBS pages or forms

Use CasesSearchable personnel directory/dashboard

Used with permission

Use CasesKronos Telestaff Integration

OTL

Kronos TeleStaff Reporting

Use Cases Personnel Action Form

Drilldown Capabilities

Interactive Reports

Interactive Reports

Methods

• Extending Oracle E-Business Suite Release 12.1 and above

using Oracle Application Express

Revision 2.01, Dated March, 2015

http://www.oracle.com/technetwork/developer-tools/apex/learnmore/apex-ebs-

extension-white-paper-345780.pdf

MOS Note 1306563.1 provides the scripts but links to an older version of

the White Paper (Revision 1, dated December, 2012)

• Insum Solutions

• Rob Sipko - Spring Issue of Insight

Prerequisites for the White Paper Sample

Oracle E-Business Suite (≥ 12.1.3)

Fully licensed Oracle Database (≥ 10.2.0.3)

Oracle Application Express (≥ 4.2)

Oracle REST Data Services (≥ 2.0)

Oracle WebLogic Server (≥ 12c)

Can use Oracle Glassfish Server or Apache Tomcat

For Oracle E-Business Suite Release 12.1, patch 9659153:R12.FND.B is required

Need patch 12316083 instead (delivers GWY.jsp)

30,000 ft Overview

Create an APEX Application

Configure APEX Login Process

Define APEX Authorizations

Define EBS Profile Option and Functions

Link Functions to Menu and Responsibility

What is APEX?

Oracle’s Primary Tool for Building Web Applications

Rapid Application Development tool

Similar to Microsoft Access

Flows – Oracle Platform – Project Marvel - HTML DB

– Application Express (APEX)

Tightly coupled with the Oracle database

Declarative (define what to do rather than how to do it)

Use Wizards and Templates to create applications

Architecture

Applications are stored as meta-data in the database

(Not an application server)

PL/SQL procedures generate HTML

The meta-data is used to render pages and processing

Can be installed on 10gR2 and above

Browser Based IDE

Development and runtime access is 100 % browser based

(no client software – ever)

(No user will ever have an out of date version)

Architecture - Logical

E-Business Suite Database

APPS

SchemaCUSTOM

Schema

Grant Select

EBS APIs

APEX

Engine

Architecture - Physical

The ‘f’ Procedure and the URL

http://myserver.com:8080/ords/dev/f?p=XXX:Y:zzz

“f” is from “flow”, APEX was once called “Project Flows.”

SELECT owner, object_type

FROM dba_objects

WHERE object_name = ‘F’;

f is a PL/SQL procedure that generates APEX pages

The ‘f’ Procedure and the URL

DESC F;

Changes in R12

In 11i, access to APEX apps was processed

via mod_plsql in Application Server

used with Oracle HTTP Server (OHS)

In R12, enabling mod_plsql is not supported

and can put your support at risk

For R12, use the APEX Listener or ORDS

with a J2EE application server:

Apache, Oracle Glassfish or WebLogic Server

or Embedded PL/SQL Gateway

Options for the HTTP Listener

Embedded PL/SQL GatewayPossible problem with scalability

ApacheHighly scalable

Doesn’t support some APEX 4 features

Oracle REST Data Services

(formerly the APEX Listener)Generally recommended

Implementation options

Embedded PL/SQL Gateway

Very easy to use

Requires Shared Server

Cannot separate the listener tier from the

database tier (less secure)

Possible issues with session management

A good option for a sandbox – no application

server required

Apache

Very scalable

Proven technology

A lot of experienced users/admins

Licensing may be an issue

Doesn’t support some newer APEX functions

RESTful web services

PDF printing

Oracle REST Data Services(replaces the APEX Listener)

Generally recommended as best choice

Supports latest APEX features

Redirects calls to APEX applications to the APEX run-time

engine

Accepts RESTful Web Service call URIs

Can marshal data from SQL to .csv or JSON formats

Deployment options

Glassfish (free)

Weblogic (extra license)

Third party container

Key Terms

• Representational State Transfer (REST) is an architectural style that specifies constraints, such as the uniform interface, that if applied to a web serviceinduces desirable properties, such as performance, scalability, and modifiability, that enable services to work best on the Web. -Whew!

• A RESTful service provides access to resources (web pages, pictures, videos, information, etc.) in a lightweight, maintainable and scalable manner.

–Bottom line difference for most developers:

myserver.com:8080:/apex/f?p=400:103

myserver.com:8080:/ords/f?p=400:103

Key Terms

• Schema (database):

– Collection of database objects owned by a user

– Parse As Schema – the default schema of the

user/app

Workspace (APEX):

– Logical container for one or more application(s)

– Separate, self contained development environment

– Contains applications, users, and schemas

Key Terms

• Users:

– Instance Administrator• The ‘sysadmin’ of APEX. Can create workspaces

– Workspace Administrator• Manages the workspace, including creating developers and

end users

– Developer• Create and edit the applications

• Have access to underlying tables and code

– End User▪ Can only run applications

Key Terms

Session: a series of related browser requests

Session State: variables representing APEX items

and their values, maintained on the server (think a

visit to Amazon that stretches over several minutes)

Submit: an operation that saves the values of the

items in the corresponding session state variable

before rendering a target page

Redirect: an operation that renders a target page

without saving values to the session state

Potential Gotchas

• LOV – List of Values to be selected

• Can allow multiple selections

• Source: Static List or SQL query

List – a navigation aid

A collection of links

Can use images or text

Overview

Suggest you create an APEX application before starting

the White Paper’s application.

Get familiar with newer screens in the wizards and with

the location of development items.

Some steps have been combined in newer versions

Version 5 is a whole new ballgame

Plenty of good books, websites, and blogs.

Create an Application with Wizards

Differences in 5.0

Grid Layout is a paradigm shift

Differences in 5.0

• Multi-item

editing

Differences in 5.0

Page 28: Create a region “Type of Region HTML”

IN 5.0 the Type is “Static Content”

Under Attributes, you can find

“Output As” which is set to HTML

In White Paper, this field is called “Item Containing Primary Key Column Value”

Free Workspace

https://apex.oracle.com/

Good place to learn APEX fundamentals

No E-Business Suite

Install APEX

Configure database for APEX

Create a user/schema in the database

(APEX_USER)

Create views and instead-of triggers in APPS

Grant select on views to APEX_USER

Install APEX

Download APEX (5.0) and Installation Guide from

OTN

Install APEX (in database)

Download and install Glassfish

Download, Install, and register Oracle REST Data

Services with Glassfish (war file)

Configure APEX

Within APEX

Create a workspace

Create users Developer(s) to create app

End User(s) to test

Create the application

Installation Best Practices

– Create custom applications in a separate schema

– Create the custom tables, views, triggers,

sequences in custom schema

– Create views on APPS tables

• Query restriction With Read Only prevents inadvertent

updates

• Can include joins to hide complexity of EBS data

• Include security conditions to mask sensitive data

– Grant select privileges on APPS views to APEX

user as necessary

Programming Best Practices

–Do NOT perform direct updates to seeded tables!

Will bypass Oracle’s validation and referential integrity

• Use published APIs

» with instead-of triggers

» direct calls from the APEX code

– Consider loading data into staging tables, then submit a

concurrent request to transfer the data into the E-Business

Suite

– Can use FND_SUBMIT for intensive updates

Programming Best PracticesDirect Update = Bad

INSERT INTO FND_USER

( USER_ID

, USER_NAME

, PASSWORD

, START_DATE

, EMPLOYEE_ID)

VALUES

( fnd_user_seq.nextval

, ‘[email protected]

, ‘oracle12’

, sysdate

, 1234

);

Programming Best PracticesAPI = Good

DECLARE

v_user_id number;

BEGIN

v_user_id := fnd_user_pkg.createuserid

( x_user_name => ‘[email protected]

, x_unencrypted_password => ‘oracle12’

, x_start_date => sysdate)

, employee_id => 1234;

COMMIT;

END;

Problem with EBS Public APIsORA-00942: table or view does not exist

Per Service Request - Users should:

Grant SELECT, INSERT, UPDATE and DELETE privileges

to your non-APPS schema for all tables owned by APPS

set pages 0

spool grantem.sql

SELECT 'grant select, insert, update, delete on

'||owner||'.'||table_name||' to polk_apex_sand;'

FROM dba_tables

WHERE owner = 'APPS';

spool off

Better Solution to Public API Problem

create or replace procedure polk_create_irec_user( v_user_name IN varchar2,v_password IN varchar2,v_email IN varchar2,v_last_name IN varchar2,v_first_name IN varchar2 )

authid definerASBEGIN

apps.irc_party_api.create_user(p_user_name => v_user_name,p_password => ‘Thursday123',p_start_date => ‘16-APR-2015',p_responsibility_id => 23350,p_resp_appl_id => 800,p_security_group_id => 0,p_email => v_email,p_last_name => v_last_name,p_first_name => v_first_name );

commit;dbms_output.put_line ('User:'||v_user_name||'Created Successfully');

EXCEPTIONwhen others then dbms_output.put_line (‘Cant create User due to'||SQLCODE||' '||SUBSTR(SQLERRM, 1, 100));rollback;

END;

Definer = author

Not current user

Compile as APPS

Grant execute to apex_user

Call from apex_user

Programming Best Practices

APEX wizards (used to) require primary keys

Wizards make life simple, but need primary

keys

Create views on seeded tables with an

arbitrary primary key (2 columns at most)

Modify APEX pages’ row processing (created

by the wizards) to call APIs

Or call APIs via INSTEAD OF triggers on views

Install APEX

apexins.sql

SQL> @apexins.sql APEX APEX TEMP /i/

Parameters:

APEX tablespace - APEX application user Not SYSAUX!

Files tablespace - APEX files Not SYSAUX!

Temporary tablespace

Images - /i/ - virtual directory for APEX images

SYSAUX belongs to Oracle (repository for Oracle tools: EM, Statspack, LogMiner, etc.)

Could limit ability to use Flashback, backup and restore, and transportable tablespaces

Install APEX

• Change (APEX) ADMIN user’s password apxchpwd.sql

Alter User APEX_PUBLIC_USER Account Unlock

Alter User APEX_PUBLIC_USER Identified by <password>;

Password Expiration in 11gIn 11g default profile PASSWORD_LIFE_TIME is 180 days. At expiration the

APEX instance will be unusable until the password is reset.

Consider creating separate profile for APEX:

CREATE PROFILE APEX_PROFILE LIMIT

PASSWORD_LIFE_TIME UNLIMITED;

ALTER USER APEX_PUBLIC_USER PROFILE APEX_PROFILE;

Apply Patch 12726556 – Launching APEX From Forms Navigator

Install APEX on R12.2

■ Must update the custom schema to enable Edition-Based

Redefinition (EBR)

■ Register the schema within E-Business Suite

■ See “Registering an Oracle Schema” Chapter 6 of

the E-Business R12.2 Suite Maintenance Guide

Apply Patch 12726556 – Launching APEX From Forms

Navigator AFTER enabling EBR

Deploy to Glassfish

Oracle® REST Data Services

Installation, Configuration, and Development Guide Release 3.0

Chapters on:

–1. Configuring ORDS

–2. Deploying ORDS to:

»Glassfish

»Weblogic

»Apache Tomcat

Configure ORDS

• PL/SQL Gateway is not Embedded PL/SQL Gateway!

• If you plan to use APEX with ORDS you MUST configure the PL/SQL Gateway.

• The PL/SQL Gateway is what provides the mod_plsql like functionality to invoke PL/SQL procedures in the database

• This step creates the apex.xml file. Without an apex.xml file APEX will not be accessible (or any other PL/SQL procedures).

Bottom line – when configuring ORDS, be sure to reply with 1 to: Enter 1 if you want to use PL/SQL Gateway or 2 to skip this step [1]:

Security

• Authentication

– Who are you?

– Controls access to application (the doorman)

• Authorization

– What are you allowed to do? (the bartender)

– Controls access to forms, pages, buttons, etc. and

to data

Authentication (the doorman)

■ Preconfigured schemes—Single Sign On

—Oracle Access Manager

■ Custom Scheme

▪ In APP - PL/SQL function to validate user based

on username and password

▪ In APEX – define an authorization scheme to use

the function

Authorization (the bartender)

Apply Authorization to all non-public pages, not just menus.

Can be applied to almost any component of an application (i.e. pages, regions, buttons, items)

Session State Protection

The URLs can be manipulated to circumvent security

Managing Application Security – Understanding Session State Protection

Session State Protection

Session State Protection uses the Page Access Protection

attributes and the Session State Protection item attributes

with checksums positioned in f?p= URLs to prevent URL

tampering and unauthorized access to and alteration of

session state.

--Oracle® Application Express Application Builder

User's Guide Release 4.2

Think changing …f?p=300:1… to …f?p=300:12 …

Custom Authorization

Note: There is a typo in Revision 1 of the White Paper.

The last RETURN statement should read “…function_test” not

“…function.test” (underscore, not period)

--Included in apexebs_apps_setup.sql

Custom Authorization

Edit the Page

Double click the page title

On the Security tab, assign the custom

scheme and set the page to require

authentication

Create the List

List Region (not in white paper)

By selecting “Do not create list regions(s)” we

can add a List Region to the Global Page or to

any page we choose later.

Terminology Gotchas

■ Page 0 is now the Global Page

▪ One Global Page per application, per interface

— Desktop UI

— Mobile UI

You can now create one application with both

a desktop and mobile interface.

Install Sample Application

• There are two ways to install the sample

application

• Via scripts

• Manually with APEX

Install Sample Application - Scripts

• apexebs_apps_setup.sql

–As APPS

• apexebs_apex_setup.sql–As apex_ebs schema

• apexebs_apex_application_rev2.sqlWithin the application builder (creates the app if you don’t

want to do it manually)

Be sure to download the “_rev2” file from the White Paper,

not the version in Note 1306563.1 as of February 2015

Manually Create Application

Create A Form

Create a Form

• Forms perform insert, update and delete operations on

table rows in the database. The rows are identified using

either a Primary Key defined on the table, or the ROWID

pseudo column, which uniquely identifies a row in a

table.

• Select "Managed by Database" if you would like to use

the ROWID. Otherwise select the Primary Key column(s)

defined for your table or view.

• Forms support up to two columns in the Primary Key. For

tables using Primary Keys with more than two columns,

the ROWID option should be used

Create a Form

Processing Code in a Page

PL/SQL Page Process calling and API

apps.apex_integration_sample_apis.apex_update_email

( p_username => :APP_USER

, p_owner => :APP_USER

, p_email_address => :P2_EMAIL_ADDRESS

);

Profile Option

In 11i, a mod_plsql procedure could redirect

the user to APEX

In R12, a JSP is used. This is configured by

setting a Profile Option and defining functions

to point to the APEX pages

Call APEX from APPS Menus

• Create form function with type : SSWA jsp

function

– An HTML call to the APEX app

– Application number, Page number, and

parameters

• Add the form function to an APPS menu

• Assign the menu to a responsibility

• Assign the responsibility to a user

Define Function

Define Function Without Responsibilities

GWY.jsp?targetAppType=APEX&p=105:1

Application ID = 105, Page 1

Define Function With ResponsibilitiesPassing Parameters

GWY.jsp?targetAppType=APEX&p=105:3:::::

EBS_RESP_ID, EBS_APP_ID, EBS_SEC_GROUP:

[RESPONSIBILITY_ID], [RESP_APPL_ID], [SECURITY_GROUP_ID]

Application Items in APEX

GWY.jsp?targetAppType=APEX&p=105:3:::::

[RESP_APPL_ID], [RESPONSIBILITY_ID], [SECURITY_GROUP_ID]

--------------------------- EBS Values -------------------------------------------------------

-------------------------- APEX “Application Items” ---------------------------------

EBS_APP_ID, EBS_RESP_ID, EBS_SEC_GROUP:

Menu

Add the functions to a menu

Responsibility

User

APEX User Home Page

EBS Look and Feel

• APEX Theme 20

• Marc Weeren’s blog

http://apex4ebs.blogspot.com/p/integration-of-oracle-apex-and-e.html

Security

Easy to deploy to production

Export the application (generates a SQL script)

Provide the script to DBA

DBA executes the script

Use DEV – TEST – PROD model

Security configuration in TEST should be identical to PROD

In PROD, run APEX in ‘run only’ mode

Mobile Apps with APEX

Responsive Design

Techniques to create content that can dynamically adapt to fit screens on phones, tablets, and computers

Page items resize and realign to conform to different screen sizes

APEX 4.2 introduced Theme 25 Templates for responsive design

Not automatic – it is the developer’s responsibility to use the templates and arrange content to achieve truly responsive interface

Not a “native” app – no access to GPS or camera Requires Internet Connection PhoneGap

References

MOS Note 1306563.1 Extending Oracle E-Business Suite

Release 12.1.3 and Above Using Oracle Application Express

Beginning Oracle Application Express 5 (NOT 4)

Doug Gault (Cannell, Cimolini, D’Souza, St. Hilaire)

Oracle Application Express for Mobile Web Applications

Hartman, Rokitta, Peake

Understanding Oracle APEX 5 Application Development

Edward Sciore

Oracle Application Express 5 For BeginnersRiaz Ahmed

Blogs: David Peake, Dimitri Gielis, Martin D’Souza, Patrick

Wolf, Joel Kallman