How i can recive a object like a dataset-handle and convert

Posted by Daniel Ruiz on 06-Oct-2016 10:20

Hello

I make charts through querys, but recently i need make it more dinamically.

Now i have need to recovery some  temporal tables of my dataset-handle. This is de code:

1- I declare  buffers, temp-table and a dataset:

 /*----------Buffers------------*/    
    DEFINE         VARIABLE numBuffers            AS INTEGER                                NO-UNDO.
    DEFINE         VARIABLE controlBuffer         AS HANDLE                                 NO-UNDO .
    
    /*Tabla temporal */
    DEF TEMP-TABLE tablaTemporal NO-UNDO
        FIELD categoria AS CHAR
        FIELD valor     AS DECIMAL . 
        
    DEFINE DATASET dinamico FOR tablaTemporal.

 

2- I receive these parameters in my constructor:

CONSTRUCTOR PUBLIC testGrafica (
        INPUT tituloH AS CHARACTER, INPUT tituloV AS CHARACTER,
        INPUT dimensionH AS INTEGER,INPUT dimensionV AS INTEGER, 
        INPUT DATASET-HANDLE dsTablas 
        ):
		
        SUPER().
/*I recover something with this instruction*/ DO numBuffers = 1 TO dsTablas:NUM-BUFFERS: controlBuffer = dsTablas:GET-BUFFER-HANDLE(numBuffers). END. configuraChart(tituloH, tituloV). LoadChart(). despliegaChart(dimensionH, dimensionV). InitializeComponent(). THIS-OBJECT:ComponentsCollection:ADD(THIS-OBJECT:components). CATCH e AS Progress.Lang.Error: UNDO, THROW e. END CATCH. END CONSTRUCTOR.

 

 

3.- I use this method to fill my chart

METHOD PRIVATE VOID LoadCHart():
        
        FOR EACH tablaTemporal:
            ASSIGN 
                dimension = dimension + 1.
        END.
        EXTENT (ListaCategorias) = dimension.
        
        FOR EACH tablaTemporal:
            miCategoria = NEW Telerik.Charting.CategoricalDataPoint().
            miCategoria:Category = tablaTemporal.categoria.   
            miCategoria:Label = Progress.Util.CastUtil:ToDouble(tablaTemporal.valor). 
            miCategoria:Value = Progress.Util.CastUtil:ToDouble(tablaTemporal.valor). 
            ListaCategorias[contador] = miCategoria.
            contador = contador + 1.
        END.  
        
    END METHOD.

 

4.- what is the process i require to pass data from my buffer to my temp-table?

Thanks for read this, greetings :).

All Replies

Posted by Mike Fechner on 14-Oct-2016 00:08

So if I understand you right, you are asking on how to iterate records in a ProDataset that should are receiving by DATASET-HANDLE. Right? If I misunderstood your question, please come back at any time.
 
First advice, don’t use a DATASET-HANDLE in that situation, just pass the HANDLE of the Dataset. A DATASET-HANDLE can be a deep copy (decision of the caller) and the callee is responsible to DELETE OBJECT it properly.
 
CONSTRUCTOR PUBLIC testGrafica (
        INPUT tituloH AS CHARACTER, INPUT tituloV AS CHARACTER,
        INPUT dimensionH AS INTEGER,INPUT dimensionV AS INTEGER,
        INPUT HANDLE hdsTablas
        ):
 
Then you need to know the name of the tables and fields. I’m going to use the first root table of the dataset and cField as CHARACTER variable to hold a field name now.
 
DEFINE VARIABLE hBuffer  AS HANDLE NO-UNDO .
DEFINE VARIABLE hQuery   AS HANDLE NO-UNDO.
DEFINE VARIABLE cField   AS CHARACTER NO-UNDO INIT "custnum".
 
ASSIGN hBuffer = hdsTablas:GET-TOP-BUFFER (1)
       hQuery = hdsTablas:TOP-NAV-QUERY (1) .
 
hQuery:QUERY-OPEN () .
hQuery:GET-FIRST () .
 
DO WHILE NOT hQuery:QUERY-OFF-END:
 
    MESSAGE hBuffer:BUFFER-FIELD(cField):BUFFER-VALUE
        VIEW-AS ALERT-BOX.
 
    hQuery:GET-NEXT () .
END.
 
 

This thread is closed