upc formas de pagamento

Discussão em 'EMS , HCM e Totvs 11' iniciado por Carlos Alberto Giusti, Junho 26, 2023.

  1. Carlos Alberto Giusti

    Carlos Alberto Giusti Membro Ativo

    Estou criando uma upc para colocar uma informação no programas bas_forma_pagto.
    Mesmo só chamando o programa sem nenhuma informação já da erro de parâmetros.
    Alguém sabe o porque?
  2. v.marinh

    v.marinh Sem Pontuação

    Boa tarde,

    Imagino que a ultima entrada de parâmetro da sua UPC esteja esperando um ROWID, mas nesse programa é passado um RECID em vez do ROWID.

    Exemplo:

    Código:
    /******************************************************************************
    **  Programa: upc-apb005aa.p
    **  Data....:
    **  Autor...:
    **  Objetivo:
    ******************************************************************************/
    
    /* Parametros */
    def input param p-ind-event  as char          no-undo.
    def input param p-ind-object as char          no-undo.
    def input param p-wgh-object as handle        no-undo.
    def input param p-wgh-frame  as widget-handle no-undo.
    def input param p-cod-table  as char          no-undo.
    def input param p-rec-table  as recid         no-undo.
    
    /* Variveis Locais */
    def var c-objeto as char no-undo.
    
    assign c-objeto = entry(NUM-ENTRIES(p-wgh-object:private-data, "~/"), p-wgh-object:private-data, "~/").
    
    message "EVENTO:" p-ind-event       skip
            "OBJETO:" p-ind-object      skip
            "NOME OBJ:" c-objeto        skip
            "FRAME:" p-wgh-frame        skip
            "TABELA:" p-cod-table       skip
            "RECID:" string(p-rec-table) view-as alert-box.
    
    RETURN "OK":U.
    
  3. Carlos Alberto Giusti

    Carlos Alberto Giusti Membro Ativo


    Obrigado. Vou testar.
  4. Carlos Alberto Giusti

    Carlos Alberto Giusti Membro Ativo



    Não deu certo.
    Se faço com racid aceita para colocar o campo mas ao buscar o item dá erro. Precisa do Rowind

    /******************************************************************************
    ** Programa: upc-apb005aa.p
    ** Data....:
    ** Autor...:
    ** Objetivo:
    ******************************************************************************/

    /* Parametros */
    def input param p-ind-event as char no-undo.
    def input param p-ind-object as char no-undo.
    def input param p-wgh-object as handle no-undo.
    def input param p-wgh-frame as widget-handle no-undo.
    def input param p-cod-table as char no-undo.
    def input param p-rec-table as ROWID no-undo.

    /* Variveis Locais */
    def var c-objeto as char no-undo.
    define new global shared variable wh-label-flag-sped as handle no-undo.
    define new global shared variable wh-campo-flag-sped as handle no-undo.
    define new global shared var h-folder as handle no-undo.
    define new global shared var h-viewer as handle no-undo.
    define var c-folder AS character no-undo.
    define var c-objects AS character no-undo.
    define var h-object AS handle no-undo.
    define var i-objects AS integer no-undo.
    define var l-record AS logical no-undo initial no.
    define var l-group-assign AS logical no-undo initial no.

    assign c-objeto = entry(NUM-ENTRIES(p-wgh-object:private-data, "~/"), p-wgh-object:private-data, "~/").

    message "EVENTO:" p-ind-event skip
    "OBJETO:" p-ind-object skip
    "NOME OBJ:" c-objeto skip
    "FRAME:" p-wgh-frame skip
    "TABELA:" p-cod-table skip
    "RECID:" string(p-rec-table) view-as alert-box.

    if p-ind-event = "INITIALIZE" and p-ind-object = "viewer" THEN DO:
    message "achei" view-as alert-box.
    CREATE TOGGLE-BOX wh-campo-flag-sped
    ASSIGN FRAME = p-wgh-frame
    COLUMN = 62
    ROW = 6
    WIDTH = 9
    HEIGHT = 1
    HELP = "Regime de Apuração?"
    VISIBLE = YES
    SENSITIVE = no
    TOOLTIP = "Sped?"
    NAME = 'wh-campo-flag-sped'
    LABEL = 'Sped?'.
    END.
    if p-ind-event = 'DELETE' and p-ind-object = "viewer" THEN DO:
    if valid-handle(wh-campo-flag-sped) then
    assign wh-campo-flag-sped:checked = false.
    FIND FIRST emscad.forma_pagto where rowid(forma_pagto) = p-rec-table no-lock no-error.
    if avail forma_pagto then do:
    find first ext-forma-pagto of forma_pagto no-lock no-error.
    IF AVAIL ext-forma-pagto THEN DO:
    FIND CURRENT ext-forma-pagto exclusive-lock no-error.
    delete ext-forma-pagto.
    END.
    END.
    end.
    if p-ind-event = 'BEFORE-ADD' and p-ind-object = "viewer" THEN DO:
    if valid-handle(wh-campo-flag-sped) then
    assign wh-campo-flag-sped:checked = false.
    END.
    if p-ind-event = 'ENABLE' and p-ind-object = "viewer" THEN DO:
    if valid-handle(wh-campo-flag-sped) then
    assign wh-campo-flag-sped:sensitive = true.
    END.
    if p-ind-event = 'DISABLE' and p-ind-object = "viewer" THEN DO:
    if valid-handle(wh-campo-flag-sped) then
    assign wh-campo-flag-sped:sensitive = false.
    END.
    if p-ind-event = 'ASSIGN' and p-ind-object = "viewer" THEN DO:
    FIND FIRST forma_pagto where rowid(forma_pagto) = p-rec-table no-lock no-error.
    if avail forma_pagto then do:
    find first ext-forma-pagto of forma_pagto exclusive-lock no-error.
    IF NOT AVAIL ext-forma-pagto THEN DO:
    create ext-forma-pagto.
    assign ext-forma-pagto.cod_forma_pagto = forma_pagto.cod_forma_pagto
    ext-forma-pagto.sped = no.
    END.
    assign ext-forma-pagto.sped = if wh-campo-flag-sped:checked then YES else NO.
    FIND CURRENT ext-forma-pagto no-lock no-error.
    END.
    END.
    if p-ind-event = 'DISPLAY' and p-ind-object = "viewer" THEN DO:
    if valid-handle(wh-campo-flag-sped) then
    assign wh-campo-flag-sped:checked = false.
    FIND FIRST forma_pagto where rowid(forma_pagto) = p-rec-table no-lock no-error.
    if avail forma_pagto then do:
    find first ext-forma-pagto of forma_pagto no-lock no-error.
    IF AVAIL ext-forma-pagto THEN DO:
    assign wh-campo-flag-sped:checked = ext-forma-pagto.sped.
    END.
    END.
    END.
    RETURN "OK":U.
  5. v.marinh

    v.marinh Sem Pontuação

    Bom dia,

    Tente com o código abaixo:

    Exemplo:

    Código:
    /******************************************************************************
    ** Programa: upc-apb005aa.p
    ** Data....:
    ** Autor...:
    ** Objetivo:
    ******************************************************************************/
    
    /* Parametros */
    def input param p-ind-event as char no-undo.
    def input param p-ind-object as char no-undo.
    def input param p-wgh-object as handle no-undo.
    def input param p-wgh-frame as widget-handle no-undo.
    def input param p-cod-table as char no-undo.
    def input param p-rec-table as recid no-undo.
    
    /* Variveis Locais */
    def var c-objeto as char no-undo.
    define new global shared variable wh-label-flag-sped as handle no-undo.
    define new global shared variable wh-campo-flag-sped as handle no-undo.
    define new global shared var h-folder as handle no-undo.
    define new global shared var h-viewer as handle no-undo.
    define var c-folder AS character no-undo.
    define var c-objects AS character no-undo.
    define var h-object AS handle no-undo.
    define var i-objects AS integer no-undo.
    define var l-record AS logical no-undo initial no.
    define var l-group-assign AS logical no-undo initial no.
    
    assign c-objeto = entry(NUM-ENTRIES(p-wgh-object:private-data, "~/"), p-wgh-object:private-data, "~/").
    
    message "EVENTO:" p-ind-event skip
        "OBJETO:" p-ind-object skip
        "NOME OBJ:" c-objeto skip
        "FRAME:" p-wgh-frame skip
        "TABELA:" p-cod-table skip
        "RECID:" string(p-rec-table) view-as alert-box.
    
    if p-ind-event = "INITIALIZE" and p-ind-object = "viewer" THEN DO:
        if not valid-handle(wh-campo-flag-sped) then
        do:
            CREATE TOGGLE-BOX wh-campo-flag-sped
                ASSIGN FRAME = p-wgh-frame
                COLUMN = 62
                ROW = 6
                WIDTH = 9
                HEIGHT = 1
                HELP = "Regime de Apuração?"
                VISIBLE = YES
                SENSITIVE = no
                TOOLTIP = "Sped?"
                NAME = 'wh-campo-flag-sped'
                LABEL = 'Sped?'.
        end.
    END.
    
    if p-ind-event = 'DELETE' and p-ind-object = "viewer" THEN DO:
        if valid-handle(wh-campo-flag-sped) then
            assign wh-campo-flag-sped:checked = false.
           
        find first emscad.forma_pagto where 
            recid(forma_pagto) = p-rec-table no-lock no-error.
       
        if avail forma_pagto then do:
            find first ext-forma-pagto of forma_pagto no-lock no-error.
            if avail ext-forma-pagto then do:
                find current ext-forma-pagto exclusive-lock no-error.
                delete ext-forma-pagto.
            END.
        END.   
    end.
    
    if p-ind-event  = 'BEFORE-ADD' and 
       p-ind-object = "viewer"     then do:
        if valid-handle(wh-campo-flag-sped) then
            assign wh-campo-flag-sped:checked = false.
    END.
    
    if p-ind-event   = 'ENABLE' and
        p-ind-object = "viewer" then do:
        if valid-handle(wh-campo-flag-sped) then
            assign wh-campo-flag-sped:sensitive = true.
    end.
    
    if p-ind-event  = 'DISABLE' and 
       p-ind-object = "viewer"  then do:
        if valid-handle(wh-campo-flag-sped) then
            assign wh-campo-flag-sped:sensitive = false.
    end.
    
    if p-ind-event  = 'ASSIGN' and 
       p-ind-object = "viewer" then do:
       
        find first forma_pagto where 
            recid(forma_pagto) = p-rec-table no-lock no-error.
           
        if avail forma_pagto then do:
       
            find first ext-forma-pagto of forma_pagto exclusive-lock no-error.
           
            if not avail ext-forma-pagto then do:
                create ext-forma-pagto.
                assign ext-forma-pagto.cod_forma_pagto = forma_pagto.cod_forma_pagto
                       ext-forma-pagto.sped            = no.
            END.
    
            if available ext-forma-pagto then
                assign ext-forma-pagto.sped = if wh-campo-flag-sped:checked then YES else NO.
           
            find current ext-forma-pagto no-lock no-error.
        end.
    end.
    
    if p-ind-event  = 'DISPLAY' and 
       p-ind-object = "viewer"  then do:
       
        if valid-handle(wh-campo-flag-sped) then
            assign wh-campo-flag-sped:checked = false.
           
        find first forma_pagto where 
            recid(forma_pagto) = p-rec-table no-lock no-error.
       
        if avail forma_pagto then do:
            find first ext-forma-pagto of forma_pagto no-lock no-error.
            if avail ext-forma-pagto then
                assign wh-campo-flag-sped:checked = ext-forma-pagto.sped.
        end.
    end
    .
    RETURN "OK":U.
    
  6. Carlos Alberto Giusti

    Carlos Alberto Giusti Membro Ativo


    OK. Deu certo. Muito Obrigado.
    v.marinh curtiu isso.

Compartilhe esta Página