Wednesday 28 October 2015

OAF: Calling AM method from CO in Oracle Application Framework

In this post I just want to put some sample code to show how to call the Application Module (AM) methods from the Controller (CO). The reason for this post with the basics is because, I still see in the OTN forum that AM methods are not called in the recommended approach.

In this post I have given example for methods with parameters, without parameters, couple of different types of parameters and methods with return types.

Sample 1:- AM method without parameter and return type.

AM Method:
 public void methodWithoutParams()  
 {  
   System.out.println("Dummy Method");  
 }  
CO Code:
 import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;  
 OAApplicationModuleImpl appModule = (OAApplicationModuleImpl)pageContext.getApplicationModule(webBean);  
 appModule.invokeMethod("methodWithoutParams");  

Sample 2 :- AM method with parameters and return type.

AM Method:
 public String methodWithParams(String[] strArray,String strVal)  
 {  
      System.out.println("strVal: " + strVal);  
      for(int i = 0; i < strArray.length; i ++)       
      {  
           System.out.println("strArray["+i+"]: " + strArray[i]);  
      }  
      return "Success";  
 }  
CO Code:
 import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;  
 import java.io.Serializable;  
 OAApplicationModuleImpl appModule = (OAApplicationModuleImpl)pageContext.getApplicationModule(webBean);  
 String[] strArray = {"1","2"};  
 String strVal   = "AJ";  
 Serializable[] params = {strArray, strVal};  
 Class[] paramTypes  = {String[].class, String.class};  
 String returnVal = (String)appModule.invokeMethod("methodWithParams", params, paramTypes);  
 System.out.println("returnVal : "+ returnVal);  

If we need to deal with non-Serializable parameters, refer : http://www.adftraining.com/blog/how-to-call-am-methods-from-controller-without-using-invokemethod

Feel free to point out if anything is missing/wrong in this blog.

Monday 26 October 2015

Oracle Apps: Some useful UNIX tips when working on Oracle Apps / Oracle eBusiness

In this post, I just want to put some useful UNIX commands when working on Oracle Apps/ eBusiness. This will be updated frequently with more commands.If you are reading this, you can contribute more commands in the comments and I can reference in this blog (obviously your name against it :)), which can help someone else as well.

#1. How to run .env file.
ENV files needs to be run to set the environment files for the session. I have seen some people try to run the file with 'sh' command and complains that the environment variables are not set. To run the env file, you just type (dot)(space)(filename).
 $ . <file_name>.env  

Related link: What are source environment file settings in Oracle Applications R12

#2. How to search for a file name.
You can search using the find command. 
Just type find(space)(starting directory)(space)-name(space)(file_name)
 find /home -name <file_name>  

More help: In Unix, what is the find command, and how do I use it to search through directories for files?


#3. How to find the version of a file.
You can use any of the below commands to get the header info of a file.
 $ adident Header <file_name>  
 $ strings -a <file_name> | grep Header  

Related links : 
Check Versions of Oracle Applications Components
Oracle Technical : How to find Files Versions and Locations

Feel free to point out if anything is missing/wrong in this blog.

Wednesday 14 October 2015

PL/SQL: Sample code for using PRAGMA AUTONOMOUS_TRANSACTION

In this post I just want to post a sample code (which I use) to write debug in PL/SQL using PRAGMA AUTONOMOUS_TRANSACTION.

The AUTONOMOUS_TRANSACTION pragma changes the way a subprogram works within a transaction. A subprogram marked with this pragma can do SQL operations and commit or roll back those operations, without committing or rolling back the data in the main transaction. Read more
 --create table  
 create table xxaj_debug (id number, msg varchar2(4000), date_stamp date);  
 --create sequence  
 create sequence xxaj_seq start with 1 increment by 1;  
 --create procedure  
 create or replace procedure xxaj_proc ( msg varchar2)  
 is  
      PRAGMA AUTONOMOUS_TRANSACTION;  
 begin  
      insert into xxaj_debug values (xxaj_seq.nextval, msg, sysdate);  
      commit;  
 end;  


Feel free to point out if anything is missing/wrong in this blog.