After searching in a database how to display the r

2019-09-11 07:17发布

问题:

Accept a customer number and then output the details of each order and items to an editor widget. Display them in the editor widget ( editor-1 as object name).

define temp-table ttcustomer
field custnum like customer.cust-num
field cname like customer.name
field orders like order.order-num
field items like item.item-num
field itemname like item.item-name .


find first customer WHERE customer.cust-num = input f1 NO-LOCK .

create ttcustomer . 

  assign
  ttcustomer.custnum = customer.cust-num
  ttcustomer.cname     = customer.name. 



 for each order WHERE Order.cust-num = input f1  NO-LOCK .

  assign
  ttcustomer.orders   = order.order-num.

  for each order-line where order-line.order-num = order.order-num no-lock.


     for each item where item.item-num = order-line.item-num no-lock.

     assign 
     ttcustomer.items = item.item-num
     ttcustomer.itemname = item.item-name. 
     end.
  end.
end.

回答1:

I have no idea why you would want to display that on an editor. So I'll assume you want to concatenate the info you gathered in the for each loop into an editor. So after the last end, you could do this:

define variable editor-1 as character view-as editor.
for each ttcustomer:
    assign editor-1 = editor-1 + ttcustomer.items + ' ' + ttcustomer.itemname + chr(13). 
end.
display editor-1.

If chr(13) doesn't work to skip a line, try chr(10). PS: An editor is really probably not the widget you want to display this. I'd use a browse. But since the question asks for an editor, there. PS2: You didn't assign the other fields you put on the temp-table, so I'm not displaying them. But it's just a matter of adding them to the assign line above, not forgetting the spaces, dashes or whatever you'd like to use as a separator.