Error making inventory hit by VBA

3

I want to launch VBA inventories, but I'm not getting the system to automatically launch hit moves. That is, you create the stock input / output documents as you do when you close the inventory in ERP. Is this function / method not public? Is there any way I can get what I need without having to check the inventory line and make the release of the correct documents?

Now, another curiosity: when I prepare the inventory in ERP I have an "update" button that fills me the preparation lines with the current warehouse stock - I have some way to call this button by VBA?

Follow my code below.

Thank you in advance.

'Public Sub PrepInv()
Dim PrepInv As GcpBEInventario
Set PrepInv = New GcpBEInventario

Dim LinhasInv As GcpBELinhaInventario
Set LinhasInv = New GcpBELinhaInventario

With PrepInv
.Armazem = "1"
.Data = Now()
.DataLancamento = Now()
.EmModoEdicao = True
.EstadoInventario = False
.Id = PSO.FuncoesGlobais.CriaGuid(True)
.UsaDataLancamento = True
'.TipoDocEntrada = "AIP"
'.SerieDocEntrada = "2018"
'.TipoDocSaida = "AIN"
'.SerieDocSaida = "2018"
End With

Dim RefArtigo As String
RefArtigo = "0195"

With LinhasInv
.artigo = RefArtigo
.DataUltimaContagem = Now()
.EmModoEdicao = True
.Id = PSO.FuncoesGlobais.CriaGuid(True)
.IDCabecInventario = PrepInv.Id
.NumLinha = 1
.PCMedio = BSO.Comercial.Artigos.DaValorAtributo(RefArtigo, "PCMedio")
.QtdContagem = 50
.QtdPreparacao = 1
'.TipoLinha = Null   ' ou L para lotes
.UnidadeBase = BSO.Comercial.Artigos.DaValorAtributo(RefArtigo, "UnidadeBase")
.itemContado = True

End With

PrepInv.LinhasInventarios.Insere LinhasInv
BSO.Comercial.Inventarios.Actualiza PrepInv

MsgBox PrepInv.Id


End Sub
    
asked by anonymous 16.07.2018 / 10:25

1 answer

4

Hit moves are calculated at the end of the inventory count by the interface itself, there is no method in the engine as it would be desirable. This situation is already completely different in v10 where everything is treated at the level of the engines.

In the same way, in the preparation, grid loading is also only treated at the screen level, there is also no method that returns a list of the articles to load into the grid.

    
16.07.2018 / 18:00