How to import records from an excel sheet with PRIMAVERA API

2

Good afternoon,

I would like a little information with the following scenario: I have an excel sheet with 65000 records to import into the Spring Accounting editor what I would like to know was the following: Using these spring motor methods

.bso.Contabilidade.Documentos.ValidaActualizacao(docCBL, strErro) - this method validates the rules for setting up accounting documents

.bso.Contabilidade.Documentos.Actualiza(docCBL) - this method writes information in Spring

My question is this: It is possible to import these records all and not have any performance problems using the method (bso.Contabilidade.Documentos.Actualiza (docCBL)) into the spring and the performance is managed by the spring engines from this method or we have to manage the number of records that will be imported in the spring?

    
asked by anonymous 04.05.2018 / 19:13

2 answers

2

Well the method of writing the bso.Contabilidade.Documentos.Actualiza(docCBL) document already validates the business rules. Since what you want to import in bulk is the 65,000 moves you will have to call atualiza sometimes necessary.

The API does not address performance issues. From my experience this type of operations should be done in dead periods to avoid overloading the system.

    
05.05.2018 / 23:47
1

Good morning,

However based on the last response I started to build the validation structure. The structure I started to build was the following. Based on this form the test I was doing was as follows:

Iwantedtorecordrow2androw3inadocumentandrow4androw5inanotherdocument,butIamnotabletodothisstructureanyonecanhelpme?ThecodeIstartedtodowasasfollows:    PrivateSubbtnProcessar_Click(senderAsSystem.Object,andAsSystem.EventArgs)HandlesbtnProcessar.Click        DimclsDocAsInterop.CblBE900.CblBEDocument        DimclsLinksAsInterop.CblBE900.CblBDocGeral        'DimclsLinhaCentroAsInterop.CblBE900.CblBelinhaDocCentros        'DimclsLinkerAsInterop.CblBE900.CblBelowDocFuncoes        'DimclsFlowTheCblBeClearDocContaFlowo

