how to use break by statements in a nested for each loop with three tables in progress 4gl

Nisha

New Member
I am fairly new to progress. I am trying to figure out the working of a nested for-each loop. Suppose I have three tables Customer, Order and Orderline. I would like to use break by on these tables based on customer.customer-num and Order.ordernum to generate a final report. This is the code I have so far.




Code:
for each Customer no-lock,
  each order where
  order.custnum = customer.custnum no-lock,
  each orderline where
  orderline.ordernum = order.ordernum
  break by customer.custnum
  by order.ordernum:

  if first-of(customer.custnum) then 
  do:

    put stream s1 unformatted

      space(3) customer.custnum format ">>>>9" space(1)
      customer.name format "x(30)" space(1)
      customer.city format "x(12)" space(1)
      customer.state format "x(20)" space(1)
      customer.country format "x(20)" space(1)
      /*order.ordernum format "zzzzzzzzz9" space(1)
      order.orderDate format "99/99/99" space(1)
      order.orderStatus format "x(20)" */ skip .


  end.

  put stream s1 unformatted

    space(95) order.ordernum format "zzzzzzzzz9" space(1)
    order.orderDate format "99/99/99" space(1)
    order.orderstatus format "x(20)" space(1).
end.

if first-of(order.ordernum) then 
do:


  put stream s1 unformatted

    orderline.linenum format ">>9" space(1)
    orderline.itemnum format "zzzzzzzzz9" space(1)
    orderline.price format "->,>>>,>>9.99" space(1)
    orderline.qty format "->>>>9" skip.
END.
 
Last edited by a moderator:
Please us [ C O D E ] tags so that we can actually read your example.

Is there something about your posted code that does not work? It seems to have BREAK BY in it. So what is the problem?
 
I've edited the code tags in for the OP.
I would suggest that the erors are because the second first-of is outside the for each.
 
Back
Top