380 por custom pkg iprocurement part1

12
Custom Defaulting and Validation in iProcurement Written by Kishore Ryali Tuesday, 17 March 2009 20:37                         Part I – POR_CUSTOM_PKG One of the common requirements in iProcurement implementation is to perform custom defaulting or validating fields in requisition header/line/distribution during Requisition creation. For example, you may want to default project value based on requestor or validate deliver-to location to check if it is valid for a project etc. The objective of the article is to share different approaches I learnt from my experience, to achieve it. I will take a simple requirement to explain each of the approaches and analyze their pros and cons. My requirement in is as follows as. Please note I'm using 11.5.10.2 iProcurement. Requirement:  I’ve defined attributes (Attribute15) on requisition header and line with the name “Fund”. Fund attribute on the line drives charge account generation. User is required to enter fund on header in ‘Checkout: Requisition Information’ page, this value is defaulted or copied to fund attribute on the line. This means user doesn’t have to enter fund attribute for all the lines in the requisition, in fact fund on line is 1 / 12

Upload: vijaykrishna

Post on 08-Apr-2015

469 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: 380 Por Custom Pkg Iprocurement Part1

Custom Defaulting and Validation in iProcurement

Written by Kishore RyaliTuesday, 17 March 2009 20:37

                                Part I – POR_CUSTOM_PKG

One of the common requirements in iProcurement implementation is to performcustom defaulting or validating fields in requisition header/line/distribution duringRequisition creation. For example, you may want to default project value based onrequestor or validate deliver-to location to check if it is valid for a project etc. Theobjective of the article is to share different approaches I learnt from myexperience, to achieve it.

I will take a simple requirement to explain each of the approaches and analyzetheir pros and cons. My requirement in is as follows as. Please note I'm using11.5.10.2 iProcurement.

Requirement:

 

I’ve defined attributes (Attribute15) on requisition header and line with the name“Fund”. Fund attribute on the line drives charge account generation. User isrequired to enter fund on header in ‘Checkout: Requisition Information’ page, thisvalue is defaulted or copied to fund attribute on the line. This means user doesn’thave to enter fund attribute for all the lines in the requisition, in fact fund on line is

1 / 12

Page 2: 380 Por Custom Pkg Iprocurement Part1

Custom Defaulting and Validation in iProcurement

Written by Kishore RyaliTuesday, 17 March 2009 20:37

not displayed unless it is shown using OAF Personalization (DFFs are by defaultnot shown in OAF page). Only Fund attribute on header is displayed by setting‘Rendered’ property to “true” for item ‘ReqHeaderDFF’ using OAF Personalization.Fund on requisition header in Checkout page is shown in the below screenshot.

 

Solution Approach:

 

Different solution approaches for addressing the above requirementare:

 

1.

POR_CUSTOM_PKG

2 / 12

Page 3: 380 Por Custom Pkg Iprocurement Part1

Custom Defaulting and Validation in iProcurement

Written by Kishore RyaliTuesday, 17 March 2009 20:37

This is Oracle seeded package provided as a hook to include customdefaulting and validation logic in iProcurement requisition creation.

 

1.

Extending Application Module and Controller of Checkout pageusing OAF extension.

Create a method to copy fund from header to line in extendedapplication module. Extend controller to make a call to that AM methodduring page events like Edit Lines, Submit etc.

 

1.

Extend existing Helper / Server Command classes using OAF.

iProcurement OAF architecture is designed to use Server Commandand Helper classes to encapsulate the business logic. These additional

3 / 12

Page 4: 380 Por Custom Pkg Iprocurement Part1

Custom Defaulting and Validation in iProcurement

Written by Kishore RyaliTuesday, 17 March 2009 20:37

classes contain code that would normally be placed in ApplicationModule. The code is separated to prevent AM from growing too big andpromote reusability. We can extend these classes to place custom logicto meet our requirement. This approach requires good understanding ofOAF and its integration with underlying BC4J components.

 

I will use above approaches to implement my requirement, and pointout some limitations of each approach. This first article in the series hasimplementation using POR_CUSTOM_PKG.

Approach 1: POR_CUSTOM_PKG

POR_CUSTOM_PKG provides customization hooks to perform thedefaulting logic and validation of the requisition header, line, anddistribution data. The procedures in this package are called duringrequisition creation in iProcurement. Requisitions created in Purchasingmodule doesn’t use this package.

 

4 / 12

Page 5: 380 Por Custom Pkg Iprocurement Part1

Custom Defaulting and Validation in iProcurement

Written by Kishore RyaliTuesday, 17 March 2009 20:37

The procedures are invoked from CustomReqHeaderHelper,CustomReqLineHelper, and CustomReqDistHelper classes whichimplements interface classes PoRequisitionHeaderEOHelper,PoRequisitionLineEOHelper, and PoReqDistributionEOHelperrespectively. Without going too much into details of theirimplementation, let us look at different pl/sql procedures available inpor_custom_pkg.

 

This package contains 7 procedures (3 for defaulting logic, 3 forvalidations and 1 for updating charge account). Function of eachprocedure is self explanatory by looking at their names; I will give a gistof each of them:

Procedure Name

Purpose

CUSTOM_DEFAULT_REQ_HEADER

