Convert-Exception with Timefields and "24:00:00"

  • Serge Volkov
  • Serge Volkov's Avatar
3 years 7 months ago #102 by Serge Volkov
Replied by Serge Volkov on topic Convert-Exception with Timefields and "24:00:00"
Thank you for the detailed answer.
Now, we can reproduce the case.

Really, the problem is that the value "240000" (24:00:00) received from SAP can not be stored in TDateTime (which is a container for values of ABAP type "T") as is. It raises the conversion-exception from EncodeTime.

We have decided to add support of such a corner case in the following way:
SAPx will treat "000000" and "240000" as 0 hours, 0 mins, 0 seconds.

In your case, it should avoid the convert-exception - the value received from SAP will be stored as "000000" internally.

Currently, we are preparing the new version of Connect for SAP - 4.0.5, that will include (among other improvements) the mentioned handling of time-fields. We plan to ship the version this week.

As a quick solution you can replace the mentioned function "SAPxNWParseTime" with:
function SAPxNWParseTime(const ABuffer: string): TDateTime; overload;

  function IsSapMaxTime(AHour, AMin, ASec: Word): Boolean;
  begin
    Result := (AHour = HoursPerDay) and (AMin = 0) and (ASec = 0);
  end;

const
  SESAPxNWTimeConvertError = 'Time can not be encoded [Hours: %d; Minutes: %d; Seconds: %d].';
var
  iHour, iMin, iSec: Word;
begin
  SAPxNWParseTime(ABuffer, iHour, iMin, iSec);
  if not TryEncodeTime(iHour, iMin, iSec, 0, Result) then
  begin
    if IsSapMaxTime(iHour, iMin, iSec) then
      Result := EncodeTime(0, 0, 0, 0)
    else
      SAPxNWRaiseException(Format(SESAPxNWTimeConvertError, [iHour, iMin, iSec]));
  end;
end;

Please Log in to join the conversation.

  • Serge Volkov
  • Serge Volkov's Avatar
3 years 7 months ago #105 by Serge Volkov
Replied by Serge Volkov on topic Convert-Exception with Timefields and "24:00:00"
Hello Ulrich

We have released the new version of Connect for SAP - 4.0.5 .
It includes the mentioned fix for time-fields handling in particular.
Please upgrade to the version.

Please Log in to join the conversation.

Contact US

  • gs-soft AG

    Delfterstrasse 10

    CH-5000 Aarau

    Switzerland

    Phone:
    +41 (0)62 832 20 40
    E-Mail:
    This email address is being protected from spambots. You need JavaScript enabled to view it.


  • Language