当前位置: 动力学知识库 > 问答 > 编程问答 >

progress 4gl - Passing a value as a search criteria

问题描述:

I do want to filter the results according to the input in the search-box, i will explain how it should work

  1. Initially it should display the complete results "for each customer"
  2. Then on results if i press "s" a search box should appear which will prompt for customer number
  3. On giving the company number, the results should be displayed only for that company.

Code:

for each customer where customer.no = num no-lock:

tmpname.name = customer.name

tmpname.no = customer.no

end.

if num = "" then

for each customer no-lock:

create tmptable

tmpname.name = customer.name

tmpname.no = customer.no

end.

the above table will display results for all the companies,

this form will prompt for customer.no

 form num

customer.no

with frame f1.

update num with frame f1.

Now, I dont know how to pass this num back to the first "FOR EACH". to filter the search only for the given customer number. Your help is much appreciated. Thanks in advance.

网友答案:

I think that this does what you seem to be describing with the text (but not the code):

define variable cNum as integer no-undo.

define query q for customer.

define browse b query q display customer.custNum customer.name with 10 down.

form b with frame custList row 1 column 1.

form
  cNum
 with
  frame updCustNum
  column 50
  row 1
.

on "s" anywhere do:
  apply "entry" to cNum in frame updCustNum.
  return no-apply.
end.

on "go", "enter" of cNum in frame updCustNum do:
  cNum = integer( self:screen-value ).
  close query q.
  open query q for each customer no-lock where customer.custNum = cNum.
  apply "entry" to b in frame custList.
  return no-apply.
end.

open query q for each customer no-lock.

enable cNum with frame updCustNum.
enable b with frame custList.
apply "entry" to b in frame custList.

wait-for "close" of this-procedure.

return.
网友答案:

I'm really not 100% sure what your asking but you could (should) put your logic inside a procedure or even a separate program an call it on the specific event (button-click, start of program or whatever you choose).

PROCEDURE searchCustomer:
    DEFINE INPUT  PARAMETER piCustomerNo AS INTEGER     NO-UNDO.
    DEFINE OUTPUT PARAMETER TABLE FOR tmpname.

    IF piCustomerNo = 0 THEN DO:
        FOR EACH customer NO-LOCK TABLE-SCAN: /* TABLE-SCAN only works in version 11.something and forward */
            CREATE tmpname.
            BUFFER-COPY customer TO tmpName.
        END.
    END.
    ELSE DO:
        FOR EACH customer NO-LOCK WHERE Customer.NO = piCustomerNo:
            CREATE tmpname.
            BUFFER-COPY customer TO tmpName.
        END.
    END.

END PROCEDURE.

And on the specific events you do:

RUN searchCustomer(INPUT 0, OUTOUT TABLE tmpname).

or

RUN searchCustomer(INPUT iCustomer, OUTOUT TABLE tmpname).
分享给朋友:
您可能感兴趣的文章:
随机阅读: