>ag_account = 5608 && und_owner=5608 will be agent specific settings >ag_pmtnb6 = 5 >ag_maxnb6 = 5 > >SCAN WHILE NOT EOF() > IF UNDGUIDE.UND_EFF <= DATE() AND ( UNDGUIDE.UND_OWNER = 1 OR UNDGUIDE.UND_OWNER = m.ag_account) > CASE UNDGUIDE.UGI_ID = UGI_MAX6PMT > IF BETWEEN(UNDGUIDE.UND_VALUE,1,6) > m.ag_maxnb6 = UNDGUIDE.UND_VALUE <--und_value = 4 in the record for und_owner = 1 > m.ag_maxrn6 = UNDGUIDE.UND_VALUE > *--Here ag_pmtnb6 is changed to 4 because ag_maxnb6 is now 4 > IF m.ag_pmtnb6 > m.ag_maxnb6 > m.ag_pmtnb6 = m.ag_maxnb6 > ENDIF > ENDIF > >*Now based on the record with und_owner = 1 above the two values below have been changed: > >*ag_pmtnb6 = 4 >*ag_maxnb6 = 4 > >*Next the record und_owner = 5608 is found which does not change the ag_pmtnb6 back > >CASE UNDGUIDE.UGI_ID = UGI_MAX6PMT >IF BETWEEN(UNDGUIDE.UND_VALUE,1,6) > m.ag_maxnb6 = UNDGUIDE.UND_VALUE <--und_value = 5 in the record for und_owner=5608 > m.ag_maxrn6 = UNDGUIDE.UND_VALUE > IF m.ag_pmtnb6 > m.ag_maxnb6 <<<<----Here ag_pmtnb6 is not changed because it is now 4 and 4 < 5 > m.ag_pmtnb6 = m.ag_maxnb6 > ENDIF >ENDIF >>This obviously is not working. A value of ag_pmtnb6 should be 5 not 4 when the code finished because we set it to 5 before the code is run and the record for und_owner=5608 with the ag_maxnb6 value allows for 5 as the max value for 5608.
IF Agent_Record_Exists * Use Agent values ELSE * Use Owner values ENDIF