Wednesday 23 January 2008

Oracle IAS 10g 10.1.3.1 Installation on Enterprise Linux 5

Yesterday I completed my first installation of Oracle SOA Suite 10.1.3.1 on Oracle Enterprise Linux 5. In order to complete the installation I followed Metalink Note:465159.1, which explains the exact procedure.

Now the only tip I can give you, is to make sure that the /etc/hosts file contains a line that resolves the locally or DNS assigned computer name and domain to the machines network IP address.

My up until now experience has been with SuSE systems only, so on my machine the /etc/hosts/ file always contains a line like

10.5.1.8 lxbakalidis.shelman.int lxbakalidis

An OEL installation hosts file only contains

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain   localhost       lxBakalidis
::1     localhost6.localdomain6 localhost6

... but this is not enough. The installation completed successfully only after I added the line that resolved the external IP to my computer name. So the final etc/hosts file looked something like this :

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain   localhost       lxBakalidis
::1     localhost6.localdomain6 localhost6
10.5.1.8 lxbakalidis.shelman.int lxbakalidis

The symptoms before that were: First OUI was taking a very long time to do the file copy operation and next when at some point installation would complete, then two out of three configuration assistants would fail.

Friday 11 January 2008

ABAP Get the value of a date type characteristic

When an object is classified with characteristics of type date then, using BAPI BAPI_OBJCL_GETCLASSES these characteristics are returned as numeric. That means that entries for date characteristics are found in the valuesnum array which --as you remeber from a couple of postings back -- is defined to be a standard table of bapi1003_alloc_values_num.

When I first saw this I thought that the actual date value could be acquired by assigning the value_from part of the returned bapi1003_alloc_values_num structure to a date variable, but it was not at all like this. The actual value is stored like an integer representing the ABAP internal date fromat which is YYYYMMDD. So an integer value like 20080112 represents January 12th 2008.

In ABAP code this translates as follows

  DATA :
    temp_int TYPE i,
    temp_date_str(8) TYPE c, 
    my_date TYPE d.

  FIELD-SYMBOLS :
     TYPE bapi1003_alloc_values_num.

      READ TABLE valuesnum
        WITH KEY charact = 'MY_DATE_CHARACT'
        ASSIGNING .

      IF sy-subrc = 0.
        temp_int = -value_from.
        temp_date_str = temp_int.
        my_date = temp_date_str.
      ENDIF.

Java: Dates/Times and Calendars

The problem that many new Java programmers -- me included -- face when they start dealing with dates and times is : Given a java.util.Date object get month, date and year fields in separate variables.

The usual misunderstanding here is that the class java.util.Date is almost deprecated and all things you expect to be able to perform with dates are done using the java.util.Calendar; class.

Calendar is an abstract class whose javadoc can be found here. The class provides get and set methods that allow you to alter any of the fields that constitute a point in time. The following example demonstrates one way to calculate the date corresponding to the start of the current term, using the Calendar get and set functions. It also shows how to convert a Date to a Calendar and vice versa.

    private void calStartOfCurrentTerm()
    {
        // create a new Gregorian Calendar
        Calendar c = new GregorianCalendar();
        // you can synchronize a Calendar with a date by using the
        // setTime() method
        c.setTime( new Date());
        
        // once you get a Calendar extracting field information is 
        // as easy as ....
        int month = c.get( Calendar.MONTH);
        int day = c.get(Calendar.DAY_OF_MONTH);
        int year = c.get(Calendar.YEAR);
        
        // let's calculate the date that corresponds to the 
        // start of the current term
        int newMonth;
        
        switch (month) {
        case Calendar.JANUARY:
        case Calendar.FEBRUARY:
        case Calendar.MARCH:
            newMonth = Calendar.JANUARY;
            break;
        case Calendar.APRIL:
        case Calendar.MAY:
        case Calendar.JUNE:
            newMonth = Calendar.JANUARY;
            break;
        case Calendar.JULY:
        case Calendar.AUGUST:
        case Calendar.SEPTEMBER:
            newMonth = Calendar.JULY;
            break;
        default:
            newMonth = Calendar.OCTOBER;
        }
        
        // adjust the calendar to point to the new date
        c.set(Calendar.MONTH, newMonth);
        c.set(Calendar.DAY_OF_MONTH, 1);
        
        // get the information to a new date variable
        Date startOfTerm = c.getTime();
        
        // display results
        System.out.println("Day is " + day +" month is " + month + " year is " + year);
        System.out.println( startOfTerm.toString());
    }

