Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [Frustrated - Solved (temporarily)] Bug with sorting on a Time field

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[Frustrated - Solved (temporarily)] Bug with sorting on a Time field
 Login/Join
 
Expert
posted
I'm having trouble sorting with a Time field to create a calendar type report.

Test Code:

-SET &ECHO=ON;

-*-- Create the master for TEST1 -------------------------------------
FILEDEF DATAMAST DISK TEST1.MAS
-RUN

-*--
-WRITE DATAMAST FILE=TEST1, SUFFIX=FIX, $
-WRITE DATAMAST SEGNAME=SEG1, SEGTYPE=S0, $
-WRITE DATAMAST FIELD=COUNTRY, ALIAS=COUNTRY, USAGE=A10, ACTUAL=A10, $
-WRITE DATAMAST FIELD=,        ALIAS=FILL1,   USAGE=A01, ACTUAL=A01, $
-WRITE DATAMAST FIELD=WDATE,   ALIAS=WDATE,   USAGE=A08, ACTUAL=A08, $
-WRITE DATAMAST FIELD=,        ALIAS=FILL2,   USAGE=A01, ACTUAL=A01, $
-WRITE DATAMAST FIELD=WTIME,   ALIAS=WTIME,   USAGE=A06, ACTUAL=A06, $
-WRITE DATAMAST DEFINE DTTMX/A25 = WDATE | ' ' | EDIT(WTIME,'99:99:99') | '.000';
-WRITE DATAMAST DEFINE DATETIME/HYYMDS = HINPUT(25, DTTMX, 8, 'HYYMDS');

-*-- Create the data file for TEST1 ----------------------------------
FILEDEF TEST1 DISK TEST1.FTM
-RUN

-WRITE TEST1 ENGLAND    20081112 175305
-WRITE TEST1 CANADA     20081112 083001
-WRITE TEST1 CANADA     20081113 083001
-WRITE TEST1 CANADA     20081113 084213
-WRITE TEST1 CANADA     20081113 101010
-WRITE TEST1 CANADA     20081113 172222
-WRITE TEST1 CANADA     20081113 120934
-WRITE TEST1 CANADA     20081114 140030
-WRITE TEST1 S KOREA    20081114 101030
-WRITE TEST1 S KOREA    20081116 110956
-WRITE TEST1 USA        20081114 171030
-WRITE TEST1 USA        20081116 190956

-*-- Create the report -----------------------------------------------
DEFINE FILE TEST1
STARTDATE/YYMD    = HDATE(DATETIME, 'YYMD');
STARTDATE1/wMtDYY = STARTDATE;
STARTTIME/HHI     = DATETIME;
END
-RUN

TABLE FILE TEST1
PRINT
COUNTRY
DATETIME

BY STARTDATE NOPRINT
ON STARTDATE SUBHEAD
" "
"<STARTDATE1"

BY STARTTIME
END
-RUN

Result:

STARTTIME COUNTRY DATETIME 
  
Wed, Nov 12 2008 
 
08:30     CANADA  2008/11/12 08:30:01 
          ENGLAND 2008/11/12 17:53:05 
  
Thu, Nov 13 2008 
 
08:30     CANADA  2008/11/13 08:30:01 
          CANADA  2008/11/13 08:42:13 
          CANADA  2008/11/13 10:10:10 
          CANADA  2008/11/13 12:09:34 
          CANADA  2008/11/13 17:22:22 
  
Fri, Nov 14 2008 
 
10:10     S KOREA 2008/11/14 10:10:30 
          CANADA  2008/11/14 14:00:30 
          USA     2008/11/14 17:10:30 
  
Sun, Nov 16 2008 
 
11:09     S KOREA 2008/11/16 11:09:56 
          USA     2008/11/16 19:09:56 

Expected result:

STARTTIME COUNTRY DATETIME 
  
Wed, Nov 12 2008 
 
08:30     CANADA  2008/11/12 08:30:01 
17:53     ENGLAND 2008/11/12 17:53:05 
  
Thu, Nov 13 2008 
 
08:30     CANADA  2008/11/13 08:30:01 
08:42     CANADA  2008/11/13 08:42:13 
10:10     CANADA  2008/11/13 10:10:10 
12:09     CANADA  2008/11/13 12:09:34 
17:22     CANADA  2008/11/13 17:22:22 
  
Fri, Nov 14 2008 
 
