Display calculated data in report but getting last value in every row

Hi i am trying to calculate the sync duration but issue is that its display last value in every row.

IF "WMS Activity Log".FIND('-') THEN REPEAT
IF "WMS Activity Log"."Action Type" = 'SyncStart' THEN BEGIN
CurrentUser := "WMS Activity Log"."User ID";
StartTime := "WMS Activity Log"."Date Time";

IF "WMS Activity Log".FIND('>') THEN
IF "WMS Activity Log"."Action Type" = 'SyncEnd'THEN
If NextUser = CurrentUser then
NextUser := "WMS Activity Log"."User ID";
EndTime := "WMS Activity Log"."Date Time";
TotalDuration := EndTime - StartTime;
END;

UNTIL ("WMS Activity Log".NEXT =0);

Best Answers

  • MubasherMubasher Member Posts: 25
    Answer ✓

    IF ( "WMS Activity Log"."Action Type" = 'SyncStart') AND (CurrentUser <> "WMS Activity Log"."User ID" ) THEN BEGIN
    CLEAR(StartTime);
    CLEAR(TotalDuration);
    CurrentUser := "WMS Activity Log"."User ID";
    StartTime := "WMS Activity Log"."Date Time";
    WMSActivityTemp.INIT;
    WMSActivityTemp.ID := "WMS Activity Log".ID;
    WMSActivityTemp."User ID" := "WMS Activity Log"."User ID";
    WMSActivityTemp.TotalDuration := TotalDuration;
    WMSActivityTemp."Action Type" := "WMS Activity Log"."Action Type";
    WMSActivityTemp.INSERT;
    END;

    IF ("WMS Activity Log"."Action Type" = 'SyncEnd') AND ("WMS Activity Log"."User ID" = CurrentUser) THEN BEGIN
    WMSActivityTemp.INIT;
    WMSActivityTemp.ID := "WMS Activity Log".ID;
    WMSActivityTemp."User ID" := "WMS Activity Log"."User ID";
    WMSActivityTemp.TotalDuration := "WMS Activity Log"."Date Time" - StartTime;
    WMSActivityTemp."Action Type" := "WMS Activity Log"."Action Type";
    WMSActivityTemp."Device ID" := "WMS Activity Log"."Device ID";
    WMSActivityTemp."Date Time" := StartTime;
    WMSActivityTemp.Value := "WMS Activity Log".Value;
    WMSActivityTemp.INSERT;
    CLEAR(CurrentUser);
    END;

Answers

  • MubasherMubasher Member Posts: 25
    @lubost Thanks for reply i just change my logic and solved this problem.
  • MubasherMubasher Member Posts: 25
    Answer ✓

    IF ( "WMS Activity Log"."Action Type" = 'SyncStart') AND (CurrentUser <> "WMS Activity Log"."User ID" ) THEN BEGIN
    CLEAR(StartTime);
    CLEAR(TotalDuration);
    CurrentUser := "WMS Activity Log"."User ID";
    StartTime := "WMS Activity Log"."Date Time";
    WMSActivityTemp.INIT;
    WMSActivityTemp.ID := "WMS Activity Log".ID;
    WMSActivityTemp."User ID" := "WMS Activity Log"."User ID";
    WMSActivityTemp.TotalDuration := TotalDuration;
    WMSActivityTemp."Action Type" := "WMS Activity Log"."Action Type";
    WMSActivityTemp.INSERT;
    END;

    IF ("WMS Activity Log"."Action Type" = 'SyncEnd') AND ("WMS Activity Log"."User ID" = CurrentUser) THEN BEGIN
    WMSActivityTemp.INIT;
    WMSActivityTemp.ID := "WMS Activity Log".ID;
    WMSActivityTemp."User ID" := "WMS Activity Log"."User ID";
    WMSActivityTemp.TotalDuration := "WMS Activity Log"."Date Time" - StartTime;
    WMSActivityTemp."Action Type" := "WMS Activity Log"."Action Type";
    WMSActivityTemp."Device ID" := "WMS Activity Log"."Device ID";
    WMSActivityTemp."Date Time" := StartTime;
    WMSActivityTemp.Value := "WMS Activity Log".Value;
    WMSActivityTemp.INSERT;
    CLEAR(CurrentUser);
    END;
Sign In or Register to comment.