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     [CODE] MacGyver Technique for Dynamic Number of Grouped Subtotals/Subfoots

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CODE] MacGyver Technique for Dynamic Number of Grouped Subtotals/Subfoots
 Login/Join
 
Platinum Member
posted
MacGyver Technique for Dynamic Number of Grouped Subtotals/Subfoots

By David Smith
________________________________________

There are several presentations on the MacGyver Tips and Techniques page discussing moving groups of subtotals to the bottom of a report, but they deal with a known set of grouped values that are hard coded. And what if the number of sort groupings is dynamic and greater than what you may want to manually code? This technique may be of help.

Our business group needed a purchase report that:
1) List detail values (date, invoice#, qty, extend cost, etc.) sorted by region, vendor, and product type
2) At each change in vendor, display on one line beneath the detail the total sales tax for all purchases from the vendor for the period selected as free text.
3) Under the sales tax subtotal line, display a subtotal of the extended cost for each product type purchased from the vendor for the period selected. The number of lines is dynamic and could range from 1 to 100 based on the product types purchased during the as free text.
4) On one line, under the product type subtotals, display the Total Extended cost for the Vendor for all detail lines as free text.

After several "Almost, but no cigar" attempts, I attended the recent MacGyver Webinar, and the light came on.

Use of the MacGyver technique and the new SET DROPBLNKLINES=ON command syntax provided new in 7.6.11 met our business requirement.

Using the CAR database to mimic what our business group needed, I am presenting the output example in HTML format and the underlying fex code.



MGTEST.FEX
-* Set up MacGyver master and data file.
-* Build MacGyver MFD
FILEDEF MCMAS DISK MCGYV.MAS
-RUN
-WRITE MCMAS FILENAME=mcgyv, SUFFIX=FIX , $
-WRITE MCMAS SEGMENT=ONE, SEGTYPE=S0, $
-WRITE MCMAS FIELDNAME=CONTROL, USAGE=A1, ACTUAL=A1, $
-WRITE MCMAS SEGMENT=TWO, SEGTYPE=S0, PARENT=ONE, OCCURS=VARIABLE, $
-WRITE MCMAS FIELDNAME=CHAR1, USAGE=A1, ACTUAL=A1, $
-WRITE MCMAS FIELDNAME=CTR, ALIAS=ORDER, USAGE=I4, ACTUAL=I4, $
-WRITE MCMAS DEFINE REPORT_NUMBER/I4 WITH CHAR1=CTR; $
-* Build MacGyver FTM. Set for count of 2
FILEDEF MCGYV DISK MCGYV.FTM
-RUN
-WRITE MCGYV XAB
-RUN
-*********************************************************************
SET NODATA = ' '
JOIN CONTROL WITH BODYTYPE IN CAR TO UNIQUE CONTROL IN MCGYV AS J2
-* If CTR eq 1 display in detail, if CTR eq 2 use for subfoots.
DEFINE FILE CAR
CONTROL /A1 WITH BODYTYPE='X';
CARX /A40 =IF CTR EQ 1 THEN CAR ELSE ' ';
SORTCTYCAR/A35 =IF CTR EQ 1 THEN COUNTRY ELSE
IF CTR EQ 2 THEN CAR;
SORTMODEL /A30 =IF CTR EQ 1 THEN MODEL ELSE ' ';
SLS_DTL /A15 =IF CTR EQ 2 THEN ' ' ELSE PTOA(SALES,'(P12.2CM)','A15');
SLS_SF /P12.2CM =SALES;
DCOST_DTL /A15 =IF CTR EQ 2 THEN ' ' ELSE PTOA(DEALER_COST,'(P12.2CM)','A15');
DCOST_SF /P12.2CM =DEALER_COST;
END
-* Command to remove blank lines above subfoots
SET DROPBLNKLINE=ON
TABLE FILE CAR
HEADING
"MacGyver Technique with Dynamic Subtotals/SubFoots"
SUM
CARX AS 'Car'
SORTMODEL AS 'Model'
SLS_DTL AS 'Sales'
DCOST_DTL AS 'Cost'
BY COUNTRY NOPRINT
BY CTR NOPRINT
BY SORTCTYCAR NOPRINT
BY SORTMODEL NOPRINT
ON COUNTRY SUBHEAD
"ON CTR SUBFOOT
"Total Dealer Cost: WHEN CTR EQ 1
ON CTR SUBFOOT
"Total sales for WHEN CTR EQ 2
ON SORTCTYCAR SUBFOOT
"Subtotal Sales for WHEN CTR EQ 2
WHERE COUNTRY EQ 'ITALY'
ON TABLE NOTOTAL
ON TABLE SET PAGE NOLEAD
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET STYLE *
GRID=ON,BORDER=OFF,SQUEEZE=ON,SIZE=8,$
TYPE=HEADING,JUSTIFY=CENTER,$
TYPE=TITLE,JUSTIFY=CENTER,$
TYPE=DATA,COLUMN=SLS_DTL ,JUSTIFY=RIGHT,WHEN=CTR EQ 1,$
TYPE=DATA,COLUMN=DCOST_DTL,JUSTIFY=RIGHT,WHEN=CTR EQ 1,$
ENDSTYLE
END

Notes:
• This technique works for HTML, PDF, and EXL2K formats. There is an open case for Active (AHTML) format.
• This technique can work in earlier versions of WebFocus (pre 7.6.10 and earlier) but you will have blank data rows above the subfoots.
• Go to MacGyver Techniques for all of the Tips and Technique documents
• Read MacGyver Technique Introduction by Noreen Redden to learn about the mechanics of how MacGyver actually works. It’s old, but still applies.
• To see a replay of the recent Webinar, go to MacGyver Technique Introduction

I'll be submitting this to the Tips & Techniques folks for posting there, also.

David



In FOCUS since 1985 - WF 8.009/8.104 Win 8 Outputs: ALL of 'em! Adapters: Sql Server Teradata Oracle
 
Posts: 161 | Location: Dallas, TX | Registered: February 20, 2009Report This Post
Expert
posted Hide Post
Thanks David for sharing this with all. I will work on the HTML page for the Tips and Techniques section, and will post it here for all to review.

Cheers,

Kerry


Kerry Zhan
Focal Point Moderator
Information Builders, Inc.
 
Posts: 1948 | Location: New York | Registered: November 16, 2004Report This Post
Expert
posted Hide Post
Hi all,

FYI, this technique is now posted to our Tips and Techniques section: http://www.informationbuilders...evelopers/index.html

Thanks David for sharing with all. Smiler

Cheers,

Kerry


Kerry Zhan
Focal Point Moderator
Information Builders, Inc.
 
Posts: 1948 | Location: New York | Registered: November 16, 2004Report This Post
Virtuoso
posted Hide Post
very good to see this again explained




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
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CODE] MacGyver Technique for Dynamic Number of Grouped Subtotals/Subfoots

Copyright © 1996-2020 Information Builders