Bom dia !
Por favor, poderia auxiliar sobre o assunto. As documentações não são completas.
Segue fonte do objeto de negocio. Criei dois parâmetros:
self:addParameter(“FILIAL”, “Filial do Pedido”, “string”, .T., “SC5.C5_FILIAL”)
self:addParameter(“NUMERO”, “Numero do Pedido”, “string”, .T., “SC5.C5_NUM”)
Preciso recuperar os parâmetros informados pelo usuário no Smartview. Tentei algumas opções disponíveis no TDN, porém se sucesso.
Fonte completo: (Os filtros estão fixos no SQL para testes)
#include “msobject.ch”
#include “totvs.framework.treports.integratedprovider.th”
//-------------------------------------------------------------------
//*/{Protheus.doc} SC5TReportsBusinessObject
//Objeto de Negócio (TReports) para visualização de Pedidos de Venda (SC5)
//-------------------------------------------------------------------
namespace custom.faturamento.pedidos.integratedprovider
@totvsFrameworkTReportsIntegratedProvider(active=.T., team=“SIGAFAT”, tables=“SC5,SC6,SA1,SA3,SB1”, name=“PEDIDOSCUSTOM”, country=“ALL”, initialRelease=“12.1.2210”)
class SC5TReportsBusinessObject from totvs.framework.treports.integratedprovider.IntegratedProvider
public method new() as object
public method getData() as object
public method getSchema() as object
endclass
/*
| new()
| Construtor da classe. Define as informações básicas do Objeto de Negócio.
*/
method new() class SC5TReportsBusinessObject
_Super:new()
self:appendArea("Local")
self:setDisplayName("PEDIDOS CUSTOM")
self:setDescription("PRO COM LOCAL")
return self
/*
| getData()
| Prepara e define a consulta SQL que será executada.
*/
method getData() as object class SC5TReportsBusinessObject
local cQuery as character
self:setPageSize(500)
// A sua nova query foi inserida aqui. A ordem dos campos é a mesma do getSchema().
cQuery := "SELECT SC5.C5_FILIAL, SC5.C5_NUM, SC5.C5_EMISSAO, SA1.A1_NOME, SA1.A1_TIPO, SA1.A1_CGC, SA1.A1_INSCR, " +;
" SA1.A1_EST, SA1.A1_MUN, SA1.A1_BAIRRO, SA1.A1_CEP, SA1.A1_END, SA1.A1_EMAIL, SA1.A1_DDD, " +;
" SA1.A1_TEL, SC5.C5_REDESP, SC6.C6_ITEM, SC6.C6_PRODUTO, SC6.C6_DESCRI, SC6.C6_ESTPAI, SC6.C6_ESTPAII, " +;
" SC6.C6_UM, SB1.B1_DESCOME, SB1.B1_LINKIMG, SC5.C5_CONDPAG, ISNULL(SC5.C5_FRETE, 0) AS C5_FRETE, SC5.C5_USUARIO, " +;
" SA3.A3_NREDUZ, SC6.C6_TES, SC6.C6_CF, ISNULL(SC6.C6_QTDVEN, 0) AS C6_QTDVEN, ISNULL(SC6.C6_PRUNIT, 0) AS C6_PRUNIT, " +;
" ISNULL(SC6.C6_VALDESC, 0) AS C6_VALDESC, ISNULL(SC6.C6_VALOR, 0) AS C6_VALOR, ISNULL(SC6.C6_IPI, 0) AS C6_IPI, " +;
" ISNULL(SC6.C6_VALIPI, 0) AS C6_VALIPI, ISNULL(SC6.C6_PICM, 0) AS C6_PICM, ISNULL(SC6.C6_VALICM, 0) AS C6_VALICM, " +;
" ISNULL(SC6.C6_PRCVEN, 0) AS C6_PRCVEN, SC6.C6_ENTREG, ISNULL(SC6.C6_ACRSFIN, 0) AS C6_ACRSFIN " +;
"FROM " + RetSqlName("SC5") + " SC5 " +;
"INNER JOIN " + RetSqlName("SC6") + " SC6 ON SC5.C5_FILIAL = SC6.C6_FILIAL AND SC5.C5_NUM = SC6.C6_NUM AND SC5.C5_FILIAL = '01' AND SC5.C5_NUM = '894660' " +;
"INNER JOIN " + RetSqlName("SB1") + " SB1 ON SC6.C6_PRODUTO = SB1.B1_COD " +;
"INNER JOIN " + RetSqlName("SA3") + " SA3 ON SC5.C5_VEND1 = SA3.A3_COD " +;
"INNER JOIN " + RetSqlName("SA1") + " SA1 ON SC5.C5_CLIENTE = SA1.A1_COD AND SC5.C5_LOJACLI = SA1.A1_LOJA "
// Cláusula WHERE com os filtros, incluindo a macro %Filter()% para que você possa filtrar na tela.
//self:setWhere("SC5.D_E_L_E_T_ = ' ' AND SC6.D_E_L_E_T_ = ' ' AND SA1.D_E_L_E_T_ = ' ' AND SA3.D_E_L_E_T_ = ' ' AND SB1.D_E_L_E_T_ = ' ' AND SC6.C6_TES <> '999' %Filter()%")
self:setWhere("%Filial('SC5')% AND SC5.D_E_L_E_T_ = ' ' AND SC6.D_E_L_E_T_ = ' ' AND SA1.D_E_L_E_T_ = ' ' AND SA3.D_E_L_E_T_ = ' ' AND SB1.D_E_L_E_T_ = ' ' AND SC6.C6_TES <> '999' %Filter()%")
self:setQuery(cQuery)
self:setOrder("SC6.C6_ITEM")
// O retorno deve ser o objeto de dados (self:oData).
return self:oData
/*
| getSchema()
| Define a estrutura (colunas/propriedades) que estarão disponíveis no SmartView.
*/
method getSchema() as object class SC5TReportsBusinessObject
// Adicionando os parâmetros com a sintaxe correta que você forneceu
self:addParameter("FILIAL", "Filial do Pedido", "string", .T., "SC5.C5_FILIAL")
self:addParameter("NUMERO", "Numero do Pedido", "string", .T., "SC5.C5_NUM")
self:addProperty("C5_FILIAL", "Filial", "string", "Filial do Pedido", "SC5.C5_FILIAL")
self:addProperty("C5_NUM", "Numero", "string", "Número do Pedido", "SC5.C5_NUM")
self:addProperty("C5_EMISSAO", "Emissão", "date", "Data de Emissão", "SC5.C5_EMISSAO")
self:addProperty("A1_NOME", "Nome Cliente", "string", "Nome do Cliente", "SA1.A1_NOME")
self:addProperty("A1_TIPO", "Tipo Pessoa", "string", "Tipo de Pessoa (F ou J)", "SA1.A1_TIPO")
self:addProperty("A1_CGC", "CNPJ/CPF", "string", "CNPJ ou CPF", "SA1.A1_CGC")
self:addProperty("A1_INSCR", "Insc. Estadual", "string", "Inscrição Estadual", "SA1.A1_INSCR")
self:addProperty("A1_EST", "Estado", "string", "Estado", "SA1.A1_EST")
self:addProperty("A1_MUN", "Município", "string", "Município", "SA1.A1_MUN")
self:addProperty("A1_BAIRRO", "Bairro", "string", "Bairro", "SA1.A1_BAIRRO")
self:addProperty("A1_CEP", "CEP", "string", "CEP", "SA1.A1_CEP")
self:addProperty("A1_END", "Endereço", "string", "Endereço", "SA1.A1_END")
self:addProperty("A1_EMAIL", "E-mail", "string", "E-mail", "SA1.A1_EMAIL")
self:addProperty("A1_DDD", "DDD", "string", "DDD", "SA1.A1_DDD")
self:addProperty("A1_TEL", "Telefone", "string", "Telefone", "SA1.A1_TEL")
self:addProperty("C5_REDESP", "Redespacho", "string", "Código da Redespachadora", "SC5.C5_REDESP")
self:addProperty("C6_ITEM", "Item", "string", "Item do Pedido", "SC6.C6_ITEM")
self:addProperty("C6_PRODUTO", "Produto", "string", "Código do Produto", "SC6.C6_PRODUTO")
self:addProperty("C6_DESCRI", "Descrição Item", "string", "Descrição do Item", "SC6.C6_DESCRI")
self:addProperty("C6_ESTPAI", "Estrutura Pai", "string", "Estrutura Pai", "SC6.C6_ESTPAI")
self:addProperty("C6_ESTPAII", "Item Estrutura Pai", "string", "Item da Estrutura Pai", "SC6.C6_ESTPAII")
self:addProperty("C6_UM", "UM", "string", "Unidade de Medida", "SC6.C6_UM")
self:addProperty("B1_DESCOME", "Desc. Produto", "string", "Descrição Comercial do Produto", "SB1.B1_DESCOME")
self:addProperty("B1_LINKIMG", "Link da Imagem", "string", "Link da Imagem do Produto", "SB1.B1_LINKIMG")
self:addProperty("C5_CONDPAG", "Cond. Pagamento", "string", "Condição de Pagamento", "SC5.C5_CONDPAG")
self:addProperty("C5_FRETE", "Valor Frete", "number", "Valor do Frete", "SC5.C5_FRETE")
self:addProperty("C5_USUARIO", "Usuário", "string", "Usuário do Pedido", "SC5.C5_USUARIO")
self:addProperty("A3_NREDUZ", "Nome Vendedor", "string", "Nome Reduzido do Vendedor", "SA3.A3_NREDUZ")
self:addProperty("C6_TES", "TES", "string", "Tipo de Entrada e Saída", "SC6.C6_TES")
self:addProperty("C6_CF", "CF", "string", "Código Fiscal", "SC6.C6_CF")
self:addProperty("C6_QTDVEN", "Qtd. Venda", "number", "Quantidade Vendida", "SC6.C6_QTDVEN")
self:addProperty("C6_PRUNIT", "Preço Unitário", "number", "Preço Unitário", "SC6.C6_PRUNIT")
self:addProperty("C6_VALDESC", "Valor Desc. Item", "number", "Valor de Desconto do Item", "SC6.C6_VALDESC")
self:addProperty("C6_VALOR", "Valor Total Item", "number", "Valor Total do Item", "SC6.C6_VALOR")
self:addProperty("C6_IPI", "IPI", "number", "Aliquota IPI", "SC6.C6_IPI")
self:addProperty("C6_VALIPI", "Valor IPI", "number", "Valor do IPI", "SC6.C6_VALIPI")
self:addProperty("C6_PICM", "PIS", "number", "Aliquota ICMS", "SC6.C6_PICM")
self:addProperty("C6_VALICM", "Valor PIS", "number", "Valor do ICMS", "SC6.C6_VALICM")
self:addProperty("C6_PRCVEN", "Preço Venda", "number", "Preço de Venda", "SC6.C6_PRCVEN")
self:addProperty("C6_ENTREG", "Entrega", "date", "Data de Entrega", "SC6.C6_ENTREG")
self:addProperty("C6_ACRSFIN", "Acréscimo Financeiro Item", "number", "Acréscimo Financeiro do Item", "SC6.C6_ACRSFIN")
return self:oSchema
Grato