Focal Point
[SOLVED] Truncate/No-Rounding How To

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4437011076

April 11, 2014, 12:58 PM
Jveselka
[SOLVED] Truncate/No-Rounding How To
I am using Focus 764 and I am unable to find a function to truncate. I have read all the posts out here but have yet to find one that will help me.

How do I stop this from rounding?

The below query doesn’t round up because it has change on the end. (I know I am using wheelbase and not an amount but it will work for now)

DEFINE FILE CAR
COST/D6.1=WHEELBASE
END
TABLE FILE CAR
PRINT COST
WHERE COST EQ 112.8;
ON TABLE COLUMN-TOTAL AS 'TOTAL';
END

This query will round up because the change is not printing.

DEFINE FILE CAR
COST/D6=WHEELBASE
END
TABLE FILE CAR
PRINT COST
WHERE COST EQ 112.8
ON TABLE COLUMN-TOTAL AS 'TOTAL';
END

What I need

No rounding and no change showing for rows
No rounding but a column-total including change but no change showing

Sounds crazy but that’s what they want.

This message has been edited. Last edited by: <Kathryn Henning>,


WebFOCUS 8105m
Windows, All Outputs
April 11, 2014, 12:59 PM
Jveselka
Here is an Example.
Cost No Change Actual Cost What They Want
56,827,057 56,827,057.6 56,827,057
72,726,183 72,726,183.4 72,726,183
14,690,392 14,690,392.7 14,690,392
2,067,826 2,067,826.9 2,067,826
TOTAL 146,311,458 146,311,460.6 146,311,460


WebFOCUS 8105m
Windows, All Outputs
April 11, 2014, 01:02 PM
Jveselka
Ex
Cost No/CHG Actual Cost What They Want
56,827,057 56,827,057.6 56,827,057
72,726,183 72,726,183.4 72,726,183
14,690,392 14,690,392.7 14,690,392
2,067,826 2,067,826.9 2,067,826
TOT 146,311,458 146,311,460.6 146,311,460


WebFOCUS 8105m
Windows, All Outputs
April 11, 2014, 01:15 PM
Jveselka
Oh well I can't find out to attach a file to this thing so here is what they are looking for. The rows don't round or show change total does not show change and does not round but is a total of all with change.

56,827,057
72,726,183
14,690,392
2,067,826
146,311,460


WebFOCUS 8105m
Windows, All Outputs
April 11, 2014, 02:33 PM
Todd_Wallace
quote:
DEFINE FILE CAR
COST/D6.1=WHEELBASE
END
TABLE FILE CAR
PRINT COST
WHERE COST EQ 112.8;
ON TABLE COLUMN-TOTAL AS 'TOTAL';
END


You can try
   
DEFINE FILE CAR
COST/D6.1=WHEELBASE
END
TABLE FILE CAR
PRINT COST 
COMPUTE TRUNCATED_COST/D6=INT(COST);
COMPUTE RUNNING_TOTAL_COST/D8.1=RUNNING_TOTAL_COST + COST;
COMPUTE TRUNCATED_TOTAL_COST/D8=INT(RUNNING_TOTAL_COST);
WHERE COST EQ 112.8;
ON TABLE COLUMN-TOTAL AS 'TOTAL'
END


Which will only give you the integer portion of the number.
You can do a running total to add them up with the decimal and then INT that value to get it truncated but with the decimals added. Not sure how you would put it in a total easily though.

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


WebFOCUS 8.1.05
Windows-iSeries DB2, All Outputs
HTML
April 11, 2014, 04:16 PM
susannah
i can't understand your objective
but be aware that Integer format truncates.
DEFINE FILE CAR
COST/I6 = WHEELBASE;
END
...and you get a truncated value.
If you want to keep track of something with decimal postions, but not show it until the total,
then PRINT COST WHEELBASE NOPRINT
and ON TABLE SUBFOOT
"EG:
DEFINE FILE CAR
COST/I6=WHEELBASE;
END
 
TABLE FILE CAR
SUM COST WHEELBASE NOPRINT BY COUNTRY BY CAR
ON TABLE SUBFOOT
"  <TOT.COST"
" Wheelbase= <TOT.WHEELBASE  "
ON TABLE SET STYLE *
TYPE=TABFOOTING, LINE=1,JUSTIFY=RIGHT,$
 
END





In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
April 11, 2014, 05:15 PM
jimster06
Take a look at this:
DEFINE FILE CAR
COST/D6.1=WHEELBASE;
FRACT_PART/D6.1= DMOD(COST,1,FRACT_PART);
COST_NOCHANGE/D6=COST-FRACT_PART;
END
TABLE FILE CAR
PRINT WHEELBASE COST FRACT_PART COST_NOCHANGE
ON TABLE SUBTOTAL
END

HTH


jimster06
DevStu WF 7.6.11
W7
HTML, PDF, EXL2K
April 14, 2014, 06:08 AM
Alan B
COMPUTE can be used instead of DEFINE:
TABLE FILE CAR
PRINT 
COMPUTE COST/I6=WHEELBASE;
ON TABLE RECOMPUTE AS 'TOTAL'
END



Alan.
WF 7.705/8.007
April 14, 2014, 11:40 AM
Jveselka
Ok, thanks for all the posts, I think what I will have to do is print this out in one report using the define to get my nochange number.
FRACT_PART/D6.1= DMOD(COST,1,FRACT_PART);
COST_NOCHANGE/D6=COST-FRACT_PART;
Then I could run a second report as a compound report for the totals, but how do you only print totals?


