passing a browse object

jmac13

Member
Hi All,

I'm using open edge 10.2b.

We currently send information to excel to printout in a the form of a CSV and excel then imports. We build up this csv by doing the following:


Code:
    whHeaderBuffer = buffer {&browse-table}:handle. 
              
    get first {&browse-name}.                     
    repeat:                   
         
        process events.                 
        if not available {&browse-table} then                     
            leave.               
         
        assign chrLine = ""         
               intRow  = intRow + 1.            
         
        do intI = 1 to num-entries(xHeaders):         
        
            assign chrVariable = ""        
                   hName = entry(intI,xHeaders).         
        
            case hName:           
                otherwise      
                do:     
                    whFieldInfo  =  whHeaderBuffer:BUFFER-FIELD (hName).     
                    run ExcelFormat(whFieldInfo,intStartRow,intRow,intI).     
                    if whFieldInfo:data-type = "character" then     
                        chrVariable  = excelText(string(whFieldInfo:buffer-value, whFieldInfo:format)).      
                    else      
                        chrVariable  = trim(string(whFieldInfo:buffer-value, whFieldInfo:format)).     
                end.           
            end case.         
         
            If chrVariable = ? then         
                chrLine = chrLine + "|".         
            else         
                chrLine = chrLine + chrVariable + "|".         
        end.           
         
        put stream Ostream unformatted        
            chrline skip.         
                     
        get next {&browse-name}.                     
    end.

This uses the query in the browse and goes round the table and we then add whats columns are in the browse (xheaders) to the string.

My question is that at the moment this is having to be done in every program is there a way to do this in a persistent procedure. Does the browse hold the data i need? Can i just pass the browse handle and make a string from that? the browse object gets a lot of what i want.. the column headings the columns i want but im not sure how to get hold of the data?

any ideas would be great cheers

ssss weq
 
Of course it can.
What U require is the query used to populate the browse.
Because database access can only B realized in the query, UR code needs to B executed from
within the query. *This would B a super procedure in the ABL, this super procedure
is essentially just a persistent procedure that U R accessing executing the SDO
Good luck.
BFN
 
I'll take it that you talk about a static browse and query object (defined with the DEFINE statement and resolved at compile time). Anyway, what you need is the handle to the static query object which is associated with the browse. As soon as you have that handle you can do everything with the query object you need to:
  • Close the query
  • Change the query predicate
  • Re-open the query
The only thing you can't do with a static query object is to change the buffers on which it is based. You can grab the handle of the query with the QUERY attribute on the handle to the browse widget. From there on you need to "dynamic" all the way. In order to be able to code this you need to be familiar with dynamic queries and buffers because the code you need is exactly the same as it would be with dynamic objects.

Heavy Regards, RealHeavyDude.
 
Yeah its a static Browse RHD, I know if i pass the browse handle i can go through the query just dont know how to point at the table/data to get the data. Is it a matter of just passing the handle of table that is used in the browse? is this ok if its a static table or a temp table?
 
This code won't work, but it'll point in the right direction I think.
Code:
REPEAT:

    IF lvLine = 1 THEN
      lvResult = ipBrowser:SELECT-ROW(1).
    ELSE
      lvResult = ipBrowser:SELECT-NEXT-ROW().
    ASSIGN
      lvLine               = lvLine + 1.
    DO lvCnt = 1 TO ipBrowser:NUM-COLUMNS:
      lhBrowseCol = ipBrowser:GET-BROWSE-COLUMN(lvCnt).

      MESSAGE lhBrowseCol:SCREEN-VALUE SKIP lhBrowseCol:FORMAT VIEW-AS ALERT-BOX.
    END.
END.
 
just to update ppl What I've done so far (its still in the testing stage) is to pass the browse object and i can get all the info i need from that. I can get the data thats in the browse by going round the query in the browse object and using the column Buffer-fields to get the data to populate my string that then gets passed to a program that loads the CSV into excel..


Code:
    define input parameter ipchrProgramName   as character no-undo.    /*Program Name e.g. gradman.w*/             
    define input parameter ipHanBrowse as handle no-undo.              /*Browse Object Passed*/
         Chrfilename =   session:temp-directory + ipchrProgramName + ".Txt".         
         
    output stream ostream to value(Chrfilename).                
                     
    ipHanBrowse:query:get-first().  /*start of the query*/                   
    repeat:                   
         
        process events.                 
        if ipHanBrowse:query:query-off-end then                   
            leave.               
         
        assign hbrCol   = ipHanBrowse:first-column 
                  chrLine = ""         
                  intRow  = intRow + 1.            
         
        repeat:
            if hbrCol = ? then                          
                leave. 
            if hbrCol:visible = false then                          
                next.   
            
            hanFieldInfo = hbrCol:buffer-field. /*get the handle to the data via the column*/
            chrVariable  = trim(string(hanFieldInfo:buffer-value, hanFieldInfo:format)).  /*Get the Buffer Data*/

            If chrVariable = ? then         
                chrLine = chrLine + "|".         
            else         
                chrLine = chrLine + chrVariable + "|".

            assign hbrCol = hbrCol:next-column.
         
        end.
                        
        put stream Ostream unformatted        
            chrline skip.         
                     
        ipHanBrowse:query:get-next().  /*Get the next line of the query*/      
        if ipHanBrowse:query:query-off-end then leave.                      
    end.             
         
    output stream ostream close.
 
Back
Top