1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Urgente Mapa EDI com valor de saída calculado

Discussão em 'Progress 4GL' iniciado por Fernanda Motta, Janeiro 25, 2023.

  1. Fernanda Motta

    Fernanda Motta Sem Pontuação

    Não entendi, me desculpa.
  2. Fernanda Motta

    Fernanda Motta Sem Pontuação

    Não entendi, me desculpa.
  3. Fernanda Motta

    Fernanda Motta Sem Pontuação

    Não entendi, me desculpa.
  4. bootstrapmaster

    bootstrapmaster Moderator Moderador Equipe de Suporte

    quando vc chama um programa de formula, ele te envia uns dados do mapa, nesse momento vc consegue ler qualquer linha que tenha sido gerado até o momento, então, basta vc navegar pelas linhas geradas e pegar os valores que precisa, outra forma, eu em particular não gosto, é vc criar uma variavel global shared na linha que calcula o seu valor, e ir acumulando nela o que vc calcula, na linha trailler, vc le essa global shared e usa.
  5. Fernanda Motta

    Fernanda Motta Sem Pontuação

    Já vi aqui no fórum vcs comentando que é ruim utilizar uma váriavel global shared, então vou tentar essa primeira ideia sua.
    Só não sei ainda como fazer essa navegação pelas linhas já geradas do mapa EDI. Seria através da temp table mesmo? Eu consigo definir qual mapa, elemento e segmento que quero acessar? Obrigada.
  6. bootstrapmaster

    bootstrapmaster Moderator Moderador Equipe de Suporte

    Faz muito tempo que eu não mexo com isso, mas tem esse exemplo, veja que vc recebe como parametro uma tabela tt_param_program_formul, e é pra vir todo o conteudo do mapa nela, se eu não me engano.
    esse codigo era um modelo que a propria datasul oferecia e nós só adaptavamos as nossas necessidades, por isso que tem bastante variaveis global shared, eles adoram usar isso.

    Código:
    /*****************************************************************************
    ** Copyright DATASUL S.A. (1994)
    ** Todos os Direitos Reservados.
    **
    ** Este fonte e de propriedade exclusiva da DATASUL, sua reproducao
    ** parcial ou total por qualquer meio, so' podera ser feita mediante
    ** autorizacao expressa.
    **
    ** Programa..............: fnc_prg_formul_10
    ** Descricao.............: Consiste c¢digo/data entrega Montadoras
    ** Versao................:  1.00.00.001
    ** Procedimento..........: utl_programs_formulas_edi
    ** Nome Externo..........: prgint/edf/edf700zj.py
    ** Data Geracao..........: 04/04/2000 - 17:12:57
    ** Criado por............: bre12882
    ** Criado em.............: 29/10/1999 09:38:05
    ** Alterado por..........: bre12882
    ** Alterado em...........: 15/03/2000 09:50:14
    ** Gerado por............: bre12882
    *****************************************************************************/
    
    def var c-versao-prg as char initial " 1.00.00.001":U no-undo.
    
    {include/i_dbinst.i}
    {include/i_dbtype.i}
    
    
    /******************************* Private-Data *******************************/
    assign this-procedure:private-data = "HLP=0":U.
    /*************************************  *************************************/
    
    /********************* Temporary Table Definition Begin *********************/
    
    def temp-table tt_param_program_formul no-undo
        field tta_cdn_segment_edi              as Integer format ">>>>>9" initial 0 label "Segmento" column-label "Segmento"
        field tta_cdn_element_edi              as Integer format ">>>>>9" initial 0 label "Elemento" column-label "Elemento"
        field tta_des_label_utiliz_formul_edi  as character format "x(10)" label "Label Utiliz Formula" column-label "Label Utiliz Formula"
        field ttv_des_contdo                   as character format "x(47)" label "Conteudo" column-label "Conteudo"
        index tt_param_program_formul_id       is primary
              tta_cdn_segment_edi              ascending
              tta_cdn_element_edi              ascending
        .
    
    
    
    /********************** Temporary Table Definition End **********************/
    
    /************************ Parameter Definition Begin ************************/
    
    def Input param p_cdn_mapa_edi
        as Integer
        format ">>>>>9"
        no-undo.
    def Input param p_cdn_segment_edi
        as Integer
        format ">>>>>9"
        no-undo.
    def Input param p_cdn_element_edi
        as Integer
        format ">>>>>9"
        no-undo.
    def Input param table
        for tt_param_program_formul.
    
    
    /************************* Parameter Definition End *************************/
    
    /************************* Variable Definition Begin ************************/
    
    def new global shared var v_cod_aplicat_dtsul_corren
        as character
        format "x(3)"
        no-undo.
    def new global shared var v_cod_ccusto_corren
        as character
        format "x(11)"
        label "Centro Custo"
        column-label "Centro Custo"
        no-undo.
    def new global shared var v_cod_dwb_user
        as character
        format "x(21)"
        label "Usu rio"
        column-label "Usu rio"
        no-undo.
    def new global shared var v_cod_empres_usuar
        as character
        format "x(3)"
        label "Empresa"
        column-label "Empresa"
        no-undo.
    def new global shared var v_cod_estab_usuar
        as character
        format "x(3)"
        label "Estabelecimento"
        column-label "Estab"
        no-undo.
    def new global shared var v_cod_funcao_negoc_empres
        as character
        format "x(50)"
        no-undo.
    def new global shared var v_cod_grp_usuar_lst
        as character
        format "x(3)"
        label "Grupo Usu rios"
        column-label "Grupo"
        no-undo.
    def new global shared var v_cod_idiom_usuar
        as character
        format "x(8)"
        label "Idioma"
        column-label "Idioma"
        no-undo.
    def new global shared var v_cod_modul_dtsul_corren
        as character
        format "x(3)"
        label "M¢dulo Corrente"
        column-label "M¢dulo Corrente"
        no-undo.
    def new global shared var v_cod_modul_dtsul_empres
        as character
        format "x(100)"
        no-undo.
    def new global shared var v_cod_pais_empres_usuar
        as character
        format "x(3)"
        label "Pa¡s Empresa Usu rio"
        column-label "Pa¡s"
        no-undo.
    def new global shared var v_cod_plano_ccusto_corren
        as character
        format "x(8)"
        label "Plano CCusto"
        column-label "Plano CCusto"
        no-undo.
    def new global shared var v_cod_unid_negoc_usuar
        as character
        format "x(3)"
        view-as combo-box
        list-items ""
        inner-lines 5
        bgcolor 15 font 2
        label "Unidade Neg¢cio"
        column-label "Unid Neg¢cio"
        no-undo.
    def new global shared var v_cod_usuar_corren
        as character
        format "x(12)"
        label "Usu rio Corrente"
        column-label "Usu rio Corrente"
        no-undo.
    def new global shared var v_cod_usuar_corren_criptog
        as character
        format "x(16)"
        no-undo.
    def var v_dat_aux
        as date
        format "99/99/9999"
        no-undo.
    def var v_des_dat_conver
        as character
        format "x(10)"
        no-undo.
    def new global shared var v_des_flag_public_bloco
        as character
        format "x(15)"
        extent 10
        no-undo.
    def var v_des_ret
        as character
        format "x(09)"
        no-undo.
    def var v_nom_title_aux
        as character
        format "x(60)"
        no-undo.
    def var v_num_aux_5
        as integer
        format "9"
        no-undo.
    def var v_num_cont
        as integer
        format ">,>>9"
        initial 0
        no-undo.
    def new global shared var v_num_ped_exec_corren
        as integer
        format ">>>>9"
        no-undo.
    def var v_rec_log
        as recid
        format ">>>>>>9"
        no-undo.
    
    
    /************************** Variable Definition End *************************/
    
    
    /****************************** Main Code Begin *****************************/
    
    
    /* Begin_Include: i_version_extract */
    def new global shared var v_cod_arq
        as char 
        format 'x(60)'
        no-undo.
    def new global shared var v_cod_tip_prog
        as character
        format 'x(8)'
        no-undo.
    
    def stream s-arq.
    
    if  v_cod_arq <> '' and v_cod_arq <> ?
    then do:
        run pi_version_extract ('fnc_prg_formul_10', 'prgint/edf/edf700zj.py', '1.00.00.001', 'pro').
    end /* if */.
    /* End_Include: i_version_extract */
    
    if  p_cdn_segment_edi = 44 and
         p_cdn_element_edi = 3537
    then do:
    
        find tt_param_program_formul where
             tt_param_program_formul.tta_cdn_segment_edi = 44 and
             tt_param_program_formul.tta_cdn_element_edi = 5879 no-error.
    
        if  avail tt_param_program_formul
        then do:
             case tt_param_program_formul.ttv_des_contdo:
                when '222222' then
                     return '01011980'.
                when '333333' then do:
                     assign v_dat_aux        = today - 1
                            v_des_dat_conver = replace(string(v_dat_aux,"99/99/9999"),"/","").
                     return v_des_dat_conver.
                end.
                when '444444' then do:
                     assign v_dat_aux        = today
                            v_des_dat_conver = replace(string(v_dat_aux,"99/99/9999"),"/","").
                     return v_des_dat_conver.
                end.
                when '555555' then do:
                     assign v_des_flag_public_bloco[1] = "555555".
                     return '01011980'.
                end.
                otherwise do:
                     if  substring(tt_param_program_formul.ttv_des_contdo,5,2) = "00"
                     then do: /* * Vem formato AAMM00 **/
                         assign v_des_dat_conver = "01" +
                                                   substring(tt_param_program_formul.ttv_des_contdo,03,02) + 
                                                   substring(tt_param_program_formul.ttv_des_contdo,01,02)
                                v_dat_aux        = date(v_des_dat_conver)
                                v_des_dat_conver = replace(string(v_dat_aux,"99/99/9999"),"/","").
                         return v_des_dat_conver.
                     end /* if */.
                     else do:
                         if  substring(tt_param_program_formul.ttv_des_contdo,3,2) = "00"
                         then do: /* * Vem formato AA00SS -> SS = Semana **/
                             assign v_des_dat_conver = "01" + "01" +
                                                       substring(tt_param_program_formul.ttv_des_contdo,01,02)
                                    v_dat_aux        = date(v_des_dat_conver)
                                    v_dat_aux        = v_dat_aux - weekday(v_dat_aux)
                                    v_dat_aux        = v_dat_aux + (7 * int(substring(tt_param_program_formul.ttv_des_contdo,5,2)) - 6)
                                    v_des_dat_conver = replace(string(v_dat_aux,"99/99/9999"),"/","").
                             return v_des_dat_conver.
                         end /* if */.
                         if  v_des_flag_public_bloco[1] = "555555"
                         then do:
                             assign v_des_dat_conver = "01" + "01" +
                                                       substring(tt_param_program_formul.ttv_des_contdo,01,02)
                                    v_dat_aux        = date(v_des_dat_conver)
                                    v_dat_aux        = v_dat_aux - weekday(v_dat_aux)
                                    v_dat_aux        = v_dat_aux + (7 * int(substring(tt_param_program_formul.ttv_des_contdo,3,2)) - 6)
                                    v_des_dat_conver = replace(string(v_dat_aux,"99/99/9999"),"/","").
                             return v_des_dat_conver.
                         end /* if */.
                         else do:
                            assign v_des_dat_conver = substring(tt_param_program_formul.ttv_des_contdo,05,02) +
                                                      substring(tt_param_program_formul.ttv_des_contdo,03,02) + 
                                                      substring(tt_param_program_formul.ttv_des_contdo,01,02)
                                   v_dat_aux        = date(v_des_dat_conver)
                                   v_des_dat_conver = replace(string(v_dat_aux,"99/99/9999"),"/","").
                            return v_des_dat_conver.
                         end /* else */.
                     end /* else */.
                end.
             end case.
        end /* if */.
        else
           return string("Elemento" /*l_elemento*/  + ' ' + "nÆo esta no programa" /*l_nao_esta_prog*/ ).
    end /* if */.
    
    if  p_cdn_segment_edi = 44 and
         p_cdn_element_edi = 3540
    then do:
         find tt_param_program_formul where
             tt_param_program_formul.tta_cdn_segment_edi = 44 and
             tt_param_program_formul.tta_cdn_element_edi = 5879 no-error.
    
         if  tt_param_program_formul.ttv_des_contdo = '222222' or
            tt_param_program_formul.ttv_des_contdo = '555555'
         then do:
            find tt_param_program_formul where
                 tt_param_program_formul.tta_cdn_segment_edi = 44 and
                 tt_param_program_formul.tta_cdn_element_edi = 5839 no-error.
            return '0'.
         end /* if */.
         else do:
            find tt_param_program_formul where
                 tt_param_program_formul.tta_cdn_segment_edi = 44 and
                 tt_param_program_formul.tta_cdn_element_edi = 5839 no-error.
            return tt_param_program_formul.ttv_des_contdo.
        end /* if */.
    end /* if */.
    
    
    
    /******************************* Main Code End ******************************/
    
    /************************* Internal Procedure Begin *************************/
    
    /*****************************************************************************
    ** Procedure Interna.....: pi_version_extract
    ** Descricao.............: pi_version_extract
    ** Criado por............: jaison
    ** Criado em.............: 31/07/1998 09:33:22
    ** Alterado por..........: Gilmar
    ** Alterado em...........: 29/01/1999 13:50:32
    *****************************************************************************/
    PROCEDURE pi_version_extract:
    
        /************************ Parameter Definition Begin ************************/
    
        def Input param p_cod_program
            as character
            format "x(8)"
            no-undo.
        def Input param p_cod_program_ext
            as character
            format "x(8)"
            no-undo.
        def Input param p_cod_version
            as character
            format "x(8)"
            no-undo.
        def Input param p_cod_program_type
            as character
            format "x(8)"
            no-undo.
    
    
        /************************* Parameter Definition End *************************/
    
        if  can-do(v_cod_tip_prog, p_cod_program_type)
        then do:
            if p_cod_program_type = 'dic' then
               assign p_cod_program_ext = replace(p_cod_program_ext, 'database/', '').
    
            output stream s-arq to value(v_cod_arq) append.
    
            put stream s-arq unformatted
                p_cod_program            at 1
                p_cod_program_ext        at 43
                p_cod_version            at 69
                today                    at 84
                string(time, 'HH:MM:SS') at 94 skip.
    
            if  p_cod_program_type = 'pro' then do:
                &if '{&emsbas_version}' > '1.00' &then
                find mguni.prog_dtsul
                    where prog_dtsul.cod_prog_dtsul = p_cod_program
                    no-lock no-error.
                if  avail prog_dtsul
                then do:
                    &if '{&emsbas_version}' > '5.00' &then
                        if  prog_dtsul.nom_prog_dpc <> '' then
                            put stream s-arq 'DPC : ' at 5 prog_dtsul.nom_prog_dpc  at 15 skip.
                    &endif
                    if  prog_dtsul.nom_prog_appc <> '' then
                        put stream s-arq 'APPC: ' at 5 prog_dtsul.nom_prog_appc at 15 skip.
                    if  prog_dtsul.nom_prog_upc <> '' then
                        put stream s-arq 'UPC : ' at 5 prog_dtsul.nom_prog_upc  at 15 skip.
                end /* if */.
                &endif
            end.
    
            if  p_cod_program_type = 'dic' then do:
                &if '{&emsbas_version}' > '1.00' &then
                find mguni.tab_dic_dtsul
                    where tab_dic_dtsul.cod_tab_dic_dtsul = p_cod_program
                    no-lock no-error.
                if  avail tab_dic_dtsul
                then do:
                    &if '{&emsbas_version}' > '5.00' &then
                        if  tab_dic_dtsul.nom_prog_dpc_gat_delete <> '' then
                            put stream s-arq 'DPC-DELETE : ' at 5 tab_dic_dtsul.nom_prog_dpc_gat_delete  at 25 skip.
                    &endif
                    if  tab_dic_dtsul.nom_prog_appc_gat_delete <> '' then
                        put stream s-arq 'APPC-DELETE: ' at 5 tab_dic_dtsul.nom_prog_appc_gat_delete at 25 skip.
                    if  tab_dic_dtsul.nom_prog_upc_gat_delete <> '' then
                        put stream s-arq 'UPC-DELETE : ' at 5 tab_dic_dtsul.nom_prog_upc_gat_delete  at 25 skip.
                    &if '{&emsbas_version}' > '5.00' &then
                        if  tab_dic_dtsul.nom_prog_dpc_gat_write <> '' then
                            put stream s-arq 'DPC-WRITE : ' at 5 tab_dic_dtsul.nom_prog_dpc_gat_write  at 25 skip.
                    &endif
                    if  tab_dic_dtsul.nom_prog_appc_gat_write <> '' then
                        put stream s-arq 'APPC-WRITE: ' at 5 tab_dic_dtsul.nom_prog_appc_gat_write at 25 skip.
                    if  tab_dic_dtsul.nom_prog_upc_gat_write <> '' then
                        put stream s-arq 'UPC-WRITE : ' at 5 tab_dic_dtsul.nom_prog_upc_gat_write  at 25 skip.
                end /* if */.
                &endif
            end.
    
            output stream s-arq close.
        end /* if */.
    
    END PROCEDURE. /* pi_version_extract */
    
    
    /************************** Internal Procedure End **************************/
    
    /************************* External Procedure Begin *************************/
    
    
    
    /************************** External Procedure End **************************/
    
    /*************************************  *************************************/
    /*****************************************************************************
    **  Procedure Interna: pi_messages
    **  Descricao........: Mostra Mensagem com Ajuda
    *****************************************************************************/
    PROCEDURE pi_messages:
    
        def input param c_action    as char    no-undo.
        def input param i_msg       as integer no-undo.
        def input param c_param     as char    no-undo.
    
        def var c_prg_msg           as char    no-undo.
    
        assign c_prg_msg = "messages/"
                         + string(trunc(i_msg / 1000,0),"99")
                         + "/msg"
                         + string(i_msg, "99999").
    
        if search(c_prg_msg + ".r") = ? and search(c_prg_msg + ".p") = ? then do:
            message "Mensagem nr. " i_msg "!!!" skip
                    "Programa Mensagem" c_prg_msg "nÆo encontrado."
                    view-as alert-box error.
            return error.
        end.
    
        run value(c_prg_msg + ".p") (input c_action, input c_param).
        return return-value.
    END PROCEDURE.  /* pi_messages */
    /*************************  End of fnc_prg_formul_10 ************************/
    

Compartilhe esta Página