Narrowing Down Export

Phillip

Member
Hi,

I'm still learning Progress and am trying to run an output from our Syteline database. Here is my query that I have:

OUTPUT TO l:\test\testfolder\runrate.dat.
EXPORT DELIMITER ","
"Item"
"Description"
"Machine Run Rate"
"Labor Run Rate"
.

FOR EACH ITEM WHERE product-code = "FGCTL1",
FIRST job where ITEM.ITEM = job.ITEM,
EACH jrt-sch WHERE job.job = jrt-sch.job AND jrt-sch.oper-num = 10,
EACH jobroute WHERE job.job = jobroute.job AND jobroute.wc = "855" NO-LOCK:

EXPORT DELIMITER ","
item.item
ITEM.DESCRIPTION
jrt-sch.pcs-per.mch-hr
jrt-sch.pcs-per-lbr-hr

.
END.



What I'm trying to do is get a job for each item from that product code. I need to get the job to connect into the jrt-sch table (job route schedule). Then I want to pull each jrt-sch associated with that job that has a 10 for oper-num. Finally i need only those jrt-sch that are from 855 in the jobroute table.

How can i tier this down to the results I want?

Thanks
 

GregTomkins

Active Member
I don't know Syteline and I lack the energy to correlate your code with your question. But for years I wrote FOR EACH all day long and almost never used complex multi-part clauses like that. I would write something like this:

Code:
FOR EACH ITEM WHERE product-code = "FGCTL1":
  FIND FIRST job where ITEM.ITEM = job.ITEM.
  FOR EACH jrt-sch WHERE job.job = jrt-sch.job AND jrt-sch.oper-num = 10:
    FOR EACH jobroute WHERE job.job = jobroute.job AND jobroute.wc = "855":
        EXPORT whatever.

I don't think this actually matters; you could no doubt make it work either way, but this way might be simpler for you and also you can put interim EXPORT or MESSAGE statements after each statement to make sure it's working right.

Of course, if this were real code, I would also add sensible NO-LOCK and NO-ERROR, omitted here for clarity.

Now ... prepare for the wrath of ProgressTalk for using FIND FIRST ;), and for heaven's sake don't tell them if you are still on Version 9!

Edit: added code tags for avoid further wrath.
Edit: added sarcastic comment about versions.
 

TomBascom

Curmudgeon
Good points. Especially regarding FIND FIRST and ancient, obsolete and unsupported releases....

So, about FIND FIRST... Why? What is so special about the "first" one? What makes it "first"? What do you plan to do with the 2nd and 3rd etc? Why aren't they special? Isn't their self-esteem likely to suffer from this disparate treatment?
 
Top