PERGUNTAS E RESPOSTAS
 
Bem Vindo, Visitante  Todos os Fórums
  ADVPL
Enviar para a impressoraImprimir  Enviar e-mail para um amigoEnviar Para um Amigo
Precisa estar Logado

Subject Assunto:
Erro Worflow
Versão:
12.1.17
Plataforma:
Microsoft
Complemento:
DB:
SQL Server
Complemento:
LinkedIn
Foto
Mensagem do Enviar e-mail Abrir o Perfil do usuário LUCADVPL LUCADVPL em 08/03/2024, 18:19 h
Local: SP  Registro: 05/02/2024  Postagens: 14
Fala pessoal blz? Estou com um probleminha com workflow. Eu ja criei e configurei todo o ambiente, e ja havia cadastrado antes um pedido de compras para teste, e cadastrei normalmente. Porém agora compilei um ponto de entrada(WFW120P - ativa o workflow após a gravação do pedido de compras para o controle de alçadas) e quando vou cadastrar um pedido de compras aparece o seguinte erro: ‘variable does not exist MSGP_NONE on TWFPROCESS:EXEC(WFPROCESS.PRW) 02/06/2017 09:46:05 line : 392‘. Ja tentei algumas coisas porem não tive sucesso, se alguem puder me ajudar agradeço desde já. Segue o codigo fonte no arquivo.

Foto
Mensagem do Enviar e-mail Abrir o Perfil do usuário LUCADVPL LUCADVPL em 08/03/2024, 18:22 h
Local: SP  Registro: 05/02/2024  Postagens: 14
#include "protheus.ch"
#include "TbiConn.ch"
#include "TOTVS.ch"                                                 
#include "TbiCode.ch"
#include "topconn.ch"
#Include ‘ApWebEx.ch‘

/*/{Protheus.doc} WFW120P

    Ponto de Entrada que ativacao WF apos gravacao do Pedido de compras para do controle de alcadas

    @author     Milton
     @since          01/01/2023
    @version    1.0
/*/

User Function WFW120P(nOpcao,oProcess)
     Private cPerg := "WFW120P"
     Private cGrupo := SuperGetMV("FS_WFGRAPR",.F.,"000001")                // Grupo de Aprovacao com popup
     Private cGrpWF := AllTrim(SuperGetMV("FS_WFGRPAP",.F.,"000001")) // Grupo de Aprovacao WF     //100002

     CONOUT("LOGWF: ***ENTRADA DO WF")

     If ValType(nOpcao) = "A"
          nOpcao := nOpcao[1]
     Endif

     If nOpcao == NIL
          nOpcao := 0
     End

     /*/
          Criacao do processo do WorkFlow
     /*/

     If nOpcao <> 0 .AND. oProcess == NIL
          PREPARE ENVIRONMENT EMPRESA ‘99‘ FILIAL ‘01‘
          oProcess := TWFProcess():New( "000001", "Pedido de Compras" )
          conout("LOGWF: Cria novo processo 1 : "+oProcess:fProcessID)
     End

     Do Case
          Case nOpcao == 0
          CONOUT("LOGWF: OPCAO 0")
          /*/
               Verifica qual o proximo usuario para liberacao
          /*/

          cNum := SC7->C7_NUM

          AjustaSX1(cPerg)

          lPerg     := .F.
          lAprov1 := .F.
          lPoupUp := .F.

          DbSelectArea("SCR")
          SCR->(DbSetOrder(1))
          If SCR->(DbSeek(xFilial("SCR")+"PC"+PadR(cNum,TamSx3("CR_NUM")[1])))
               //While !lPerg
               While SCR->(!EOF()) .And. SCR->CR_TIPO = "PC" .And. AllTrim(SCR->CR_NUM) = AllTrim(cNum)     
                    If !(SCR->CR_STATUS $ "01/02")
                         Return
                    EndIf

                    mv_par01 := SCR->CR_APROV

                    //If Posicione("SY1",3,xFilial("SY1")+SC7->C7_USER,"Y1_GRUPCOM") $ cGrupo
                    //If SCR->CR_GRUPO $ cGrupo
                    //     lPoupUp := .T.
                    //End

                    If !(SCR->CR_STATUS $ "03/05")
                         SPCIniciar(cNum,SCR->CR_APROV,SCR->CR_APROV)
                    ElseIf SCR->CR_STATUS $ "03/05"
                         lAprov1 := .T.
                    EndIf

                    //EndDo     
                    /*If SCR->CR_NIVEL = "01" .and. lPoupUp == .T.

                    If Pergunte(cPerg)
                    DbSelectArea("SAL")
                    DbSetOrder(3)
                    If DbSeek(xFilial("SAL")+cGrpWF+mv_par01)
                    lPerg := .T.

                    CONOUT("LOGWF: CR_NIVEL : "+SCR->CR_NIVEL)

                    RecLock("SCR",.F.)
                    SCR->CR_USER := SAL->AL_USER
                    SCR->CR_APROV := SAL->AL_APROV
                    SCR->CR_GRUPO := cGrpWF
                    SCR->CR_ITGRP := SAL->AL_ITEM
                    MsUnlock()

                    //aSCRArea := SCR->(GetArea())
                    SPCIniciar(cNum,mv_par01,mv_par01)
                    Exit
                    EndIf
                    EndIf
                    EndIf*/

                    SCR->(DbSkip())

               EndDo                         
          EndIf

          Case nOpcao == 1
          conout("LOGWF: nOpcao = 1")
          SPCRetorno( oProcess )
          oProcess:Free()
          Case nOpcao == 2       
          conout("LOGWF: nOpcao = 2")
          SPCTimeOut( oProcess )
          oProcess:Free()
     EndCase

Return

/*
     Programa : SPCIniciar
     Autor      : Milton J.dos Santos
     Data      : 01/01/2023
     Descricao : Ativa processo inicial do WorkFlow
*/

Static Function SPCIniciar(cNum,cCodAprov,cAprovAnt)

     Local lUsaLink          := .T.
     Local cDirWF          := SuperGetMV("FS_WFDIR",.F.,"workflow")

     /*/
          Variaveis utilizadas para envio via Link
     /*/

     Local cServer        := SuperGetMV("FS_WFLINK",.F.,"localhost:8080/confirmacao") // --> Messenger
//     Local cPastaWf          := "workflow"
//     Local cID           := ""
     Local oProcess          := nil
     Local cEmailCC      := SuperGetMv("FS_WFMAIL",.F.,"[email protected]")

     DbSelectArea("SC7")
     DbSetOrder(1)
     DbGotop()
     If !MsSeek(xFilial("SC7")+cNum)
          CONOUT("LOGWF: WF PC: Pedido de compra nao encontrado:"+cNum)
          Return
     EndIf

     If Right(cDirWF,1) == "\"
          cDirWF := SubStr(cDirWF,1,Len(cDirWF)-1)
     EndIf
     If Left(cDirWF,1) == "\"
          cDirWF := SubStr(cDirWF,2,Len(cDirWF)-1)
     EndIf

     /*/
          Criacao de uma nova tarefa e abertura do WTML
     /*/

     oProcess := TWFProcess():New( "000001", "Pedido de Compras" )
     oProcess:NewTask( "Pedido", "\"+cDirWF+"\html\wfw120p1.html" )
     oProcess:cSubject     := "Aprovacao de Pedido de Compra "+ cNum
     oProcess:bReturn     := "U_WFW120P(1)"

     /*/
          Atualiza variaveis do modelo de WF
     /*/

     U_WFATUVAR(@oProcess,"Aprovação de Pedido de Compras",cAprovAnt)    

     oProcess:fDesc := "Pedido de Compras No "+ cNum                                                                                           

     cIdProcess := oProcess:start("\" + cDirWF + "\http\messenger\confirmacao\")

     If lUsaLink
          cNomAprov := Posicione("SAK",1,xFilial("SAK")+cCodAprov,"AK_NOME")              

          oProcEmail := TWFProcess():New("000001","Pedido de Compras - Link")
          oProcEmail:NewTask( "Pedido", "\"+cDirWF+"\html\WFPCLINK.html" )          
          oProcEmail:cTo          := UsrRetMail(Posicione("SAK",1,xFilial("SAK")+cCodAprov,"AK_USER"))
          oProcEmail:cCC          := cEmailCC
          oProcEmail:cSubject := "Aprovação do Pedido de Compra: "+ cNum + " - Aprovador(a): "+cNomAprov

          CONOUT("LOGWF: WFID LINK:"+cIdProcess)
          oProcEmail:ohtml:valbyname("aprovador"     ,cNomAprov)
          oProcEmail:ohtml:valbyname("C7_NUM"          ,SC7->C7_NUM)
          oProcEmail:ohtml:valbyname("abertura"     ,DtoC(SC7->C7_EMISSAO))
          oProcEmail:ohtml:valbyname("comprador"     ,UsrRetName(SC7->C7_USER))    
          oProcEmail:ohtml:valbyname("cLink","http://"+cServer+"/"+AllTrim(cIdProcess)+".htm") //Link para resposta do Processo      
          oProcEmail:start()     
          oProcEmail:Free()

          RecLock("SC7",.F.)
          SC7->C7_XWFID := cIdProcess
          MsUnlock()

     EndIf

     oProcess:Free()

Return

/*
     Programa : SPCRetorno
     Autor      : Milton J.dos Santos
     Data      : 01/01/2023
     Descricao : Tratamento do Retorno do WorkFlow de Pedido de compras
*/    

Static Function SPCRetorno( oProcess )
     Private cNum       := ""
     Private cNivelSCR := ""
     Private cUsrLib   := ""
     Private cAprov    := ""
     Private nTotSCR   := 0
     Private lPedOK      := .F.
     Private nRecSCR      := 0
     Private lTemNivel := .F.
     Private cStatus   := ""
     Private nValLib   := 0
     Private cTipoLim := ""
     Private cObs      := 0
     Private cCodApv   := 0

     cNum         := oProcess:oHtml:RetByName(‘C7_NUM‘)
     cSC7User   := oProcess:oHtml:RetByName(‘C7_USER‘)
     cNivelSCR := oProcess:oHtml:RetByName(‘CR_NIVEL‘)   
     cUsrLib    := oProcess:oHtml:RetByName(‘CR_USER‘)
     cAprov     := oProcess:oHtml:RetByName(‘APROVADOR‘)
     nTotSCR    := Val(StrTran(oProcess:oHtml:RetByName(‘CR_TOTAL‘),",","."))
     aItens     := oProcess:oHtml:RetByName(‘it.item‘)
     aProds     := oProcess:oHtml:RetByName(‘it.produto‘)
     cObserv    := oProcess:oHtml:RetByName(‘OBS‘)

     Conout("LOGWF: RETORNO - Pedido:"+cNum+" Nivel: "+cNivelSCR+" Aprovacao: "+Upper(oProcess:oHtml:RetByName("Aprovacao")))

     if Upper(oProcess:oHtml:RetByName("Aprovacao")) <> "S"
          Conout("LOGWF: ENTROU NO IF REPROVADO")
          dbSelectarea("SCR")
          dbSetorder(1)
          dbGoTop()
          dbSeek( xFilial("SCR") + "PC" + alltrim(cNum))    
          While !EOF() .and. alltrim(SCR->CR_NUM) == alltrim(cNum)
               If Empty(SCR->CR_DATALIB)
                    If AllTrim(SCR->CR_APROV) = AllTrim(cAprov)
                         cStatus := "04"
                         cObs     := oProcess:oHtml:RetByName(‘OBS‘)
                    Else
                         cStatus := "05"
                         cObs     := "Doc.Bloq.Usuário: "+cAprov
                    EndIf

                    dbSelectArea("SCR")
                    SCR->(dbsetorder(2)) // CR_FILIAL+CR_TIPO+CR_NUM+CR_USER                                                                                                                              

                    If SCR->(dbseek(xFilial("SCR")+"PC"+PadR(cNum,TamSx3("CR_NUM")[1])+cUsrLib))                    
                         RecLock("SCR",.f.)
                         SCR->CR_DATALIB := dDataBase
                         SCR->CR_STATUS := cStatus // Bloqueado
                         SCR->CR_OBS     := cObs
                         SCR->CR_USERLIB := cUsrLib
                         SCR->CR_LIBAPRO := cAprov
                         SCR->CR_VALLIB := 0
                         MsUnLock()
                    EndIf
               Endif
               Dbskip()
          End
          SPCAprov(.F.) //Envia email de reprovacao
     Else
          Conout("LOGWF: ENTROU NO IF APROVADO")
          SC7->(DBSETORDER(1))
          SC7->(DBGoTop())
          If SC7->(dbseek(xFilial("SC7")+cNum)) .AND. SC7->C7_CONAPRO <> "L"
               SCR->(dbsetorder(1))
               If SCR->(dbseek(xFilial("SCR")+"PC"+PadR(cNum,TamSx3("CR_NUM")[1])+cNivelSCR))
                    While !EOF() .and. alltrim(SCR->CR_NUM) == alltrim(cNum)
                         IF AllTrim(SCR->CR_NIVEL) == AllTrim(cNivelSCR)
                              If SCR->CR_STATUS $ "01/02"

                                   conout("LOGWF: ==>>WF APROVADO")

                                   If AllTrim(SCR->CR_APROV) = AllTrim(cAprov)
                                        cStatus := "03"
                                        nValLib := nTotSCR
                                        cTipoLim := Posicione("SAK",1,xFilial("SAK")+SCR->CR_APROV,"AK_TIPO")
                                        cCodApv := cAprov
                                   Else
                                        cStatus := "05"
                                        nValLib := 0     
                                        cTipoLim := ""
                                        cCodApv := ""
                                   EndIf
                                   
                                   dbSelectArea("SCR")
                                   SCR->(dbsetorder(2)) // CR_FILIAL+CR_TIPO+CR_NUM+CR_USER                                                                                                                              

                                   If SCR->(dbseek(xFilial("SCR")+"PC"+PadR(cNum,TamSx3("CR_NUM")[1])+cUsrLib))
                                        SCR->(RecLock("SCR",.F.))
                                        SCR->CR_DATALIB := dDataBase
                                        SCR->CR_STATUS := cStatus
                                        SCR->CR_USERLIB := cUsrLib
                                        SCR->CR_LIBAPRO := cCodApv
                                        SCR->CR_VALLIB := nValLib
                                        SCR->CR_TIPOLIM := cTipoLim
                                        SCR->CR_OBS     := oProcess:oHtml:RetByName(‘OBS‘)
                                        SCR->(MsUnLock())
                                        nRecSCR     := SCR->(Recno())
                                   
                                        lPedOK := .T.
                                   
                                   EndIf

                              EndIf   
                         Else
                              If SCR->CR_STATUS == "01"
                                 If lPedOK
                                    SCR->(RecLock("SCR",.F.))
                                    SCR->CR_STATUS := "02"
                                 Endif   
                              ENDIF
                         Endif     
                         SCR->(DbSkip())
                    EndDo     
               EndIf
          EndIf
     EndIf     

     oProcess:Finish()
     oProcess:Free()

     If lPedOK
          lCont := .T.

          DbSelectArea("SCR")
          SCR->(dbsetorder(1))
          If SCR->(dbseek(xFilial("SCR")+"PC"+PadR(cNum,TamSx3("CR_NUM")[1])))
               While !EOF() .and. alltrim(SCR->CR_NUM) == alltrim(cNum)
                    If !(SCR->CR_STATUS $ "03/05")//SCR->CR_STATUS <> "03"
                         If !(SCR->CR_STATUS $ ‘04/05‘)
                              Conout("LOGWF: Enviando para o próximo nível.")
                              SPCIniciar(cNum,SCR->CR_APROV,cAprov)
                         EndIf
                         lCont := .F.
                    EndIf
                    SCR->(DbSkip())
               EndDo
          EndIf     


          If lCont
               SC7->(DBSETORDER(1))
               SC7->(DBGoTop())
               SC7->(dbseek(xFilial("SC7")+cNum))
               Conout("LOGWF: pedido ok aprovado")
               while !SC7->(EOF()) .and. SC7->C7_Num == cNum
                    SC7->(RecLock("SC7",.F.))
                    SC7->C7_ConaPro := "L"
                    SC7->(MsUnLock())
                    SC7->(DBSkip())
               enddo
               SPCAprov(.T.) //Envia email de Aprovacao
          EndIf     
     EndIf

     //Conout("LOGWF: Executa WFW120P novamente. ")
     //U_WFW120P(0)

Return

Static Function SPCAprov(lAprovado)
     Local nx       := 0
     Local cEmailCC := SuperGetMv("FS_WFMAIL",.F.,"[email protected]")

     CONOUT("LOGWF: Envia email de aprovacao: "+cNum)

     oProcAprov := TWFProcess():New("000001","Pedido de Compras - Aprovacao")
     If lAprovado
          oProcAprov:NewTask("Pedido","\workflow\html\wfw120p2.html")
          oProcAprov:cSubject := "Pedido de Compra Nº "+cNum+" aprovado."
          CONOUT("LOGWF: Aprovado. Pedido: "+cNum)
     Else
          oProcAprov:NewTask("Pedido","\workflow\html\wfw120p3.html")
          oProcAprov:cSubject := "Pedido de Compra Nº "+cNum+" reprovado."
          CONOUT("LOGWF: Reprovado. Pedido: "+cNum)
     EndIf     
     oProcAprov:cTo          := UsrRetMail(cSC7User)
     oProcAprov:cCC          := cEmailCC
     oProcAprov:ohtml:valbyname("Num",cNum)
     oProcAprov:ohtml:valbyname("Emissao",DtoC(Posicione("SC7",1,xFilial("SC7")+cNum,"C7_EMISSAO")))
     oProcAprov:ohtml:valbyname("Req",UsrRetName(cSC7User))

     For nx := 1 to Len(aItens)
          AAdd((oProcAprov:oHTML:ValByName("it.item")),aItens[nx])
          AAdd((oProcAprov:oHTML:ValByName("it.produto")),aProds[nx])
     Next

     oProcAprov:ohtml:valbyname("Motivo",cObserv)

     oProcAprov:start()     
     oProcAprov:Free()

Return

/*
     Programa : WFAtuVar
     Autor      : Milton J.dos Santos
     Data      : 01/01/2023
     Descricao : Atualiza variaveis do modelo de WorkFlow
*/

User Function WFAtuVar(oProcess,cTitulo,cAprovAnt)
     Local aArea          := GetArea()
     Local aSC7Area     := SC7->(GetArea())
     Local aSCRArea     := SCR->(GetArea())
     Local nVlrTotal     := 0
     Local nVlrFrete := 0
     Local nTotGeral := 0
     Local cNum           := SC7->C7_NUM
     Local cCotacao      := SC7->C7_NUMCOT
//     Local cNumSC     := SC7->C7_NUMSC
     Local cObsp     := ""
//     Local cLogo          := ""
//     Local cFilterCR     := SCR->(DbFilter())   

     oProcess:oHTML:ValByName( "C7_NUM"      , SC7->C7_NUM )
     oProcess:oHTML:ValByName( "C7_EMISSAO", DtoC(SC7->C7_EMISSAO) )
     oProcess:oHTML:ValByName( "C7_USER"   , SC7->C7_USER)

     dbSelectArea(‘SA2‘)
     dbSetOrder(1)
     dbSeek(xFilial(‘SA2‘)+SC7->C7_FORNECE)
     oProcess:oHTML:ValByName( "A2_NOME", SA2->A2_COD+"/"+SA2->A2_LOJA+" - "+SA2->A2_NOME )

     DbSelectArea("SE4")
     DbSetOrder(1)
     If MsSeek(xFilial("SE4")+SC7->C7_COND)
          oProcess:oHTML:ValByName( "E4_DESCRI", SE4->E4_CODIGO + " - " + SE4->E4_DESCRI )
     EndIf

     oProcess:oHTML:ValByName("aprovant",Posicione("SAK",1,xFilial("SAK")+cAprovAnt,"AK_NOME"))

     /*/
          Dados do aprovador corrente
     /*/

     oProcess:oHTML:ValByName( "APROVADOR"     , SCR->CR_APROV )
     oProcess:oHTML:ValByName( "CR_FILIAL"     , SCR->CR_FILIAL )
     oProcess:oHTML:ValByName( "CR_NUM"           , SCR->CR_NUM )
     oProcess:oHTML:ValByName( "CR_NIVEL"     , SCR->CR_NIVEL )
     oProcess:oHTML:ValByName( "CR_USER"          , SCR->CR_USER )//Posicione("SAK",1,xFilial("SAK")+mv_par01,"AK_USER") )
     oProcess:oHTML:ValByName( "CR_TOTAL"     , SCR->CR_TOTAL )

     /*/
          Tratamento dos itens
     /*/

     dbSelectArea(‘SB1‘)
     SB1->( dbSetOrder(1) )
     SB1->( DbGoTop() )

     dbSelectArea(‘SC7‘)
     SC7->( dbSetOrder(1) )              
     SC7->( DbGoTop() )
     SC7->( dbSeek(xFilial(‘SC7‘)+cNum) )

     nVlrFrete := SC7->C7_VALFRE

     Do While SC7->(!Eof()) .AND. (Alltrim(SC7->C7_NUM) == Alltrim(cNum))

          nVlrTotal := nVlrTotal + SC7->C7_TOTAL
          nTotGeral := nTotGeral + SC7->C7_TOTAL + SC7->C7_VALIPI
          SB1->(dbSeek(xFilial(‘SB1‘)+SC7->C7_PRODUTO) )

          AAdd( (oProcess:oHTML:ValByName( "it.item" ))     ,SC7->C7_ITEM )
          AAdd( (oProcess:oHTML:ValByName( "it.produto" ))     ,SC7->C7_PRODUTO + " - "+SB1->B1_DESC )
          AAdd( (oProcess:oHTML:ValByName( "it.quant" ))     ,TRANSFORM( SC7->C7_QUANT ,‘@E 99,999.99‘ ) )
          AAdd( (oProcess:oHTML:ValByName( "it.um" ))          ,SB1->B1_UM )
          AAdd( (oProcess:oHTML:ValByName( "it.preco" ))     ,TRANSFORM( SC7->C7_PRECO ,‘@E 999,999,999.99‘ ) )
          AAdd( (oProcess:oHTML:ValByName( "it.total" ))     ,TRANSFORM( SC7->C7_TOTAL ,‘@E 999,999,999.99‘ ) )
     //     AAdd( (oProcess:oHTML:ValByName( "it.obs" ))     ,TRANSFORM( SC7->C7_OBS   ,‘@!‘ ) )
         if Len(alltrim(cObsp)) == 0
            cObsp := SC7->C7_OBS
         Else
            if Len(alltrim(SC7->C7_OBS)) > 0
               cObsp := cObsp+‘ - ‘+SC7->C7_OBS
            Endif   
         Endif   
          SC7->( dbSkip() )
     Enddo    
     oProcess:oHTML:ValByName("Obsped" , cObsp )
     oProcess:oHTML:ValByName("vlrtotal",TRANSFORM(nVlrTotal,‘@E 999,999,999.99‘))
     oProcess:oHTML:ValByName("vlrfrete",TRANSFORM(nVlrFrete,‘@E 999,999,999.99‘))
     oProcess:oHTML:ValByName("totgeral",TRANSFORM(nTotGeral,‘@E 999,999,999.99‘))

     /*/
          Dados das Cotacoes
     /*/

     DbSelectArea("SC8")
     DbSetOrder(1)
     DbGoTop()
     If DbSeek(xFilial("SC8")+cCotacao)                     
          nTotCot := 0
          cFornCot := ""
          While !EOF() .AND. xFilial("SC8")+cCotacao == SC8->(C8_FILIAL+C8_NUM)
               If cFornCot <> SC8->C8_FORNECE
                    If !Empty(cFornCot)                                          
                         AAdd( (oProcess:oHTML:ValByName( "ct.cot"      ))     , " " )
                         AAdd( (oProcess:oHTML:ValByName( "ct.fornec"     ))     , " " )
                         AAdd( (oProcess:oHTML:ValByName( "ct.produto"))     , " " )
                         AAdd( (oProcess:oHTML:ValByName( "ct.emissao"))     , " " )
                         AAdd( (oProcess:oHTML:ValByName( "ct.cond"     ))     , " " )
                         AAdd( (oProcess:oHTML:ValByName( "ct.prev"     ))     , " " )
                         AAdd( (oProcess:oHTML:ValByName( "ct.obs"     ))     , " " )    
                         AAdd( (oProcess:oHTML:ValByName( "ct.qtde"      ))     , " " )    
                         AAdd( (oProcess:oHTML:ValByName( "ct.um"        ))     , " " )
                         AAdd( (oProcess:oHTML:ValByName( "ct.vlunit"     ))     , "Total:" )
                         AAdd( (oProcess:oHTML:ValByName( "ct.vlTot"      ))     , ""+TRANSFORM(nTotCot,‘@E 999,999,999.99‘ )+"" )
                    EndIf
                    cFornCot := SC8->C8_FORNECE
                    nTotCot := 0
                    AAdd( (oProcess:oHTML:ValByName( "ct.cot"          )), SC8->C8_NUM )
                    AAdd( (oProcess:oHTML:ValByName( "ct.fornec"      )), Alltrim(Posicione("SA2",1,xFilial("SA2")+SC8->(C8_FORNECE+C8_LOJA),"A2_NREDUZ")) )
               Else                                                               
                    AAdd( (oProcess:oHTML:ValByName( "ct.cot"          )), SC8->C8_NUM )
                    AAdd( (oProcess:oHTML:ValByName( "ct.fornec"      )), " " )
               EndIf            
               AAdd( (oProcess:oHTML:ValByName( "ct.produto"      )), SC8->C8_PRODUTO+" - "+Alltrim(Posicione("SB1",1,xFilial("SB1")+SC8->C8_PRODUTO,"B1_DESC")) )
               AAdd( (oProcess:oHTML:ValByName( "ct.emissao"      )), DtoC(SC8->C8_EMISSAO) )
               AAdd( (oProcess:oHTML:ValByName( "ct.cond"          )), Alltrim(Posicione("SE4",1,xFilial("SE4")+SC8->C8_COND,"E4_DESCRI")) )
               AAdd( (oProcess:oHTML:ValByName( "ct.prev"          )), DtoC(SC8->C8_DATPRF) )
               AAdd( (oProcess:oHTML:ValByName( "ct.obs"          )), SC8->C8_OBS )       
               AAdd( (oProcess:oHTML:ValByName( "ct.qtde"           )), TRANSFORM( SC8->C8_QUANT,‘@E 99,999.99‘ ) )
               AAdd( (oProcess:oHTML:ValByName( "ct.um"           )), Alltrim(Posicione("SB1",1,xFilial("SB1")+SC8->C8_PRODUTO,"B1_UM")) )
               AAdd( (oProcess:oHTML:ValByName( "ct.vlunit"     )), TRANSFORM( SC8->C8_PRECO,‘@E 999,999,999.99‘ ) )
               AAdd( (oProcess:oHTML:ValByName( "ct.vlTot"      )), TRANSFORM( SC8->C8_TOTAL,‘@E 999,999,999.99‘ ) )

               nTotCot += SC8->C8_TOTAL

               DbSelectArea("SC8")
               DbSkip()
          EndDo                                                       
          AAdd( (oProcess:oHTML:ValByName( "ct.cot"      ))     , " " )
          AAdd( (oProcess:oHTML:ValByName( "ct.fornec"     ))     , " " )
          AAdd( (oProcess:oHTML:ValByName( "ct.produto"))     , " " )
          AAdd( (oProcess:oHTML:ValByName( "ct.emissao"))     , " " )
          AAdd( (oProcess:oHTML:ValByName( "ct.cond"     ))     , " " )
          AAdd( (oProcess:oHTML:ValByName( "ct.prev"     ))     , " " )
          AAdd( (oProcess:oHTML:ValByName( "ct.obs"     ))     , " " )    
          AAdd( (oProcess:oHTML:ValByName( "ct.qtde"      ))     , " " )
          AAdd( (oProcess:oHTML:ValByName( "ct.um"))     , " " )
          AAdd( (oProcess:oHTML:ValByName( "ct.vlunit"     ))     , "Total:" )
          AAdd( (oProcess:oHTML:ValByName( "ct.vlTot"      ))     , ""+TRANSFORM(nTotCot,‘@E 999,999,999.99‘ )+"" )
     Else                                                            
          AAdd( (oProcess:oHTML:ValByName( "ct.cot"      ))     , " " )
          AAdd( (oProcess:oHTML:ValByName( "ct.fornec"     ))     , "Pedido sem Cotação" )
          AAdd( (oProcess:oHTML:ValByName( "ct.produto"))     , " " )
          AAdd( (oProcess:oHTML:ValByName( "ct.emissao"))     , " " )
          AAdd( (oProcess:oHTML:ValByName( "ct.cond"     ))     , " " )
          AAdd( (oProcess:oHTML:ValByName( "ct.prev"     ))     , " " )
          AAdd( (oProcess:oHTML:ValByName( "ct.obs"     ))     , " " )    
          AAdd( (oProcess:oHTML:ValByName( "ct.qtde"      ))     , " " )    
          AAdd( (oProcess:oHTML:ValByName( "ct.um"))     , " " )
          AAdd( (oProcess:oHTML:ValByName( "ct.vlunit"     ))     , " " )
          AAdd( (oProcess:oHTML:ValByName( "ct.vlTot"      ))     , " " )
     EndIf

     SCR->(RestArea(aSCRArea))
     SC7->(RestArea(aSC7Area))
     RestArea(aArea)
Return

/*
     Programa : AjustaSX1
     Autor      : Milton J.dos Santos
     Data      : 01/01/2023
     Descricao : Cria os parametros na tabela SX1
*/

Static Function AjustaSX1(cPerg)

     Local aAreaAtu     := GetArea()
     Local aAreaSX1     := SX1->( GetArea() )

     PutSx1(cPerg,"01","Aprovador ? ","Aprovador ? ","Aprovador ? ","Mv_ch1",TAMSX3("AK_COD")[3],TAMSX3("AK_COD")[1],TAMSX3("AK_COD")[2],0,"G","","SALZ","","N","mv_par01","","","","","","","","","","","","","","","","",{"Informe o aprovador.",""},{""},{""},"")

     RestArea( aAreaSX1 )
     RestArea( aAreaAtu )

Return(cPerg)

Foto
Mensagem do Enviar e-mail Abrir o Perfil do usuário SMATOS SMATOS em 11/03/2024, 06:38 h
Local: SC  Registro: 12/03/2007  Postagens: 3
olá,

Experimente aplicar a patch do link a seguir:
https://suporte.totvs.com/portal/p/10098/download?e=660308

Foto
Mensagem do Enviar e-mail Abrir o Perfil do usuário BLACKSTAR2 BLACKSTAR2 em 03/04/2024, 12:17 h
Local: SP  Registro: 03/04/2024  Postagens: 1
* excluido *

Para postar no Fórum você precisa efetuar o seu login ou se registrar

 Mudar para Fórum

 

 

 
 
   
Pagina Principal Shopping PROTHEUS Tire suas duvidas Vagas Microsiga em todo Brasil Aprofunde seus conhecimentos Noticias Online Fale Conosco Pagina Principal