Feeds:
Posts
Comments

1.  If you submit the concurrent Program (XML Report) through back and  as  normal way using “FND_REQUEST. SUBMIT_REQUEST”, it will not take Attached Template(Layout) to the Concurrent Program. This we can observe in SRS Window -> View Details -> Options below Screen will appear.

1

 2.  If you want to appear Template to the Concurrent Program, we need to add Layout Explicitly using “FND_REQUEST.ADD_LAYOUT” Packaged Procedure. Before submitting the Concurrent Program (XML Report). (See given example code below)

3. After Completion of Point 2, Template details we can see in SRSàView Details à Options in below Screen.

2

Example Script:

Click here for sample code

SELECT ROWNUM

,fat.application_name application_name

,fat.application_short_name appl_short_name

,fcpt.user_concurrent_program_name concurrent_program_name

,fcp.concurrent_program_name concurrent_program_short_name

,fcp.output_file_type output_type

, fe.executable_name executable_name

,flv.meaning execution_method_type

,fat1.application_name executable_application_name

,fat1.application_short_name executable_appl_short_name

,xddt.data_source_name data_definition_name

,xtb.template_code template_code

, xtb.template_type_code template_type

,xl.file_content_type file_content

, xl.file_name rtf_file_name

, (SELECT user_name

     FROM fnd_user

     WHERE user_id = xtb.created_by) creation_user

  FROM fnd_concurrent_programs_tl fcpt,

       fnd_concurrent_programs fcp,

       fnd_executables fe,

       fnd_application_vl fat,

       fnd_application_vl fat1,

       fnd_lookup_values flv,

       xdo_ds_definitions_tl xddt,

       xdo_templates_b xtb,

       xdo_lobs xl

 WHERE fcp.concurrent_program_id = fcpt.concurrent_program_id

   AND fat.application_id = fcpt.application_id

   AND fcp.executable_id = fe.executable_id

   AND fcp.executable_application_id = fe.application_id

   AND fat1.application_id = fe.application_id

   AND xddt.data_source_code(+) = fcp.concurrent_program_name

   AND flv.lookup_type(+) = ‘CP_EXECUTION_METHOD_CODE’

   AND flv.lookup_code(+) = fe.execution_method_code

   AND xtb.data_source_code(+) = xddt.data_source_code

   AND xl.lob_code(+) = xtb.template_code

   AND xl.lob_type(+) = ‘TEMPLATE_SOURCE’

   AND flv.enabled_flag = ‘Y’

   –AND fcp.output_file_type=’XML’

   AND fcp.enabled_flag=’Y’

   AND NVL (flv.end_date_active, SYSDATE) >= SYSDATE 

   AND fcpt.user_concurrent_program_name=:p_concurrent_program_name

 

 2) To find out previous, current and next years first date and last date

           SELECT TRUNC

          (LAST_DAY (ADD_MONTHS (SYSDATE,

                                 -TO_NUMBER (TO_CHAR (SYSDATE, ‘mm’)))),

           ‘YEAR’

          ) privious_year_first_date,

       TRUNC

          (LAST_DAY (ADD_MONTHS (SYSDATE,

                                 -TO_NUMBER (TO_CHAR (SYSDATE, ‘mm’))))

          ) privious_year_last_date,

       TRUNC

          (LAST_DAY (ADD_MONTHS (SYSDATE,

                                 12 – TO_NUMBER (TO_CHAR (SYSDATE, ‘mm’))

                                )

                    ),

           ‘YEAR’

          ) current_year_first_date,

       TRUNC

          (LAST_DAY (ADD_MONTHS (SYSDATE,

                                 12 – TO_NUMBER (TO_CHAR (SYSDATE, ‘mm’))

                                )

                    )

          ) current_year_last_date,

       TRUNC

          (LAST_DAY (ADD_MONTHS (SYSDATE,

                                 24 – TO_NUMBER (TO_CHAR (SYSDATE, ‘mm’))

                                )

                    ),

           ‘YEAR’

          ) next_year_first_date,

       TRUNC

          (LAST_DAY (ADD_MONTHS (SYSDATE,

                                 24 – TO_NUMBER (TO_CHAR (SYSDATE, ‘mm’))

                                )

                    )

          ) next_year_last_date

  FROM DUAL

Oracle Workflow is tightly integrated with Oracle Apps and it is very common to invoke workflow from OAF Pages too.

The class oracle.apps.fnd.framework.webui.OANavigation provides Java wrappers for Oracle Workflow Engine’s PL/SQL APIs.

 It is very simple to invoke Workflow using OAF, again there are two options first using Java wrappers and second through calling PL/SQL procedures but the later approach you can use if you are converting some Oracle Form into OAF form and all the code for Workflow is already ready and tested but if it is new workflow then you should use Java wrappers:

 Following piece of code invokes the Workflow from OAF:

 import oracle.apps.fnd.framework.webui.OANavigation;

 public void launchWorkFlowFromOAF(OAPageContext pageContext)

{

String wfItemType = “‘XXSR’”;

String wfProcess = “‘SR_MAIN_PROCESS’”;

OADBTransaction transaction = getOADBTransaction();

String Sr_No ;

String wfItemKey = ” “;

Sr_No = pageContext.getParameter(“sr_no”);

wfItemKey = Sr_No+ transaction.getSequenceValue(“xxsr_key_s.NEXTVAL”).toString();

OANavigation wfClass = new OANavigation();

// Create Workflow Process

wfClass.createProcess(pageContext, wfItemType, wfProcess, wfItemKey);

// Set Number Attribute: SR_NO

wfClass.setItemAttrNumber( pageContext,

                                       wfItemType,

                                       wfItemKey,

                                       ”SR_NO”,

                                       Sr_No      );

// Start Workflow Process

wfClass.startProcess(pageContext, wfItemType, wfProcess, wfItemKey);

}

