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.
The report should sum-up values only when there is negative value for Transaction id In example above, For Transaction id 1, there is no negative value. Hence it is displayed as it is but For transaction id 2 and 3, there are negative values, so in report output, Only one records is displayed for 2 and 3 with rolled up values. Can some one please advise the way to achieve this?
Many Thanks.This message has been edited. Last edited by: Tamra,
-SET &ECHO=ON;
SET HOLDLIST=PRINTONLY
SET BYDISPLAY=ON
-RUN
-*-- Create the master for shankar1
FILEDEF DATAMAST DISK SHANKAR1.MAS
-RUN
-WRITE DATAMAST FILE=SHANKAR1, SUFFIX=FIX, $
-WRITE DATAMAST SEGNAME=SHANKAR1, SEGTYPE=S0, $
-WRITE DATAMAST FIELD=TX_ID , ALIAS=TX_ID , USAGE=A1, ACTUAL=A1, $
-WRITE DATAMAST FIELD=FILL1 , ALIAS=FILL1 , USAGE=A1, ACTUAL=A1, $
-WRITE DATAMAST FIELD=TX_AMT, ALIAS=TX_AMT, USAGE=I3, ACTUAL=A3, $
-*-- Create the data file for shankar1
FILEDEF SHANKAR1 DISK shankar1.ftm
-RUN
-WRITE SHANKAR1 1 100
-WRITE SHANKAR1 1 020
-WRITE SHANKAR1 1 050
-WRITE SHANKAR1 2 110
-WRITE SHANKAR1 2 060
-WRITE SHANKAR1 2 020
-WRITE SHANKAR1 3 100
-WRITE SHANKAR1 3 -30
-WRITE SHANKAR1 4 090
-WRITE SHANKAR1 4 -10
-WRITE SHANKAR1 5 017
-WRITE SHANKAR1 5 22
-WRITE SHANKAR1 5 130
-WRITE SHANKAR1 6 010
-WRITE SHANKAR1 6 -20
-WRITE SHANKAR1 6 030
-WRITE SHANKAR1 7 -10
-WRITE SHANKAR1 7 020
-WRITE SHANKAR1 7 040
-*-- ensure the data is in the correct order (by TX_ID and negatives need to be first)
TABLE FILE SHANKAR1
PRINT
TX_ID
TX_AMT
BY TX_ID NOPRINT
BY TX_AMT NOPRINT
ON TABLE HOLD AS HOLD_SHANKAR1
END
-RUN
-*-- Create the report
DEFINE FILE HOLD_SHANKAR1
AGGREGATE_IND/A1 = IF AGGREGATE_IND EQ 'Y' AND TX_ID EQ LAST TX_ID THEN 'Y' ELSE IF TX_AMT LT 0 THEN 'Y' ELSE 'N';
SORT_COL/I9 = IF AGGREGATE_IND EQ 'N' THEN SORT_COL + 1 ELSE SORT_COL;
END
-RUN
TABLE FILE HOLD_SHANKAR1
SUM
TX_AMT
BY TX_ID
BY SORT_COL NOPRINT
END
-RUN
The data needs to be in the correct order - by Transaction ID, with negative values for each Transaction ID before positive values. Then, using the LAST function, determine whether the data should be aggregated or not - if no aggregation, increment a secondary sort column; if aggregation leave the sort column value the same. I have additional cases in my example to make sure it worked.
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
Did Francis's example help you with your question? Add it into a focexec and run it. Take the NOPRINT off the BY SORT_COL to see how this sorts the data for you.
You can apply the HOLD and DEFINE section to your existing report.
Thank your for participating in the Focal Point Forum,
Tamra Colangelo Focal Point Moderator Information Builders
WebFOCUS 8x - BI Portal, Developer Studio, App Studio, Excel, PDF, Active Formats and HTML5
Posts: 487 | Location: Toronto | Registered: June 23, 2009