[RESOLVIDO] EPC no z09di159 - não consigo relacionar query/browse

Discussão em 'EMS , HCM e Totvs 11' iniciado por toshyro, Outubro 26, 2010.

Status do Tópico:
Não esta aberto para novas mensagens.
  1. toshyro

    toshyro Sem Pontuação

    Boa tarde, pessoal

    Tô enrolado numa EPC que estou implementando no zoom z09di159. Nesse zoom, estou adicionando uma aba ao final, com opção de busca por campos de extensão do ped-venda... mas, a título de exemplo, digamos que eu queira buscar todas as cotações para a matriz de um emitente (emitente.nome-matriz).

    A interface está ok. Meu problema está na lógica que alimenta o browser. Com os dados preenchidos nos campos de seleção, eu alimento a temp-table sem problemas, mas não tô conseguindo jogar esses valores no browse... acredito que seja um erro de lógica, um detalhe que estou perdendo/confundindo, porque já misturei vários exemplos aqui e a confusão (na minha cabeça) já tá grande.

    Vou colar os código dos meus fontes aqui, e se alguém puder dar um pitaco, será de grande valia.


    Pra testar, basta copiar cada um dos códigos pra um arquivo (conforme nomenclatura no início deles), respeitar a hierarquia dos diretórios, cadastrar a EPC, e testar via QO0310.


    Código:
    /******************************************************************************
    *      Programa .....: EZ09DI159.P                                            *
    *      Objetivo .....: Opção de busca no zoom z09di159                        *
    *******************************************************************************
    
    {utp/ut-glob.i}
    
    /* Parâmetros Datasul */
    define input param p-ind-event  as char          no-undo.
    define input param p-ind-object as char          no-undo.
    define input param p-wgh-object as handle        no-undo.
    define input param p-wgh-frame  as widget-handle no-undo.
    define input param p-cod-table  as char          no-undo.
    define input param p-row-table  as rowid         no-undo.
    
    def var c-objeto    as char          no-undo.
    def var h-objeto    as widget-handle no-undo.
    
    def new global shared var h-fPage4              as widget-handle no-undo.
    def new global shared var wh-nome-matriz-ini    as widget-handle no-undo.
    def new global shared var wh-nome-matriz-fim    as widget-handle no-undo.
    def new global shared var wh-button-ok          as widget-handle no-undo.
    def new global shared var wh-query              as widget-handle no-undo.
    def new global shared var wh-browse             as widget-handle no-undo.
    def new global shared var h-text-1              as widget-handle no-undo.
    def new global shared var wh-image-1            as widget-handle no-undo.
    def new global shared var wh-image-2            as widget-handle no-undo.
    
    def temp-table tt-pesquisa
        field i-nr-pedido       like ped-venda.nr-pedido
        field c-nome-abrev      like dcn-ped-venda.nome-abrev-cotacao
        field c-nr-pedcli       like ped-venda.nr-pedcli
        field dt-implant        like ped-venda.dt-implant
        field dt-entrega        like ped-venda.dt-entrega
        field rw-ped-venda      as rowid
        index idx i-nr-pedido.
    
    /* Variáveis Locais */
    assign c-objeto = entry(num-entries(p-wgh-object:file-name,"~/"),p-wgh-object:file-name, "~/") no-error.
    
    /*
    message 'Nome progrm: ' c-objeto                      skip
            'Nome evento: ' p-ind-Event                   skip
            'Nome objeto: ' p-ind-object                  skip
            'WHO:         ' string ( p-wgh-object )       skip
            'WHF:         ' string ( p-wgh-frame )        skip
            'WHF Nome:    ' string ( p-wgh-frame:name )   skip
            'Nome tabela: ' p-cod-table                   skip
            'RowiD tabela: ' string ( p-row-table )           
            view-as alert-box.                                
    */
    
    if  p-ind-event  = "AFTER-INITIALIZE"
    and p-ind-object = "CONTAINER"
    then do:
    
         empty temp-table tt-pesquisa.
    
         create frame h-fPage4
             assign col         = 2.72
                    row         = 2.58
                    width       = 86.5
                    height      = 13
                    name        = "fPage4"
                    side-labels = YES
                    sensitive   = YES
                    overlay     = YES
                 /* bgcolor     = ? */
                    box         = NO
                    three-d     = YES.
         
         assign h-objeto = p-wgh-object.
         
         do while valid-handle(h-objeto):
             if h-objeto:file-name = "utp/thinFolder.w" 
             then leave.
             assign h-objeto = h-objeto:next-sibling.
         end.
         
         run insertFolder in h-objeto (input 5,
                                       input p-wgh-frame,
                                       input h-fPage4,
                                       input "Matriz").
                                       
                                       
         create text h-text-1
         assign frame           = h-fPage4
                width           = 24
                height          = 0.88
                row             = 1.5
                col             = 8
                font            = 1
                bgcolor         = ?
                visible         = yes
                sensitive       = yes
                format          = "x(24)"
                screen-value    = "Matriz:".
                                       
                                       
         create fill-in wh-nome-matriz-ini      
         assign frame           = h-fPage4
                data-type       = "character"
                width           = 20
                height          = 0.88
                row             = 1.5
                col             = 20
                font            = 1
                bgcolor         = ?
                visible         = yes
                sensitive       = yes
                format          = "x(12)".
                                                        
                
         create fill-in wh-nome-matriz-fim      
         assign frame           = h-fPage4
                data-type       = "character"
                width           = 18
                height          = 0.88
                row             = 1.5
                col             = 50
                font            = 1
                bgcolor         = ?
                visible         = yes
                sensitive       = yes
                format          = "x(12)".
                
                
         create button wh-button-ok
         assign row             = 1.5
                column          = 80
                width           = 4
                height          = 1.21 
                frame           = h-fPage4
                sensitive       = yes 
                visible         = yes 
                label           = "Busca".
                        
         wh-button-ok:load-image-up("image/im-chck1.bmp").  
               
         create query wh-query.       
         wh-query:set-buffers(buffer tt-pesquisa:handle ).
         wh-query:query-prepare("for each tt-pesquisa").
         wh-query:query-open.            
                
         create browse wh-browse
         assign frame           = h-fPage4
                query           = wh-query
                row             = 4
                col             = 8
                width           = 74
                down            = 10
                font            = 1
                bgcolor         = ?
                visible         = yes
                sensitive       = yes
                read-only       = no
                name            = "brMatriz"
                .
                     
         
         create image wh-image-1
         assign row             = 1.5
                column          = 40.5
                frame           = h-fPage4.
         wh-image-1:load-image("image/im-fir.bmp").
         
         create image wh-image-2
         assign row             = 1.5
                column          = 46.5
                frame           = h-fPage4.
         wh-image-2:load-image("image/im-las.bmp").
         
         run dcnp/dcnz09di159.p persistent.
    
         run setFolder in h-objeto (input 5).
    
    end.
    Agora, código do programa complementar, que cuida do comportamento da busca dos dados e alimentação do browse. Deve ser um detalhezinho para o qual não estou me atentando.

    Código:
    /******************************************************************************
    *      Programa .....: DCNZ09DI159.P                                            *
    *******************************************************************************
    
    def new global shared var h-fPage4          as widget-handle no-undo.
    def new global shared var wh-nome-matriz-ini as widget-handle no-undo.
    def new global shared var wh-nome-matriz-fim as widget-handle no-undo.
    def new global shared var wh-button-ok      as widget-handle no-undo.
    def new global shared var wh-br-prospect    as widget-handle no-undo.
    def new global shared var wh-query-1        as widget-handle no-undo.
    
    def temp-table tt-pesquisa no-undo
        field i-nr-pedido       like ped-venda.nr-pedido
        field c-nome-abrev      like emitente.nome-abrev
        field c-nr-pedcli       like ped-venda.nr-pedcli
        field dt-implant        like ped-venda.dt-implant
        field dt-entrega        like ped-venda.dt-entrega
        field rw-ped-venda      as rowid
        index idx i-nr-pedido.
    
    
    ON 'choose':U OF wh-button-ok
    DO:
    
        message "toshyro" view-as alert-box.
    
        empty temp-table tt-pesquisa.
    
        for each emitente
           where emitente.nome-matriz >= wh-nome-matriz-ini:screen-value
             and emitente.nome-matriz <= wh-nome-matriz-fim:screen-value
                 no-lock,
            each ped-venda
           where ped-venda.nome-abrev   = emitente.nome-abrev
             and ped-venda.log-cotacao  = yes
             and ped-venda.cod-sit-ped  = 1
                 no-lock:
                 
            create  tt-pesquisa.
            assign  tt-pesquisa.i-nr-pedido     = ped-venda.nr-pedido
                    tt-pesquisa.c-nome-abrev    = ped-venda.nome-abrev
                    tt-pesquisa.c-nr-pedcli     = ped-venda.nr-pedcli
                    tt-pesquisa.dt-implant      = ped-venda.dt-implant
                    tt-pesquisa.dt-entrega      = ped-venda.dt-entrega
                    tt-pesquisa.rw-ped-venda    = rowid(ped-venda).
        end.
    
        
        for each tt-pesquisa:
    
            message 'pesq: '  tt-pesquisa.i-nr-pedido
                view-as alert-box.
    
         /*  assign i-nr-pedido:screen-value in wh-br-prospect = tt-pesquisa.i-nr-pedido. */
    
        end. 
    
        OPEN QUERY wh-br-prospect FOR EACH tt-pesquisa.
    
        /*
        DEFINE QUERY coq FOR tt-pesquisa.
            def browse wh-br-prospect
                query coq
                display tt-pesquisa.i-nr-pedido
                        tt-pesquisa.c-nome-abrev
                        with 2 down .
        OPEN QUERY coq FOR EACH tt-pesquisa.
        REPEAT:
            GET NEXT coq. 
            IF NOT AVAILABLE tt-pesquisa THEN LEAVE. 
    
            assign input browse wh-br-prospect tt-pesquisa.c-nome-abrev.
    
            DISPLAY tt-pesquisa.c-nome-abrev
                    tt-pesquisa.c-nr-pedcli
                WITH FRAME q-frame 10 DOWN.
        END.
        */
    
        /*
        wh-br-prospect:query in frame h-fPage4 = QUERY coq:HANDLE.
        
        OPEN QUERY coq FOR EACH tt-pesquisa. 
    
        {&open-query-wh-br-prospect} 
        */
    
        /*
        wh-query-1:query = wh-query-1.
        wh-query-1:set-buffers(buffer tt-pesquisa:handle ).
        wh-query-1:query-prepare("for each tt-pesquisa").
    
        wh-query-1:query-open.
        
        {&open-query-wh-br-prospect}
        */
    
        /*
        do while true:
            wh-query-1:get-next().
        
            if wh-query-1:query-off-end then leave.
        
            DISPLAY CURRENT-RESULT-ROW("wh-query-1") LABEL "Result Row" 
                tt-pesquisa.i-nr-pedido
                tt-pesquisa.c-nome-abrev
                .
        end.
        */
    
     /* open query wh-query-1 for each tt-pesquisa. */
        
        /*
        browse brProspect:QUERY = QUERY wh-query-1:HANDLE.
        */
    
        /* OPEN QUERY wh-br-prospect FOR EACH tt-pesquisa BY tt-pesquisa.i-nr-pedido. */
        
        /* {&open-query-wh-br-prospect} */
      
    end.
    
    
    Mais uma vez, meu muito obrigado in advance.

    Abraços!

    --
    Toshyro
    http://toshyro.net/
  2. tiaglo

    tiaglo Sem Pontuação

    Boa Tarde!

    Toshyro,

    Você conseguiu finalizar essa UPC? Cheguei no mesmo ponto que você no exemplo.

    Se conseguiu, e se puder postar ou me enviar, please!!!

    Agradeço desde já,

    Tiaglo.
Status do Tópico:
Não esta aberto para novas mensagens.

Compartilhe esta Página