1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

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

Discussão em 'StackOverflow' iniciado por fdantas, Agosto 13, 2015.

  1. fdantas

    fdantas Administrator Moderador

    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.

    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.

    Continue reading...

Compartilhe esta Página