How to find difference in recordset of a table?

havhav Member Posts: 299
Hi All,
I have created a table "WMSchedule" in NAV 2009 demo database. The table has primary key as (JobNo, ItemNo). The table stores scheduling details of a Job & its items.
Currently the table is populated with records for the job that are already scheduled.
I have created an interface called "Schedule Board" which displays list of both scheduled and un-scheduled jobs. The interface provides menus through which i can select an un-scheduled job and schedule it in a batch, select a scheduled job and can un-schedule it or re-schedule it.
My concern is to identify the changes that takes place in scheduling when i return from the interface "Schedule Board".
So what i did is
1. Obtain the WMSchedule recordset before invoking the "Schedule Board"
2. Invoke the "Schedule Board'
3. Obtain the WMSchedule recordset again after retuning from the "Schedule Board".

and the code is as pasted below:-
WMSchedule1.RESET;                   //WMSchedule1 --> record var. of type WMSchedule table
WMSchedule1.SETRANGE(JobNo);
WMSchedule1.SETRANGE(ItemNo);

InvokeScheduleBoard();      //Opens Schedule Board dialog and allows user to change schedule

WMSchedule2.RESET;                   //WMSchedule2 --> record var. of type WMSchedule table
WMSchedule2.SETRANGE(JobNo);
WMSchedule2.SETRANGE(ItemNo);
IF WMSchedule2.FINDFIRST THEN
BEGIN
    REPEAT
         WMSchedule1.SETFILTER(JobNo, WMSchedule2.JobNo);
         WMSchedule1.SETFILTER(ItemNo, WMSchedule2.ItemNo);
         //Few more filters are there
         IF WMSchedule1.FIND('-') THEN
              MESSAGE("Job %1 is re-scheduled", WMSchedule1.JobNo)
         ELSE
              MESSAGE("Job %1 is scheduled", WMSchedule2.JobNo);
    UNTILL WMSchedule2.NEXT = 0;    
END

Here WMSchedule1 stores the recordset before invoking the schedule board whereas WMSchedule2 stores the recordset after invoking the schedule board. The logic is i loop through each record in WMSchedule2 and check if it exists in WMSchedule1. If yes, the the job is rescheduled i.e. the record for the job exists in both views.
If no, then the job is scheduled i.e. the record for the job was not there before and now it is there.

Say, WMSchedule stores 10 records for job J1 to J10 that are already scheduled. So WMSchedule1 will store record count = 10. When i invoke the schedule board, say i schedule a new job J11. So WMSchedule1 will not have an entry for J11 whereas WMSchedule2 will have an entry for J11. This means that when i compare J11 of WMSchedule2 with WMSchedule1, it will flag message "Job J11 is scheduled".
However this is not the case. It flags message "Job J11 is re-scheduled".

I am not sure why WMSchedule1 & WMSchedule2 does not show me the difference. Is it the case although i have taken the recordset WMSchedule1 before invoking the schedule board, when i fire a database operation, WMSchedule1.FIND(), it will always get the latest recordset.

If this is the case then how should i maintain a before and after view of a recordset so that i can identify the difference that takes place after invoking the schedule board.

Any idea?

Regards.
Hemant
Regards,
Hemant
MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)

Comments

  • mabl4367mabl4367 Member Posts: 143
    WMSchedule1 must be temporary table or else it will refer to the same table in the database as WMSchedule2, only having different filters and pointing to different records.

    If you insert something i WMSchedule1 when it's not a temp table, it will be inserted into WMSchedule2 also since they both refer to the same table in the database.

    If you declare WMSchedule1 as temporary you must populate it by iterating through and copying the WMSchedule in the database.
Sign In or Register to comment.