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.
DEFINE FILE ggsales
Month-Year/A6 = DATETRAN( DATECVT( DATE, 'I8YYMD', 'MY' ), '(MY)', '(-t)', 'EN', 6, 'A6');
END
TABLE FILE ggsales
BY DATE
BY Month-Year
END
Hallway
Prod: 8202M1
Test: 8202M4
Repository:
OS:
Outputs:
Posts: 608 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015
Originally posted by Hallway: LOL... I'm always on a quest to shorten the lines of code 🤓
TABLE FILE ggsales
SUM COMPUTE Month-Year/A6 = DATETRAN( DATECVT( DATE, 'I8YYMD', 'MY' ), '(MY)', '(-t)', 'EN', 6, 'A6');
BY DATE
END
The above does work because you only have the BY DATE, but if it is as below, only one date from each CITY will be displayed and depending one data organization it may be any one. So, when using a COMPUTE to shorten the lines of code you need to pay attention at the result and desired result.
TABLE FILE ggsales
SUM COMPUTE Month-Year/A6 = DATETRAN( DATECVT( DATE, 'I8YYMD', 'MY' ), '(MY)', '(-t)', 'EN', 6, 'A6');
BY CITY
-*BY DATE
END
WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF In Focus since 2007
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013
INDATA/A8YYMD WITH DVAL = '&YYMD' ;
MYM/A2 = EDIT(INDATA,'$$$$99');
MYMT/A3 = DECODE MYM(01 Jan 02 Feb 03 Mar 04 Apr 05 May 06 Jun
07 Jul 08 Aug 09 Sep 10 Oct 11 Nov 12 Dec ELSE ???);
MYD/A2 = EDIT(INDATA,'$$99');
MYMYR/A6 = MYMT | '-' | MYD ;
This technique uses no functions (EDIT is not really a function, but rather a compiled construct).
Just for fun, here is a benchmark that compares all three techniques for efficiency:
-DEFAULTS &FLD=MYEAR,&RECLIM=20000
DEFINE FILE SMALL
INDAT/I8YYMD WITH DVAL = &YYMD;
INDATA/A8YYMD WITH DVAL = '&YYMD' ;
INA/A6 WITH DVAL = 'Aug-19';
INYYMD/YYMD WITH DVAL = &YYMD;
MYEAR/A6 = DATETRAN( DATECVT ( INDAT, 'I8YYMD', 'MY' ), '(MY)', '(-t)', 'EN', 6, 'A6');
MONTH4/Mt = INYYMD;
THEMONTH/A3 = FPRINT(MONTH4, 'Mt', 'A3');
YEAR2/Y = INYYMD;
YR/A2 = EDIT(YEAR2);
HDDATE/A10 = THEMONTH || '-' || YR;
MYM/A2 = EDIT(INDATA,'$$$$99');
MYMT/A3 = DECODE MYM(01 Jan 02 Feb 03 Mar 04 Apr 05 May 06 Jun
07 Jul 08 Aug 09 Sep 10 Oct 11 Nov 12 Dec ELSE ???);
MYD/A2 = EDIT(INDATA,'$$99');
MYMYR/A6 = MYMT | '-' | MYD ;
END
-RUN
-TYPE First, get the base benchmark.
-SET &MYCPU = &FOCCPU ;
TABLE FILE SMALL
SUM INA
IF RECORDLIMIT EQ &RECLIM
END
-RUN
-SET &DIFF = &FOCCPU - &MYCPU ;
-TYPE CPU BASE: &DIFF
-TYPE Now, the MYEAR technique:
-SET &MYCPU = &FOCCPU ;
TABLE FILE SMALL
SUM MYEAR
IF RECORDLIMIT EQ &RECLIM
END
-RUN
-SET &DIFF = &FOCCPU - &MYCPU ;
-TYPE CPU MYEAR: &DIFF
-TYPE Next, the HDDATE technique:
-SET &MYCPU = &FOCCPU ;
TABLE FILE SMALL
SUM HDDATE
IF RECORDLIMIT EQ &RECLIM
END
-RUN
-SET &DIFF = &FOCCPU - &MYCPU ;
-TYPE CPU HDDATE: &DIFF
-TYPE Finally, the MYMYR technique (no functions)
-SET &MYCPU = &FOCCPU ;
TABLE FILE SMALL
SUM MYMYR
IF RECORDLIMIT EQ &RECLIM
END
-RUN
-SET &DIFF = &FOCCPU - &MYCPU ;
-TYPE CPU MYMYR: &DIFF
The SMALL file is just a file with 20000 short records, with the DVAL field in the segment that has 20000 records. You can substitute your own SMALL file with your own 'WITH' field, and the benchmark will work.
Here is the result on a zos mainframe:
>>ex test
First, get the base benchmark.
PAGE 1
INA
---
Aug-19
CPU BASE: 59
Now, the MYEAR technique:
PAGE 1
MYEAR
-----
Aug-19
CPU MYEAR: 147
Next, the HDDATE technique:
PAGE 1
HDDATE
------
Aug-19
CPU HDDATE: 139
Finally, the MYMYR technique (no functions)
PAGE 1
MYMYR
-----
Aug-19
CPU MYMYR: 56
So, what does this tell us? The base benchmark is 59ms. This represents the overhead of reading the file, collecting the alpha value, and printing the report. It essentially does nothing.
The MYEAR technique took 147ms total, and subtracting the base, about 88ms. The HDDATE benchmark took 139ms total, or about 80ms. The MYMYR benchmark took 56ms total, or, wait- it was *faster* than the base! This happened because in reality, the MYMYR overhead is essentially unmeasureable compared to the base, and is smaller than the normal benchmark variation from one execution to the next. Probably, MYMYR is dozens if not hundreds of times faster than the other two techniques.
So, why is MYMYR so fast? Because it does not use any functions, and the DEFINE code is actually compiled into very fast native zos instructions without any subroutine calls.
So, in general, if you *really* want fast code, avoid function calls and just use FOCUS computations.