Tuesday, May 12, 2020

Playing with Dates in Oracle Application Framework (OAF)

//Playing with Dates in Oracle Application Framework (OAF)

//below classes are used in the examples:

oracle.jbo.domain.Date;
oracle.jbo.domain.Timestamp;
java.sql.Date;
java.sql.Timestamp;
java.util.Date;
java.util.Calendar;
java.text.DateFormat;
java.text.SimpleDateFormat;
java.lang.String;

//1. Get the current Date time.

    Using java.util.Date.

 import java.util.Date; 

 Date utilDate = new Date();  
 System.out.println("utilDate :" + utilDate);  

    Using oracle.jbo.domain.Date.

 import java.sql.Timestamp;                  
 import oracle.jbo.domain.Date; 

 Timestamp sqlTimestamp = new Timestamp(System.currentTimeMillis());   
 Date jboDomainDate = new Date(sqlTimestamp); 
 System.out.println("jboDomainDate :" + jboDomainDate); 

    Using java.util.Calendar.

 import java.util.Calendar; 

 Calendar utilCalendar = Calendar.getInstance();  
 System.out.println("utilCalendar :" + utilCalendar); 

//2. Get the current Date time in oracle.jbo.domain.Date and add 10 hours to that and get the time back in oracle.jbo.domain.Date along with the time component.

 import oracle.jbo.domain.Date; 
 import java.sql.Timestamp; 
 import java.util.Calendar; 

 Timestamp datetime = new Timestamp(System.currentTimeMillis());  
 Date jboDomainStartDate = new Date(datetime);  
 System.out.println("jboDomainDate :" + jboDomainStartDate);
 
 Calendar utilCalendar = Calendar.getInstance();  
 utilCalendar.setTime(jboDomainStartDate.getValue());  
 System.out.println("utilCalendar Start:" + utilCalendar.getTime());
  
 int hoursToAdd = 10;  
 utilCalendar.add(Calendar.HOUR, hoursToAdd);  
 System.out.println("utilCalendar End:" + utilCalendar.getTime());
  
 Timestamp sqlTimeStampEnd = new Timestamp(utilCalendar.getTime().getTime());  
 Date jboDomainEndDate = new Date(sqlTimeStampEnd);  
 System.out.println("jboDomainEndDate :" + jboDomainEndDate);
 

//3. To print the Current time in DD-MON-YYYY HH24:MI:SS format.

 import java.text.SimpleDateFormat; 
 import java.text.DateFormat; 
 import java.util.Calendar; 

 DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); 
 Calendar cal = Calendar.getInstance();
 String dateStr = dateFormat.format(cal.getTime());   
 System.out.println("Current Time : " + dateStr); 

Refer: Class SimpleDateFormat
//4. To get the oracle.jbo.domain.Date in DD-MON-YYYY HH24:MI:SS format.

 import java.text.SimpleDateFormat; 
 import java.text.DateFormat; 
 import java.util.Calendar; 

 // This is a sample code to initialize the domain Date
 Timestamp datetime = new Timestamp(System.currentTimeMillis());  
 Date jboDomainDate = new Date(datetime);
        
 DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); 
 String dateStr = dateFormat.format(jboDomainDate.getValue());  
 System.out.println("Current Time : " + dateStr); 

//5. To get the difference between two oracle.jbo.domain.Date in days.

 import oracle.jbo.domain.Date; 

 Date jboDomainStartDate = null; 
 Date jboDomainEndDate  = null;

 // Code to get the date Values has to be written here
 
 int diffDays = (int)((jboDomainEndDate.getValue().getTime() - jboDomainStartDate.getValue().getTime()) / (1000 * 60 * 60 * 24)); 
 System.out.println("Diff in days:"+ diffDays); 

//6. To convert string oracle.jbo.domain.Date.

 import java.text.SimpleDateFormat;  
 import java.text.DateFormat; 
 import oracle.jbo.domain.Date; 

 try 
 { 
      DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy"); 
      java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse("10-JAN-2010").getTime());  
      Date jboDomainDate = new Date(sqlDate); 
 }catch(Exception e) { 
      System.out.println(e.getMessage()); 
      // throw appropirate Error Message 
 } 

//7. Calculate the age based on the Date of Birth from a oracle.jbo.domain.Date.

  import oracle.jbo.domain.Date;  
  import java.util.Calendar; 

  Date doB = null; 
  // get the DOB and populate the doB variable 
    
  Calendar dob = Calendar.getInstance(); 
  dob.setTimeInMillis(doB.getValue().getTime()); 
    
  Calendar sysDate = Calendar.getInstance(); 
    
  int age = sysDate.get(Calendar.YEAR) - dob.get(Calendar.YEAR); 
    
  if ((dob.get(Calendar.MONTH) > sysDate.get(Calendar.MONTH)) 
       ||  
      (dob.get(Calendar.MONTH) == sysDate.get(Calendar.MONTH) &&  
           dob.get(Calendar.DAY_OF_MONTH) > sysDate.get(Calendar.DAY_OF_MONTH))) { 
    age--; 
  } 
  System.out.println("Age:" + age); 

 //8. Calculate the difference between two Dates in OAF


Date StartDate= (Date)CurrentRow.getAttribute("StartDate");
    Date CurrentDate = (Date)am.getOADBTransaction().getCurrentDBDate();
    java.sql.Date sdate = (java.sql.Date) StartDate.dateValue();
    java.sql.Date cdate = (java.sql.Date) CurrentDate.dateValue();
    int days = daysBetween(sdate,cdate );

  public int daysBetween(java.sql.Date d1, java.sql.Date d2){
     return (int)( (d2.getTime() - d1.getTime()) / (1000 * 60 * 60 * 24));
         }

Thursday, April 30, 2020

fmb file version find on application server

--Example of  FNDRSRUN.fmb file version find on application server

cd $AU_TOP/forms/US/
strings -a FNDRSRUN.fmb | grep Header

  FDRCSID('$Header: APPSTAND.fmb 120.6.12010000.6 2010/03/10 12:58  dbowles ship                                                                                                                                                                                                                                                         $');
$Header: APPSTAND.fmb 120.6.12010000.6 2010/03/10 12:58  dbowles ship                                                                                                                                                                                                                                                         $
CFDRCSID('$Header: FNDRSRUN.fmb 120.44.12010000.39 2010/06/15 10:15  ggupta ship                                                                                                                                                                                                                                                         $');
$Header: FNDRSRUN.fmb 120.44.12010000.39 2010/06/15 10:15  ggupta ship

API to Purge Workflow Notifications

 --API to Purge Workflow Notifications
begin
exec wf_purge.total(itemtype => 'HRSSA',itemkey => '458976');
commit;

end;

Monday, April 20, 2020

OAF - Write Diagnostic statements for debug Purposes:

--OAF - Write Diagnostic statements for debug Purposes:
From your contorller :
import oracle.apps.fnd.framework.OAFwkConstants;

String testmsg = "This is a test diagnostic message";
pageContext.writeDiagnostics(this,"TESTDIAG: = " + testmsg ,OAFwkConstants.STATEMENT);

Then set profile option at user level
FND: Diagnostics - set to Yes
FND: Debug Log Enabled - set to Yes --default to NO
FND: Debug Log Level - set to Statement
FND: Debug Log Filename for Middle-Tier - give a path to a log file on the server. (test.log)
FND: Debug Log Level ---%

run the application and search for your diagnostic message in test.log file.

Wednesday, February 19, 2020

Useful DOC IDs

1)How to Change the System Name in Workflow? (Doc ID 387337.1)

==========================================================================================================================

2)How to Manually Process the Events from Workflow Queues When The Deferred Agent Listener Won't Start (Doc ID 953103.1)

==========================================================================================================================

3) How To Create List Of Values With Specific Users In Workflow Notifications (Doc ID 304673.1)

==========================================================================================================================

4) Oracle Application Framework Developer's Guide: Index (Doc ID 1315485.1)

==========================================================================================================================
5) Patch 30543303: ORACLE APPLICATION FRAMEWORK (FWK) RELEASE 12.2.6 BUNDLE 23
==========================================================================================================================
Beginner's Guide: Create a Custom Event Alert to Fire against a Custom Table (Doc ID 103418.1)
==========================================================================================================================
Customization in Oracle Applications (Doc ID 743490.1)
R12: AP: How to Send Email Notifications When Concurrent Requests are Executed? (Doc ID 2254379.1)
Mobile Supply Chain For information on how to configure mobile services on the server and for app-specific information, see My Oracle Support Note 1641772.1 the required setups/configurations as per MOS Note ID: 2108155.1. Oracle MWA Personalization Framework (Doc ID 469339.1) ========================================================================================================================== R12.2.10 OAF enhancements https://blogs.oracle.com/ebstech/oa-framework-12210-bundle-1-released?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+OracleE-BusinessSuiteTechnology+%28Oracle+E-Business+Suite+Technology%29 ========================================================================================================================== ========================================================================================================================== R12: AP: Email Feature For Payables Generic Data fix Patches (Doc ID 1582550.1) ==========================================================================================================================  


Sunday, February 9, 2020

Find file by its contains on linux

grep -r "ACTUAL_END_DATE" *

--Contain is ACTUAL_END_DATE

Responsibilities Sessions

/* Responsibilities Sessions*/

SELECT   usr.user_name, ful.login_id, ses.session_id,
         TO_CHAR (ses.first_connect, 'YYYY/MM/DD HH24:MI:SS') first_connect,
         TO_CHAR (ses.last_connect, 'YYYY/MM/DD HH24:MI:SS') last_connect,
         ses.counter, ses.disabled_flag,
         TO_CHAR (ful.end_time, 'YYYY/MM/DD HH24:MI:SS') end_time,
         TO_CHAR (ful.start_time, 'YYYY/MM/DD HH24:MI:SS') start_time,
         rsp.responsibility_name, fff.user_function_name
    FROM icx_sessions ses,
         fnd_user usr,
         fnd_logins ful,
         fnd_responsibility_tl rsp,
         fnd_form_functions_vl fff
   WHERE 1 = 1
/* joins */
     AND ses.login_id(+) = ful.login_id
     AND ses.responsibility_id = rsp.responsibility_id(+)
     AND ses.responsibility_application_id = rsp.application_id(+)
     AND ses.function_id = fff.function_id(+)
     AND usr.user_id = ful.user_id
     AND rsp.LANGUAGE(+) = USERENV ('LANG')
/* filters */
--and    USR.USER_NAME like nvl(upper('&USER_NAME_FILTER'), '%')
     AND ful.start_time > SYSDATE - 61                 /* two month history */
ORDER BY ful.start_time