LC_ORCA1034.PRW 971 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. //-----------------------------------------
  2. // Função ORCA1034. Buscar % de Frete. SZ3
  3. // Solicitante: Comercial.
  4. // Autor: Fonseca.
  5. // Data: 03-09-2014.
  6. //-----------------------------------------
  7. #include 'protheus.ch'
  8. #include 'rwmake.ch'
  9. #include 'totvs.ch'
  10. #include "Topconn.ch"
  11. User Function ORCA1034()
  12. Local aArea := GetArea()
  13. If Funname() = "RPC" //Portal SMS
  14. Return
  15. Endif
  16. If Select("QRY") > 0
  17. dbSelectArea("QRY")
  18. QRY->(dbCloseArea())
  19. Endif
  20. cQuery := "SELECT * FROM " + RetSQLName("SZ3") + " WHERE D_E_L_E_T_ = ' ' AND "
  21. // cQuery += "Z3_FILIAL = '" + xFilial("SZ3") + "' AND D_E_L_E_T_ = ' ' AND "
  22. cQuery += "Z3_UF = '" + Substr(CJ_UFEnt,1,2) + "' ORDER BY Z3_MUNICIP"
  23. TcQuery cQuery New Alias "QRY"
  24. CJ_PERCFRT := QRY->Z3_PERFRAD
  25. While QRY->(!EOF())
  26. If Trim(QRY->Z3_MUNICIP) == Substr(CJ_UFEnt,3,5)
  27. CJ_PERCFRT := QRY->Z3_PERFRAD
  28. EndIf
  29. QRY->(DbSkip())
  30. EndDo
  31. RestArea(aArea)
  32. Return(CJ_PERCFRT)