___ ___ erkimt error in the data change in the existing document header ______ qstntxt ___

Good morning.

I have a function in VB to edit purchase documents.

Everything goes well but if you call %code% the header variables are changed, but when calling %code% always gives an error:

  

8169: Conversion failed when converting from a character string to   uniqueidentifier.

It gives the idea that the doccompra gets lost after %code% .

Thank you for your help

%pre%     
______ azszpr332118 ___

When calling the %code% method with the second parameter equal to 5, it means that we will change the data related to %code% , %code% , %code% , etc. When you change data related to %code% , the %code% method will change the %code% by suggesting the next number in the series. To work around the problem, you can re-assign the %code% after calling the %code% method.

Code:

%pre%

Another solution would be to call the %code% method with the second parameter equal to 2, so it only changes the entity's related data.

Code:

%pre%     
______ azszpr332130 ___

John

In the code you are running there are some improvements you can make, for example, as the property %code% is controlled by PRIMAVERA you do not have to do anything about it. The type of entity also does not have to be indicating, and by utlimo as Flavio Jardim said is to use parameter 2 because in reality it is only changing the entity and only this is that it has impact on other properties of the document. > %pre%

More information about the codes of this method.

%pre%     
___

1

Good morning.

I have a function in VB to edit purchase documents.

Everything goes well but if you call motor.Comercial.Compras.PreencheDadosRelacionados(doccompra) the header variables are changed, but when calling motor.Comercial.Compras.Actualiza(doccompra) always gives an error:

  

8169: Conversion failed when converting from a character string to   uniqueidentifier.

It gives the idea that the doccompra gets lost after PreencheDadosRelacionados .

Thank you for your help

docCompra = motor.Comercial.Compras.EditaID(iddoc)
docCompra.EmModoEdicao = True
docCompra.Entidade = Entidade
docCompra.NumDocExterno = vreferencia
docCompra.DataDoc = datadoc
docCompra.DataIntroducao = datadoc
docCompra.TipoEntidade = "F"
motor.Comercial.Compras.PreencheDadosRelacionados(docCompra, 5)
motor.Comercial.Compras.Actualiza(docCompra)
    
asked by anonymous 25.09.2018 / 13:41

2 answers

2

When calling the PreencheDadosRelacionados method with the second parameter equal to 5, it means that we will change the data related to TipoDoc , Moeda , Entidade , etc. When you change data related to TipoDOC , the PreencheDadosRelacionados method will change the NumDoc by suggesting the next number in the series. To work around the problem, you can re-assign the Numdoc after calling the PreencheDadosRelacionados method.

Code:

Dim numDoc As New Long
docCompra = motor.Comercial.Compras.EditaID(iddoc)
docCompra.EmModoEdicao = True
docCompra.Entidade = Entidade
docCompra.NumDocExterno = vreferencia
docCompra.DataDoc = datadoc
docCompra.DataIntroducao = datadoc
docCompra.TipoEntidade = "F"
num = docCompra.numDoc
motor.Comercial.Compras.PreencheDadosRelacionados(docCompra, 5)
docCompra.NumDoc = numDoc
motor.Comercial.Compras.Actualiza(docCompra)

Another solution would be to call the PreencheDadosRelacionados method with the second parameter equal to 2, so it only changes the entity's related data.

Code:

docCompra = motor.Comercial.Compras.EditaID(iddoc)
docCompra.EmModoEdicao = True
docCompra.Entidade = Entidade
docCompra.NumDocExterno = vreferencia
docCompra.DataDoc = datadoc
docCompra.DataIntroducao = datadoc
docCompra.TipoEntidade = "F"
motor.Comercial.Compras.PreencheDadosRelacionados(docCompra, 2)
motor.Comercial.Compras.Actualiza(docCompra)
    
25.09.2018 / 18:18
2

John

In the code you are running there are some improvements you can make, for example, as the property EmModoEdicao is controlled by PRIMAVERA you do not have to do anything about it. The type of entity also does not have to be indicating, and by utlimo as Flavio Jardim said is to use parameter 2 because in reality it is only changing the entity and only this is that it has impact on other properties of the document. >

Set docCompra = BSO.Comercial.Compras.EditaID("id")
docCompra.Entidade = "F0001"
docCompra.NumDocExterno = "qwq"
docCompra.DataDoc = "03/01/2018"
docCompra.DataIntroducao = "03/01/2018"
BSO.Comercial.Compras.PreencheDadosRelacionados docCompra, 2
BSO.Comercial.Compras.Actualiza docCompra

More information about the codes of this method.

/// <summary>
/// Tipo enumerado com as opções de preenchimento dos dados relativos ao cabeçalho do documento
/// </summary>
public enum PreencheRelacaoCompras
{
    /// <summary>Preenche o documento com os dados associados ao tipo do documento, ou seja, a data do documento e o número.</summary>
    compDadosTipoDoc = 1,
    /// <summary>Preenche o documento com todo os dados associados ao cliente.</summary>
    compDadosCliente = 2,
    /// <summary>Preenche o documento com os dados associados à moeda, ou seja, o câmbio da moeda.</summary>
    compDadosMoeda = 3,
    /// <summary>Preenche o documento com os dados associados à condição de pagamento, ou seja, a data de vencimento e o desconto financeiro.</summary>
    compDadosCondPag = 4,
    /// <summary>Preenche o documento com os dados associados a todo o cabeçalho do documento</summary>
    compDadosTodos = 5,
    compDadosPrestacao = 6,
    /// <summary>Preenche o documento com os dados associados ao contrato.</summary>
    compDadosContrato = 7
}
    
25.09.2018 / 18:40