Compare the same
bRahms
Member Posts: 44
Hi again,
we've got a problem, once again. It's probably a quite easy problem to fix, but we just don't get it to fix it. The code given below i'm sure isn't correct, because you search the DossierID and then again you search for the same Dossier ID. What we want is, when he found twice the same DossierID (which isn't the primary key), they only show that one on our report.
So for example:
Dossier ID
1
2
5
8
9
2
9
The ones who should be shown on the report are just 2 and 9. How to? Any help would be thankful.
we've got a problem, once again. It's probably a quite easy problem to fix, but we just don't get it to fix it. The code given below i'm sure isn't correct, because you search the DossierID and then again you search for the same Dossier ID. What we want is, when he found twice the same DossierID (which isn't the primary key), they only show that one on our report.
So for example:
Dossier ID
1
2
5
8
9
2
9
The ones who should be shown on the report are just 2 and 9. How to? Any help would be thankful.
recrecidive.RESET;
recrecidive.SETCURRENTKEY(DossierID);
recrecidive.SETFILTER(DossierID,'=%1', recrecidive.DossierID);
IF recrecidive.FIND('-') THEN
REPEAT
recrecidive.SETFILTER(DossierID,'=%1', recrecidive.DossierID);
IF recrecidive.FIND('-') THEN
REPEAT
IF DATE2DMY(recdossier.Opstartdatum,2) >= DATE2DMY(recdossier.Afsluitdatum,2) THEN BEGIN
IF DATE2DMY(recdossier.Opstartdatum,1) >= DATE2DMY(recdossier.Afsluitdatum,1) THEN BEGIN
END ELSE BEGIN
EXIT;
END END;
UNTIL recrecidive.NEXT = 0;
UNTIL recrecidive.NEXT = 0;
0
Comments
-
I think that your code is completely wrong, because you changes the record position of "recrecidive" inside repeat ... until loop. Of course it is possible but for special reason (I don't know such).0
-
You need a second instance of the table, such as recrecidive2.
So
inside your recrecidive REPEAT do a
recrecidive2.RESET;
recrecidive2.SETFILTER(the same filters you had in the outter loop)
REPEAT
IF recrecidive2.whateverdate > recrecidive.whateverdate
THEN you know you have the newest date
UNTIL recrecidive2.NEXT = 0;
UNTIL outter loop processed
I hope this helps, have a great day!
No one loves you like the one who created you...0 -
One way to go:
Dataitem for recrecidive2.
Then in OnAfterGetRecord:LocalVariable_recrecidive2.RESET; LocalVariable_recrecidive2.SETRANGE(DossierID,recrecidive2.DossierID); IF LocalVariable_recrecidive2..COUNT = 1 THEN CurrReport.SKIP;
So it only displays duplicate values, and skips unique ones. I'm just writing this off the top of my head, so you'll probably have to tweak it a little bit.0 -
we did it kind of like saint-sage said, thanks for that. but now we've got problems when einddatum isn't filled in (not all the dossierID's have an einddatum). Then he says the date is invalid
recrecidive.RESET; recrecidive.SETCURRENTKEY(DossierID); IF recrecidive.FIND('-') THEN REPEAT recdossier.RESET; recdossier.SETCURRENTKEY(DossierID); recdossier.SETFILTER(DossierID,'=%1', recrecidive.DossierID); IF recdossier.FIND('-') THEN REPEAT recrecidive2.RESET; recrecidive2.SETFILTER(DossierID,'=%1', recdossier.DossierID); IF recrecidive2.FIND('-') THEN REPEAT IF DATE2DMY(recrecidive2.Begindatum,2) > DATE2DMY(recrecidive.Einddatum,2) THEN BEGIN MESSAGE('hi' + format(recrecidive2.dossierID)); END; UNTIL recrecidive2.NEXT = 0; UNTIL recdossier.NEXT = 0; UNTIL recrecidive.NEXT = 0;0 -
ofcourse0
-
we did know the offcourse as well, but we don't know how to fix it.. if it's fixable0
-
So you have the recrecidive table, through which you loop, then you filter the Dossier table on DossierID, through which you loop, and then for each rec found, you filter a second instance of the recrecidive table, and you filter on DossierID That is a classic example of redundancy :shock:
Why not set a filter on DossierID directly in the second instance of your recrecidive table? If DossierID is the primary key of the Dossier table, then do Dossier.GET(DossierID) instead, because there is only one record for that ID, and you shouldn't have to loop.
NAV can only do DATE2DMY if there is a date value, so you should add something to your recrecidive2 loop, something like this:IF recrecidive2.FINDSET THEN REPEAT IF (recrecidive2.Begindatum = 0D) OR (recrecidive2.Einddatum = 0D) THEN BEGIN MESSAGE('blank date value found'); END ELSE BEGIN IF DATE2DMY(recrecidive2.Begindatum,2) > DATE2DMY(recrecidive.Einddatum,2) THEN BEGIN MESSAGE('hi' + format(recrecidive2.dossierID)); END ELSE BEGIN //program what should happen if the condition is not met END; END; UNTIL recrecidive2.NEXT = 0;0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
