[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference iamok::dtrdig

Title:DATATRIEVE INTEREST GROUP
Notice:ADD KEYWORDS TO NOTES FOR EASY SEARCHES
Moderator:IMTDEV::KRATZER
Created:Fri Mar 21 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3011
Total number of notes:9337

3004.0. "How to Round Decimal Places" by CONSLT::G_WOLSKI () Wed Apr 09 1997 19:04

    I've tried every edit string I know of and can't seem to get the
    results I need.   Can someone help?  
    
    I have a series of calculated sub-totals with 2 decimal places 
    ($$$,$$$.99) that are being totaled to one grand total with the same
    2 decimal places.  
    
    Since some of the sub-totals are 3 or 4 decimal places in real numbers,
    I want to round the decimal place to 2 if necessary.  
    
    How do I make DTR do this?  I have a program running against the
    results of this DTR procedure which is failing since the numbers are 
    not consistantly totaling and the sub-totals and totals are not
    matching.  Currently DTR will not round no matter what edit string I've
    tried.
    
    Does anyone know how to get around this?  
    
    Thanks for any help!!
    
    
    
T.RTitleUserPersonal
Name
DateLines
3004.1BUSY::SLABExit light ... enter nightWed Apr 09 1997 21:3810
    
    	I'm not sure why it's not working if the edit string you posted is
    	the one you're using.
    
    	Just make sure to use the exact same edit string wherever you're
    	trying to round a number.
    
    	Failing that, post the procedure here and someone will be able to
    	figure it out for you.
    
3004.2Rounding....does this help?CSC32::COMULADAThu Apr 10 1997 13:3838
The key to getting DATATRIEVE to round the computed
by variable to two decimal points is to use the
FORMAT statement.                                
 



DTR> SHOW ROUNDING_PROC                              
                        
PROCEDURE ROUNDING_PROC                              
                        
DECLARE A_NUM PIC 99V999.                            
                        
DECLARE B_NUM PIC 99V999.                            
                        
A_NUM = 11.856                                       
                        
B_NUM = 2.1234                                       
                        
DECLARE C_NUM COMPUTED BY FORMAT ( A_NUM * B_NUM )
USING 99.99.               
PRINT C_NUM                                          
                        
END_PROCEDURE                                        
                        
                                                     
                        
DTR> :ROUNDING_PROC                                  
                        
                                                     
                        
  C                                                  
                        
 NUM                                                 
                        
                                                     
                        
25.18 
3004.3Not sure how to include FORMATCONSLT::G_WOLSKIThu Apr 10 1997 17:2620
    Hi,
    
    Attached is the portion of the procedure with the problem.  How would I 
    include the FORMAT statement when I'm using the AMT USING and TOTAL AMT
    USING?  
    
    thanks again..
    
    
    PRINT BADGE_NUMBER, PERSONS_NAME, PROJECT_NUMBER, PROJECT_DESCRIPTION,
           PROJECT_SUB_DESCRIP, DIRECT_HOURS, AMT USING $$,$$$,$$$.99
    AT BOTTOM OF BADGE_NUMBER PRINT SKIP, "   Subtotal:", TOTAL
           DIRECT_HOURS,TOTAL AMT USING $$,$$$,$$$.99
    AT BOTTOM OF BADGE_NUMBER SPACE
    AT BOTTOM OF PAGE PRINT SKIP 2,COL 28,"- Digital Confidential -"
    AT BOTTOM OF REPORT PRINT SKIP, "Grand Total:",  TOTAL DIRECT_HOURS,
           TOTAL AMT USING $$,$$$,$$$.99
    END_REPORT
    END_PROCEDURE
    
3004.4BUSY::SLABGot into a war with reality ...Thu Apr 10 1997 17:414
    
    	If AMT is indeed a "computed by" field, we need to see the DECLARE
    	statement also.
    
3004.5Don't see a DECLARE statementCONSLT::G_WOLSKIThu Apr 10 1997 18:1527
    
    This is the entire procedure.  I don't see a DECLARE statement.
    
    REDEFINE PROCEDURE SEVENSEVEN
    READY TIME SHARED READ
    :ACT_DOLLARS
    FIND AA IN TIME WITH
    (COST_CENTER EQUAL "COP", "REP", "3CJ") AND
    (YYMMDD_DATE BT FN$GET_SYMBOL("P1") AND FN$GET_SYMBOL("P2")) AND
    PROJECT_NUMBER NE "E098-40274", "E098-40629", "E098-40631"
    SORT BY PROJECT_NUMBER, COST_CENTER
    REPORT AA ON SYS$LOGIN:REPORT07.RPT
    SET COLUMNS_PAGE=132
    SET REPORT_NAME = "CARDS Labor Tracking System"/
      "TCS Charges for Automatic JV Feed"
    PRINT BADGE_NUMBER, PERSONS_NAME, PROJECT_NUMBER, PROJECT_DESCRIPTION,
              PROJECT_SUB_DESCRIP, DIRECT_HOURS, AMT USING $$,$$$,$$$.99
    AT BOTTOM OF BADGE_NUMBER PRINT SKIP, "   Subtotal:", TOTAL
              DIRECT_HOURS,TOTAL AMT USING $$,$$$,$$$.99
    AT BOTTOM OF BADGE_NUMBER SPACE
    AT BOTTOM OF PAGE PRINT SKIP 2,COL 28,"- Digital Confidential -"
    AT BOTTOM OF REPORT PRINT SKIP, "Grand Total:",  TOTAL DIRECT_HOURS,
              TOTAL AMT USING $$,$$$,$$$.99
    END_REPORT
    END_PROCEDURE
    
    
3004.6BUSY::SLABGreat baby! Delicious!!Thu Apr 10 1997 20:035
    
    	OK, so it appears that AMT is a field in the TIME domain, yes?  If
    	so, I still see no reason why PRINT AMT USING $$.99 doesn't give
    	you a 2-decimal output.
    
3004.7BUSY::SLABGreat baby! Delicious!!Thu Apr 10 1997 20:046
    
    	Oops, how about posting procedure ACT_DOLLARS also?
    
    	If AMT isn't a field in the TIME domain, it might be a declared
    	variable in that procedure.
    
3004.8Sub ProcCONSLT::G_WOLSKIFri Apr 11 1997 17:1015
    Oh.. is this my problem?  
    
    DTR> show act_dollars
    PROCEDURE ACT_DOLLARS
    DECLARE RATE COMPUTED BY BADGE_NUMBER VIA ACT_RATE_TABLE EDIT_STRING
        $$$$$.99.
    DECLARE AMT EDIT_STRING IS $$$$,$$$.$$ COMPUTED BY
        DIRECT_HOURS * RATE.
    DECLARE OHRATE COMPUTED BY BADGE_NUMBER VIA ACT_OH_RATE_TABLE
    EDIT_STRING
        $$$$$.99.
    DECLARE OHAMT EDIT_STRING IS $$$$,$$$.$$ COMPUTED BY
        OVER_HEAD_HOURS * OHRATE.
    END_PROCEDURE
    
3004.9BUSY::SLABWanted: a life. Will pay top dollar.Sat Apr 12 1997 16:2812
    
    	So, combining your DECLARE statement with Felix's suggestion, we
    	now have:
    
    DECLARE AMT COMPUTED BY FORMAT (DIRECT_HOURS * RATE) USING
        $$$$,$$$,$$9.99.
    
    
    	So in your PRINT statement[s] that contain[s] AMT, you can remove
    	the EDIT_STRING qualifier since the DECLARE statement already def-
    	ines the EDIT_STRING.
    
3004.10WOTVAX::DODDMon Apr 14 1997 11:4510
    I'd want to look at some of the data to be sure...
    
    Might this be because some of the fields are table fields accessed VIA.
    Are these not character fields? They may contain digits but they will
    be truncated rather than rounded. I might suggest that rather than
    computed by you use x=y via... where x is a real numeric.
    
    Try printing some intermediate stuff and see what is actually going on.
    
    Andrew