10:10     S KOREA 2008/11/14 10:10:30 
14:00     CANADA  2008/11/14 14:00:30 
17:10     USA     2008/11/14 17:10:30 
  
Sun, Nov 16 2008 
 
11:09     S KOREA 2008/11/16 11:09:56 
19:09     USA     2008/11/16 19:09:56 

What's going on here?

This message has been edited. Last edited by: Francis Mariani,


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
<JG>
posted
That has got to be one of the strangest things I've seen in a while. Definitely a bug.

This works

 
TABLE FILE TEST1
PRINT
 COMPUTE XSTARTTIME/HHI= STARTTIME;
COUNTRY
DATETIME

BY STARTDATE NOPRINT
ON STARTDATE SUBHEAD
" "
"<STARTDATE1"

BY  STARTTIME NOPRINT
END
-RUN
 
 
Report This Post
Virtuoso
posted Hide Post
This is strange indeed.
It only works as expected when you remove the NOPRINT from the by-field.
I'd make this a case for IBI, since this can not be correct behaviour.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Platinum Member
posted Hide Post
The field you are sorting by STARTDATE has no time component so he result is hardly surprising.
Sort by the field that has the time compnent.
 
Posts: 140 | Location: Adelaide South Australia | Registered: October 27, 2006Report This Post
<JG>
posted
quote:
DEFINE STARTTIME/HHI = DATETIME;

SORT BY STARTTIME


OPALTOSH I seem to be reading different code to you
 
Report This Post
Master
posted Hide Post
I think the problem is in your master definition. This gives you the desired result:
 
-SET &ECHO=ON;

-*-- Create the master for TEST1 -------------------------------------
FILEDEF DATAMAST DISK /usr/ibi/apps/wfmast/test1.mas
-RUN

-*--
-WRITE DATAMAST FILE=TEST1, SUFFIX=FIX, $
-WRITE DATAMAST SEGNAME=SEG1, SEGTYPE=S0, $
-WRITE DATAMAST FIELD=COUNTRY, ALIAS=COUNTRY, USAGE=A10, ACTUAL=A10, $
-WRITE DATAMAST FIELD=,        ALIAS=FILL1,   USAGE=A01, ACTUAL=A01, $
-WRITE DATAMAST FIELD=WDATE,   ALIAS=WDATE,   USAGE=A08, ACTUAL=A08, $
-WRITE DATAMAST FIELD=,        ALIAS=FILL2,   USAGE=A01, ACTUAL=A01, $
-WRITE DATAMAST FIELD=WTIME,   ALIAS=WTIME,   USAGE=A06, ACTUAL=A06, $
-WRITE DATAMAST DEFINE DTTMX/A25 = WDATE | ' ' | EDIT(WTIME,'99:99:99') | '.000';
-WRITE DATAMAST DEFINE DATETIME/HYYMDS = HINPUT(25, DTTMX, 8, 'HYYMDS');

-*-- Create the data file for TEST1 ----------------------------------
FILEDEF TEST1 DISK /cisfocrpt/data/test.dat
-RUN

-WRITE TEST1 ENGLAND    20081112 175305
-WRITE TEST1 CANADA     20081112 083001
-WRITE TEST1 CANADA     20081113 083001
-WRITE TEST1 CANADA     20081113 084213
-WRITE TEST1 CANADA     20081113 101010
-WRITE TEST1 CANADA     20081113 172222
-WRITE TEST1 CANADA     20081113 120934
-WRITE TEST1 CANADA     20081114 140030
-WRITE TEST1 S KOREA    20081114 101030
-WRITE TEST1 S KOREA    20081116 110956
-WRITE TEST1 USA        20081114 171030
-WRITE TEST1 USA        20081116 190956
-RUN

-*-- Create the report -----------------------------------------------
DEFINE FILE TEST1
STARTDATE/YYMD    = HDATE(DATETIME, 'YYMD');
STARTDATE2/A8YYMD=STARTDATE;
STARTDATE1/wMtDYY = STARTDATE;
STARTTIME/HHI     = DATETIME;
STARTTIME2/A5=EDIT(WTIME,'99:99');
END
-RUN


TABLE FILE TEST1
PRINT  
COUNTRY
DATETIME
BY STARTDATE2 NOPRINT
BY DATETIME  NOPRINT

BY STARTTIME2 
ON STARTDATE2 SUBHEAD
" "
"<STARTDATE1"

END
-RUN




 