If you want to invoke this workflow using callable statement then you have to write code like this:

OAF code:

 if(pageContext.getParameter(“btnSubmit”)!=null)

{
String sql = "BEGIN xx_sr_notf_pkg.invoke_wf (:1); END;";
String status = null;
OracleCallableStatement cs = (OracleCallableStatement)
am.getOADBTransaction().createCallableStatement(sql,1);
try
{
cs.setString(1,srNo);
cs.execute();
cs.close();
}
catch (Exception ex)
{
throw new OAException(ex.getMessage().toString(),
OAException.ERROR);
}
throw new OAException("SR "+srNo+" has been submitted",
OAException.CONFIRMATION);
} 
PL/SQL Code to Invoke Workflow:
   PROCEDURE invoke_wf (p_sr_doc_number IN VARCHAR2)
   IS
      l_item_key             VARCHAR2 (50);
   BEGIN
        SELECT p_sr_doc_number ||  xxegasr_key_s.NEXTVAL
        INTO l_item_key
        FROM DUAL;
wf_engine.createprocess ('XXSR', l_item_key, 'SR_MAIN_PROCESS');
wf_engine.setitemattrnumber(itemtype      => 'XXSR',
                            itemkey       => l_item_key,
                            aname         => 'P_SR_DOC_NO',
                            avalue        => p_sr_doc_number
                           );      
      wf_engine.startprocess ('XXSR', l_item_key);
      COMMIT;
   END invoke_wf;
 

There is lot of requirements where we need to use Java like zipping the files stored in database, deleting files from server.

 Oracle provides the way to access Java stored Procedure and classes from PL/SQL, we can use according to our need

Following steps are required:

  1. Create Java class according to your requirement
  2. Compile and load it into database
  3. Write one PL/SQL Wrapper Program to call this.

Simple Demonstration:

Requirement: To delete file from server, file name will be provided as input parameter

Steps to achieve this:

1. Write Java class to delete the file and compile it. 

 public class TestDelete {

   public static int delete ...
   public static void main (String args[]) {
      System.out.println (
         delete (args[0])
         );
    }
}
2. Load java class into database
 
C:\oracle9i\bin>loadjava -user scott/tiger -oci8 -resolve
TestDelete.class
 
3. Write PL/SQL Wrapper Program:
CREATE OR REPLACE FUNCTION fDelete (
   file IN VARCHAR2)
   RETURN NUMBER
AS LANGUAGE JAVA
   NAME 'TestDelete.delete (
            java.lang.String) 
            return int';
 
LoadJava utility: The loadjava utility (Oracle 8.1.5 and up) loads
Java source and class files into the database.When class files are
created in a conventional manner, outside the database,
loadjava is used to get them into the database.

Figure 1: Loading Java elements into Oracle

  1

Here is the syntax:

loadjava {-user | -u} username/password[@database]
  [-option_name [-option_name] ...] filename [filename ]...

where option_name stands for the following syntax:

{  {andresolve | a}
 | debug
 | {definer | d}
 | {encoding | e} encoding_scheme_name
 | {force | f}
 | {grant | g} {username | role_name}[,{username | role_name}]...
 | {oci8 | o}
 | oracleresolver
 | {resolve | r}
 | {resolver | R} "resolver_spec"
 | {schema | S} schema_name
 | {synonym | s}
 | {thin | t}
 | {verbose | v} }

loadjava requires two database privileges to load java objects into your own schema: CREATE PROCEDURE and CREATE TABLE.  To load Java objects into a schema other than the currently connected user, CREATE ANY PROCEDURE and CREATE ANY TABLE privileges are required.

