Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: First row returned NOT setting to zero as needed Post Reply Post New Topic
Author Message
dlg_az
Newbie
Newbie


Joined: 16 May 2011
Location: United States
Online Status: Offline
Posts: 14
Quote dlg_az Replybullet Topic: First row returned NOT setting to zero as needed
     Posted: 19 Jul 2013 at 1:19pm
I have a formula that has several conditions for calculating time records. 
 
One condition is that when certain pay codes are returned (FMLA, LOA, etc) I set the code to intentionally zero out their hours so they don't get applied in the total field (business policy reasons).
 
The problem is when any of those specific paycodes show up as the very first record in the results it does NOT set that one record to zero but all others DO show zero.
 
I assume this is a function of using whileprintingrecords and "if recordcount + 1 ...." but I don't know how to handle this in the code. 
 
Can anyone help out with some ideas? 
 
-------------------------CODE-----------------------------------

whileprintingrecords; 

global stringvar Multiple;

global numbervar RecordCounter;

global stringvar LastMultipleDate;

global numbervar Applied;

global numbervar Total;

stringvar temp:= cstr({@HoursAbsent});

 

if recordcounter = 1 then

                                (Multiple := "No";

        Applied := {@HoursAbsent};

        temp := Cstr({@HoursAbsent});

        Total := Total + Applied; recordcounter := recordcounter + 1; temp;)

 

else if (Qualify4Multiple (CDate(Previous({MCHP_ABSENCE.ABSENCEDATE})),CDate({MCHP_ABSENCE.ABSENCEDATE}))

          or Previous({MCHP_ABSENCE.ABSENCEDATE}) = {MCHP_ABSENCE.ABSENCEDATE})

          or InStr(GroupName ({MCHP_ABSENCE.PAYCODENAME}), "Intermittent - ")>0.00

          or InStr(GroupName ({MCHP_ABSENCE.PAYCODENAME}), "FMLA - ")>0.00

          or InStr(GroupName ({MCHP_ABSENCE.PAYCODENAME}), "OFLA - ")>0.00

          or InStr(GroupName ({MCHP_ABSENCE.PAYCODENAME}), "OFLA-FMLA ")>0.00

then

        (Multiple := "Yes";   Applied := 0;  temp := "0";

 

        if LastMultipleDate = "N/A"

 

        then

                LastMultipleDate := Cstr(previous({MCHP_ABSENCE.ABSENCEDATE}),"MM/dd/yyyy");

            Total := Total + Applied;

            recordcounter := recordcounter + 1;

            temp;)

                else

            (temp := Cstr({@HoursAbsent});       

            Applied := {@HoursAbsent};

            Total := Total + Applied;

            recordcounter := recordcounter + 1;

            temp; )

------------- END CODE -------------------------------------------------------------------------
 
Example output - specific paycode that needs set to zero, but when paycode appears first in records returned, does NOT zero out while others do:
 
Taken      Applied    Absence Code
-------------------------------------------------------
11.60       11.60       OFLA-FMLA - PA
11.60               0       OFLA-FMLA - PA
11.60               0       OFLA-FMLA - PA
11.60               0       OFLA-FMLA - Unpaid
11.60               0       OFLA-FMLA - Unpaid
11.60       11.60       PA - Charged
11.60       11.60       PA - Charged


Edited by dlg_az - 22 Jul 2013 at 8:54am
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 21 Jul 2013 at 8:36pm
Hi
 
Whatever it is you have to copy and past your formula in the post.  Without seeing your formula no one can answer your query.
 
Please share formula which is causing error.
Thanks,
Sastry
IP IP Logged
dlg_az
Newbie
Newbie


Joined: 16 May 2011
Location: United States
Online Status: Offline
Posts: 14
Quote dlg_az Replybullet Posted: 22 Jul 2013 at 6:22am
Code added plus output example, to my original post.
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 22 Jul 2013 at 7:17am
Hi
 
Applied is refering {@HoursAbsent} formula, can you past that formula in your post.
 
 
Thanks,
Sastry
IP IP Logged
dlg_az
Newbie
Newbie


Joined: 16 May 2011
Location: United States
Online Status: Offline
Posts: 14
Quote dlg_az Replybullet Posted: 22 Jul 2013 at 8:51am
Hi
 
Thanks for your response.
 
 
@hoursabsent is just a formula to convert seconds to standard time:
 
{MCHP_ABSENCE.TIMEINSECONDS} / 3600
 
"Taken" values show as 11.60, for example; it shows total hours taken.
 
The "Applied" field holds the formula @executecompare, which is the code I copied to my original post. 
 
The "Taken" field (formula @hoursabsent) is showing all original hours taken by the employee.  The "Applied" field shows the same hours, except for the specific pay codes I am trying to set to zero in the "Applied" field.
 
The "Applied" field holds the "Taken" hours and is used to determine if the employee is allowed to take additional time off.  There are special circumstance where the hours in Taken do not apply to the Applied field, so those are the ones I want to set to zero hours. 
 
In my original post, I've updated the output example to show the "Taken" field.


Edited by dlg_az - 22 Jul 2013 at 8:55am
IP IP Logged
dlg_az
Newbie
Newbie


Joined: 16 May 2011
Location: United States
Online Status: Offline
Posts: 14
Quote dlg_az Replybullet Posted: 26 Jul 2013 at 7:17am

Anyone else have an idea?

IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum