Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remaining text does not appear to be part of the formula problem

Status
Not open for further replies.

Siggy19

Technical User
Jan 6, 2003
141
US
I have a crystal report which calculates the hours worked between two datetimes.

It works fine in Crystal, but we use a standalone program called Reporter (about which I know nothing !) to run reports and the report does NOT work from there. It gives me the following error;
_____________

There was a problem opening that report. Please contact your network
administrator. Error = 'Error in formula <TT_HourlyTurnTime>.
'
'
The remaining text does not appear to be part of the formula.'.
_____________

The really annoying thing is that it appears to work on everyone else's machine, but I cannot release it until I know what the problem is, just in case.

HELP !

The formula concerned is;
_________________

Code:
EvaluateAfter ({@TT_SetupHolidayList});
EvaluateAfter ({@TT_StartDate});
EvaluateAfter ({@TT_EndDate});

// Function:    TT_HourlyTurnTime
// Written by:  Simon Holzman
// Date:        2 January 2003
// Amendments:
//              01/02/03    Sample amendment description


// This is the Hourly Turn Time Calculation.

// It calculates the number of working hours between two datetime values, excluding weekends, holidays and non-working hours.

// For the moment, it assumes that the working hours are always 8am to 6pm, Monday to Friday.
// If it is necessary to change these hours, they can either be changed explicitly here, or a function can be created to calculate them
// even making them different for different periods or days, if needed.

timeVar XTT_WorkDayStartTime := Time (08, 00, 00);
timeVar XTT_WorkDayEndTime := Time (18, 00, 00);

// The original version is in the Crystal Report &quot;HourlyTurnTime&quot;.

// It is also used by the following Crystal Reports;
//      dynreport:\Default\1\SampleReportName.rpt

// ALWAYS update this version and copy it to the other Crystal Reports listed so that it remains consistent.
// Include the paths and names of any reports that use it so that they can be maintained easily.

// All of the variables declared elsewhere but used by this function start with TT_
// All of the variables which are only used within this function start with XTT_

// The @TT_StartDate must be set to the Start DateTime of the Turn Time period to be calculated.
// The @TT_EndDate must be set to the End DateTime of the Turn Time period to be calculated.

// It also NEEDS the @TT_SetupHolidayList function which MUST be in the report header, although it can be suppressed so that it
// is not visible.

// The result of this function is a number giving the total working hours (including decimals where 0.5 = 30 minutes)


// Calculate the Hourly Turn Time version of the Start DateTime setting the start time to XTT_StartTime if it is on
// a weekend or a holiday.


global dateVar array TT_HolidayList;

datevar XTT_CheckDate := date({@TT_StartDate});
timevar XTT_CheckTime := time({@TT_StartDate});
datevar XTT_EndDate := date({@TT_EndDate});
timevar XTT_EndTime := time({@TT_EndDate});

numbervar XTT_WorkingHours := 0;


// If the Start Time is not within normal working hours, adjust it to the start of the next working period.

if XTT_CheckTime < XTT_WorkDayStartTime then 
    XTT_CheckTime := XTT_WorkDayStartTime;

if XTT_CheckTime > XTT_WorkDayEndTime then
(
    XTT_CheckDate := XTT_CheckDate + 1;
    XTT_CheckTime := XTT_WorkDayStartTime
);


// If the End Time is not within normal working hours, adjust it to the start of the next working period.

if XTT_EndTime < XTT_WorkDayStartTime then 
    XTT_EndTime := XTT_WorkDayStartTime;

if XTT_EndTime > XTT_WorkDayEndTime then 
(
    XTT_EndDate := XTT_EndDate + 1;
    XTT_EndTime := XTT_WorkDayStartTime
);


// Check each day between the two dates and accumulate the hours worked.

while XTT_CheckDate < XTT_EndDate do
(
    if not(DayOfWeek(XTT_CheckDate, crMonday) > 5) and not(XTT_CheckDate in TT_HolidayList) then
        XTT_WorkingHours := XTT_WorkingHours
            + (datediff('n', cdatetime(CurrentDate, XTT_CheckTime), cdatetime(CurrentDate, XTT_WorkDayEndTime)) / 60);

    XTT_CheckDate := XTT_CheckDate + 1;
    XTT_CheckTime := XTT_WorkDayStartTime
);

if ((DayOfWeek(XTT_CheckDate, crMonday) < 6) and not (XTT_CheckDate in TT_HolidayList)) then
    XTT_WorkingHours := XTT_WorkingHours
            + (datediff('n', cdatetime(CurrentDate, XTT_CheckTime), cdatetime(CurrentDate, XTT_EndTime)) / 60);


// Output from the Formula ... Working Hours

XTT_WorkingHours;
_________________