This example will use a simple Java program that will be compiled outside of Oracle and then loaded into the database.

 public class SimpleJava {

   public void main(String[] args) {

      System.out.println(“Here we are”);

   }

From DOS or  UNIX :

C:\oracle9i\bin>javac SimpleJava.java

C:\oracle9i\bin>loadjava -user scott/tiger SimpleJava.class

The class file is now loaded into the database and visible from the dba_objects view with an object type of JAVA CLASS.

From SQL*Plus, create the PL/SQL wrapper to invoke the newly loaded Java class:

SQL> create or replace procedure call_simplejava

  2  as language java

  3  name ‘SimpleJava.showMessage()’;

  4  /

Execute the code from SQL*Plus:

SQL> set serveroutput on;

SQL> call dbms_java.set_output(50);

Call completed.

SQL> execute call_simplejava;

Here we are

PL/SQL procedure successfully completed.

In this example, the Java class file was loaded into the database.  The Java source file can also be loaded.  But, both the source and class files cannot be loaded at the same time.

 C:\oracle9i\bin>loadjava -user scott/tiger SimpleJava.java

If loading many Java class files at one time, it is advisable to put them in a JAR file and load them into the database at one time, since the loadjava program will also load JAR files.   A JAR file is a group of Java class files lumped into one file, a format similar to TAR (on  UNIX ) and WinZip (on Windows).   The contents of a JAR file can be viewed using these popular utilities.  Java developers prefer to distribute a few JAR files rather than many individual Java class files.

Oracle8i has created two new roles to support Java security. For many Java-based operations within the database, you will not have to work with these roles. If, on the other hand, you want to interact with the operating system (to access or modify operating system files, for example), you need to be granted one of the following roles:

JAVASYSPRIV
JAVAUSERPRIV

You grant these roles as you would any other database role. For example, if I want to allow SCOTT to perform any kind of Java-related operation, I would issue this command from a SYSDBA account:

GRANT JAVASYSPRIV TO SCOTT;

If I want to place some restrictions on what the user can do with Java, I might execute this grant instead:

GRANT JAVAUSERPRIV TO SCOTT;
To access Java class methods from within Oracle, you must take the following steps:
  1. Create the Java code elements. You can do this in Oracle’s JDeveloper, or in any other Java Integrated Development Environment. Load the Java class(es) into Oracle using the loadjava command-line utility or the CREATE JAVA statement.
  2. Publish the Java class methods inside PL/SQL by writing wrapper programs in PL/SQL around the Java code.
  3. Grant privileges as required on the PL/SQL wrapper programs and the Java class referenced by the PL/SQL wrapper.
  4. Call the PL/SQL programs from any one of a number of environmentsOracle8i offers a variety of components and commands to work with Java following table summarizes these different elements:

Table 1: Oracle Components and Commands for Java

Component Description
Aurora JVM The Java Virtual Machine (JVM) that Oracle implemented in its database server
loadjava An operating system command-line utility that loads your Java code elements (classes, .jar files, etc.) into the Oracle database
dropjava An operating system command-line utility that drops your Java code elements (classes, .jar files, etc.) from the Oracle database
CREATE JAVA

DROP JAVA

ALTER JAVA

New DDL statements that perform some of the same tasks as loadjava and dropjava
DBMS_JAVA A built-in package that offers a number of utilities to set options and other aspects of the JVM
DBMS_JAVA_TEST A built-in package you can use to more easily test your JSPs
JPublisher A utility used to build Java classes around object types and REFs defined in the Oracle database

 

Figure 9.1: Accessing JSPs from within the Oracle database

2

Data Type Mapping Between Java and SQL:

SQL Type Java Class
CHAR, NCHAR, LONG, VARCHAR2, NVARCHAR2
oracle.sql.CHAR
java.lang.String
java.sql.Date
java.sql.Time
java.sql.Timestamp
java.lang.Byte
java.lang.Short
java.lang.Integer
java.lang.Long
java.lang.Float
java.lang.Double
java.math.BigDecimal
byte, short, int, long, float, double
DATE
oracle.sql.DATE
java.sql.Date
java.sql.Time
java.sql.Timestamp
java.lang.String
NUMBER
oracle.sql.NUMBER
java.lang.Byte
java.lang.Short
java.lang.Integer
java.lang.Long
java.lang.Float
java.lang.Double
java.math.BigDecimal
byte, short, int, long, float, double
RAW, LONG RAW
oracle.sql.RAW
byte[]
ROWID
oracle.sql.CHAR
oracle.sql.ROWID
java.lang.String
BFILE
oracle.sql.BFILE
BLOB
oracle.sql.BLOB
oracle.jdbc2.Blob
CLOB, NCLOB
oracle.sql.CLOB
oracle.jdbc2.Clob 
OBJECT
oracle.sql.STRUCT
oracle.SqljData
oracle.jdbc2.Struct 
REF
oracle.sql.REF
oracle.jdbc2.Ref 
TABLE, VARRAY
oracle.sql.ARRAY
oracle.jdbc2.Array 
Any of the above SQL types
oracle.sql.CustomDatum
oracle.sql.Datum 

It is a very common requirement where we want to generate reports in PDF, MSWord, MS Excel and HTML format from an OAF page itself without submitting any concurrent program. 

To generate the output in PDF or other formats we need the following:

  • XML Data Definition, registered with Apps
  • Template, registered with Apps
  • XML Publisher APIs to process the template and generate the output in required format.

As we are going to generate the output from OAF, we need to generate the XML data using view object, View Object is having inbuilt functionality to read and write data in XML format. View Object is having one method called writeXML which will generate the data in XML format. We can use it for two purposes:

  1. To generate XML Data in Jdeveloper Embedded OC4J Sever Log (It will give XML Definition of data; we can use it for designing our Template and register this as Data definition).
  2. To generate XML data for actual template processing.

Steps to Generate the Output in required format:

Step 1: Create OAWorkspace, Project, packages, VO and AM (I hope you are already familiar with these)

Step 2: Import following Packages in AM and Controller:

import java.io.ByteArrayInputStream;

import java.io.ByteArrayOutputStream;

import javax.servlet.ServletOutputStream;

import javax.servlet.http.HttpServletResponse;

import oracle.apps.fnd.framework.webui.beans.table.OAAdvancedTableBean;

import oracle.apps.xdo.oa.schema.server.TemplateHelper;

import oracle.jbo.XMLInterface;

Step 3: Create one method in your AM to generate XML output, call this method from your processRequest mathod and get it printed on Jdeveloper console:

Your code for should look like this:

public void getPrintDataXML()

{

 try

 {

   ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

   OAViewObject vo = (OAViewObject)am.findViewObject(“XXEGASRPrintPageVO1″);

   ((XMLNode) vo.writeXML(4, XMLInterface.XML_OPT_ALL_ROWS)).print(outputStream);

   System.out.println(outputStream.toString());

  }

 catch(Exception e)

 {

  throw new OAException (e.getMessage());

 }

}  

Statements highlighted(BOLD) will print the XML data generated by your view object to Jdeveloper console.

In first line vo.writeXML will generate the XML for VO and print method will write the XML data in outputstream that can further be used to print XML data on Jdeveloper console using println method.

1

You can copy this output and save with some meaningful name and use it to register as data definition and to design your template(copy only XML data). 

Step 4: Design your template

Step 5: Register your Template and data Definition in Oracle Apps

2

Step 5: Register your Template and data Definition in Oracle Apps

3

Click on “Create Data Definition” button

4

Fill in all the mandatory columns and give a short code for your data definition and clink on “Apply” button

now click on “Template” Tab

5

 Click on “Create Template” button

6

Fill in all the mandatory columns and give a short code (It will be used by XML Publisher APIs to process the template) for your template and clink on “Apply” button

 Step 6: Generate output, using XML publisher APIs

    Step 6.1: Create a submit button to Generate the output say “Print”

     Step 6.2: Add following method to your AM Impl class

  public XMLNode getPrintDataXML()//XMLNode

  {

   OAViewObject vo = (OAViewObject)findViewObject(“EmpVO1″);

   ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

   XMLNode xmlNode = (XMLNode) vo.writeXML(4, XMLInterface.XML_OPT_ALL_ROWS);

   return xmlNode;

  }

     Step 6.3: Handle the event for “Print” button:

 /*

 * Handles functionality of Print button

 */

 if(pageContext.getParameter(“btnPrint”)!=null)

               {

// Get the HttpServletResponse object from the PageContext. The report output is written to HttpServletResponse.

DataObject sessionDictionary = (DataObject)pageContext.getNamedDataObject(“_SessionParameters”);

 HttpServletResponse response = (HttpServletResponse)sessionDictionary.selectValue(null,”HttpServletResponse”);

                         try {

                          ServletOutputStream os = response.getOutputStream();

                           // Set the Output Report File Name and Content Type

                           String contentDisposition = “attachment;filename=PrintPage.pdf”;

                           response.setHeader(“Content-Disposition”,contentDisposition);

                           response.setContentType(“application/pdf”);

                           // Get the Data XML File as the XMLNode

                           XMLNode xmlNode = (XMLNode) am.invokeMethod(“getPrintDataXML”);

            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

            ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());

            ByteArrayOutputStream pdfFile = new ByteArrayOutputStream();

            //Generate the PDF Report.

            //Process Template

            TemplateHelper.processTemplate(

            ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getAppsContext(),

            “AK”,//APPLICATION SHORT NAME

            “Print Template TMP”, //TEMPLATE_SHORT_CODE

            ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getLanguage(),

            ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getCountry(),

            inputStream,

            TemplateHelper.OUTPUT_TYPE_PDF,

            null,

            pdfFile);

              //TemplateHelper.

            // Write the PDF Report to the HttpServletResponse object and flush.

            byte[] b = pdfFile.toByteArray();

            response.setContentLength(b.length);

            os.write(b, 0, b.length);

            os.flush();

            os.close();

    pdfFile.flush();

    pdfFile.close();

            }

            catch(Exception e)

            {

            response.setContentType(“text/html”);

            throw new OAException(e.getMessage(), OAException.ERROR);

            }

            pageContext.setDocumentRendered(true);

            } 

