Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

Bloco de código
titleExemplo 1 - padrão LookUp - Valores setados manualmente
collapsetrue
#include "msobject.ch"
#include "protheus.ch"
#include "totvs.framework.treports.integratedprovider.th"
 
namespace custom.materiais.produtos.integratedprovider.lookup
 
@totvsFrameworkTReportsIntegratedProvider(active=.T.)
class SB1TReportsBusinessObject from totvs.framework.treports.integratedprovider.IntegratedProvider
    public method new() as object
    public method getDisplayName() as character
    public method getDescription() as character
    public method getData() as object
    public method getSchema() as object
    public method getLookUp() as object
endclass
 
method new() class SB1TReportsBusinessObject
_Super:new()
self:appendArea("Materiais")
self:setIsLookUp(.T.)
return self
 
method getDisplayName() as character class SB1TReportsBusinessObject
return "Produtos"
 
method getDescription() as character class SB1TReportsBusinessObject
return "Produtos do Protheus"
 
method getData(nPage as numeric, oFilter as object) as object class SB1TReportsBusinessObject
local cQuery as character
local cAlias as character
 
cQuery := "SELECT B1_FILIAL, B1_COD, B1_DESC, B1_TIPO, B1_UM, B1_UREV FROM " + RetSQLName("SB1") + " WHERE D_E_L_E_T_ = ' '"
 
//Os filtros serão setados na interface do novo TReports
if oFilter:hasFilter()
    cQuery += " AND " + oFilter:getSQLExpression()
endif
 
cAlias := MPSysOpenQuery(cQuery)

while !(cAlias)->(Eof())
    cDate := FwTimeStamp(6, StoD((cAlias)->B1_UREV))
    self:oData:appendData({"Filial": (cAlias)->B1_FILIAL,; 
            "Codigo": (cAlias)->B1_COD,; 
            "Descricao": (cAlias)->B1_DESC,;
            "Tipo": (cAlias)->B1_TIPO, ;
            "Unidade": (cAlias)->B1_UM, ;
            "Revisao": cDate})
    (cAlias)->(DBSkip())
enddo
 
(cAlias)->(DBCloseArea()) 
 
return self:oData
 
method getSchema() as object class SB1TReportsBusinessObject
local cField as character
local aStruct as array
local lIsRequired as logical

//Seta a descrição da consulta
self:oSchema:setDescriptor("Código","Código do Produto", "Descrição")

self:oSchema:addProperty("Filial", "Filial", "string", "Filial", "B1_FILIAL", cComboFil,.F.)
self:oSchema:addProperty("Codigo", "Codigo", "string", "Codigo", "B1_COD")
self:oSchema:addProperty("Descricao", "Descricao", "string", "Descricao","B1_DESC")
self:oSchema:addProperty("Tipo", "Tipo", "string", "Tipo","B1_TIPO")
self:oSchema:addProperty("Unidade", "Unidade de medida", "string", "Unidade","B1_UM") 
self:oSchema:addProperty("Revisao", "Revisao", "date", "revisao","B1_UREV") 
self:oSchema:addProperty("Camp Log", "Camp Log", "boolean", "Camp Lógico","B1_LOGI")

cField := "B1_COD"
aStruct := {}
aAdd(aStruct, {"ATF0510001", "ATFA036 EMISSAO DE NOTA EM LOT"})
aAdd(aStruct, {"0003","PRODUTO PADRAO"})
aAdd(aStruct, {"EST00000000000000000000001GGGR","'PRODTO ESTOQUE GRADE EAI INTE"})
lIsRequired := .F.

//Seta os valores para o Lookup
self:oSchema:setLookUpVal(cField, aStruct, lIsRequired)

return self:oSchema

...