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     [CLOSED] How To Get a Year Total and Percentage - Code Error

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] How To Get a Year Total and Percentage - Code Error
 Login/Join
 
Member
posted
Dear All,

I have a report which is working fine until I added the following line of codes in order to get the Total and Percentage by the channels against the Grand Total.

Would appreciate it if anyone help.

Below are the code snippet:

YEAR1/A4='&yearFrom';
YEAR2/A4='&yearTo';
STDT/DMYY=HDATE(PYMT_V3.INBDAT, 'YYMD');
DATE3/A8YYMD=STDT;
MM3/A2=EDIT(DATE3,'$$$$99$$');
YY3/A4=EDIT(DATE3,'9999$$$$');
YEAR_YY/YY=STDT;
MONTH_M/Mt=STDT;
YEAR_A/A5=EDIT(YEAR_YY,'9999$');
CURRDT/DMYY='&DMYY';
MTH/A1=
IF MM3 EQ '01' THEN 'A' ELSE IF MM3 EQ '02' THEN 'B' ELSE IF MM3 EQ '03' THEN 'C' ELSE
IF MM3 EQ '04' THEN 'D' ELSE IF MM3 EQ '05' THEN 'E' ELSE IF MM3 EQ '06' THEN 'F' ELSE
IF MM3 EQ '07' THEN 'G' ELSE IF MM3 EQ '08' THEN 'H' ELSE IF MM3 EQ '09' THEN 'I' ELSE
IF MM3 EQ '10' THEN 'J' ELSE IF MM3 EQ '11' THEN 'K' ELSE IF MM3 EQ '12' THEN 'L';
MONTH/A5=DECODE MTH (
A 'JAN' B 'FEB' C 'MAR' D 'APR' E 'MAY' F 'JUN'
G 'JUL' H 'AUG' I 'SEP' J 'OCT' K 'NOV' L 'DEC'
);
YEARTOT/D12.2C=JAN + FEB + MAR + APR + MAY + JUN + JUL + AUG + SEP + OCT + NOV + DEC;
PTYPE/A20=
IF INTTYP EQ 2000 THEN 'CDM' ELSE IF INTTYP EQ 2100 THEN 'CASH' ELSE IF INTTYP EQ 2300 THEN 'IB' ELSE IF INTTYP EQ 2310 THEN 'IBG' ELSE
IF INTTYP EQ 2320 THEN 'IBFT' ELSE IF INTTYP EQ 2400 THEN 'CHEQUE' ELSE IF INTTYP EQ 2700 THEN 'ATM' ELSE IF INTTYP EQ 2800 THEN 'AUTO DEBIT';
END

TABLE FILE PYMT_V3
SUM
'PYMT_V3.INBEL/D12.2C' AS 'TOTAL AMOUNT'
'PYMT_V3.YEARTOT' AS 'TOTAL'
BY YEAR_A AS 'YEAR'
BY INTTYP AS 'CHANNEL CODE'
BY PTYPE AS 'CHANNEL'
ACROSS MONTH_M AS 'MONTH'
WHERE YY3 GE YEAR1;
WHERE YY3 LE YEAR2;
ON TABLE HOLD AS HOLD1
END
TABLE FILE HOLD1
SUM
YEARTOT
ON TABLE SAVE
END
-RUN
-READ SAVE &GRAND_TOT.D12.2C.
-RUN

TABLE FILE PYMT_V3
SUM
'PYMT_V3.INBEL/D12.2C' AS 'TOTAL AMOUNT'
COMPUTE PCT/D6.2% = YEARTOT / &GRAND_TOT * 100; AS '%'
BY YEAR_A AS 'YEAR'
BY INTTYP AS 'CHANNEL CODE'
BY PTYPE AS 'CHANNEL'
ACROSS MONTH_M AS 'MONTH'
ON 'PYMT_V3.YEAR_A' SUBTOTAL AS '*TOTAL'

This message has been edited. Last edited by: Kerry,


R7.7.0.1
Windows, All Outputs
 
Posts: 15 | Location: Malaysia | Registered: January 19, 2012Report This Post
Expert
posted Hide Post
Do you have fields named JAN FEB MAR etc?

You might to understand what you are doing before making changes to code.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Master
posted Hide Post
What you are doing seems unnecessarily complicated

1) You take a two-character representation for the month - 01, 02 .. 12 and convert it to a single-character letter value - A, B .. L;

2) You take that letter value and convert it to a 3-character representation for the month - JAN, FEB .. DEC (although ypu allow 5 characters to do this in);

3) You then try to add the names of the months and put them in a double-precision field. I think you somehow lost your way here and what you want is some value, not the names of the months.

I think for starters you could make it a lot simpler by:

DEFINE FILE x
YY3/YY=PYMT_V3.INBDAT;
MM3/M=PYMT_V3.INBDAT;
MTH/MTR=PYMT_V3.INBDAT;
END


I don't understand all the unnecessary (to me) conversion of the date information to alpha. You have it as YYMD in the beginning and you can go from there directly to what you need: the year, month in numeric format, month spelled out.

If you clean this up (replace 16 lines of code with 3) I think the problem with the totals should become apparent.


WebFOCUS 7.7.05 Windows, Linux, DB2, IBM Lotus Notes, Firebird, Lotus Symphony/OpenOffice. Outputs PDF, Excel 2007 (for OpenOffice integration), WP
 
Posts: 674 | Location: Guelph, Ontario, Canada ... In Focus since 1985 | Registered: September 28, 2010Report This Post
Member
posted Hide Post
Dear George,

Thank you for replying and the simplified code.

Will definitely test it out next week.


Regards...JS


R7.7.0.1
Windows, All Outputs
 
Posts: 15 | Location: Malaysia | Registered: January 19, 2012Report 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     [CLOSED] How To Get a Year Total and Percentage - Code Error

Copyright © 1996-2020 Information Builders