Now run your page and click on Print button:

7

In this manner we can generate the output in Excel, Word and HTML format also but we need to modify our code a bit, few statements in above code are in BOLD… 

The statements in BOLD need to be modified:

First file name in following statement :

String contentDisposition = “attachment;filename=PrintPage.pdf”;

In above statement PrintPage.pdf  can be  replaced with <userdefined_filename>.doc/.xls/.htm

Second is file MIME Type needs to be changed:

response.setContentType(“application/pdf”);

Here application/pdf can be replaced with valid MIME type for Excel/Word and HTML 

Third, TemplateHelper.OUTPUT_TYPE_PDF, in this OUTPUT_TYPE_PDF can be replaced by OUTPUT_TYPE_HTML/ OUTPUT_TYPE_EXCEL/ OUTPUT_TYPE_RTF.

If we want to call any method of Application Module from Controller class in OA Framework there are two ways to achieve this:

  1. Using invokeMethod: invokeMethod is the method of OAApplicationModule class it takes three parameters:
    • Method Name- Data Type String
    • Parameters(Optional)- array of type Serializable
    • paramTypes(Optional)- array of datatypes, one to one mapping with parameters.

 Example:

 OAApplicationModule am = pageContext.getApplicationModule(webBean);

Boolean executeQuery = BooleanUtils.getBoolean(false);

String s3 = pageContext.getParameter(“auctionHeaderId”);

Serializable parameters[] = {s3, executeQuery};

Class paramTypes[] = {String.class, Boolean.class};

am.invokeMethod(“initSummary”, parameters, paramTypes); 

  1. Creating an Interface of Application Module: This method is useful if we have to pass serializable parameters to AM. In this case first we need to create an interface for Application module:

Following are the steps to create Interface of Application Module: 

Step 1: Select required AM, right click, from context menu select edit <AMName>

Step 2: Select Client Method option 

If we want to call any method of Application Module from Controller class there are two ways to achieve this:

  1. Using invokeMethod: invokeMethod is the method of OAApplicationModule class it takes three parameters:
    • Method Name- Data Type String
    • Parameters(Optional)- array of type Serializable
    • paramTypes(Optional)- array of datatypes, one to one mapping with parameters.

Example:

 

OAApplicationModule am = pageContext.getApplicationModule(webBean);

Boolean executeQuery = BooleanUtils.getBoolean(false);

String s3 = pageContext.getParameter(“auctionHeaderId”);

Serializable parameters[] = {s3, executeQuery};

Class paramTypes[] = {String.class, Boolean.class};

am.invokeMethod(“initSummary”, parameters, paramTypes);

 

  1. Creating an Interface of Application Module: This method is useful if we have to pass serializable parameters to AM. In this case first we need to create an interface for Application module

Following are the steps to create Interface of Application Module:

Step 1: Select required AM, right click, from context menu select edit <AMName>

 

1

  

 

  Step 2: Select Client Method option

2

 

