Iterate through operations, find where only one certain operation exists


(Chris Simpson) #1

Maybe I’m over thinking this one or just brain dead right now. So I have many jobs that have one or many operations. I am trying to single out jobs which only have a single JobOper.OpCode of “ASSEM”. I am just trying to get assembly only jobs but I’m struggling… Oh Epicor 9.05, so this would be in ABL.

Thank you!
Chris


(Jose C Gomez) #2

Why not write a BAQ with a Count per OpCode and filter out anything whrere the count is > 0


(Chris Simpson) #3

Exactly where I am at but for some reason I am struggling with something that should be so simple… lol


(Chris Conn) #4

Not sure how diff in E9 it is, but in general
image

image

image


(Chris Simpson) #5

For me to do this, the JobOper table must be a summary table which I cannot have. This BAQ/Dashboard is to display all Jobs and their operations. I am trying to set a calculated field to true if there is only one operation where the OpCode equals ASSEM.


(Chris Conn) #6

Does E9 allow subqueries? If so, you could make a separate query and link it back in


(Chris Simpson) #7

Unfortunately, no. Not until e10.


(Chris Conn) #8

Awwww drats


(Jose C Gomez) #9

Didn’t realize it was part of a dashboard you are kind of out of luck you’ll have to either customize the dashboard to fill in that caculated fied… or use a BPM to flag the records ahead of time. (in 9)


(Chris Simpson) #10

That’s what I am trying to do is write the BPM to set a field to true and then filter by that field in the dashboard.


(Chris Simpson) #11

In my BPM, I should be able to iterate through each operation (for each) within a job with a counter. If it only counts 1 AND that counted operation’s OpCode is “ASSEM” then set my calculated field to true…Just how?


(Jose C Gomez) #12

Here’s some info on using aggregates in ABL
https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dvref/aggregate-phrase.html


(Chris Simpson) #13

Thank you


(Chris Simpson) #14

My brain just unlocked… This was a big duh so sorry for wasting all of your time.

DEF VAR COUNTER AS INTEGER no-undo.

For EACH ttResults no-lock.
COUNTER = 0.

Find FIRST JobHead where JobHead.JobNum = ttResults.JobHead_JobNum no-lock no-error.
	If AVAIL JobHead then DO:
		For EACH JobOper where JobOper.JobNum = JobHead.JobNum no-lock.
				COUNTER = COUNTER + 1.
		End.
		If COUNTER = 1 and JobOper.OpCode = "ASSEM" then ttResults.Calculated_AssemblyOnly = TRUE.
	End.

End.