BrokerDate Problems

A BrokerDate has had the clear() method (Reason no date provided in the event) preformed in a custom operation step. This BrokerDate is mapped to an ODBC insert operation. The ODBC Insert operation then fails with an invalid date format error. (The ODBC debug trace prints nothing for this parameter)

For dates filled in the triggering event the mapping of the BrokerDate from the custom operation step to the ODBC Insert operation step works fine and the ODBC row insert is performed.

I have also set the ODBC insert operation mapping for the date column to ‘not assigned’ and the ODBC insert operation inserts the row just fine.

This leads me to believe that I am some how not setting the BrokerDate correctly for non-existent dates.

PS: Using 4.1.1 Adapter with the latest service packs. EI 4.1.1 and Broker Server 4.1

Thanks in advance

The best way to set fields for NULL values is to not set them at all. A cleared BrokerDate is all zeroes, which is usually not welcomed by the DBs.

Test the value of the incoming date to determine whether or not to set the BrokerDate field. If the incoming String/Date/whatever is not set, don’t set the BrokerDate field–or set it to the current date/time to provide a default.

If what you have is a BrokerDate already, use BrokerEvent.clearField() to unset the field completely. That should do the trick.

Thanks, I have tried not assigning(setting) any value to the out.EXPDATE field if my string date in is null. But to no avail I still experance the insert error. So How would I do the same thing you suggested with the event field with the out.EXPDATE BrokerDate in my custom step?

Is the Allow unset Fields checkbox checked?

Yes the ‘allow unset fields’ checkbox is checked.

Current incantation of code looks like (see Below)
Previous incantation of code I would not assign anything to the out.LOTEXPDATE if the string date field in was blank and the next operation errored out…

customStep_ConvertJDEDatestoMSSQL_method$out out = new customStep_ConvertJDEDatestoMSSQL_method$out();

/* begin custom code */
out.$LOTEXPDATE = true;
out.$PROMDELDATE = true;
out.$RECEIPTDATE = true;
out.$DATETIME = true;
out.$PROCESSTIME = true;

out.LOTEXPDATE = DDDDYYYYTimetoBrokerDate( LOTEXPDATE, “” );
out.PROMDELDATE = DDDDYYYYTimetoBrokerDate( PROMDELDATE, “” );
out.RECEIPTDATE = DDDDYYYYTimetoBrokerDate( RECEIPTDATE, “” );

/* end custom code */

return out;
}

public static class customStep_ConvertJDEDatestoMSSQL_method$in { 
    public String LOTEXPDATE; 
    public boolean $LOTEXPDATE; 
    public String PROMDELDATE; 
    public boolean $PROMDELDATE; 
    public String RECEIPTDATE; 
    public boolean $RECEIPTDATE; 
    public String DATETIME; 
    public boolean $DATETIME; 
    public String PROCESSTIME; 
    public boolean $PROCESSTIME; 
} 

public static class customStep_ConvertJDEDatestoMSSQL_method$out { 
    public BrokerDate LOTEXPDATE; 
    public boolean $LOTEXPDATE; 
    public BrokerDate PROMDELDATE; 
    public boolean $PROMDELDATE; 
    public BrokerDate RECEIPTDATE; 
    public boolean $RECEIPTDATE; 
    public BrokerDate DATETIME; 
    public boolean $DATETIME; 
    public BrokerDate PROCESSTIME; 
    public boolean $PROCESSTIME; 
} 


/* begin custom code */ 
public static BrokerDate DDDDYYYYTimetoBrokerDate(String dateIn, String timeIn ){ 

// Assumption made that dateIn is in the following format DDD/YYYY
// Assumption made that timeIn is in the following format HH:MI:SS

// Set up objects one time.
BrokerDate brokerDateObject = new BrokerDate();
Calendar calendarObject = new GregorianCalendar();
Date dateObject = new Date();

try {
if ( dateIn.length() > 4 ) { // We think we have a date
// clear calendar values
calendarObject.clear();

// set calendar year 
calendarObject.set(Calendar.YEAR, Integer.parseInt(dateIn.substring( 4, dateIn.length() ) ) ); 

// set calendar day of year to input julian day of year 
 calendarObject.set(Calendar.DAY_OF_YEAR, Integer.parseInt(dateIn.substring( 0, 3 ) ) ); 

// set time objects 
if ( timeIn.length() > 7 ) { // We think we have a time 
 try { 
  calendarObject.clear(Calendar.HOUR); 
  calendarObject.clear(Calendar.MINUTE); 
  calendarObject.clear(Calendar.SECOND); 
  //System.out.println("Hour=" + timeIn.substring( 0, 2 ) + "\n" ); 
  //System.out.println("Minute=" + timeIn.substring( 3, 5 ) + "\n" ); 
  //System.out.println("Second=" + timeIn.substring( 6, 8 ) + "\n" ); 
  // set calander hour 
  calendarObject.set(Calendar.HOUR, Integer.parseInt(timeIn.substring( 0, 2 ) ) ); 
  // set calancer minutes 
  calendarObject.set(Calendar.MINUTE, Integer.parseInt(timeIn.substring( 3, 5 ) ) );

The doc doesn’t describe how the $ entries are to be used, but have you tried setting out.$LOTEXPDATE to false when you left it null? Just taking a stab in the dark…

Thanks Rob, you are a savior.

It worked.

Does mapping any other Date object into the configured operation input field work? Have you tried mapping in the _env.recvTime field, for example?

Are you able to capture your SQL INSERT statement using the debug log and successfully execute the INSERT from TOAD or some other environment?