Step 3: In above figure you are able to see methods under available select required methods (methods you want to call without using invokeMethod) and move those to right side and click on Apply and OK.

3

After this step, Jdeveloper will create one java file name of AM, you can see this Object Navigator:

4

Contents of that file will be:

package xxbc.oracle.apps.icx;

import oracle.jbo.ApplicationModule;

//  —————————————————————

//  —    File generated by Oracle Business Components for Java.

//  —————————————————————

/**

 *

 * Generated interface. Do not modify.

 */

public interface EmpAM extends ApplicationModule

{

  void deleteEmpMethod(String pEmpId);

  void createEmpMethod();

  void createEmp();

  void updateEmpMethod(String pEmpId);

  void saveEmpToDatabase();

  void rollbackToDatabase();

}

Now to call these methods from your controller you need to add following things to your controller class:

  • Import package which contains your Application Module definition to controller class e.g.

           Import xxx.oracle.apps.xxx.server;

  • Create an object of your Application module

XXEGAAwardByQuoteAM xxegaawardbyquoteam = (XXEGAAwardByQuoteAMImpl)pageContext.getApplicationModule(webBean);

Where XXEGAAwardByQuoteAM is Interface class of Application module XXEGAAwardByQuoteAM.

  • Call your method like:

<AMObject>.<method>

Example:

Import XXEGA.oracle.apps.pon.awardbyqt.server.XXEGAAwardByQuoteAMImpl;

processFormRequest(….)

{

XXEGAAwardByQuoteAMImpl xxegaawardbyquoteam = (XXEGAAwardByQuoteAMImpl)pageContext.getApplicationModule(webBean);

Number s5 = xxegaawardbyquoteam.get_msgCount();

} 

Contents of that file will be:

 

package xxbc.oracle.apps.icx;

import oracle.jbo.ApplicationModule;

//  —————————————————————

//      File generated by Oracle Business Components for Java.

//  —————————————————————

/**

 *

 * Generated interface. Do not modify.

 */

 

public interface EmpAM extends ApplicationModule

{

  void deleteEmpMethod(String pEmpId);

  void createEmpMethod();

  void createEmp();

  void updateEmpMethod(String pEmpId); 

  void saveEmpToDatabase();

  void rollbackToDatabase();

}

Now to call these methods from your controller you need to add following things to your controller class:

·        Import package which contains your Application Module definition to controller class e.g.

           Import xxx.oracle.apps.xxx.server;

 

·        Create an object of your Application module

XXEGAAwardByQuoteAM xxegaawardbyquoteam = (XXEGAAwardByQuoteAMImpl)pageContext.getApplicationModule(webBean);

Where XXEGAAwardByQuoteAM is Interface class of Application module XXEGAAwardByQuoteAM.

 

·        Call your method like:

<AMObject>.<method>

Example:

Import XXEGA.oracle.apps.pon.awardbyqt.server.XXEGAAwardByQuoteAMImpl;

processFormRequest(….)

{

XXEGAAwardByQuoteAMImpl xxegaawardbyquoteam = (XXEGAAwardByQuoteAMImpl)pageContext.getApplicationModule(webBean);

Number s5 = xxegaawardbyquoteam.get_msgCount();

}

In Release 12, the architecture of multi-org and the way in which data is partitioned by operating unit has changed significantly. As a result the ways in which data are stored and accessed has changed.

In Previous Releases data was restricted to a single operating unit using views which striped base table data based on the current operating unit setting.

Base tables (generally named with ‘_ALL’, e.g. MY_TABLE_ALL) contained data for all operating units. Each such table contained a column named ORG_ID to indicate what operating unit a particular row belonged to.Data was then restricted by using restricted views (e.g. MY_TABLE) which would only return rows which corresponded to the current operating unit’s organization ID. The current operating unit was stored in the first 10 characters of the database Application Context variable CLIENT_INFO. When logging into the applications, the CLIENT_INFO value was set to the appropriate operating unit organization ID for the session based on the profile option setting for “MO: Operating Unit”. In SQL*Plus, CLIENT_INFO could be set to point to a particular operating unit using execute dbms_application_info.set_client_info(‘’);

In Release 12 a more flexible architecture has been put in place to support Multi-Org Access Control (MOAC). This architecture allows users to define security profiles so that users may access data for more than one operating unit within a single responsibility.

To accomplish this

Multi-org views have been removed, and replaced with synonyms. For example, MY_TABLE would no longer be a view defined on MY_TABLE_ALL, but rather a synonym which points to MY_TABLE_ALL
The data restriction is accomplished by assigning a virtual private database (VPD) policy to the synonym. This policy allows the system to dynamically generate restricting conditions when queries are run against the synonym.

For example: In release 12 in the APPS schema, PA_PROJECTS and PA_PROJECTS_ALL are both synonyms which point to the table PA.PA_PROJECTS_ALL. However, the view PA_PROJECTS_ALL is unrestricted, whereas, PA_PROJECTS will only display data for the user’s current operating unit(s) because of the VPD policy that has been assigned to it.

Data relating to defined VPD policies is viewable in the data dictionary view DBA_POLICIES. These policies associate a function with an object, and when the object is accessed, this function can return additional restrictions on the object to restrict the data returned. The particular policy used to implement Multi-Org in release 12 is:

Policy_name: ORG_SEC
Policy_group: SYS_DEFAULT
Package: MO_GLOBAL
Function: ORG_SECURITY
The function (MO_GLOBAL.ORG_SECURITY) is called with the following parameters:
obj_schema – the object schema, in this case APPS
obj_name – the object name (e.g., MY_TABLE)

The function then returns additional where clause conditions to restrict the data accessible from the object. The structure of this function will dynamically generate conditions which will either:

Restrict the data to a single operating unit if the access mode is Single
Restrict the data to multiple operating units if the access mode is Multiple
Restrict the data to eliminate only seed data rows is the access mode is All
Restrict the data to not return any rows if the access mode is None
The conditions returned in each case are as follows:

Single OU Access

org_id = sys_context(‘multi_org2′,’current_org_id’)

Only data for the current operating unit is accessible. The value of sys_context(‘multi_org2′,’current_org_id’) would have to be set to the current operating unit as described below.

Multiple OU Access
EXISTS (SELECT 1
FROM mo_glob_org_access_tmp oa
WHERE oa.organization_id = org_id)
The user will be able to access data for any org_id which has been populated into mo_glob_org_access_tmp. When a session is initialized in the applications, values will be populated into mo_glob_org_access_tmp for each of the operating units the user has access to based on their “MO: Security Profile” setting.

All OU Access
org_id -3113
Seed template records, which are used to create new seed data when a new operating unit is created. are created with an org_id of –3113. So in this mode, only these template records, which do not correspond to any actual operating unit, will be filtered out.

No OU Access
1 = 2
The condition is never satisfied. No data will be returned from the object.

Multi-Org Session Context
The database utility DBMS_SESSION.SET_CONTEXT(, , ) is used to initialize and set the Multi-Org context information for a user’s session. The utility SYS_CONTEXT(, ) is used to retrieve this data. The key context items are:

Namespace Namespace Value
multi_org access_mode S=Single, M=Multiple, A=All, X=None
multi_org2 current_org_id Operating unit org id, only applicable if access mode is Single

For example: The following example shows how you could set the access mode or determine the current setting:

dbms_session.set_context(‘multi_org’,'access_mode’,'S’);

myvar := sys_context(‘multi_org’,'access_mode’);
dbms_output.put_line(‘Access Mode: ‘||myvar);

However, it is generally preferable to use the following wrapper functions from MO_GLOBAL which will call the appropriate utilities to maintain the various elements of the multi-org context:

Procedure: SET_POLICY_CONTEXT(p_access_mode varchar2, p_org_id number)
This procedure will set the access mode, and when applicable the current operating unit context.

Procedure: SET_ORG_ACCESS(p_org_id_char varchar2, p_sp_id_char varchar2, p_appl_short_name varchar2)
This procedure determines if the application specified has multi-org access control enabled, by querying FND_MO_PRODUCT_INIT for the application short name. If this is enabled, and a security profile is specified (p_sp_id_char), then all orgs the user has access to will be populated in MO_GLOB_ORG_ACCESS_TMP. If there are more than one such org, the access method will be set to “Multiple”. Otherwise if no security profile id is specified, it will use the value of p_org_id to set the current operating unit value and set the access mode to “Single”.

Procedure: INIT(p_appl_short_name varchar2)
The procedure used by the applications when starting a new session. Based on the profile options “MO: Operating Unit” (ORG_ID) and “MO: Security Profile” (XLA_MO_SECURITY_PROFILE_LEVEL), this procedure calls set_org_access to establish the multi-org context for the session. To call this from withing SQL, the profile option context should have been initialized for the session.

Function: GET_CURRENT_ORG_ID
Returns the current operating unit setting. This should be null if the access mode is not ‘S’

Function: GET_ACCESS_MODE
Returns the current access mode value.

For Example:

1) When logging into a SQL session to set the org context as it would be for a particular user in a particular responsibility:

a) If you know the security_profile_id for that responsibility and user, you could call:

execute mo_global.set_org_access(null, , ‘PA’);
Security profiles are stored in PER_SECURITY_PROFILES, and the final parameter is the application short name of the application associated with the responsibility you would be using.

b) If you do not know the security profile or operating unit profile option settings for your user, responsibility and application, you could use code similar to the following to get this information:

declare

l_user_id fnd_user.user_id%type;
l_resp_id fnd_responsibility.responsibility_id%type;
l_appl_id fnd_application.application_id%type;
l_appl_short_name fnd_application_vl.application_short_name%type;
l_ou_value fnd_profile_option_values.profile_option_value%type;
l_sp_value fnd_profile_option_values.profile_option_value%type;

begin

select user_id into l_user_id
from fnd_user
where user_name = upper(‘&user_name’);

select responsibility_id into l_resp_id
from fnd_responsibility_vl
where responsibility_name = (‘&resp_name’);

select application_id, application_short_name into l_appl_id, l_appl_short_name
from fnd_application_vl
where application_short_name = upper(‘&appl_short_name’);

l_ou_value := fnd_profile.value_specific(
‘ORG_ID’,l_user_id, l_resp_id, l_appl_id);
l_sp_value := fnd_profile.value_specific(
‘XLA_MO_SECURITY_PROFILE_LEVEL’, l_user_id, l_resp_id, l_appl_id);

dbms_output.put_line(‘MO: Operating Unit: ‘||l_ou_value);
dbms_output.put_line(‘MO: Security Profile: ‘||l_sp_value);

if l_sp_value is null and l_ou_value is null then
dbms_output.put_line(‘No operating unit or security profile information
found’);
else
mo_global.set_org_access(l_ou_value, l_sp_value, l_appl_short_name);
end if;

exception when others then
dbms_output.put_line(‘Error: ‘||sqlerrm);
end;
/

2) To set the operating unit context to a single operating unit, you could simply use:

execute mo_global.set_policy_context(‘S’,);

Backwards Compatibility
When running queries on multi-org objects in SQL, you can still use the old CLIENT_INFO settings to gather data and run queries against multi-org objects if the profile option:

MO: Set Client_Info for Debugging (FND_MO_INIT_CI_DEBUG) is set to “Yes”.