Pat
WF 7.6.8, AIX, AS400, NT
AS400 FOCUS, AIX FOCUS,
Oracle, DB2, JDE, Lotus Notes
 
Posts: 755 | Location: TX | Registered: September 25, 2007Report This Post
Expert
posted Hide Post
Pat,

There is no difference in the Master in your solution, you simply have a different way of determining the Time portion of the Date/Time column in the DEFINE statements.

I can't see anything wrong with the way I am doing it. I'm sorting on the Date/Time column that has been reformatted to display only the Hours:Minutes, the result sure looks like a bug to me.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
OPALTOSH,
quote:
BY STARTTIME
is the field that has the time component.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Virtuoso
posted Hide Post
Francis

DEFINE FILE TEST1
STARTDAG/YYMD    = HDATE(DATETIME, 'YYMD');
STARTDATE1/wMtDYY = STARTDAG;
STARTTIME/HHI     = DATETIME;
DUMMY/A1='';
END
-RUN

TABLE FILE TEST1
SUM
COUNTRY
DATETIME

BY STARTDAG NOPRINT
BY DUMMY AS ''
BY  STARTTIME 
ON STARTDAG SUBHEAD
" "
"<STARTDATE1"


END




I created an extra dummy field as BY field and then is works, but strange it is!!!!




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Guru
posted Hide Post
I think STARTDATE, STARTDATE1, STARTTIME are all the same internally which pointing to the value of DATETIME.
But why NOPRINT before STARTTIME triggers this behavior?!


Developer Studio 7.6.11
AS400 - V5R4
HTML,PDF,XLS
 
Posts: 305 | Location: Winnipeg,MB | Registered: May 12, 2008Report This Post
Expert
posted Hide Post
Frank, thanks a million!

That is an acceptable temporary fix to the problem. I may still open a case so that someone at IBI can explain the issue, something to do with the internal matrix not doubt.

Thanks a lot,

Francis.

------------------------------------------------------------------------------------
Doesn't work:

-SET &ECHO=ON;

-*-- Create the master for TEST1 -------------------------------------
FILEDEF DATAMAST DISK TEST1.MAS
-RUN

-*--
-WRITE DATAMAST FILE=TEST1, SUFFIX=FIX, $
-WRITE DATAMAST SEGNAME=SEG1, SEGTYPE=S0, $
-WRITE DATAMAST FIELD=COUNTRY,  ALIAS=COUNTRY,  USAGE=A10,    ACTUAL=A10, $
-WRITE DATAMAST FIELD=,         ALIAS=FILL1,    USAGE=A01,    ACTUAL=A01, $
-WRITE DATAMAST FIELD=DATETIME, ALIAS=DATETIME, USAGE=HYYMDS, ACTUAL=A17, $

-*-- Create the data file for TEST1 ----------------------------------
FILEDEF TEST1 DISK TEST1.FTM
-RUN

-WRITE TEST1 ENGLAND    20081112175305000
-WRITE TEST1 CANADA     20081112175305000
-WRITE TEST1 CANADA     20081112083001000
-WRITE TEST1 CANADA     20081113083001000
-WRITE TEST1 CANADA     20081113172222000
-WRITE TEST1 USA        20081113172222000
-WRITE TEST1 CANADA     20081113120934000
-WRITE TEST1 CANADA     20081114140030000
-WRITE TEST1 S KOREA    20081114101030000
-WRITE TEST1 W GERMANY  20081114101030000
-WRITE TEST1 S KOREA    20081116110956000
-WRITE TEST1 USA        20081114171030000
-WRITE TEST1 USA        20081116190956000

-*-- Create the report -----------------------------------------------
DEFINE FILE TEST1
STARTDATE/YYMD    = HDATE(DATETIME, 'YYMD');
STARTDATE1/wMtDYY = STARTDATE;
STARTTIME/HHIA    = DATETIME;
END
-RUN

TABLE FILE TEST1
PRINT
COUNTRY
DATETIME
STARTTIME

BY STARTDATE NOPRINT
ON STARTDATE SUBHEAD
" "
"<STARTDATE1"

BY STARTTIME
END
-RUN

------------------------------------------------------------------------------------
Works:

-SET &ECHO=ON;

-*-- Create the master for TEST1 -------------------------------------
FILEDEF DATAMAST DISK TEST1.MAS
-RUN

