Message Boards

How to search for unmatched records in a browse

Cathy Jeanes, modified 3 Years ago.

How to search for unmatched records in a browse

Post Date: 5/30/16 (Bronze, 6 Posts) Recent Posts

I want to link 2 tables and return only the records from the 1st table that don't exist in the 2nd table.

An example - looking at all items that don't have a production line assigned to them.

I have created a browse with an outer join from the pt_mstr table to the Lnd_det table but I can't work out how to select records in pt_mstr that don't exist in lnd_det

Would welcome any ideas

thanks

Scott Dulecki, modified 10 Years ago.

Re: How to search for unmatched records in a browse

Post Date: 5/31/16 (Silver, 29 Posts) Recent Posts
Hi, Cathy.

First step... add this in the filter field on the query tab: pt_pm_code = "L" and pt_run_seq1 = "" <p>

That will show everything that is line sequenced with no Run Sequence 1.

That's not exactly what you're looking for... I suspect there's a creative way with local variables and preprocessors to do that, and if I figure it out, I'll share it with you.
thumbnail
Phill Norrey, modified 10 Years ago.

Re: How to search for unmatched records in a browse

Post Date: 5/31/16 (Yoda, 1010 Posts) Recent Posts
This might not work. If you are using msw/psw then you could have some parts that are M rather than L. Also not sure if you use run sequences. Finally, do you use site records. If you do they you need to look for the ptp_det to get the pm code. Now this is not the perfect solution but would get you by until you find a better one. You could create a browse to get the part data and export it to excel. Do the same for the production lines. Then use a v-lookup to find which ones are not set up
Cathy Jeanes, modified 10 Years ago.

Re: How to search for unmatched records in a browse

Post Date: 5/31/16 (Bronze, 6 Posts) Recent Posts
thanks both for your replies. We are using the workbench and products are set up as M not L. We are using run sequences but don't have site records. I had thought about extracting the data from the two tables and using Excel to compare but the users are after a number of quick data checks on screen that they can use to show things needing attention. For the moment I've given them the browses returning all records for them to sort and show any blanks at the top which works (though not ideal) until I can figure out how to do directly in the browse or I may end up linking in a database and scheduling some overnight queries there if all else fails.
thumbnail
Xavier Pechadre, modified 10 Years ago.

Re: How to search for unmatched records in a browse

Post Date: 6/1/16 (Silver, 70 Posts) Recent Posts
Hello, Perhaps you can use a function in your browse. In your browse, you read pt_mstr table and you can add a field who use a function like this. Find lnd_det where domain, site and lnd_part = pt_part no-lock no-error. If not available lmd_det then return "Error" else return "Ok" for example. best regards
thumbnail
Phill Norrey, modified 9 Years ago.

Re: How to search for unmatched records in a browse

Post Date: 7/12/16 (Yoda, 1010 Posts) Recent Posts

Cathy.  What you need to do is set up the part as the left table (ie the first table)  then add the lnd_det as the second table.

Create the joins between the records and then RIGHT CLICK on one of the join lines and select properties.

At the bottom of the properties screen there is the option to include ALL records from the left table.  Click on that option.

Then when you run your report it will show you a blank where there is a missing record.

BUT it will be slow depending upon how many records you have

Tomaz Ranzinger, modified 9 Years ago.

Re: How to search for unmatched records in a browse

Post Date: 7/13/16 (Silver, 77 Posts) Recent Posts

Cathy, in you case you need just ONE table in browse - that is pt_mstr.

And as Xavier said, add local-ariable and call function which returns lnd_line.

Here is function:

FUNCTION GetLndLine returns character (input partcode as character):            
define variable returnValue as character no-undo.    
define buffer pt_mstr for pt_mstr.

for first pt_mstr no-lock where                                                
pt_domain = global_domain and pt_part = partcode:                                 
 
    for first lnd_det no-lock
      where lnd_domain = pt_domain and
            lnd_part   = pt_part :
      returnValue      = lnd_part.                                       
    end.   
end.                                 
return returnValue.    
end function.

 

And here is what you have to put in local-variable properties: GetLndLine (input pt_part).

 

 

Message place holder