When this profile option is set to “Yes” and the global access mode setting is null (as it would be in a SQL*Plus or other client session unless specifically set), the VPD function MO_GLOBAL.ORG_SECURITY will return the following as the additional where clause condition for the object:

org_id = substrb(userenv(‘CLIENT_INFO’),1,10)

How to setup and check MO/MOAC setup in APPS instance at R12 Level
Ebusiness Suite started using this feature at R12 level
MOAC (Multi-Organization Access Control)

A) How To Setup MO / MOAC Setup In APPS Instance At R12 Level ?
B) What Are The Defaulting Rules Between Different Profile Options
C) How To Check MO / MOAC Setup In APPS Instance At R12 Level ?

Here is the solution for the above questions.
Solution 1:

Setup MOAC (Multi-Organization Access Control) :

1) Define Security Profile for MOAC (Multi-Organization Access Control)

a) HRMS Super User Responsibility > Security > Define Security Profile.
b) Enter name ‘XX-TM-SECURITY-PROFILE’.
c) Enter ‘Vision Corporation’ for ‘Business Group’.
d) Select ‘Organization Security’ tab,
e) For ‘Security Type’, select ‘Secure organizations by organization hierarchy and/or organization list’
f) Enter rows with the following organization names with Classification ‘Operating Unit’ :

- Vision Operations
- Vision Corporation
- Vision Services
- Vision Utilities

2) Run Security List Maintenance request

a) Processes & Reports > Submit Process & Report.
b) Select ‘Security List Maintenance’ for request name.
c) Enter the followings :

- Generate lists for = One Named Security Profile
- Security Profile = ‘XX-TM-SECURITY-PROFILE’

d) Submit the request and wait until it completes.

3) Assign TM Responsibilities to User

a) System Administrator Responsibility > Security : User > Define.
b) Query/add the User you are going to use with Trade Management ( TM).
c) Add the following direct responsibilities :

- Oracle Trade Management User
- Oracle Trade Management Administrator
4) Assign Security Profile to Responsibilities :

a) Profile > System.
b) Assign values to the following profiles as indicated for each of the above responsibilities :

- MO: Default Operating Unit = Vision Operations (e.g.)
- MO: Security Profile = XX-TM-SECURITY-PROFILE

This will give the responsibilities access to the 4 operating units assigned to the security profile ‘XX-TM-SECURITY-PROFILE’.

Note that a valid configuration is to setup only profile option MO: Security Profile and leave MO: Operating Unit at null (ie no setup at any level) which is mandatory to be in MOAC situation and also leave MO: Default Operating Unit at null (ie no setup at any level) which is a possible option

B) R12 MOAC defaulting / precedence rules:

Here is the process which determines the precedence ( priority)between MO and MOAC profile options

1) If the profile option “MO: Security Profile” is not set, then “MO: Operating Unit” value is used as the default Operating Unit even if “MO: Default Operating Unit” profile is set to a different value.

2) If the profile option “MO: Security Profile” is set and gives access to only one Operating Unit, the default Operating Unit will return this value even if “MO: Default Operating Unit” is set to a different value.

3) If the profile option “MO: Security Profile” is set and gives access to multiple Operating Units :

* If the profile value “MO: Default Operating Unit” is set, it is validated against the list of Operating Units in “MO: Security Profile”.
* If the Operating Unit is included in the security profile then it is returned as the default value.
* Else there is no defaulted Operating Unit .
* If the Profile Option “MO: Default Operating Unit” is not set, then there is zero (no) default Operating Unit.

C) Run below SQL statements :

1.To check Organization which are related to a profile

select *
from PER_SECURITY_PROFILES PPR,
PER_SECURITY_ORGANIZATIONS PPO
where PPR.security_profile_id = PPO.security_profile_id
and security_profile_name like ‘%&your_security_profile_name %’

2.To check global profile options setup :

select substr(e.profile_option_name,1,35) Profile,
decode(a.level_id,10001,’Site’,10002,’Application’,10003,’Resp’,10004,’User’) L,
decode(a.level_id,10001,’Site’,10002,c.application_short_name,
10003,b.responsibility_name,10004,d.user_name) LValue,
nvl(a.profile_option_value,’Is Null’) Value
from fnd_profile_option_values a, fnd_responsibility_tl b,
fnd_application c, fnd_user d, fnd_profile_options e
where e.profile_option_name in (‘ORG_ID’,'DEFAULT_ORG_ID’, ‘XLA_MO_SECURITY_PROFILE_LEVEL’,'XLA_MO_TOP_REPORTING_LEVEL’)
and e.profile_option_id = a.profile_option_id
and a.level_value = b.responsibility_id (+)
and a.level_value = c.application_id (+)
and a.level_value = d.user_id (+)
order by 1,2;

2. To get detail of profile options setup at user level :

select substr(e.profile_option_name,1,35) Profile,
decode(a.level_id,10001,’Site’,10002,’Application’,10003,’Resp’,10004,’User’) L,
decode(a.level_id,10001,’Site’,10002,c.application_short_name,
10003,b.responsibility_name,10004,d.user_name) LValue,
nvl(a.profile_option_value,’Is Null’) Value
from fnd_profile_option_values a, fnd_responsibility_tl b,
fnd_application c, fnd_user d, fnd_profile_options e
where e.profile_option_name in (‘ORG_ID’,'DEFAULT_ORG_ID’, ‘XLA_MO_SECURITY_PROFILE_LEVEL’,'XLA_MO_TOP_REPORTING_LEVEL’)
and e.profile_option_id = a.profile_option_id
and a.level_value = b.responsibility_id (+)
and a.level_value = c.application_id (+)
and a.level_value = d.user_id (+)
and decode(a.level_id,10001,’Site’,10002,’Application’,10003,’Resp’,10004,’User’) = ‘User’
and decode(a.level_id,10001,’Site’,10002,c.application_short_name,10003,b.responsibility_name,10004,d.user_name) in (‘&user_name’ ) — enter fnd user name
order by 1,2;

