Kbase 16293: How to get query and db-fields info on Freeform Query browse
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  5/10/1998 |
|
How to get query and db-fields info on Freeform Query browse
This Knowledge Base entry describes how to get the 4GL Query and
database fields used with a 'normal' browse and a FreeForm Query
browse via UIB API calls.
Below you will find 2 pieces of coding blocks (take note of the
comments that go along with it).
Both procedures will come up with two variables: query-4gl and
db-fields. The latter contains a comma-separated list.
For both pieces of code first define the following variables:
DEFINE VARIABLE pi_context AS INTEGER NO-UNDO.
DEFINE VARIABLE pc_name AS CHARACTER NO-UNDO.
DEFINE VARIABLE pc_request AS CHARACTER NO-UNDO.
DEFINE VARIABLE pc_info AS CHARACTER NO-UNDO.
DEFINE VARIABLE pc_mode AS CHARACTER NO-UNDO.
DEFINE VARIABLE pc_section AS CHARACTER NO-UNDO.
DEFINE VARIABLE pi_srecid AS INTEGER NO-UNDO.
DEFINE VARIABLE pc_code AS CHARACTER NO-UNDO.
DEFINE VARIABLE browse-context AS INTEGER NO-UNDO.
DEFINE VARIABLE query-4gl AS CHARACTER NO-UNDO.
DEFINE VARIABLE db-fields AS CHARACTER NO-UNDO.
PART 1: NORMAL DEFINED BROWSE
=============================
/*----------------------------------------------------------
Get context for browse.
----------------------------------------------------------*/
ASSIGN pi_context = ?
pc_name = "FRAME ?"
pc_request = "CONTAINS BROWSE RETURN NAME"
.
RUN adeuib/_uibinfo.p (INPUT pi_context,
INPUT pc_name,
INPUT pc_request,
OUTPUT pc_info).
/*----------------------------------------------------------
Variable pc_info now contains the name of the browse.
Use it to get the context-id for the browse.
----------------------------------------------------------*/
IF pc_info = "" THEN
RETURN.
ASSIGN pi_context = ?
pc_name = pc_info
pc_request = "CONTEXT"
.
RUN adeuib/_uibinfo.p (INPUT pi_context,
INPUT pc_name,
INPUT pc_request,
OUTPUT pc_info).
ASSIGN browse-context = INTEGER(pc_info).
/*----------------------------------------------------------
Now use the context-id stored in pc_info to access
the 4GL query and the database fields used
(4GL-QUERY and FIELDS).
----------------------------------------------------------*/
ASSIGN pi_context = browse-context
pc_name = "FRAME ?"
pc_request = "4GL-QUERY".
.
RUN adeuib/_uibinfo.p (INPUT pi_context,
INPUT pc_name,
INPUT pc_request,
OUTPUT pc_info).
IF RETURN-VALUE <> "Error" THEN
ASSIGN query-4gl = pc_info.
/*----------------------------------------------------------
Convert variable pc_info to a comma separated list of
database fields
----------------------------------------------------------*/
ASSIGN pi_context = browse-context
pc_name = "FRAME ?"
pc_request = "FIELDS".
.
RUN adeuib/_uibinfo.p (INPUT pi_context,
INPUT pc_name,
INPUT pc_request,
OUTPUT pc_info).
IF RETURN-VALUE <> "Error" THEN
ASSIGN db-fields = pc_info.
PART 2: BROWSE DEFINED WITH A FREEFORM QUERY
============================================
/*----------------------------------------------------------
Get context for browse.
----------------------------------------------------------*/
ASSIGN pi_context = ?
pc_name = "FRAME ?"
pc_request = "CONTAINS BROWSE RETURN NAME".
RUN adeuib/_uibinfo.p (INPUT pi_context,
INPUT pc_name,
INPUT pc_request,
OUTPUT pc_info).
/*----------------------------------------------------------
Variable pc_info now contains the name of the browse.
Use it to get the context-id for the browse.
----------------------------------------------------------*/
IF pc_info = "" THEN
RETURN.
ASSIGN pi_context = ?
pc_name = pc_info
pc_request = "CONTEXT".
RUN adeuib/_uibinfo.p (INPUT pi_context,
INPUT pc_name,
INPUT pc_request,
OUTPUT pc_info).
/*----------------------------------------------------------
Now use the context-id stored in pc_info to access
the trigger blocks which contain the 4GL query and
the database fields used (pseudo trigger-blocknames:
OPEN_QUERY and DISPLAY.
----------------------------------------------------------*/
ASSIGN pc_mode = "GET"
pi_context = INTEGER(pc_info)
pc_section = "TRIGGER:OPEN_QUERY"
pi_srecid = ?
.
RUN adeuib/_accsect.p (INPUT pc_mode,
INPUT pi_context,
INPUT pc_section,
INPUT-OUTPUT pi_srecid,
INPUT-OUTPUT pc_code).
IF RETURN-VALUE <> "Error" THEN
/*--------------------------------------------------------------------
Strip off the "OPEN QUERY <BROWSE-NAME> FOR" part + dot at the end
--------------------------------------------------------------------*/
ASSIGN query-4gl =
TRIM(SUBSTRING(pc_code,INDEX(pc_code, "EACH"),
LENGTH(pc_code) - INDEX(pc_code,"EACH"))).
ASSIGN pc_mode = "GET"
pi_context = INTEGER(pc_info)
pc_section = "TRIGGER:DISPLAY"
pi_srecid = ?
.
RUN adeuib/_accsect.p (INPUT pc_mode,
INPUT pi_context,
INPUT pc_section,
INPUT-OUTPUT pi_srecid,
INPUT-OUTPUT pc_code).
/*----------------------------------------------------------
Convert variable pc_code to a comma separated list of
database fields
----------------------------------------------------------*/
IF RETURN-VALUE <> "Error" THEN
ASSIGN db-fields =
REPLACE(TRIM(REPLACE(pc_code, CHR(10), "")),
FILL(" ",6), ",").
REFERENCES TO WRITTEN DOCUMENTATION
===================================
User Interface Builder Developer's Guide, Appendix B.3
Programming Handbook, chapter 9
Progress Software Technical Support Note # 16293