DimiAsLongDimsAnoAsInteger=0DimsPeriodoAsInteger=0DimsNumDocOrigAsString=String.EmptyDimNumDocOrigAnteriorAsString=String.EmptyDimsDataAsDate=NowDimsValorAsDouble=0DimsDescricaoAsString=String.EmptyDimsContaOrigAsString=String.EmptyDimsCentroCustoOrigAsString=String.EmptyDimsContaDestAsString=String.EmptyDimsCentroCustoDestAsString=String.EmptyDimsNaturezaAsString=String.EmptyDimstrDocAsString=txtDocumento.TextDimstrDiarioAsString=txtDiario.TextDimlngNumDiarioAsLong=0DimoAuxAsObjectDimintLoteAsIntegerDimcounterAsLongTrybso.IniciaTransaccao()i=0'Fori=0TogridMovimentos.RowCount-1DoWhilei<=i'AnosAno=gridMovimentos.Rows(i).Cells("colAno").Value

            'Periodo
            sPeriodo = gridMovimentos.Rows(i).Cells("colPeriodo").Value

            'NumeroDocumento
            sNumDocOrig = gridMovimentos.Rows(i).Cells("colDocNum").Value

            'DataDocumento
            sData = FormatDateTime(gridMovimentos.Rows(i).Cells("colDocData").Value, DateFormat.ShortDate)

            If NumDocOrigAnterior <> sNumDocOrig Then


                clsDoc = New Interop.CblBE900.CblBEDocumento
                clsDoc.EmModoEdicao = False

                With clsDoc
                    .DataDoc = sData
                    .Mes = sData.Month
                    .Dia = sData.Day
                    .Ano = sAno
                    .Modulo = "L"
                    .Doc = strDoc
                    If bso.Contexto.IFMesInicio <> 1 Then 
                        .Mes = sData.Month
                        oAux = bso.Consulta("select CASE WHEN Max(NumDiario) IS NULL THEN 0 ELSE Max(NumDiario) END AS TOT from movimentos with(nolock) where diario='" & strDiario & "' and mes=" & sPeriodo & "")

                        If oAux("TOT") = 0 Then
                            lngNumDiario = bso.Contabilidade.Diarios.GetNumDiarioActual(.Ano, .Diario, .Mes) + 1
                        Else
                            lngNumDiario = oAux("TOT") + 1
                        End If

                    Else
                        .Mes = sPeriodo
                        .NumDiario = bso.Contabilidade.Diarios.GetNumDiarioActual(.Ano, .Diario, .Mes) + 1
                    End If
                    .Diario = strDiario
                    .NumDiario = lngNumDiario
                    .NumDoc = .NumDiario
                    .Moeda = "EUR"
                    .NumeroDocExterno = sNumDocOrig
                    .Descricao = sDescricao
                    .TipoLancamento = "000"

                End With
            End If


            For counter = i To 2

                'Valor
                'sValor = Math.Abs(CDbl(gridMovimentos.Rows(i).Cells("colMontante").Value))

                'Natureza
                'If CDbl(gridMovimentos.Rows(i).Cells("colMontante").Value) >= 0 Then
                '    sNatureza = "D"
                'Else
                '    sNatureza = "C"
                'End If

                'Descricao
                sDescricao = gridMovimentos.Rows(counter).Cells("colDescricao").Value

                'Conta Origem
                sContaOrig = gridMovimentos.Rows(counter).Cells("colContaGL").Value
                sContaDest = DevolveContaDestino("S", gridMovimentos.Rows(counter).Cells("colContaGL").Value)

                'Centro Custo
                'If objWorkSheet.Cells(linhaExcel, colExcel.cCentroCustoOrigem).Text <> String.Empty Then
                '    sCentroCustoOrig = objWorkSheet.Cells(linhaExcel, colExcel.cCentroCustoOrigem).Text
                '    sCentroCustoDest = DevolveContaDestino("C", objWorkSheet.Cells(linhaExcel, colExcel.cCentroCustoOrigem).Text)
                'End If

                'If gridMovimentos.Rows(i).Cells("colCentroCusto").Value <> String.Empty Then
                '    sCentroCustoOrig = gridMovimentos.Rows(i).Cells("colCentroCusto").Value
                '    sCentroCustoDest = DevolveContaDestino("C", gridMovimentos.Rows(i).Cells("colCentroCusto").Value)
                'End If


                intLote = 1
                clsLinha = New Interop.CblBE900.CblBELinhaDocGeral
                clsLinha.Conta = sContaDest
                clsLinha.Descricao = sDescricao
                clsLinha.Moeda = clsDoc.Moeda
                If CDbl(gridMovimentos.Rows(counter).Cells("colMontante").Value) > 0 Then
                    clsLinha.Natureza = "D"
                    clsLinha.ValorOrigem = Math.Abs(CDbl(gridMovimentos.Rows(counter).Cells("colMontante").Value))
                    clsLinha.ValorAlt = Math.Abs(CDbl(gridMovimentos.Rows(counter).Cells("colMontante").Value))
                    clsLinha.Valor = Math.Abs(CDbl(gridMovimentos.Rows(counter).Cells("colMontante").Value))
                Else
                    clsLinha.Natureza = "C"
                    clsLinha.ValorOrigem = Math.Abs(CDbl(gridMovimentos.Rows(counter).Cells("colMontante").Value))
                    clsLinha.ValorAlt = Math.Abs(CDbl(gridMovimentos.Rows(counter).Cells("colMontante").Value))
                    clsLinha.Valor = Math.Abs(CDbl(gridMovimentos.Rows(counter).Cells("colMontante").Value))
                End If
                clsLinha.TipoLinha = "F"
                clsLinha.Cambio = 1
                clsLinha.CambioMAlt = 1
                clsLinha.CambioOrigem = 1
                clsLinha.Lote = intLote

                clsDoc.LinhasGeral.Insere(clsLinha)
                clsLinha = Nothing
                intLote = intLote + 1

                If counter >= 1 Then
                    Exit For
                End If

            Next counter

            If clsDoc.LinhasGeral.NumItens > 0 Then
                bso.Contabilidade.Documentos.Actualiza(clsDoc)
            End If


            'NumDocOrigAnterior = sNumDocOrig

            i = counter + 1
            'Next i
        Loop


        'bso.Contabilidade.Documentos.Actualiza(clsDoc)

        bso.TerminaTransaccao()

        MsgBox("Importação efetuada com sucesso.", vbInformation)




    Catch ex As Exception
        MsgBox(ex.Message, vbInformation)
    End Try

End Sub

Someone can help me, I can not finish this cycle.

    
07.05.2018 / 10:56