Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SImple Problem - Making me crazy

Status
Not open for further replies.

mlspmk

Technical User
May 9, 2007
1
US
This code is not getting me to the appropriate key values - it keeps breaking where I have the ****. The statement should kick me out of the loop after I have cycled through all ketyed records with the same closure value. But when I do the SET ... NEXT for values of 0 or 1, it is not finding the correct values. MOD:ClosureStatus is being set properly. HELP!!!

! MOD: values are MODULE variables.

CLEAR(MOD:ClosureStatus) ; CLEAR(MOD:DueDate); CLEAR(MOD:Division) ; CLEAR(MOD:Owner) ; CLEAR(MOD:Category) ; CLEAR(MOD:ExcludeZeroDueDates)
CLEAR(GLO:FirstDate) ; CLEAR(GLO:LastDate)

BIND(IS1:Record) ; BIND(IS2:Record) ; BIND(IS3:Record) ; BIND(ALL:Record)
EMPTY(AllIssues) ; CLEAR(IS1:Record) ; CLEAR(IS2:Record) ; CLEAR(IS3:Record)

ReportCriteria ! sets the MOD: criteria values


! Select from IS1, IS2, IS3 using criteria from ReportCriteria, and place in the MEM file ALLISSUES
! ISSUES1 PROCESSING ================================================
message('before case' & '|' & 'IS1:Closed = ' & IS1:Closed & '|' & 'MOD:ClosureStatus = ' & MOD:ClosureStatus)
CASE MOD:ClosureStatus ! set keys to speed processing
OF 0 OROF 1 ! 0=Open , 1=Closed , 2=All records
IS1:Closed = MOD:ClosureStatus
IS1:Issue1Date = 0 ! clear second element of key for good SET ... NEXT result
SET(IS1:Closure,IS1:Closure)
OF 2
SET(Issues1)
.
LOOP
NEXT(Issues1)
IF ERROR() THEN BREAK.
IF MOD:ClosureStatus < 2 ! open or closed
**** IF IS1:Closed <> MOD:ClosureStatus THEN BREAK.
.
IF IS1:DueDate = 0 AND MOD:ExcludeZeroDueDates = 1
CYCLE
.
IF MOD:DueDate = IS1:DueDate AND IS1:DueDate > 0
DO AddIssue1 ; CYCLE
.
.
 
Hi!

If you post your table structure for Issues1 (at least the key IS1:Closure), I will be able to understand the issue better. Otherwise, put MESSAGE()'s to debug your results (for example a MESSAGE(MOD:ClosureStatus) before the LOOP.

For your code to work, the following conditions must be met:

- IS1:Closed must be the first element of the key IS1:Closure

- The key IS1:Closure must not be corrupted. Re-index to make sure.

- You are clearing MOD:ClosureStatus before calling ReportCriteria. So, is MOD:ClosureStatus is being set properly in ReportCriteria?

Otherwise, you code seems OK. Some suggestions ::

- Use IF ERRORCODE()... instead of IF ERROR() ... since ERRORCODE() returns a numeric as compared to the string by ERROR() and hence faster to compare. It makes a difference if there are many iterations in the Loop.
- Use END !If and END !Loop instead of . to make the code more readable

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top