SHARE
TWEET

Untitled

a guest Jun 26th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. User Function IM06SCX01()
  2.  
  3. Private oProcess := Nil
  4.  
  5.     FWMsgRun(, {|oSay| U_IM06SC01()}, "Processando Registros", "Processando")
  6.  
  7. Return()
  8.  
  9.  
  10. User Function IM06SC01()
  11.  
  12. Local cQuery    := ""
  13. Local aCols     := {}
  14. Local cAlias    := "SE2"
  15.  
  16. Private cPerg   := "IM06SC01  "
  17.  
  18.  
  19.  
  20. /*PRIVATE mv_par01
  21. PRIVATE mv_par02
  22. PRIVATE mv_par03
  23. PRIVATE mv_par04
  24. */
  25.  
  26. ValidPerg(cPerg)
  27. If !Pergunte(cPerg,.T.)
  28.     Return
  29. EndIf
  30.  
  31.         cQuery := " SELECT * "                                                                 + CRLF
  32.         cQuery += " FROM "+RetSQLName("SE2")+" SE2  "                                          + CRLF
  33.         cQuery += " WHERE D_E_L_E_T_ = ' '  "                                                  + CRLF
  34.         cQuery += " AND E2_EMISSAO <> E2_EMIS1  "                                              + CRLF
  35.         cQuery += " AND E2_FILIAL  BETWEEN '"+  mv_par01 +"' AND '"+  mv_par02 +"'  "          + CRLF
  36.         cQuery += " AND E2_EMISSAO BETWEEN '" + Dtos(mv_par03)+"' AND  '"  + Dtos(mv_par04)+"'"+ CRLF  
  37.         TCQUERY cQuery NEW ALIAS (cAlias)
  38.  
  39.         (cAlias)->(DbGoTop())    
  40.  
  41.         Do While !(cAlias)->(Eof())
  42.  
  43.             aAdd(aCols,{.F.,;
  44.             (cAlias)->E2_FILIAL,;          
  45.             (cAlias)->E2_NUM,;
  46.             (cAlias)->E2_TIPO,;
  47.             (cAlias)->E2_FORNECE,;
  48.             (cAlias)->E2_LOJA})
  49.             (cAlias)->(dbSkip())
  50.  
  51.         EndDo
  52.  
  53.         (cAlias)->(DbGoTop())
  54.  
  55.         DbSelectArea("SE2")
  56.         SE2->(dbSetOrder(1))
  57.         SE2->(dbGoTop())
  58.  
  59.         For nx := 1 To Len(aCols)              
  60.             If SE2->(dbSeek(aCols[nx][2]+aCols[nx][3]+aCols[nx][4]+aCols[nx][5]+aCols[nx][6]))
  61.                     RecLock("SE2",.F.)
  62.                     SE2->E2_EMIS1 := SE2->E2_EMISSAO                            
  63.                     SE2->(MsUnlock())  
  64.  
  65.                     nCont++
  66.             Endif
  67.  
  68.  
  69.         Next nx
  70.  
  71.         If nCont > 0
  72.             MsgInfo(cValtoChar(nCont) + " registros processados.", "TOTVS")
  73.         Else
  74.             MsgInfo("Nenhum registro processado","TOTVS")
  75.         Endif
  76.  
  77. Return
  78.  
  79. //*--------------------------------------------------------------------------------------------------------------------
  80.  
  81. Static Function ValidPerg(cPerg)
  82.  
  83. Local aArea := GetArea()
  84.  
  85. cPerg := PADR(cPerg,10)
  86.  
  87. PutSx1(cPerg,"01","Filial de      ","","","mv_ch1","C",06,0,0,"G","","","","","mv_par01","","","","","","","","","","","","","","","","","","","","","","")
  88. PutSx1(cPerg,"02","Filial ate     ","","","mv_ch2","C",06,0,0,"G","","","","","mv_par02","","","","","","","","","","","","","","","","","","","","","","")
  89. PutSx1(cPerg,"03","Data de        ","","","mv_ch3","D",08,0,0,"G","","","","","mv_par03","","","","","","","","","","","","","","","","","","","","","","")
  90. PutSx1(cPerg,"04","Data Ate       ","","","mv_ch4","D",08,0,0,"G","","","","","mv_par04","","","","","","","","","","","","","","","","","","","","","","")
  91.  
  92. RestArea(aArea)
  93.  
  94. Return
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top