Kbase 20025: ADM2. How to Print Selected Rows of a Multiple Selected Browser
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  12/10/2008 |
|
Status: Verified
GOAL:
How to retrieve each of the selected rows in a multiple Selection SmartDataBrowser and store them in a temporary table for later use (output to a file, output to a printer etc.).
GOAL:
How to retrieve multiple elements selected in a SmartDataBrowser?
GOAL:
How to Print Selected Rows of a Multiple Selected Browser
FACT(s) (Environment):
Progress 9.x
SYMPTOM(s):
ADM2
FIX:
You cannot directly access these rows using the RowObject temp-table in the SmartDataBrowse because the RowObject temp-table does not really contain the data.
To retrieve selected rows, follow these steps:
1) Load the AppBuilder.
2) Connect to the Sports2000 database.
3) Create a new SDO against the Customer table (select all fields).
4) Create a new SmartDataBrowse and specify the SDO you created in Step 3 as the data source.
5) Double-Click the browse widget in the SmartDataBrowse and turn on the "Multiple-Selection" setting.
6) Resize the frame of the SmartDataBrowse so that you can add a button to the frame.
7) Add a button to the SmartDataBrowse's frame.
8) Put the following code into the DEFINITION section for the button:
DEFINE WORK-TABLE MyTable LIKE customer
FIELD MTNumber LIKE customer.custnum
FIELD MTName LIKE customer.name.
9) Put the following code into the CHOOSE trigger for the button:
DO:
DEFINE VARIABLE hquery AS HANDLE NO-UNDO.
DEFINE VARIABLE hBuffer AS HANDLE NO-UNDO.
DEFINE VARIABLE hCustNum AS HANDLE NO-UNDO.
DEFINE VARIABLE hCustName AS HANDLE NO-UNDO.
DEFINE VARIABLE iCount AS INTEGER NO-UNDO.
ASSIGN hquery = br_table:QUERY
hbuffer = hquery:GET-BUFFER-HANDLE(1)
hCustNum = hBuffer:BUFFER-FIELD("CustNum").
hCustName = hBuffer:BUFFER-FIELD("Name").
DO iCount = 1 TO br_table:NUM-SELECTED-ROWS:
br_table:FETCH-SELECTED-ROW(icount).
MESSAGE "Customer Number" hCustNum:BUFFER-VALUE
"Customer Name" hCustName:BUFFER-VALUE
"Selected" VIEW-AS ALERT-BOX.
CREATE mytable.
mytable.MTNumber = hCustNum:BUFFER-VALUE.
mytable.MTName = hCustName:BUFFER-VALUE.
END.
OUTPUT TO mytest.txt.
FOR EACH mytable:
DISPLAY mytable.MTNumber mytable.MTname.
END.
OUTPUT CLOSE.
FOR EACH Mytable
DELETE Mytable.
END.
END.
10) Save the SmartDataBrowse.
11) Create a SmartWindow.
12) Add the SDO to the SmartWindow.
13) Add the SmartDataBrowse to the SmartWindow.
14) Run the SmartWindow.
15) Select several rows in the browse widget.
16) Click the button.
At this point, a message box is displayed for each selected customer
that shows you the customer number and name, a work-table is created containing the selected rows with the two field (custnum and name).
The values stored in the work-table are outputed to "mytest.txt" file. The contain of the work-table is deleted after the output, for the next selection.
You can print the contain of the work-table directly to the
printer using the "output to printer" instead to a file.