Adapters apps-102-change orderapi

47
Oracle SOA Suite 11g - Sample SAMPLE NAME : adapters-apps-102-ChangeOrderAPI COMPONENT : Stored Procedure OVERVIEW Oracle Applications provides a set of Stored Procedures to insert and update data in Oracle Applications. The Oracle Adapter for Oracle Applications exposes Stored Procedures as Web Services that can inturn be invoked from a BPEL process. The Adapter supports both out-of-the-box as well as custom stored procedures.This sample illustrates use of Apps adapter to change a purchase order in Oracle Ebusiness suite. The quantity of already created purchase order is changed based on user input. It is recommended to run adapters-apps-101-OrderImportConcurrentProgram sample before running this sample. OrderImportConcurrentProgram creates a purchase order from scratch. The created order can be used here to change its details like ordered quantity This example showcases updating the “quantity” field of an existing Purchase Order in Oracle Applications using Oracle Adapter for Oracle Applications. The Adapter exposes the following operations as Web Services: A custom Order Management stored procedure API to update the existing Purchase Order Another custom Order Management stored procedure API to initialize the Purchase Order PROVIDED FILES README.txt adapters-apps-102-ChangeOrderAPI.zip-Files needed for the sample. o artifacts\ input\ changeorder_data.xml- Payload file to be read by the File Adapter sql\ XX_BPEL_INITLINEREC.sql- Creates wrapper package for the stored procedure XX_BPEL_ORDERMANAGEMENT.sql- Creates wrapper package for the stored procedure o docs adapters-apps-102-ChangeOrderAPI.pdf--Instructions

Transcript of Adapters apps-102-change orderapi

Oracle SOA Suite 11g - Sample

SAMPLE NAME : adapters-apps-102-ChangeOrderAPI

COMPONENT : Stored Procedure

OVERVIEW

Oracle Applications provides a set of Stored Procedures to insert and update data in

Oracle Applications. The Oracle Adapter for Oracle Applications exposes Stored

Procedures as Web Services that can inturn be invoked from a BPEL process. The

Adapter supports both out-of-the-box as well as custom stored procedures.This sample

illustrates use of Apps adapter to change a purchase order in Oracle Ebusiness suite. The

quantity of already created purchase order is changed based on user input. It is

recommended to run adapters-apps-101-OrderImportConcurrentProgram sample before

running this sample. OrderImportConcurrentProgram creates a purchase order from

scratch. The created order can be used here to change its details like ordered quantity

This example showcases updating the “quantity” field of an existing Purchase Order in

Oracle Applications using Oracle Adapter for Oracle Applications. The Adapter exposes

the following operations as Web Services:

• A custom Order Management stored procedure API to update the existing

Purchase Order

• Another custom Order Management stored procedure API to initialize the

Purchase Order

PROVIDED FILES

• README.txt

• adapters-apps-102-ChangeOrderAPI.zip-Files needed for the sample.

o artifacts\

� input\

• changeorder_data.xml- Payload file to be read by the File

Adapter

� sql\

• XX_BPEL_INITLINEREC.sql- Creates wrapper package

for the stored procedure

• XX_BPEL_ORDERMANAGEMENT.sql- Creates

wrapper package for the stored procedure

o docs

� adapters-apps-102-ChangeOrderAPI.pdf--Instructions

Oracle SOA Suite 11g - Sample

o ChangeOrder API-App.zip – JDeveloper Application and project

o README.txt

STEP BY STEP INSTRUCTIONS

RUNNING THE PREBUILT SAMPLE

• Set up the wrapper packages on target DB (The database on which you intend to

run this sample) by executing XX_BPEL_INITLINEREC.sql and

XX_BPEL_ORDERMANAGEMENT.sql as APPS/APPS.

• Edit the input File changeorder_data.xml.

Set LINE_ID

o This file contains two elements LINE_ID and ORDERED_QUANTITY.

o LINE_ID corresponds to the line item of the already created purchase order.

o In order to find line_id of already created order, run this query as APPS on

target database.

select l.line_id from oe_order_lines_all l, oe_order_headers_all h where

h.orig_sys_document_ref='<ORDER_ID>' and h.header_id=l.header_id;

o Replace <ORDER_ID> with order id of the order created in adapters-apps-

101-OrderImportConcurrentProgram Sample.

o The default order_id in adapters-apps-101-OrderImportConcurrentProgram

sample is 'order_id_01'.

o Replace this value in above query.

o Set the result of the query in LINE_ID element in changeorder_data.xml

file.

Set Order Quantity

As the purpose of this sample is to change order by changing its quantity, we

need to first find what is current value of quantity. Use this query to find current

order quantity

select l.ordered_quantity from oe_order_lines_all l, oe_order_headers_all h

where h.orig_sys_document_ref='<ORDER_ID>' and

h.header_id=l.header_id;

o Replace <ORDER_ID> value in above query.

Oracle SOA Suite 11g - Sample

o Execute above query and note down the value of current quantity for future

reference.

o Now search xml file for ORDERED_QUANTITY element.

o Change its value so that it is different from current quantity of the order.

• Make sure that the input files exist in the path mentioned in composite.xml

• Build the sample using JDeveloper.

• Deploy the BPEL process adapters-apps-102-ChangeOrderAPI to the weblogic

server

• Invoke the BPEL Process.

• Verify that the sample has executed successfully. Steps are mentioned in

VERIFYING EXECUTION

INSTALLING & CONFIGURING

• Configure the data source for the target database in the weblogic server.

• Create Connection to weblogic Server in the Jdeveloper.

RUNNING THE SAMPLE

• Launch JDeveloper and start weblogic server.

• Open the application ChangeOrderAPI-App.jws

• Drill down further to the .bpel file and double-click to open it.

• Navigate to composite.xml in the project adapters-apps-102-ChangeOrderAPI.

• Edit composite.xml to specify the physical directory for the File Adapter –

synchronous read operation.

<property name="inputDir" type="xs:string" many="false"

override="may">/usr/tmp</property>

Deploy the BPEL Process

• Right click the project adapters-apps-102-ChangeOrderAPI under projects in

the Application Navigator.

• Select Deploy -> adapters-apps-102-ChangeOrderAPI ->’serverConnection’

Oracle SOA Suite 11g - Sample

• Select the sample and click on Test to test the process.

• Enter a random string ‘test’ as input and click Testwebservice.

Oracle SOA Suite 11g - Sample

• Click on the BPEL process name in the left pane to see the instances.

• Click on the latest Instance ID under Instances tab to see the process flow trace.

Oracle SOA Suite 11g - Sample

VERIFYING EXECUTION

• Check for update of purchase order in Order management tables of target database

with this query

select l.ordered_quantity from oe_order_lines_all l, oe_order_headers_all h where

h.orig_sys_document_ref='<ORDER_ID>' and h.header_id=l.header_id;

• Note that the ordered_quantity should be same as the value given in

changeorder_data.xml

• Update of purchase order could also be checked using Oracle Forms Applications

o Log on to Oracle Self service Application on the target database using

Username: operations password: welcome

Oracle SOA Suite 11g - Sample

o Choose responsibility Order Management Super User, Vision Operations

(USA) from left panel.

o Choose Sales Order. Oracle forms application would open up.

o Select Order Returns-->Sales Order. Sales Order Form would open up.

o Press F11 to search for Order. In Customer PO field enter <ORDER_ID>

o Press CTRL+F11 keys. Press on Line items tab. Check the quantity of the

order is same as set in changeorder_data.xml file.

BUILDING THE SAMPLE

PROCESS FLOW

• Receive activity-- a dummy input from the BPEL Console triggers this.

• An invoke activity that points to a File Adapter – Performs synchronous Read

operation to read the “Purchase Order” from the input file.

Oracle SOA Suite 11g - Sample

• An invoke activity that points to “GET_G_MISS_LINE_REC” – Invokes the

stored procedure GET_G_MISS_LINE_REC. This is required to initialize the

“Process Purchase Order Line” stored procedure.

• An invoke activity that points to a “Process Purchase Order Line”– Invokes the

Stored Procedure service.

• A Transform activity – Sets the output of the File Adapter service to a temporary

variable.

• An assign activity –sets the input of the “Process Purchase Order Line” Stored

Procedure service.

• Set Apps Adapter Context--Sets the application context for the invocation of the

“Process Purchase Order Line” Stored Procedure Service

Create a service Connection

• Select view->Database Navigator.

• Right click on IDE Connections and select New Connection to create a new

database connection.

• Enter the following values in the Create Database Connection window.

Oracle SOA Suite 11g - Sample

• Click OK

Create a New Application

• Click New Application in the Application Navigator.

• Enter ChangeOrderAPI-App as the Application Name.

• Select SOA Application in the Application Template.

• Click Next

Oracle SOA Suite 11g - Sample

• Enter adapters-apps-102-ChangeOrderAPI as the Project Name.

• Select SOA from the Project Technologies.

• Click Next

Oracle SOA Suite 11g - Sample

• Select Composite With BPEL from the Composite Template.

• Click Finish

Oracle SOA Suite 11g - Sample

• Enter ChangeOrderAPI as the name of the BPEL Process.

• Click OK

• Select Asynchronous BPEL Process as the Template.

Oracle SOA Suite 11g - Sample

Create Oracle Apps Adapter Partner Link for Stored Procedure

• Click BPEL services in the Component palette

• Click Oracle Applications, drag-and-drop it onto the right ‘Partner Links’ swim

lane.

Oracle SOA Suite 11g - Sample

• Click Next if the welcome page appears

• Enter the Service Name as OrderManagement.

• Select the service using icon.

• Click Copy Connection.

• Service Connection page will be displayed with the connection information.

Oracle SOA Suite 11g - Sample

• Click Next.

• This opens the window IREP File not present.

• Click No to select interface using live connection

Oracle SOA Suite 11g - Sample

• Click Next in the Operation page. This opens ‘Oracle Applications Module

Browser’.

• Select Product Families >>Supply Chain Management (SCM_PF)>> Supply

Chain Trading Connector (CLN) >> Sales Order (ONT_SALES_ORDER) >>

PLSQL >> Process Order API (OE_ORDER_PUB)

• Select Process Order Line (PROCESS_LINE).

Oracle SOA Suite 11g - Sample

• The input and the output parameters of the Stored Procedure contains complex

data types that are not readily mapped to JDBC types. The Oracle Adapter for

Oracle Applications wizard provides a mechanism that detects when these types

are used and then invokes Oracle JPublisher to generate the necessary wrappers

automatically. Oracle JPublisher generates two SQL files, one to create schema

objects, and another to drop them. The SQL that creates the schema objects is

automatically executed from within the wizard to create the schema objects in the

database schema before the XSD is generated.

• The wrapper procedure has the naming convention “XX_BPEL” +

<Service_Name> + <Package Name> + “$” + <Procedure Name>. The

wrapper procedure generated in this case is

“XX_BPEL_OrderManagement_OE_ORDER_PUB$PROCESS_LINE”. The

Adapter Service points to the wrapper Stored Procedure instead of the Process

Order Line Stored Procedure. The Adapter design-time automatically loads the

wrapper design-time automatically loads the wrapper procedure onto the

underlying database

• Click Finish in the Finish page of the wizard.

Oracle SOA Suite 11g - Sample

Oracle SOA Suite 11g - Sample

Invoke the Partner link

• Select BPEL Activities and Components in the component palette.

• Drag and drop an Invoke activity into the center swim lane.

• Drag the arrow of Invoke activity and link to the InsertOrder Partnerlink

Oracle SOA Suite 11g - Sample

• Change the Name of the Invoke activity to Invoke.

• Click on to create the Input and output Variables.

• Leave the default name for the variable and click OK.

Oracle SOA Suite 11g - Sample

\

• Click Apply and OK

Oracle SOA Suite 11g - Sample

Create Oracle Apps Adapter Partner Link for Stored Procedure

• Click BPEL services in the Component palette

• Click Oracle Applications, drag-and-drop it onto the right ‘Partner Links’ swim

lane.

• Click Next if the welcome page appears

Oracle SOA Suite 11g - Sample

• Enter initLineRec as the Service Name.

• Click Next.

• Select the service using icon.

• Click Copy Connection.

• Service Connection page will be displayed with the connection information.

• Click Next.

• This opens the window IREP File not present.

• Click No to select interface using the live connection

Oracle SOA Suite 11g - Sample

• Click Next in the Operation page.

• This opens Oracle Applications Module Browser.

• Navigate to Other Interfaces >> Custom Objects >>PLSQL APIs >>

OE_ORDER_PUB

• Select GET_G_MISS_LINE_REC.

Oracle SOA Suite 11g - Sample

• The GET_G_MISS_LINE_REC (GET_G_MISS_LINE_REC) Stored

Procedure does not take any input but has a complex data type (PL/SQL Table) as

output. The Oracle Adapter for Oracle Applications design-time automatically

generates a wrapper Stored Procedure and loads it on the underlying database.

This is captured in the figures below

• Click Finish in the Finish page of the wizard.

Oracle SOA Suite 11g - Sample

• Click Apply and Click ok to complete the creation of partner link.

Invoke the Partner link

• Select BPEL Activities and Components in the component palette.

• Drag and drop an Invoke activity below the receiveInput.

Oracle SOA Suite 11g - Sample

• Change the Name of the Invoke activity to Invoke.

• Click on to create Input and output Variables.

Oracle SOA Suite 11g - Sample

• Leave the default name for the variable and click OK.

• Click Apply.

• Click OK.

Create a File Adapter Partner Link.

• Click BPEL Services from the component palette.

• Click File Adapter and drag-and-drop it onto the right Partner Links swim lane.

• Click Next in the welcome page of the wizard.

• Enter the Service Name as getOrderDetails

Oracle SOA Suite 11g - Sample

• Click Next in the Adapter Interface page.

