ROWID from screen widget

gregscott

New Member
I am trying to find the rowid of the table that is associated to a widget on a screen. I can find the table name of the widget by using the <cur-widget>:TABLE attribute but cannot figure out how to use that to find the ROWID of that table. Any suggestions are welcome.
Thanks,
Greg Scott
Project Administrator
MUSCO Lighting LLC.
greg.scott@musco.com
:confused:
 

tsspdx

New Member
Don't know which row of the browse you're interested in. But if it's the one with focus try
ROWID(This-Browse:TABLE).
 

tsspdx

New Member
The ROWID function doesn't return the row of a browse. It only operates on tables (strictly speaking, on table buffers). I would use its ROW attribute if I wanted to know which row of a browse a given widget is in.

Of course, there is no TABLE attribute of a browse; for one thing, a browse can draw from multiple tables. So perhaps my meta-code confused you. I should have said, take the TABLE attribute of the widget that contains the column you're interested in, and pass that to ROWID.

This is a prime example of the confusion generated by Progress' penchant for giving the same name to different concepts, in this case database rows and browse rows. I tend to use the deprecated RECID in my code to keep from confusing myself.
 

gregscott

New Member
We're not talking apples to apples here let me explain. I am painting fill in fields on a screen and then attempting to have a generic add,change,delete procedure that will make the modifications for me. I know the field name, table name and screen values of the database fields are that are on the screen. The only thing I don't know without storing it somewhere is the rowid of the record that is being displayed on the screen. I could use the &FIRST-TABLE-IN-QUERY preprocessor for this but I want to be able to update multiple tables on the same screen. Here's what I've done so far. This works just fine as I can pass all of the fields, tables and rowids to the update procedure but I have to hard code for every occurance of a different table i.e. FIRST-TABLE-IN-QUERY SECOND-TABLE... and so forth. I would like to be able to get the ROWID's and not have to write all of this code.

Trigger code for the submit button:
DO:

RUN Find-RowIDs.

/* get the first widget within the frame */
ASSIGN cur-widget = FRAME {&FRAME-NAME}:FIRST-CHILD
cur-widget = cur-widget:FIRST-TAB-ITEM
v-fieldlist = ''
v-valuelist = ''
v-tablelist = ''
v-rowidlist = ''.

/* walk the widget tree looking at fill-ins only */
WalkIt:
DO WHILE VALID-HANDLE(cur-widget):
IF cur-widget:TYPE <> "fill-in" THEN do:
cur-widget = cur-widget:NEXT-TAB-ITEM.
NEXT walkit.
END.

/* if it has been modified, build a list of name and value */
IF cur-widget:MODIFIED THEN DO:
FIND FIRST t-Fields NO-LOCK
WHERE t-Fields.t-Table = cur-widget:TABLE AND
t-Fields.t-Field = cur-widget:NAME NO-ERROR.
IF NOT AVAILABLE t-Fields THEN DO:
FIND FIRST t-TblRows NO-LOCK
WHERE t-TblRows.t-Table = cur-widget:TABLE NO-ERROR.
CREATE t-Fields.
ASSIGN t-Fields.t-Table = cur-widget:TABLE
t-Fields.t-RowId = t-TblRows.t-RowId
t-Fields.t-Field = cur-widget:NAME
t-Fields.t-Value = cur-widget:SCREEN-VALUE.
END.
cur-widget:MODIFIED = FALSE.
END.

/* keep walking */
cur-widget = cur-widget:next-tab-item.
END.

IF CAN-FIND(FIRST t-Fields) THEN DO:
RUN Shared/o-shoth-RecMaint.p(INPUT TABLE t-Fields,
INPUT v-Action). /* Action to be performed */
END.

IF ERROR-STATUS:ERROR THEN DO:
MESSAGE RETURN-VALUE + "!".
RETURN NO-APPLY.
END.

FOR EACH t-Fields:
DELETE t-Fields.
END.

FOR EACH t-TblRows:
DELETE t-TblRows.
END.

DISABLE {&list-1} WITH FRAME {&FRAME-NAME}.
ENABLE {&list-2} WITH FRAME {&FRAME-NAME}.
v-Action = "".
END.


