Syntax problem

Posted by Admin on 09-Nov-2010 15:49

I'm sure there is something simple I'm missing here, but when I try to compile the following code:

for each tt no-lock break by tt.whse by tt.mfr:
      
    for each b-tt where b-tt.whse = tt.whse no-lock break by b-tt.mfr:
            accumulate b-tt.totlaboramt (total by b-tt.mfr).
            accumulate b-tt.labor          (total by b-tt.mfr).

            if last-of(b-tt.mfr) then do:
          
                 assign v-efftot = ((accum total by b-tt.mfr b-tt.totlaboramt) /
                                          (accum total by b-tt.mfr b-tt.labor)) * 100.
                     display
                     b-tt.whse
                     b-tt.mfr
                     v-efftot.
             end. /*if last b-tt*/
        end. /*FE b-tt*/
        assign v-efftot     = 0
               v-disptotamt = 0
               v-disptotlab = 0.
      end. /*FE b-tt*/
end. /*FE tt*/

I get the following error: BREAK keyword or BY phrase missing for aggregate expression. (574)

I can't figure out why I'm getting this message, can anyone shed some light on the syntax I'm messing up?

All Replies

Posted by kevin_saunders on 10-Nov-2010 08:38

If I copy/paste your code and make a dummy temp-table and buffer and a couple of vars, I get 'One or more extra end statements'. Commenting out the first one (/*FE b-tt*/) gets me a clean syntax check, meaning time to check those blocks.

Posted by Admin on 10-Nov-2010 09:13

I took out the extra end statement, but I'm still getting the error message:  "BREAK keyword or BY phrase missing for aggregate expression. (574)" and "Could not understand line 237. (198)" (which is the "for each b-tt" line).

Posted by Admin on 10-Nov-2010 09:32

Just a bit more info, here is how the fields on my temp table are defined:

field mfr              like zddaswel.compmfr (char x(4))
field totlaboramt  as   dec

field labor           as   dec

the mfr field is not part of the index for the temp table.

Posted by Admin on 11-Nov-2010 08:43

I found the problem, I added the break by conditions i was using to the index for the temp table and that resolved the compile error.

This thread is closed