I'm new at coding in RPG and am currently working on an assignment for a class. My problem area is with calculation of two dates (which we have not covered yet for the class). I'm using Bryan Meyer's "Programming in RPG IV", Third Edition, and though it is very helpful I'm just not getting the correct results.
I'm trying to get a date calculation that compares if a payment is made after the last day a discount is able to be paid. When I display my results, it shows 0s in my Discount Amount column. I'm trying to do this with RPGLE in Free Form. I'm including some of the code and the display to give you an idea of what is wrong and what I am looking for (I know the positions are not correctly displaying in this post). If you need more information, please let me know. Thank you in advance for the help!
	The Display is:
	I also realize my Amount Total is not correct and that is just a matter of placing it correctly within the Free Form.
Thanks again
					I'm trying to get a date calculation that compares if a payment is made after the last day a discount is able to be paid. When I display my results, it shows 0s in my Discount Amount column. I'm trying to do this with RPGLE in Free Form. I'm including some of the code and the display to give you an idea of what is wrong and what I am looking for (I know the positions are not correctly displaying in this post). If you need more information, please let me know. Thank you in advance for the help!
Code:
	
	
DDISDTE           S               D   DATFMT(*MDY)
DPAYDTE           S               D   DATFMT(*MDY)
DTOTAMTDUE        S              7  2             
DDTEDIF           S              3  0             
DDISCAMT          S              5  2             
DNETDUE           S              7  2             
DTOTDISAMT        S              5  2             
DTOTNETDUE        S              7  2   
/FREE                                    
  EXCEPT Headings;                       
  READ RPGEXAM1;                         
                                         
  DOW NOT %EOF;                          
    EXCEPT DETAIL;                       
    READ RPGEXAM1;                       
    DISDTE = %DATE(ADSDTE:*MDY);         
    PAYDTE = %DATE(APADTE:*MDY);         
    DTEDIF = %DIFF(PAYDTE:DISDTE:*DAYS); 
    IF DTEDIF >= 0;                      
      EVAL(H) DISCAMT = DISCAMT * ADSRTE;
    ELSE;                                
      DISCAMT = 0;                       
    ENDIF;                               
    TOTAMTDUE = AAMTDU + TOTAMTDUE;      
    TOTDISAMT = DISCAMT + TOTDISAMT;     
    TOTNETDUE = TOTAMTDUE - TOTDISAMT;   
  ENDDO;           
                   
  EXCEPT TOTALS;   
  EVAL *INLR = *ON;
  RETURN;          
/END-FREE
Code:
	
	
   DATE      DATE    DISCOUNT        AMOUNT   DISCOUNT  AMOUNT   
  PAID      DUE       DUE    RATE     DUE      AMOUNT    DUE    
 2/17/07  3/01/07    2/19/07 .030  13,000.00     .00        .00 
 2/17/07  2/19/07   12/31/07 .040     500.00     .00        .00 
 2/18/07  2/15/07   12/31/06 .060  33,225.41     .00        .00 
 2/18/07  2/18/07    1/15/07 .020       5.00     .00        .00 
 2/18/07  4/01/07    3/02/07 .015      10.00     .00        .00 
 2/18/07  3/15/07    2/18/07 .020  18,000.00     .00        .00 
 2/19/07 12/15/07   11/14/07 .035     100.00     .00        .00 
 2/19/07  2/19/07    2/19/07 .020     200.00     .00        .00 
                                  $52,240.41    $.00 $52,240.41
Thanks again



 

Comment