The @TT_SetupHolidayList is in the report header, but is suppressed. Frankly, I'd prefer to read the holiday info from the database as a totally seperate query to be run each time the report runs, but I couldn't work out how and didn't need to waste any more time on this !

_________________

Code:
// @TT_SetupHolidayList function

// This is used for the Hourly Turn Time Calculation in the @TT_HourlyTurnTime Function. See that for more  information.
// This function is used to store the Holiday Dates and  MUST be updated each year.
// It MUST be in the report header, although it can be  suppressed so that it is not visible.


BeforeReadingRecords;

global dateVar array TT_HolidayList := [
Date(2000,1,1),
Date(2000,11,23),
Date(2000,11,24),
Date(2000,12,25),
Date(2001,1,1),
Date(2001,1,15),
Date(2001,1,19),
Date(2001,5,28),
Date(2001,7,4),
Date(2001,9,3),
Date(2001,11,22),
Date(2001,11,23),
Date(2001,12,25),
Date(2002,1,1),
Date(2002,1,21),
Date(2002,2,18),
Date(2002,5,27),
Date(2002,7,4),
Date(2002,9,2),
Date(2002,11,28),
Date(2002,11,29),
Date(2002,12,25),
Date(2003,1,1),
Date(2003,1,20),
Date(2003,2,17),
Date(2003,5,26),
Date(2003,7,4),
Date(2003,9,1),
Date(2003,11,27),
Date(2003,11,28),
Date(2003,12,25)
];

count(TT_HolidayList)
_________________
 
Dear Siggy,

I looked at this and didn't see anything jump out. You say it works on others' machines, is that even with this reporter? What version of Crystal Reports?

ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Hi there

I think the important part here is

&quot;It works fine in Crystal, but we use a standalone program called Reporter (about which I know nothing !) to run reports and the report does NOT work from there. It gives me the following error;&quot;

This isn't a reporter forum which may not be helpful :)

Transcend
[gorgeous]
 
Dear Siggy19,

Did it ever. Do any custom reports of the version of Crystal you are using to create this report work in this application.

Are there documented requirements? Sometimes, for packages (especially client/server apps) the dlls must reside not only in /Winnt/Crystal but also in their app directory.

A quick google search on Reporter + Crystal Reports showed that was way too vagure <smile> - some specifics on this application and we might be able to hunt down the issue.

One thing I would do is:

Take out all the comments // it might be choking on them since there are a lot or move all the comments after the formula

Does that make a difference?

ro


Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
I suspect you have some workstations on an older version of Crystal. Both the datediff() and DayofWeek() functions are fairly new, starting with Crystal v8.

If you have v7 of crystal somewhere, it will give you exactly this message if it encounters either of these functions. Software Sales, Training and Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
To clarify... the report works fine on my machine when using Crystal directly. It also works fine on OTHER machines, whether they are using Crystal or using the &quot;Reporter&quot; program. Other reports work fine on my machine. My version of Crystal is version 8.5 but I don't know what the runtime version that Reporter uses is (or even if it varies from machine to machine <sigh>)

Thus, since I cannot test every single machine, I want to try to identify why the report is failing ONLY on my machine, since it may be a bigger problem than it appears.

dgillz comments about datediff and dayofweek sounded possible, since that is probably the situation we are in, except that I replaced those with date calculations and still had the same problem. Are there any other version 8 specific commands that I should replace ?

Is there any way to put Crystal runtime into a debug mode or something ?

Thank you all for your help, this is an amazing resource !
 
Hey Siggy19,

What is this reporter tool? Is this a module in a specific application or a stand alone application. It may help to solve the problem to have more info on it. You stated that other Reporter reports work fine in reporter on your machine. Did you create any of those? Have you tried opening an existing report that works in Reporter and Saving with a new name and running in reporter.

Another thing, if when you go to save said report it states Do you want to update this is a Crystal 7.0 report - then there is your big clue.

Finally, what was the date calculation you replaced it with that also does not work? Also, if you remove the entire formula and save - does it work then?

Just trying to narrow down why this particular report doesn't work.

ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Okay... I have found the problem... It's version 7 compatibility. The Crystal runtime used by Reporter is Version 7 while I have been developing under version 8.5

The other machines I tested on had upgraded Crystal since installing Reporter which gave them a more up-to-date Crystal Runtime. I installed Reporter after Crystal...

<sigh>

I've managed a fiddle for all the incompatibilities so far except for the while loop. Was there any way to loop in Version 7 ?

Thank you all for your help. You've been great.
 
Siggy,

Several years ago I developed an App called Reporter that installed Cr7 run time files. It was only every installed at one site in New Zealand, so I suspect you have an app that has a similar name. The original evolved into my cView report viewer and cViewMANAGER report scehduler.

Can you contact me directly (bruce@chelseatech.co.nz) if you want a report viewer that supports Cr8.0, Cr8.5 and CR9 rpts. Editor and Publisher of Crystal Clear
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top