Customize it to include header defaulting logic. It is called when new requisition is created from scratch or copied from old requisition. Header DFF attributes are available to use.

5 / 12

Page 6: 380 Por Custom Pkg Iprocurement Part1

Custom Defaulting and Validation in iProcurement

Written by Kishore RyaliTuesday, 17 March 2009 20:37

CUSTOM_VALIDATE_REQ_HEADER

Customize it to include header validation logic. This validation would in addition to all validations done for requisition header. It is called when new requisition is submitted / saved.

CUSTOM_DEFAULT_REQ_LINE

Customize it to include Line defaulting logic. It is called when new requisition line is created. Header information plus line information including DFF attributes are available to use.

CUSTOM_VALIDATE_REQ_LINE

Customize it to include Line validation logic. It is called when new requisition line is submitted / saved.

CUSTOM_DEFAULT_REQ_DIST

Customize it to include distribution defaulting logic. It is called when new distribution is created.

6 / 12

Page 7: 380 Por Custom Pkg Iprocurement Part1

Custom Defaulting and Validation in iProcurement

Written by Kishore RyaliTuesday, 17 March 2009 20:37

CUSTOM_VALIDATE_REQ_DIST

Customize it to include distribution validation logic. It is called when new distribution is submitted / saved.

CUSTOM_UPDATE_CHARGE_ACCOUNT

Overrides default charge account. Use PO Account Generator workflow instead of this procedure. This procedure doesn’t execute at all.

The above defaulting and validation procedures has common OUTparameters x_return_code and x_error_msg. These parameters can beused to return the resultsof the validation. Return code (x_return_code) can be used to indicate on which tab error message to be displayed to Edit Lines page.

 

If result code is 1, error is displayed on the Delivery tab

If result code is 2, error is displayed on the Billing tab

7 / 12

Page 8: 380 Por Custom Pkg Iprocurement Part1

Custom Defaulting and Validation in iProcurement

Written by Kishore RyaliTuesday, 17 March 2009 20:37

If result code is 2, error is displayed on the Accounts tab

 

 

These procedures are by default do not have any implementation. Oncecustom code is placed, three profile options control whethercustomization takes effect on existing requisition process.

The profiles are:

 

• POR: Enable Req Header Customization

• POR: Enable Requisition Line Customization

• POR: Enable Req Distribution Customization

8 / 12

Page 9: 380 Por Custom Pkg Iprocurement Part1

Custom Defaulting and Validation in iProcurement

Written by Kishore RyaliTuesday, 17 March 2009 20:37

 

These profiles have to be set to ‘Yes’ at site level, to tell iProcurementto execute customization in corresponding procedures.

 

Implementation:

 

Going back to my requirement of copying fund value from header toline, implementation requires:

-

Coding defaulting procedure for requisition line i.e.CUSTOM_DEFAULT_REQ_LINE

-

Profile “POR: Enable Requisition Line Customization” need to be set to“Yes” at site level.

9 / 12

Page 10: 380 Por Custom Pkg Iprocurement Part1

Custom Defaulting and Validation in iProcurement

Written by Kishore RyaliTuesday, 17 March 2009 20:37

In POR_CUSTOM_PKG.CUSTOM_DEFAULT_REQ_LINE procedure,header fund value is available in header attribute15 i.e. IN parameter header_attribute_15, copy its value to line fund value i.e. IN OUT parameter x_attribute15. Return 0 at the end to signal success. Below screenshot showsimplementation of the procedure.

 

Advantages of this approach are it is simple and doesn’t requiredeveloper to have understanding of OAF or Java. If customizationneeds to turned off, clear the profile “POR: Enable Requisition LineCustomization” value or set it to “No” at site level.

Limitations of this approach is defaulting procedures are only executedwhen requisition is first created. If the user changes fund value in

10 / 12

Page 11: 380 Por Custom Pkg Iprocurement Part1

Custom Defaulting and Validation in iProcurement

Written by Kishore RyaliTuesday, 17 March 2009 20:37

header, new value is not copied to line because default procedure is notexecuted. So this implementation doesn’t fully solve the purpose.

A similar example where defaulting fails is, suppose you want to defaulta value say ‘0000000’ to header fund when requisition is created. Wecan code POR_CUSTOM_PKG. CUSTOM_VALIDATE_REQ_HEADERto copy ‘0000000’ to x_attribute15 if it is null. This works whenrequisition is created from scratch in Non-catalog request page or byselecting inventory item. iProcurement create new records in requisitionheader (po_requisition_headers_all) and line (po_requisition_lines_all)tables when checkout is done. Suppose you change fund value to‘1234567’, save it, delete lines in requisition and start over fromNon-catalog request page, default value ‘0000000’ is not shown for fundinstead  ‘1234567’ is shown. iProcurement doesn’t delete requisitionheader when lines are deleted. It uses existing header record i.e. samereq_header_id which means default header procedure is not executed.These are few scenarios where I felt default procedures doesn’t workthe way I wanted it to be. So I have to opt for alternative solution.

 

The next article in the series uses OAF extension of controller andapplication module to implement my requirement.

11 / 12

Page 12: 380 Por Custom Pkg Iprocurement Part1

Custom Defaulting and Validation in iProcurement

Written by Kishore RyaliTuesday, 17 March 2009 20:37

 

 

 

 

12 / 12