3. To get detail of profile options setup at Site and Application level :

select substr(e.profile_option_name,1,35) Profile,
decode(a.level_id,10001,’Site’,10002,’Application’,10003,’Resp’,10004,’User’) L,
decode(a.level_id,10001,’Site’,10002,c.application_short_name,
10003,b.responsibility_name,10004,d.user_name) LValue,
nvl(a.profile_option_value,’Is Null’) Value
from fnd_profile_option_values a, fnd_responsibility_tl b,
fnd_application c, fnd_user d, fnd_profile_options e
where e.profile_option_name in (‘ORG_ID’,'DEFAULT_ORG_ID’, ‘XLA_MO_SECURITY_PROFILE_LEVEL’,'XLA_MO_TOP_REPORTING_LEVEL’)
and e.profile_option_id = a.profile_option_id
and a.level_value = b.responsibility_id (+)
and a.level_value = c.application_id (+)
and a.level_value = d.user_id (+)
and decode(a.level_id,10001,’Site’,10002,’Application’,10003,’Resp’,10004,’User’) in (‘Site’, ‘Application’)
order by 1,2,3;

4. To get detail of profile options setup at Responsibility level : .

select substr(e.profile_option_name,1,35) Profile,
decode(a.level_id,10001,’Site’,10002,’Application’,10003,’Resp’,10004,’User’) L,
decode(a.level_id,10001,’Site’,10002,c.application_short_name,
10003,b.responsibility_name,10004,d.user_name) LValue,
nvl(a.profile_option_value,’Is Null’) Value
from fnd_profile_option_values a, fnd_responsibility_tl b,
fnd_application c, fnd_user d, fnd_profile_options e
where e.profile_option_name in (‘ORG_ID’,'DEFAULT_ORG_ID’, ‘XLA_MO_SECURITY_PROFILE_LEVEL’,'XLA_MO_TOP_REPORTING_LEVEL’, ‘FND_INIT_SQL’)
and e.profile_option_id = a.profile_option_id
and a.level_value = b.responsibility_id (+)
and a.level_value = c.application_id (+)
and a.level_value = d.user_id (+)
and decode(a.level_id,10001,’Site’,10002,’Application’,10003,’Resp’,10004,’User’) in (‘Resp’)
and upper(decode(a.level_id,10001,’Site’,10002,c.application_short_name,10003,b.responsibility_name,10004,d.user_name)) like upper(‘%&resp_name%’)
order by 1,2,3;

AGIS – Transaction Processing

Now we are ready with the setups for processing AGIS transaction. Login using Initiator Account . In our example BCR_S (Singapore is the initiator) and select Outbound transaction

32

This is the first form for data entry. notice the Transaction type, Initiator fields entered at the top of the screen.

In the second half, Receipient Details are entered.

33

The next screen is to complete accounting from the initiator side. Click on Add line button and enter The second effect of transaction from initiator side.

34
Once the transaction entry is complete click On Submit button.
After submition you can see the status of the transaction appears as “Submitted” which is Shown below

35

Now Login as Recipient. in our example BCR_J (Japan is Our Recipient)
and click on Inbound transaction as shown below

36

Query for the same batch number. And you will find the Status of the trasaction appears as “Received” for the Recipient.

37

Click on update icon for entering Recipient side accounting information.
38

39

40

41

42

43

44

Login to Intercompany Super user responsibility assigned to our user. The First step is defining organizations. These are the organizations which will be used by AGIS

Navigation: Intercompany Super user>>Setup>> Organization
15

Define Organization as shown below.
16

Similarly create organization for Japan legal entity also. And Query the same in organization form for confirming your creation. Note that in the above Screen while creating organization select ‘Yes’ for enabled column. This flag indicates that this organization is enabled for intercompany transactions. Without this processing of transactions in those organizations, through AGIS is not possible

17

Next Step is to security definition. Security is defined as, which user/person will have access to which and how many intercompany organizations
Navigation: Intercompany Super User>>Setup>>security

Query the Person name and the Respective organization on which the person should be given access. And enable “Yes” for the options as shown below

18

In the same way shown above give access for BCR_S to Singapore Org. and BCR_J to Japan Org.

Next set is to define Transaction types in AGIS.
Your transaction type will decide whether invoicing is required for the transaction and manual approval is required.

19

Our next step inthe process is to define AGIS system options

20

Next we will define invoicing options
21

Under invoicing option Define Receivable Assignment and Customer/Supplier association as shown in the below screen shots

22

Example setup of one of the operating unit is shown in figure.
Note that Receivables Transaction Type and Receivables Memo lines can be linked only id Receivable setups are complete.If those setups are not complete then trhe LOV will not appear.The values like “Intercompany” , “Global Intercompany” respectively are seeded values in Receivables. These have been specifically seeded in Receivables for AGIS

23

In the above step definition of Customer/ Supplier Association is done.There are two tabs in the setup.
1.Customer/Supplier association tab to define the Association
2.Trading partner tab to reviewthe earlier Created association.

24

25

The second step in the creation of customer supplier association is selection of customer and entering a “Bill To Site” for the customer
Note that both are mandatory.

26

27

28

29

30

31

With this we have completed AGIS setup required for processing AGIS transactions We will discuss on AGIS Transaction process in the next part.

Older Posts »