• Select the radio button Synchronous Read File in the Operation page and click

Next.

• Select Logical Name.

• Enter the Directory for Incoming Files (logical Name) as inputDir.

• Uncheck Delete Files after successful retrieval.

• Click Next.

Oracle SOA Suite 11g - Sample

• Enter the file Name as changeorder_data.xml

• Pick the schema that maps to the payload of the input file.

• Use the to pick the relevant XSD.The payload of the input file is the same as

that of the input of the Process Line Stored Procedure Service. This is captured in

the following figure

• Click OK in the Type Chooser.

Oracle SOA Suite 11g - Sample

• Click Next in the Messages Page.

• Click Apply and OK.

• This completes the creation of the File Adapter – Synchronous Read Operation

Partner Link

Oracle SOA Suite 11g - Sample

Invoke the Partner link

• Select BPEL Activities and Components in the component palette.

• Drag and drop an Invoke activity just below the receiveInput activity.

Oracle SOA Suite 11g - Sample

• Name the invoke activity as ‘Invoke’

• Click on for Input and Output to create Input and Output variables

respectively.

Oracle SOA Suite 11g - Sample

• Click Apply and OK.

Oracle SOA Suite 11g - Sample

Add Transform Activity

• From the structure panel, right click on variables and select Create variable

• Name the variable as temp_miss_line

• Select the radio button Message Type

• Select args_in_msg from the Type Chooser.

• Click OK.

Oracle SOA Suite 11g - Sample

• Click Apply

• Click OK

• Drag-and-drop Transform activity to set the output of initLineRec to the input of

Order Management

• Name the transform activity as set_Miss_Line

• Right click the Transform activity and click Edit.

• Select the source variable as Invoke_initLineRec_OutputVariable

• Select the Target variable as Invoke_OrderManagement_InputVariable

• Click to create a new Mapper file.

Oracle SOA Suite 11g - Sample

• Link db:OE_ORDER_PUB-24GET_G_MISS_LINE from source variable to

db:P_LINE_TBL_ITEM from Target variable

• Click OK in the Auto Map preferences window.

• Mapping is created from source variable to Target variable.

• Save the transformation file.

Add Assign Activity.

• Drag & drop an assign activity to set the output of the File Adapter –

Synchronous Read service and output of the initLineRec Stored procedure

service to the input of the Oracle Applications Adapter – Process PO Line

Stored Procedure operation.

• Right click the Assign and choose Edit

• Click the General tab and Name the Assign activity as SetOrderDetails.

Oracle SOA Suite 11g - Sample

• Click the Copy Operation tab and select Copy Operation

• Assign the values as following

Temp_miss_line>Input

Parameters>P_LINE_TBL

Invoke_OrderManagement_InputVariable>Input

Parameters>P_LINE_TBL

‘Update’

Invoke_OrderManagement_InputVariable>Input

Parameters

>P_LINE_TBL>P_LINE_TBL_ITEM>OPERATION

'Updated order quantity' Invoke_OrderManagement_InputVariable>P_LINE_TBL

>P_LINE_TBL_ITEM>CHANGE_REASON

Oracle SOA Suite 11g - Sample

Invoke_SyncRead_OutputVariable>

InputParameters > P_LINE_TBL >

P_LINE_TBL_ITEM > LINE_ID

Invoke_OrderManagement_InputVariable>P_LINETBL

> P_LINE_TBL_ITEM > LINE_ID

Invoke_SyncRead_OutputVariable>

InputParameters > P_LINE_TBL >

P_LINE_TBL_ITEM >

ORDERED_QUANTITY

Invoke_OrderManagement_InputVariable>P_LINETBL

> P_LINE_TBL_ITEM > ORDERED_QUANTITY

Oracle SOA Suite 11g - Sample

Oracle SOA Suite 11g - Sample

Oracle SOA Suite 11g - Sample

Set Apps Adapter Context

• Right-click Invoke activity of the service OrderManagement and select Edit.

• Click Properties tab to set the Header properties.

• Select jca.apps.Username and click to assign a value to it.

Oracle SOA Suite 11g - Sample

• Select the radio button Expression

• Enter the value as ‘OPERATIONS’

• Similarly assign ‘Order Management Super User, Vision Operations (USA)’

for jca.apps.Responsibility.

Oracle SOA Suite 11g - Sample

Oracle SOA Suite 11g - Sample

• Design tab of Composite.xml looks as shown in the figure

Oracle SOA Suite 11g - Sample

• Click the source tab of composite.xml

• Enter a value for the inputDir. e.g. /usr/tmp

<property name="inputDir" type="xs:string" many="false"

override="may">/usr/tmp</property>

Oracle SOA Suite 11g - Sample