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