Aug 28, 2019

Microsoft Visual Basic Run-time error '1004': Method 'VBProject' of object '_Workbook' failed

To fix this issue, pls perform the below setups in MICROSOFT EXCEL to accept the WEBADI transaction in VBProject Workbook.


In Excel, use the following navigation:

Step 1: Open the Microsoft Excel and go to FILE à OPTIONS



Step 2: On the left, click on the Trust Center



Step 3: Click on the Trust Center Settings button and go to Macro Settings and Click on “Trust access to the VBA project object model



Aug 21, 2019

Throw Bundled Exception | OAF Page



  ArrayList bundle=new ArrayList();     //first we have to initialize the Array List

             
  if(empname.contains("@"))
                {
                bundle.add(new OABundleeption("Special character not allowed",OABundleeption.ERROR));
                }
  if("".equalsIgnoreCase(pageContext.getParameter("StartDate").trim()))
                {
                bundle.add(new OABundleeption("Start date shold not be null",OABundleeption.ERROR));
                }
  if(!bundle.isEmpty())
                {
                OABundleeption.raiseBundledOABundleeption(bundle);
                }
                }

List all the Parameter names and values | OAF Page



import java.util.Enumeration; 

Enumeration enums = pageContext.getParameterNames(); 
 while(enums.hasMoreElements())
{ 
   String paramName = enums.nextElement().toString(); 
   System.out.println("Param name:-->" +paramName+ ";Value:-->"+pageContext.getParameter(paramName)); 
 }



Create VO Programmatically | Dynamic VO | OAF


ViewObject dynamicViewObject = appModule.findViewObject("XXDynamicVO"); 

 if(dynamicViewObject == null) 
 { 
  String voQuery = " SELECT USER_NAME " + 
                                " FROM fnd_users FU " + 
                                " WHERE FU.user_id = :1 "; 
  customViewObject = appModule.createViewObjectFromQueryStmt("XXDynamicVO",voQuery); 
 } 

 if(customViewObject != null) 
 { 
  customViewObject.setWhereClause(null); 
  customViewObject.setWhereClauseParams(null); 
  customViewObject.setWhereClauseParam(0,userID); 
  customViewObject.executeQuery(); 
  Row customViewObjectRow = customViewObject.first(); 
  if(customViewObjectRow != null) 
  { 
       String userName = (String)customViewObjectRow.getAttribute(0); 
  } 
 }  

Aug 20, 2019

Call PL/SQL Procedure | From OAF Page



 import oracle.jdbc.OracleCallableStatement;  
 import oracle.jdbc.OracleTypes;
 import oracle.jbo.domain.Number;
 import oracle.jbo.domain.Date;
   
 public void callPLSQLProc(Number id,String code,Date currentDate)  
 {  
      OracleCallableStatement callableStatement = null;  
      try  
      {  
           String callProc = " BEGIN xxx_pkg.xxx_proc "+  
                                         "(p_id             => :1," +  
                                         " p_code           => :2," +
                                         " p_date           => :3," +
                                         " p_commit         => :4," +                                                  
                                         " x_return_status  => :5," +  
                                         " x_msg_data       => :6," +  
                                         " x_msg_count      => :7);"+  
                                    " END; ";  
           callableStatement = (OracleCallableStatement)getOADBTransaction().createCallableStatement(callProc,1);  
           callableStatement.setNUMBER(1, id);  
           callableStatement.setString(2, code);          
           callableStatement.setDATE(3, currentDate);    
           callableStatement.setString(4, "Y");     
           callableStatement.registerOutParameter(5,OracleTypes.VARCHAR,255);  
           callableStatement.registerOutParameter(6,OracleTypes.VARCHAR,255);  
           callableStatement.registerOutParameter(7,OracleTypes.NUMBER,255);    
           callableStatement.execute();  
           String resultMessage = (String)callableStatement.getString(5);  
           String msgData  = (String)callableStatement.getString(6);  
      }  
      catch(Exception e)  
      {  
           e.printStackTrace();  
           throw new OAException(e.toString(),OAException.ERROR);  
      }  
      finally  
      {  
           try  
           {  
                callableStatement.close();  
           }  
           catch(Exception exception2)  
           {  
                throw OAException.wrapperException(exception2);  
           }  
      }  
 }        

:1,:2,:3 & :4 è IN Parameter   
:5,:6,:7 è Out Parameter

Call PL/SQL Function | From OAF Page



 import oracle.apps.fnd.framework.server.OADBTransaction; 
 import oracle.jdbc.driver.OracleTypes; 
 import oracle.jdbc.OracleCallableStatement;
 
 public String callFunction( String id) 
 { 
      String status = null;
      OADBTransaction oadbtransaction = getOADBTransaction(); 
      OracleCallableStatement oraclecallablestatement = null; 
      Object obj = null; 
     
      String sqlString = "BEGIN :1:=xx_pkg.xx_func( p_id => :2 ); END;"; 
      
      try 
      { 
           oraclecallablestatement =             (oracleCallableStatement)oadbtransaction.createCallableStatement(sqlString , 1); 
           oraclecallablestatement.registerOutParameter(1, OracleTypes.VARCHAR, 0, 10); 
           oraclecallablestatement.setString(2, id); 
           oraclecallablestatement.executeQuery(); 
           status = String.valueOf(oraclecallablestatement.getString(1)); 
      } 
      catch(Exception exception1) 
      { 
           throw OAException.wrapperException(exception1); 
      } 
      finally 
      { 
           try 
           { 
                oraclecallablestatement.close(); 
           } 
           catch(Exception exception2) 
           { 
                throw OAException.wrapperException(exception2); 
           } 
      } 
      return status ; 
 }  

:1 è Out Parameter to hold results from function.

:2 è IN Parameter   
 




Transient Attributes not getting populated | VO Extension




Scenario:

Standard VO has some transient attributes which gets populated by overriding the getter methods in the VORowmpl. When we extend this VO for adding some additional attributes, everything works except the original transient attributes. Those attributes are coming as null.

The reason is, when the extended VORowImpl is getting generated by the Jdeveloper, it will not call the super method (which is already overridden). So you need to modify the getter method of the Transient attribute in the extended VO to call the getter method in the Standard VO using super.


Standard VORowImpl getter method will be something as shown below.

                                public String getAttribute1() { 
                                                                return "Calculated Value"; 
 }  


Generated getter method in the extended VORowImpl  as shown below.

                                public String getAttribute1() { 
  return (String) getAttributeInternal("Attribute1"); 
 }  
Solution:

To fix this, modify the getter method of the extended VORowImpl as shown below.

                                public String getAttribute1() {  
  //return (String) getAttributeInternal("Attribute1"); 
  return super.getAttribute1();
 }

Useful Workflow Commands

  WFLOAD apps/columbus789 0 Y DOWNLOAD APEXP_FINDEV.wft APEXP Locations: $PO_TOP/patch/115/import/US/porpocha.wft $PO_TOP/patch/115/import/U...