Data access from a Dynamic Browse

Posted by scorona on 21-May-2015 15:00

Hi, I have a combination of Dynamic Browse, Dynamic Query and Temp Table, but I don't know how to get the record from the Dynamic Browse ....

All Replies

Posted by Richard.Kelters on 26-May-2015 11:25

How about browse:query:get-buffer-handle(1). This will give you a buffer handle and I'm pretty sure that is has the record which corresponds to the current selected row in the browse.

Posted by scorona on 26-May-2015 14:22

Thanks, how can I display the record? or How can I verify the selected record?

Posted by TheMadDBA on 26-May-2015 14:55

Once you have the buffer handle you can use buffer-field and buffer-value to get the values from the temp-table fields.

Here is a KB that shows some of the basic functions (before stacking methods existed):

knowledgebase.progress.com/.../P112854

Posted by scorona on 26-May-2015 16:13

Sorry, but I don't understand, this the first time I use this kind of objects, so I'm posting the CODE ... I'll aprreciate your contribution ...

/*DEFINITION VARIABLES SECTION */

 DEFINE VARIABLE hTable AS HANDLE NO-UNDO.

 DEFINE VARIABLE hQuery AS HANDLE NO-UNDO.

 DEFINE VARIABLE hBuffer AS HANDLE NO-UNDO.

 DEFINE VARIABLE hBufferField AS HANDLE NO-UNDO.

 DEFINE VARIABLE hBrowse AS HANDLE NO-UNDO.

 DEFINE VARIABLE hCol AS HANDLE NO-UNDO.

 DEFINE VARIABLE i AS INTEGER NO-UNDO.

 DEFINE VARIABLE j AS INTEGER NO-UNDO.

 DEFINE TEMP-TABLE tmpRespuestas

   FIELD tmpIdRespuesta AS INTEGER

   FIELD tmpIdEstructuraPregunta AS INTEGER

   FIELD tmpDetalle AS CHAR EXTENT 20.

 /**********************************************************/

 /*This is the code where I create Dynamic Tem-Table, Dynamic Browse and Dynamic Query and I use a Temp Table for records*/

 CREATE WIDGET-POOL.

 DEFINE FRAME f WITH SIZE 80 BY 20.

 DEF VAR vCampo AS INTEGER.

 DEF VAR vNombreCampo AS CHARACTER EXTENT 20.

 DEF VAR vConceptos AS CHARACTER.

 FOR EACH EstructuraPregunta WHERE EstructuraPregunta.IdPregunta = int(vIdPregunta) ,

     FIRST Concepto WHERE Concepto.IdConcepto = EstructuraPregunta.IdConcepto NO-LOCK BREAK BY EstructuraPregunta.OrdenCaptura:

     ASSIGN vConceptos = vConceptos + STRING(Concepto.IdConcepto) + ",".

 END.    

 vConceptos = SUBSTRING(vConceptos,1,LENGTH(vConceptos) - 1).

 DO vCampo = 1 TO NUM-ENTRIES(vConceptos,","):

     FIND FIRST InfRector.Concepto WHERE InfRector.Concepto.IdConcepto = int(ENTRY(vCampo,vConceptos,",")) NO-LOCK NO-ERROR.

     ASSIGN vNombreCampo[vCampo] = Concepto.Descripcion.

 END.

 FOR EACH tmpRespuestas:

       DELETE tmpRespuestas.

 END.

 /*Here I record in the Temp Table from physical table*/

 FOR EACH EstructuraPregunta WHERE EstructuraPregunta.IdPregunta = int(vIdPregunta),

       EACH Respuesta WHERE Respuesta.IdEstructuraPregunta = EstructuraPregunta.IdEstructuraPregunta AND Respuesta.cDepto = vDepto,

       FIRST Concepto WHERE Concepto.IdConcepto = EstructuraPregunta.IdConcepto

       NO-LOCK BREAK BY Respuesta.NoActividad BY Respuesta.IdRespuesta /*EstructuraPregunta.OrdenCaptura*/:

       IF FIRST-OF(Respuesta.NoActividad) THEN do:

           CREATE tmpRespuestas.

           ASSIGN tmpRespuestas.tmpIdRespuesta = Respuesta.IdRespuesta

                  tmpRespuestas.tmpIdEstructura = Respuesta.IdEstructuraPregunta.

       END.

       ASSIGN tmpRespuestas.tmpDetalle[EstructuraPregunta.OrdenCaptura] = Respuesta.cRespuesta.

 END.

 /************ Create a dynamic temp-table object **********/

 CREATE TEMP-TABLE hTable.

 DO vCampo = 1 TO NUM-ENTRIES(vConceptos,","):

   hTable:ADD-NEW-FIELD(vNombreCampo[vCampo],'CHARACTER',0,"x(30)",' ').

 END.

 hTable:TEMP-TABLE-PREPARE('tmpRespuestas').

 /************** Create the dynamic query object ************/

 CREATE QUERY hQuery.

 CREATE BUFFER hBuffer FOR TABLE hTable:DEFAULT-BUFFER-HANDLE.

 hQuery:SET-BUFFERS(hBuffer).

 hQuery:QUERY-PREPARE('FOR EACH tmpRespuestas no-lock').

 /************* Create the dynamic browse widget ***********/

 CREATE BROWSE hBrowse

   ASSIGN QUERY = hQuery

   FRAME = FrameActual   /*FRAME f:HANDLE*/

   COLUMN = 113

   VISIBLE = NO

   SENSITIVE = YES

   X = 4

   Y = 2

   WIDTH = 120

   DOWN = 10

 /* With this Trigger I try to acces the record from the dynamic browse, BUT I DON'T KNOW HOW*/

 Triggers :

   On LEFT-MOUSE-CLICK PERSISTENT RUN Muestra In This-Procedure.

 End Triggers.

 /************ Create the dynamic browse columns ***********/

 DO i = 1 TO hBuffer:NUM-FIELDS:

   hBufferField = hBuffer:BUFFER-FIELD(i).

   hCol = hBrowse:ADD-LIKE-COLUMN(hBufferField).

 END.

 /*************** Create the temp-table records ************/

 FOR EACH tmpRespuestas:

   hBuffer:BUFFER-CREATE().

   DO i = 1 TO hBuffer:NUM-FIELDS:

     hBufferField = hBuffer:BUFFER-FIELD(i).

     hBufferField:BUFFER-VALUE = tmpRespuestas.tmpDetalleIdea.    /*hBufferField:NAME + ' ' + STRING(j). */

   END.

 END.

 /** Set the browse widget's EXPANDABLE attribute to TRUE **/

 /*Here I make the BROWSE EXPANDABLE !!!!!*/

 hBrowse:EXPANDABLE = YES.

 hBrowse:VISIBLE = YES.

 hQuery:QUERY-OPEN.

 WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW.

This thread is closed