PROCEDURE Find-RowIds:
/*------------------------------------------------------------------------------
Purpose:
Parameters: <none>
Notes:
------------------------------------------------------------------------------*/
DO i = 1 TO NUM-ENTRIES("{&TABLES-IN-QUERY-DEFAULT-FRAME}"," "):
CASE i:
WHEN 1 THEN DO:
&IF DEFINED (FIRST-TABLE-IN-QUERY-DEFAULT-FRAME) &THEN
v-Rowid = ROWID({&FIRST-TABLE-IN-QUERY-DEFAULT-FRAME}).
v-Table = "{&FIRST-TABLE-IN-QUERY-DEFAULT-FRAME}".
&ENDIF
END.
WHEN 2 THEN DO:
&IF DEFINED (SECOND-TABLE-IN-QUERY-DEFAULT-FRAME) &THEN
v-Rowid = ROWID({&SECOND-TABLE-IN-QUERY-DEFAULT-FRAME}).
v-Table = "{&SECOND-TABLE-IN-QUERY-DEFAULT-FRAME}".
&ENDIF
END.
WHEN 3 THEN DO:
&IF DEFINED (THIRD-TABLE-IN-QUERY-DEFAULT-FRAME) &THEN
v-Rowid = ROWID({&THIRD-TABLE-IN-QUERY-DEFAULT-FRAME}).
v-Table = "{&THIRD-TABLE-IN-QUERY-DEFAULT-FRAME}".
&ENDIF
END.
WHEN 4 THEN DO:
&IF DEFINED (FOURTH-TABLE-IN-QUERY-DEFAULT-FRAME) &THEN
v-Rowid = ROWID({&FOURTH-TABLE-IN-QUERY-DEFAULT-FRAME}).
v-Table = "{&FOURTH-TABLE-IN-QUERY-DEFAULT-FRAME}".
&ENDIF
END.
WHEN 5 THEN DO:
&IF DEFINED (FIFTH-TABLE-IN-QUERY-DEFAULT-FRAME) &THEN
v-Rowid = ROWID({&FIFTH-TABLE-IN-QUERY-DEFAULT-FRAME}).
v-Table = "{&FIFTH-TABLE-IN-QUERY-DEFAULT-FRAME}".
&ENDIF
END.
WHEN 6 THEN DO:
&IF DEFINED (SIXTH-TABLE-IN-QUERY-DEFAULT-FRAME) &THEN
v-Rowid = ROWID({&SIXTH-TABLE-IN-QUERY-DEFAULT-FRAME}).
v-Table = "{&SIXTH-TABLE-IN-QUERY-DEFAULT-FRAME}".
&ENDIF
END.
WHEN 7 THEN DO:
&IF DEFINED (SEVENTH-TABLE-IN-QUERY-DEFAULT-FRAME) &THEN
v-Rowid = ROWID({&SEVENTH-TABLE-IN-QUERY-DEFAULT-FRAME}).
v-Table = "{&SEVENTH-TABLE-IN-QUERY-DEFAULT-FRAME}".
&ENDIF
END.
WHEN 8 THEN DO:
&IF DEFINED (EIGHTH-TABLE-IN-QUERY-DEFAULT-FRAME) &THEN
v-Rowid = ROWID({&EIGHTH-TABLE-IN-QUERY-DEFAULT-FRAME}).
v-Table = "{&EIGHTH-TABLE-IN-QUERY-DEFAULT-FRAME}".
&ENDIF
END.
WHEN 9 THEN DO:
&IF DEFINED (NINTH-TABLE-IN-QUERY-DEFAULT-FRAME) &THEN
v-Rowid = ROWID({&NINTH-TABLE-IN-QUERY-DEFAULT-FRAME}).
v-Table = "{&NINTH-TABLE-IN-QUERY-DEFAULT-FRAME}".
&ENDIF
END.
WHEN 10 THEN DO:
&IF DEFINED (TENTH-TABLE-IN-QUERY-DEFAULT-FRAME) &THEN
v-Rowid = ROWID({&TENTH-TABLE-IN-QUERY-DEFAULT-FRAME}).
v-Table = "{&TENTH-TABLE-IN-QUERY-DEFAULT-FRAME}".
&ENDIF
END.
END CASE.
CREATE t-TblRows.
ASSIGN t-TblRows.t-RowID = v-RowID
t-TblRows.t-Table = v-Table.
END.

END PROCEDURE.
 
Top