WebFOCUS 8105m
Windows, All Outputs
April 14, 2014, 07:07 PM
jimster06
Lookup Multiple Display Commands; this topic may address your need.

Edited to add: also see prefix operators.

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


jimster06
DevStu WF 7.6.11
W7
HTML, PDF, EXL2K
April 16, 2014, 09:53 AM
Jveselka
Ok I was able to get my totals in one row by using the code below, but it is still rounding. Why is there not a -SET ROUNDING OFF; ????

DEFINE FILE CAR
TOTAL/A5='TOTAL';
END
TABLE FILE CAR
SUM TOTAL AS ''
RETAIL_COST
RETAIL_COST
WHEELBASE/P11M
WHERE WHEELBASE EQ 98.4 OR 103.8 OR 105.3;
ON TABLE SET PAGE-NUM OFF
END

I did find out by trial and error that if you change the format of the Wheelbase column from P11M to I11M it will not round. So Packed Rounds and Integer does not.

DEFINE FILE CAR
TOTAL/A5='TOTAL';
END
TABLE FILE CAR
SUM TOTAL AS ''
RETAIL_COST
RETAIL_COST
WHEELBASE/I11M
WHERE WHEELBASE EQ 98.4 OR 103.8 OR 105.3;
ON TABLE SET PAGE-NUM OFF
END

Problem I still have is that when I do this my total is off because it does not add in the change.  Not sure why they want it like this but they do. So Details don’t round and don’t include change. Total does not round but does include change. I will keep working…..At least I found out how to stop it from rounding.


WebFOCUS 8105m
Windows, All Outputs
April 17, 2014, 04:13 AM
Alan B
I am not sure why you need to make this so complex.
DEFINE FILE CAR
ActualCost/D12.2 = 
IF COUNTRY EQ 'ENGLAND' THEN 56827057.6 ELSE
IF COUNTRY EQ 'FRANCE'  THEN 72726183.4 ELSE
IF COUNTRY EQ 'ITALY'  THEN  14690392.7 ELSE
IF COUNTRY EQ 'JAPAN'  THEN   2067826.9 ELSE 0;
END
TABLE FILE CAR
PRINT
COMPUTE CostNoChange/I11CM = ActualCost; AS 'What They Want'
BY COUNTRY
IF COUNTRY NE 'W GERMANY'
ON TABLE RECOMPUTE AS 'TOTAL'
END

gives the result you gave in your example, or is there something else going on?


Alan.
WF 7.705/8.007
April 17, 2014, 11:35 AM
Jveselka
It's not complex when you know what you are doing. This is a first for me, but this looks like it worked. Here is my code.

DEFINE FILE P1333_CAS_PAP
NBMA/D13.1= IF NEW_BUSINESS_MONTH_A GT 0 THEN NEW_BUSINESS_MONTH_A ELSE 0;
NBPC/D13.1= IF NEW_BSNS_POL_CNT GT 0 THEN NEW_BSNS_POL_CNT ELSE 0;
NBMC/D13.1= IF NEW_BUSINESS_MONTH_C GT 0 THEN NEW_BUSINESS_MONTH_C ELSE 0;
NBVC/D13.1= IF NEW_BSNS_VEH_CNT GT 0 THEN NEW_BSNS_VEH_CNT ELSE 0;
NBME/D13.1= IF NEW_BUSINESS_MONTH_E GT 0 THEN NEW_BUSINESS_MONTH_E ELSE 0;
NBPA/D13.1= IF NEW_BSNS_PREM_AMT GT 0 THEN NEW_BSNS_PREM_AMT ELSE 0;
NRMG/D13.1= IF RENEWAL_MONTH_G GT 0 THEN RENEWAL_MONTH_G ELSE 0;
NRPA/D13.1= IF RENW_PREM_AMT GT 0 THEN RENW_PREM_AMT ELSE 0;
TOT1/D13.1=(NEW_BUSINESS_MONTH_E + RENEWAL_MONTH_G);
TOT2/D13.1=(NEW_BSNS_PREM_AMT + RENW_PREM_AMT);
TOTAL/A5='TOTAL';
END
TABLE FILE P1333_CAS_PAP
SUM TOTAL AS ''
COMPUTE AMOUNT1/I11CM = NBMA; AS ''
COMPUTE AMOUNT1/I11CM = NBPC; AS ''
COMPUTE AMOUNT1/I11CM = NBMC; AS ''
COMPUTE AMOUNT1/I11CM = NBVC; AS ''
COMPUTE AMOUNT1/I11CM = NBME; AS ''
COMPUTE AMOUNT1/I11CM = NBPA; AS ''
COMPUTE AMOUNT1/I11CM = NRMG; AS ''
COMPUTE AMOUNT1/I11CM = NRPA; AS ''
COMPUTE AMOUNT1/I11CM = TOT1; AS ''
COMPUTE AMOUNT1/I11CM = TOT2; AS ''
ON TABLE SET PAGE-NUM OFF
ON TABLE PCHOLD FORMAT EXL2K CLOSE
END


Thanks to all and to Alan B for your help, this one will go into my ongoing WTF file.

Now how to I add Solved to the title of this thread?


WebFOCUS 8105m
Windows, All Outputs