如何使用进度4gl以更高的订单成本/价格列出给定开始日期的前十名客户

时间:2016-12-15 10:44:38

标签: progress-4gl openedge

单个客户可能有多个订单和相应的成本。 现在必须添加成本/价格,并根据应显示客户的最高价格。 我刚刚写了编程的骨架,请帮助我。

  define temp-table ttorder
  field ocust-num like order.cust-num 
  field oorder-num   like order.order-num.
  define variable i as int.
  define variable a as int.

  define temp-table ttorderln
  field oprice like order-line.price.

  for each order where order-date > 01/08/93 /*by cust-num*/ . 

      create ttorder .
      assign
        ttorder.ocust-num   =cust-num
        ttorder.oorder-num = order-num.

    for each order-line where order-line.order-num = ttorder.oorder-num break by ocust-num.

    i = order-line.price.
     a = i + a. 
  /*   display cust-num order-num a. */
    if last-of (ttorder.ocust-num) then
        do:


        create ttorderln.
        ttorderln.oprice=a. 

        end. 

   display ttorderln.

    end.  


  end.

1 个答案:

答案 0 :(得分:2)

如果您正在寻找顶级客户,您应该使用基于客户的临时表,而不是订单。浏览订单和订单行,按客户累计金额。

define temp-table ttcust
  field cust-num like order.cust-num 
  field order-tot as decimal
  index idx1 cust-num
  index idx2 order-tot.

define variable i as integer.

  for each order where order-date > 01/08/93: 

      /* Find or create a customer temp record. */
      find first ttcust where ttcust.cust-num = order.cust-num no-error.
      if not available(ttcust) then
      do:
          create ttcust.
          ttcust.cust-num = order.cust-num.
      end.

      /* Add up the order lines. */
      for each order-line where order-line.order-num = order.order-num no-lock:
          ttcust.order-tot = ttcust.order-tot + order-line.extended-price.
      end.

  end.

  /* Display the top 10. */
  for each ttcust by order-tot descending:
    i = i + 1.

        message "Cust: " ttcust.cust-num skip
                "Total: " ttcust.order-tot view-as alert-box.

    if i >= 10 then leave.

  end.