-*--
-WRITE DATAMAST FILE=TEST1, SUFFIX=FIX, $
-WRITE DATAMAST SEGNAME=SEG1, SEGTYPE=S0, $
-WRITE DATAMAST FIELD=COUNTRY,  ALIAS=COUNTRY,  USAGE=A10,    ACTUAL=A10, $
-WRITE DATAMAST FIELD=,         ALIAS=FILL1,    USAGE=A01,    ACTUAL=A01, $
-WRITE DATAMAST FIELD=DATETIME, ALIAS=DATETIME, USAGE=HYYMDS, ACTUAL=A17, $

-*-- Create the data file for TEST1 ----------------------------------
FILEDEF TEST1 DISK TEST1.FTM
-RUN

-WRITE TEST1 ENGLAND    20081112175305000
-WRITE TEST1 CANADA     20081112175305000
-WRITE TEST1 CANADA     20081112083001000
-WRITE TEST1 CANADA     20081113083001000
-WRITE TEST1 CANADA     20081113172222000
-WRITE TEST1 USA        20081113172222000
-WRITE TEST1 CANADA     20081113120934000
-WRITE TEST1 CANADA     20081114140030000
-WRITE TEST1 S KOREA    20081114101030000
-WRITE TEST1 W GERMANY  20081114101030000
-WRITE TEST1 S KOREA    20081116110956000
-WRITE TEST1 USA        20081114171030000
-WRITE TEST1 USA        20081116190956000

-*-- Create the report -----------------------------------------------
DEFINE FILE TEST1
STARTDATE/YYMD    = HDATE(DATETIME, 'YYMD');
STARTDATE1/wMtDYY = STARTDATE;
STARTTIME/HHIA    = DATETIME;
DUMMY1/A1         = '';
END
-RUN

TABLE FILE TEST1
PRINT
COUNTRY
DATETIME
STARTTIME

BY STARTDATE NOPRINT
ON STARTDATE SUBHEAD
" "
"<STARTDATE1"

BY DUMMY1 AS ''

BY STARTTIME
END
-RUN
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Virtuoso
posted Hide Post
Looks like a bug to me too.

If you run
TABLE FILE TEST1
PRINT STARTTIME/HYYMDS
BY STARTTIME
END

it will be apparent that
(a) the series of Defines in the original post copies the full date-and-time value from DATETIME into STARTTIME; and
(b) BY STARTTIME sorts on the [invisible] date and [visible] time value in the natural manner.

The use of HHI format just hides the other components (year, month, date, second) at print time.

So WF is sorting correctly by STARTTIME -- the bug is in suppressing the repeated display of the sort field within sort break groups: WF is testing for a change in just the date components in the STARTTIME column, rather than change in the overall date-time value.


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Expert
posted Hide Post
Jack,

Thanks for the explanation, but does that explain why adding a DUMMY BY statement as Frank suggested make it work?


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Virtuoso
posted Hide Post
Nor does it explain why it also gives the proper sorting when you remove the NOPRINT after the BY STARTDATE




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Virtuoso
posted Hide Post
Hey Frank -

We agree there's a bug: There is some set of circumstances (such as the original posted code) where WF misbehaves in handling an H-time-formatted sort field, and I characterized what it seems to do wrong, but made no assertion as to where the borderline of the bug-domain lies. -- Is it my fault when WF behaves correctly? Big Grin

But there's another issue people should be aware of -- Htime formats can violate WYSIWYG expectations: If you use a HYYMDS-to-HH cast to get the Hour, and sum a statistic sorted on that HH field to obtain distribution by hour-of-day using a month's data, you'll be disappointed.


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Master
posted Hide Post
Francis,

I didn't redo your master file definitions, I only redid the define. I guess I should have made that clear in my previous post. I was looking for a quick solution to give you the results you wanted.


Pat
WF 7.6.8, AIX, AS400, NT
AS400 FOCUS, AIX FOCUS,
Oracle, DB2, JDE, Lotus Notes
 
Posts: 755 | Location: TX | Registered: September 25, 2007Report This Post
<JG>
posted
The problem is only going to HTML,HTMTABLE and DHTML.

Using Francis' original code and using PDF, EXL2K and XML it works fine.
 
Report This Post
Expert
posted Hide Post
JG!

Thank you for your further investigation! I didn't try the other formats.

I'll definitely report this as a bug.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [Frustrated - Solved (temporarily)] Bug with sorting on a Time field

Copyright © 1996-2020 Information Builders