Here is a slightly different version that returns an object of type oracle.jbo.domain.Date

import java.sql.Timestamp;

import java.util.Calendar;
import java.util.GregorianCalendar;

import oracle.jbo.domain.Date;

  private Date getStartOfTerm()
  {
    // create a new Gregorian Calendar
    Calendar c = new GregorianCalendar();

    // once you get a Calendar extracting field information is 
    // as easy as ....
    int month = c.get(Calendar.MONTH);

    // let's calculate the date that corresponds to the 
    // start of the current term
    int newMonth;

    switch (month) {
      case Calendar.JANUARY:
      case Calendar.FEBRUARY:
      case Calendar.MARCH:
        newMonth = Calendar.JANUARY;
        break;
      case Calendar.APRIL:
      case Calendar.MAY:
      case Calendar.JUNE:
        newMonth = Calendar.JANUARY;
        break;
      case Calendar.JULY:
      case Calendar.AUGUST:
      case Calendar.SEPTEMBER:
        newMonth = Calendar.JULY;
        break;
      default:
        newMonth = Calendar.OCTOBER;
    }

    // adjust the calendar to point to the new date
    c.set(Calendar.MONTH, newMonth);
    c.set(Calendar.DAY_OF_MONTH, 1);
    c.set(Calendar.HOUR_OF_DAY, 0);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MILLISECOND, 0);
    
    // get the information to a new date variable
    java.util.Date javaDate = c.getTime();
    Timestamp st = new Timestamp(javaDate.getTime());
    return new Date(st);
  }

PS:. Finally There is one last thing I have to get used to. "Copy as HTML" on JDeveloper 10g, does not work on openSUSE 10.2.

Thursday 10 January 2008

ABAP Obtaining characteristics of a document from the classification system

In addition to a previous post regarding getting classification information for objects of type Material or Batch and thanks to additional info and feedback that I received from our MM specialist Ms Marilena Svolaki, I will be able to provide an example of how to do the same thing with documents.

Master information about documents is found in the DRAW table. (This is short for German Dokumentinformationssatz). The key fields for each document are displayed in the following image :

Creating the object key for BAPI_OBJCL_GETCLASSES is performed by concatenating the document type (field DRAW-DOKAR), the document number (field DRAW-DOKNR), the document version (field DRAW-DOKVR) and the document part (field DRAW-DOKTL). In code this can be expressed as follows

 DATA
    wa_draw TYPE draw, 
    cur_bapi_objectkey LIKE inob-objek,

    class_list TYPE STANDARD TABLE OF bapi1003_alloc_list,
    valueschar TYPE STANDARD TABLE OF bapi1003_alloc_values_char,
    valuescurr TYPE STANDARD TABLE OF bapi1003_alloc_values_curr,
    valuesnum  TYPE STANDARD TABLE OF bapi1003_alloc_values_num,
    return     TYPE STANDARD TABLE OF bapiret2.

*   Make wa_draw somehow correspond to a valid document entry ....     
    CONCATENATE wa_draw-dokar
                wa_draw-doknr
                wa_draw-dokvr
                wa_draw-doktl
                INTO cur_bapi_objectkey.

*   Call BAPI to get the list of characteristics
    CALL FUNCTION 'BAPI_OBJCL_GETCLASSES'
    EXPORTING
      objectkey_imp         = cur_bapi_objectkey
      objecttable_imp       = 'DRAW'
      classtype_imp         = '017'
      read_valuations       = 'X'
      keydate               = sy-datum
*     language              = 'E'
    TABLES
      alloclist             = class_list
      allocvalueschar       = valueschar
      allocvaluescurr       = valuescurr
      allocvaluesnum        = valuesnum
      return                = return.

    READ TABLE return INDEX 1 ASSIGNING <ret>.

*   Check that object allocations exist
    IF  sy-subrc = 0 AND
        <ret>-id = 'CL' AND
        <ret>-number = 741.

*      Read characteristic values
       ...
    ENDIF