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

  • Serge Volkov
  • Serge Volkov's Avatar
7 years 9 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 Anmelden to join the conversation.

  • Serge Volkov
  • Serge Volkov's Avatar
7 years 9 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 Anmelden to join the conversation.

Kontakt

  • gs-soft AG

    Delfterstrasse 10

    5000 Aarau

    Schweiz

    Telefon:
    +41 62 832 20 40
    E-Mail:
    Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!


  • Language