For each to retrieve data from two tables

kblackwel

New Member
Let me start by saying I'm entry level efficient in writing ABL.

My co-worker had some scripts that he's started to have me run. We call them QND's (Quick and Dirty's)
Currently I have to launch mpro (the wrapper for us is called sxee) and execute these scripts individually. That is not efficient.
Here's the scripts with the for loop parts.

1.
def var v-prod like icsp.prod no-undo.

for each icsp where icsp.cono = 80 and
icsp.prod = v-prod exclusive-lock:

2.
def var v-prod like icsw.prod no-undo.
for each icsw where icsw.cono = 80 and
icsw.prod = v-prod exclusive-lock:


I've been testing this

for each icsp, each icsw of icsp where icsp.prod = v-prod and
icsw.prod = v-prod
exclusive-lock:

But all that does it churn away with no results. I also probably kill before it generates results. In comparison, the scripts individually process in a manner of seconds.

Is what I'm trying to do in the right syntax? Is it possible to combine these scripts? Am I using the for each, each of where statement incorrectly?

Thanks in advance.
 

SergioC

Member
Hi, try this:

Code:
[COLOR=#333333]for each icsp 
     where [/COLOR][COLOR=#333333]icsp.cono = 80[/COLOR][COLOR=#333333]
[/COLOR][COLOR=#333333]        and icsp.prod = v-prod[/COLOR][COLOR=#333333], 
     each icsw 
     where icsw.cono = icsp.cono
        and [/COLOR][COLOR=#333333]icsw.prod = icsp.prod [/COLOR][COLOR=#333333]exclusive-lock:
     ...
[/COLOR]end.

Regards.
 
Top