You don't show where you increment ENTREVUES_AUJOURDUI, but assuming that you do this at the end of the case, I would just like to point out a couple things:
- Your code will not allow for someone to add a case and then modify it, as that modification will (presumably) be counted as a new case. Maybe this isn't an issue given your workflow.
- Your ENTREVUES_AUJOURDUI counter will always start as 0 when the interviewer opens CSEntry, so they can bypass this check by closing CSEntry and then opening it again.
To avoid the second problem, you will want to use a variable whose lifetime outlasts a single instance of CSEntry. You can do this by making the variables persistent (if using CSPro 8.0), or by using loadsetting/savesetting:
https://www.csprousers.org/help/CSPro/p ... ifier.html
https://www.csprousers.org/help/CSPro/l ... ction.html
If using CSPro 8.0, I'd probably implement this using a HashMap object. See the code here, and attached for an example that you can run:
// this code belongs in the PROC where the final case ID is entered
// cases_by_day will map case keys to the date they were initially entereed
persistent HashMap cases_by_day(string) default(notappl);
numeric today = sysdate("YYYYMMDD");
string this_case_key = currentkey(LIMIT_CASES_PER_DAY_DICT);
// check if this case has already been entered (if so, we are in modify mode)
numeric date_case_entered = cases_by_day(this_case_key);
// if this is a new case, verify that there have not been too many new cases entered today
if date_case_entered = notappl then
List string all_cases_entered;
cases_by_day.getKeys(all_cases_entered);
numeric cases_entered_today = 0;
do numeric ctr = 1 while ctr <= all_cases_entered.length()
if cases_by_day(all_cases_entered(ctr)) = today then
inc(cases_entered_today);
if cases_entered_today = 2 then
errmsg("You cannot enter more than 2 cases per day.");
reenter;
endif;
endif;
enddo;
// add this new case to the list of cases entered today
cases_by_day(this_case_key) = today;
endif;
Limit-Cases-Per-Day.zip
You do not have the required permissions to view the files attached to this post.