Relation between tfacp200 & tdpur046
This is related to Baan IV.
we have a report requirement with following details:
Supplier Tran.type Doc.No Invoice amt Order Order amt
abc FIP 20090001 1000 100001 500
abc FIP 20090001 1000 100002 500
here, invoice FIP 2009000 is paid against two purchase orders (records from tdpur046). Is there any way to join these two tables (obviously based on ttyp and ninv) in such a way that if a matching record is not found in tdpur046, the fields from tdpur046 will be blank but the values from tfacp200 will be printed. I could not find any way to use "refers to" as there is no native relationship between these two tables. One way is I can use is as below:
tfacp200.ttyp = tdpur046.ttyp and tfacp200.ninv = tdpur046.invn
ON THE FORM FOLLOWING FIELDS WILL BE USED AS SELECTION CRITERIA:
SUPPLIER FROM - TO
PURCHASE ORDER FROM - TO
TFACP200.TTYP FROM - TO
TFACP200.NINV FROM- TO
Is there any way out to overcome this problem ?
I would just use a sub query inside the query on tfacp200. So query tfacp200 on your ranges. Then inside the select do query tdpur046 - in select empty 0 out the fields or clean up the fields from the previous find. There might be better ways, but this is easy for me to follow.
As Mark said, you would start with tfacp200 as your 'driving' table and using the Document Type and Number as key, fetch the tdpur046 records based on that table's secondary key.
But the issue is that these set of records sometime (very rarely) break in strange ways. SO, you can have a tfacp200 record which satisfies let us say three purchase order receipts, but only two purchase order invoice records (tdpur046) are created. So it is not merely a matter of whether the tdpur046 record exists or not, but whether the SUM of amounts of tdpur046 match the amount of the tfacp200 record. Of course, when selecting records from tfacp200, you have to pick the records where the second document type and number are blank and zero, as the records in which the second document number, etc. is filled in represent those tfacp200 records related to say payments or adjustments and such.
For us at least, this was quite an expensive report to run unless properly constrained - so we had additional constraints like say analyze only one vendor at a time (since usually, the issue would have been raised by a particular vendor.) Once a year, we would run the complete report to 'repair' anything remaining.
|All times are GMT +2. The time now is 23:40.|
©2001-2018 - Baanboard.com - Baanforums.com