Smart Window Browses Editing (Open Edge)

fuji36

New Member
I'm working on an App Builder-Smart Window- added a browse with the 'browse wizard' . Later on I decide I need another table to be 'joined-in', the query is by now a 'free-form' query.

I cannot remember how to get to the 'browse definition' code, I can view it fine. The Section Editor does not take me there. I can open up a
Procedure Editor session, fix it up, run and all is fine. But when running as a window, no go. I know exactly what needs fixed, but I can't get to it.
 

fuji36

New Member
The App Builder is what I am using, the problem is : when editing the .w file, the Section Editor does not allow me to edit the 'browse' definition (to add another table ) that was originally created using the Query Wizard.

I can open up the .w with the Procedure Editor, make required changes and save, and actually run from the Procedure Editor. But when I again open with the App Builder, use Code preview, the changes I made in Procedure Editor are not there.
 
If you defined the query using the wizard (and didn't use a freeform query), then you should use the query wizard to edit it as well. You don't get to this from the section editor - you double-click on the browse widget (inside the smartBrowse master) to open the Property Sheet, and there are buttons for Query and Fields. Use the Query button to open the Wizard again.

If you use a freeform query, you can use the section editor to manually fiddle with it. If you use procedure editor to hand-crank it, there are multiple places you need to edit the query, and I wouldn't recommend that route.

Have you considered using a Dynamic SmartBrowse instead of the static one?
 

fuji36

New Member
I did use the Query Wizard, then went to 'free-form' as the app went along . The problem arose when I needed to add another table to the browse/query that is now 'free-form'.

Code Editor, revising the 'Open Query' trigger, no problem. However, the Code Editor does not allow me to get to the 'Definition' of the browse to adjust it. Everything else I can get to in 'Definitions' edit, as you would expect. I was able to 'hand-crank' the Procedure, but when I open the App again the Procedure reverts back, and the browse is again incorrectly defined.

I haven't used the 'dynamic' smart window.

I just feel as if there is some propertyr something that needs tweaked so that I can re-define the browse propely, thru the Section Editor.
 
Yeah, you've lost me now.

If it's a freeform query, you just use the section editor on the OPEN_QUERY pseudo trigger and edit the query definition. If you need to add another table, it just goes in there. No need to go back to the wizards.

Perhaps you can post the current query definition here, and give some idea as to what you want to change?

Hand cranking this stuff is always tricky. You'd need to change:

INTERNAL-TABLES preprocessor
FIELDS-IN-QUERY preprocessor
ENABLED-FIELDS-IN-QUERY preprocessor
QUERY-STRING preprocessor
OPEN-QUERY preprocessor
TABLES-IN-QUERY preprocessor
FIRST-TABLE-IN-QUERY preprocessor
the query definition (inside ANALYZE-SUSPEND preprocessor block)
the browse definition (inside ANALYZE-SUSPEND preprocessor block)
the _QUERY-BLOCK preprocessor

The last one is often forgotten/missed, and results in the AppBuilder resetting the query definition the next time the object is opened. But you shouldn't need to do all that!

(as an aside - I mentioned the Dynamic SDB because I thought you were using a SmartDataBrowse, but you're talking about a static browser in a SmartWindow, so ignore that)
 

fuji36

New Member
The Section Editor does take me to the 'open-query' section, added my table there, no problem.

But to re-define the 'browse' is another deal altogether, the Section Editor
doesn't get me there.

As I said earlier, I did get into the Procedure Editor and updated some of the 'pre-processor' code but I bet I missed some , that is probably why the AppBuilder is re-setting when opened as a .w.

Actually, when I updated the procedure, and ran it as a .p it was fine.

But it will drive me crazy now till I know what I'm missing.

I will try to post the code tomorrow if I get time. Thank you for your help on this.
 
Do you mean you want to change the columns displayed in the browse? That's in the DISPLAY pseudo-trigger. In section editor, click the "List..." button, and look at the code behind the "ON DISPLAY OF yourBrowseName" trigger.

If that's not it, then what browser bits exactly are you trying to change?
 

fuji36

New Member
And everything looks fine there, code from procedure Editor of .w file:

/* Browse definitions */
DEFINE BROWSE BROWSE-1
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _DISPLAY-FIELDS BROWSE-1 wWin _FREEFORM
QUERY BROWSE-1 NO-LOCK DISPLAY
JobHead.JobNum FORMAT "x(14)":U WIDTH 14.0
OrderDtl.PartNum FORMAT "x(20)":U WIDTH 15.0
OrderDtl.LineDesc FORMAT "X(50)":U WIDTH 18
JobHead.ProdQty COLUMN-LABEL "Qty" WIDTH 8.0
SchedPri.DESCRIPTION COLUMN-LABEL "Priority?" FORMAT "X(50)":U WIDTH 10.0
JobHead.SchedLocked COLUMN-LABEL "Locked?" WIDTH 9
JobHead.ReqDueDate COLUMN-LABEL "Job ReqBy" FORMAT "99/99/99":U
WIDTH 11.2
OrderDtl.DocOrdBasedPrice * OrderDtl.OrderQty @ DollarValue COLUMN-LABEL "$ Value"
WIDTH 11
JobHead.DueDate COLUMN-LABEL "Job Due" FORMAT "99/99/99":U
WIDTH 13.0
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
WITH NO-ROW-MARKERS SEPARATORS SIZE 118 BY 10.71
BGCOLOR 11 FONT 6 ROW-HEIGHT-CHARS .86 EXPANDABLE.


Pre-processor code:

/* ******************** Preprocessor Definitions ******************** */
&Scoped-define PROCEDURE-TYPE SmartWindow
&Scoped-define DB-AWARE no
&Scoped-define ADM-CONTAINER WINDOW
&Scoped-define ADM-SUPPORTED-LINKS Data-Target,Data-Source,Page-Target,Update-Source,Update-Target,Filter-target,Filter-Source
/* Name of first Frame and/or Browse and/or first Query */
&Scoped-define FRAME-NAME fMain
&Scoped-define BROWSE-NAME BROWSE-1
/* Internal Tables (found by Frame, Query & Browse Queries) */
&Scoped-define INTERNAL-TABLES JobHead JobProd OrderDtl SchedPri
/* Definitions for BROWSE BROWSE-1 */
&Scoped-define FIELDS-IN-QUERY-BROWSE-1 JobHead.JobNum OrderDtl.PartNum OrderDtl.LineDesc JobHead.ProdQty SchedPri.DESCRIPTION JobHead.SchedLocked JobHead.ReqDueDate OrderDtl.DocOrdBasedPrice * OrderDtl.OrderQty @ DollarValue JobHead.DueDate
&Scoped-define ENABLED-FIELDS-IN-QUERY-BROWSE-1
&Scoped-define SELF-NAME BROWSE-1
&Scoped-define QUERY-STRING-BROWSE-1 FOR EACH JobHead WHERE JobHead.Company = "dble" AND JobHead.JobClosed = FALSE AND JobHead.JobComplete = FALSE AND JobHead.JobReleased = TRUE NO-LOCK, ~
EACH JobProd OF JobHead NO-LOCK, ~
EACH OrderDtl OF JobProd NO-LOCK, ~
EACH SchedPri OF JobHead NO-LOCK BY JobHead.DueDate BY (OrderDtl.DocOrdBasedPrice * OrderDtl.OrderQty) DESCENDING
&Scoped-define OPEN-QUERY-BROWSE-1 OPEN QUERY {&SELF-NAME} FOR EACH JobHead WHERE JobHead.Company = "dble" AND JobHead.JobClosed = FALSE AND JobHead.JobComplete = FALSE AND JobHead.JobReleased = TRUE NO-LOCK, ~
EACH JobProd OF JobHead NO-LOCK, ~
EACH OrderDtl OF JobProd NO-LOCK, ~
EACH SchedPri OF JobHead NO-LOCK BY JobHead.DueDate BY (OrderDtl.DocOrdBasedPrice * OrderDtl.OrderQty) DESCENDING.
&Scoped-define TABLES-IN-QUERY-BROWSE-1 JobHead JobProd OrderDtl SchedPri
&Scoped-define FIRST-TABLE-IN-QUERY-BROWSE-1 JobHead
&Scoped-define SECOND-TABLE-IN-QUERY-BROWSE-1 JobProd
&Scoped-define THIRD-TABLE-IN-QUERY-BROWSE-1 OrderDtl
&Scoped-define FOURTH-TABLE-IN-QUERY-BROWSE-1 SchedPri

Here is the problem bit, under Control Definitions, definition of BROWSE-1:

/* *********************** Control Definitions ********************** */
/* Define the widget handle for the window */
DEFINE VAR wWin AS WIDGET-HANDLE NO-UNDO.
/* Definitions of the field level widgets */
/* Query definitions */
&ANALYZE-SUSPEND
DEFINE QUERY BROWSE-1 FOR
JobHead,
JobProd,
OrderDtl,
&ANALYZE-RESUME

Should be:

DEFINE QUERY BROWSE-1 FOR
JobHead,
JobProd,
OrderDtl,
Schedpri SCROLLING.

I add the 'Schedpri SCROLLING.' thru Procedure Editor, check syntax-everthing fine, save.

( Note that saving , at this point, as a .p, everthing stays in place and runs fine. )

Open again in AppBuilder, this portion has reverted back to:

DEFINE QUERY BROWSE-1 FOR
JobHead,
JobProd,
OrderDtl,
&ANALYZE-RESUME

And .w has errors, will not run.

_QUERY-BLOCK CODE:

/* Setting information for Queries and Browse Widgets fields */
&ANALYZE-SUSPEND _QUERY-BLOCK BROWSE BROWSE-1
/* Query rebuild information for BROWSE BROWSE-1
_START_FREEFORM
OPEN QUERY {&SELF-NAME} FOR EACH JobHead
WHERE JobHead.Company = "dble"
AND JobHead.JobClosed = FALSE
AND JobHead.JobComplete = FALSE
AND JobHead.JobReleased = TRUE NO-LOCK,
EACH JobProd OF JobHead NO-LOCK,
EACH OrderDtl OF JobProd NO-LOCK,
EACH SchedPri OF JobHead NO-LOCK
BY JobHead.DueDate
BY (OrderDtl.DocOrdBasedPrice * OrderDtl.OrderQty) DESCENDING.
_END_FREEFORM
_Options = "NO-LOCK INDEXED-REPOSITION"
_TblOptList = ",,"
_OrdList = "mfgsys.JobHead.DueDate|yes"
_Where[1] = "JobHead.Company = ""dble""
AND JobHead.JobClosed = FALSE
AND JobHead.JobReleased = TRUE"
_Query is OPENED
*/ /* BROWSE BROWSE-1 */
&ANALYZE-RESUME

Note that this portion is commented out for some reason, by the AppBuilder.
 
The bit commented out is Appbuilder's way of storing the ADE stuff without disrupting the compiled code. Even though it's commented out, Appbuilder reads it when you open the source file.

I've just tested this out by taking this freeform query (note - nonsense query joins, just to illustrate a similar case to your own):

Code:
OPEN QUERY {&SELF-NAME} FOR EACH pmlisthead NO-LOCK,
    EACH pmlist OF pmlisthead,
    EACH PMCRAFTS WHERE pmcrafts.cpy = pmlist.cpy
    INDEXED-REPOSITION.

and adding a new 4th buffer in OPEN_QUERY in section editor:

Code:
OPEN QUERY {&SELF-NAME} FOR EACH pmlisthead NO-LOCK,
    EACH pmlist OF pmlisthead,
    EACH PMCRAFTS WHERE pmcrafts.cpy = pmlist.cpy,
    EACH pmJobType WHERE pmJobType.cpy = pmlisthead.CPY
    INDEXED-REPOSITION.

And everything worked fine. Looking at the source code, the following bit:

Code:
/* Definitions of the field level widgets                               */
/* Query definitions                                                    */
&ANALYZE-SUSPEND
DEFINE QUERY BROWSE-2 FOR 
      pmlisthead, 
      pmlist, 
      PMCRAFTS SCROLLING.
&ANALYZE-RESUME

automatically changed to:

Code:
/* Definitions of the field level widgets                               */
/* Query definitions                                                    */
&ANALYZE-SUSPEND
DEFINE QUERY BROWSE-2 FOR 
      pmlisthead, 
      pmlist, 
      PMCRAFTS, 
      pmJobType SCROLLING.
&ANALYZE-RESUME

I can only imagine that you're doing something wrong when modifying your query, or by fiddling with the source code in procedure editor (never recommended) you've removed AppBuilder's ability to track your changes.
 

fuji36

New Member
Thanks Andrew.

The code change, adding the 4th table is where the problem is, I would expect to see exactly what your test shows.

Could be that I messed something up in the source code, although when I first made the change the problem occured, before any fiddling w/code.


I'm going to 'roll-back' to a previous version, re-do adding the 4th 'join' , maybe I can track what went wrong.

Thanks again.
 
Top