Tenho o código abaixo e preciso incluir uma Pesquisa pra o Campo ZB1_CODPRO, alguem saber colocar ele no código.
//Bibliotecas
Include "Totvs.ch"
Include "FWMVCDef.ch"
//Variveis Estaticas Static cTitulo := "Cadastro de Imagens " Static cCamposChv := "ZB1_CODPRO;" Static cTabPai := "ZB1"
//{Protheus.doc} User Function zCadImg Cadastro de Imagens //
User Function zCadImg() Local aArea := FWGetArea() Local oBrowse Private aRotina := {}
//Definicao do menu aRotina := MenuDef()
//Instanciando o browse oBrowse := FWMBrowse():New() oBrowse:SetAlias(cTabPai) oBrowse:SetDescription(cTitulo)
//Ativa a Browse oBrowse:Activate()
FWRestArea(aArea) Return Nil
//{Protheus.doc} MenuDef Menu de opcoes na funcao zCadImg //
Static Function MenuDef() Local aRotina := {}
//Adicionando opcoes do menu ADD OPTION aRotina TITLE "Visualizar" ACTION "VIEWDEF.zCadImg" OPERATION 1 ACCESS 0 ADD OPTION aRotina TITLE "Incluir" ACTION "VIEWDEF.zCadImg" OPERATION 3 ACCESS 0 ADD OPTION aRotina TITLE "Alterar" ACTION "VIEWDEF.zCadImg" OPERATION 4 ACCESS 0 ADD OPTION aRotina TITLE "Excluir" ACTION "VIEWDEF.zCadImg" OPERATION 5 ACCESS 0 ADD OPTION aRotina TITLE "Copiar" ACTION "VIEWDEF.zCadImg" OPERATION 9 ACCESS 0
Return aRotina
//{Protheus.doc} ModelDef Modelo de dados na funcao zCadImg //
Static Function ModelDef() Local oStruPai := FWFormStruct(1, cTabPai, {|cCampo| Alltrim(cCampo) $ cCamposChv}) Local oStruFilho := FWFormStruct(1, cTabPai) Local aRelation := {} Local oModel Local bPre := Nil Local bPos := Nil Local bCancel := Nil
//Cria o modelo de dados para cadastro oModel := MPFormModel():New("zCadImgM", bPre, bPos, /bCommit/, bCancel) oModel:AddFields("ZB1MASTER", /cOwner/, oStruPai) oModel:AddGrid("ZB1DETAIL","ZB1MASTER",oStruFilho,/bLinePre/, /bLinePost/,/bPre - Grid Inteiro/,/bPos - Grid Inteiro/,/bLoad - Carga do modelo manualmente/) oModel:SetDescription("Modelo de dados - " + cTitulo) oModel:GetModel("ZB1MASTER"):SetDescription( "Dados de - " + cTitulo) oModel:GetModel("ZB1DETAIL"):SetDescription( "Grid de - " + cTitulo) oModel:SetPrimaryKey({})
//Fazendo o relacionamento aAdd(aRelation, {"ZB1_FILIAL", "FWxFilial('ZB1')"} ) aAdd(aRelation, {"ZB1_CODPRO", "ZB1_CODPRO"}) oModel:SetRelation("ZB1DETAIL", aRelation, ZB1->(IndexKey(1)))
//Definindo campos unicos da linha oModel:GetModel("ZB1DETAIL"):SetUniqueLine({'ZB1_URL'})
Return oModel
//{Protheus.doc} ViewDef Visualizacao de dados na funcao zCadImg //
Static Function ViewDef() Local oModel := FWLoadModel("zCadImg") Local oStruPai := FWFormStruct(2, cTabPai, {|cCampo| Alltrim(cCampo) $ cCamposChv}) Local oStruFilho := FWFormStruct(2, cTabPai, {|cCampo| ! Alltrim(cCampo) $ cCamposChv}) Local oView
//Cria a visualizacao do cadastro oView := FWFormView():New() oView:SetModel(oModel) oView:AddField("VIEW_ZB1", oStruPai, "ZB1MASTER") oView:AddGrid("GRID_ZB1", oStruFilho, "ZB1DETAIL")
//Partes da tela oView:CreateHorizontalBox("CABEC", 30) oView:CreateHorizontalBox("GRID", 70) oView:SetOwnerView("VIEW_ZB1", "CABEC") oView:SetOwnerView("GRID_ZB1", "GRID")
//Titulos oView:EnableTitleView("VIEW_ZB1", "Cabecalho - ZB1") oView:EnableTitleView("GRID_ZB1", "Grid - ZB1")
//Adicionando campo incremental na grid oView:AddIncrementField("GRID_ZB1", "ZB1_SEQ")
Return oView