Extend the test procedure with a dynamic browse
- Last Updated: May 7, 2024
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
In this section, you apply a few of the things you just learned to add a dynamic browse to the procedure with the dynamic temp-table.
To extend the sample procedure with a dynamic browse:
- Open the h-testDynTT.p procedure and save a new version of it as h-testDynBrowse.p.
- Add a variable definition at the top for a browse handle and also a frame definition
for a frame to hold the browse:
DEFINE VARIABLE hBrowse AS HANDLE NO-UNDO. DEFINE FRAME BrowseFrame WITH SIZE 80 BY 10. - Remove the
REPEATblock from the procedure that walks through the temp-table records using the dynamic query and displays them. Instead, you display them in a dynamic browse. - Add a
CREATE BROWSEstatement after theQUERY-PREPARE. It will be the only object in the frame, so it can be atROW 1andCOLUMN 1. ItsWIDTHneeds to be slightly less than the frame to allow for the frame border. Parent it to the frame and assign the dynamic query to it. Make itSENSITIVEandVISIBLE, and give itSEPARATORSbetween columns but noROW-MARKERSat the beginning of the row:CREATE BROWSE hBrowse ASSIGN ROW = 1 COL = 1 WIDTH = 79 DOWN = 10 FRAME = FRAME BrowseFrame:HANDLE QUERY = hQuery SENSITIVE = YES SEPARATORS = YES ROW-MARKERS = NO VISIBLE = YES. - To get started, try adding all the columns from the temp-table buffer except for a
handful that you exclude, using this statement:
hBrowse:ADD-COLUMNS-FROM(hTTBuf, "SalesRep,Country,address,Address2,State").Note that you cannot pass the dynamic temp-table name as the table identifier for this method. Even though you do give the temp-table a name when you prepare it, that name is not available to the method. You must pass the handle to a buffer for the temp-table, either its
DEFAULT-BUFFER-HANDLEor another buffer you defined for it. - Enable everything in the frame and wait for the user to close the window so that the
user can manipulate the browse when the window comes up. Add these lines to the end
of the procedure:
ENABLE ALL WITH FRAME BrowseFrame. WAIT-FOR CLOSE OF CURRENT-WINDOW. - Run the procedure. You should see all the
Customers in New Hampshire with all the fields except the
ones you excluded:
To try adding specific columns to the browse:
- Remove the
ADD-COLUMNS-FROMmethod and instead add these four statements to add these four columns to the empty browse:hBrowse:ADD-LIKE-COLUMN(hTTBuf:BUFFER-FIELD("Sequence")). hBrowse:ADD-LIKE-COLUMN(hTTBuf:BUFFER-FIELD("CustNum")). hBrowse:ADD-LIKE-COLUMN(hTTBuf:BUFFER-FIELD("Name")). hBrowse:ADD-LIKE-COLUMN(hTTBuf:BUFFER-FIELD("RepName")). - Run the procedure again. You should see just the four columns
you specified: