Automatic completion of contract data on the ERP employee sheet PRIMAVERA in vba @PRIMAVERA

3

I have changed an employee code so that it has a different contract. I opened the spring on the sheet of that changed employee. I went to the Contracts tab. The contract code was the one that had been updated. But the lines do not appear on the Grid. You should see the lines in the Renewables table associated with the updated agreement.

If you change the code directly in the ERP, the lines of the Renewables table already appear.

Will it be a BUG? Or am I missing something in the employee's file?

To simulate the problem - >

Private Sub MetodoStackOverFlow()

    Dim func As New RhpBEFuncionario
    Dim funcionario As String = "001"
    Dim contrato As String = "003"

    Try
        func = BSO.RecursosHumanos.Funcionarios.Edita(funcionario)
        func.Contrato = contrato

        BSO.RecursosHumanos.Funcionarios.Actualiza(func)
    Catch ex As Exception
        MsgBox(ex.Message, vbCritical, "ERRO")
    End Try

End Sub
    
asked by anonymous 21.05.2018 / 18:17

2 answers

3

By changing the contract type in the listing, the application reloads the contract and its renewal plans.

This information comes from the "BusinessObjects" and "ContractObjects" tables, you can get the information directly from SQL and then populate the grid.

If you wish, you can run through the engines using the "RhpBEContrato Trabalho" object by editing the Renewal Plans using the following code:

Dim objCont     As RhpBEContratoTrabalho
Dim i           As Integer


Set objCont = BSO.RecursosHumanos.ContratosTrabalho.Edita(CmbContrato.Text)


 For i = 1 To objCont.PlanoRenovCont.NumItens

        With GrelhaPlano

            GrelhaPlano.Col = 2
            GrelhaPlano.Row = i
            GrelhaPlano.TypeComboBoxList = m_strListaTiposVinculo
            GrelhaPlano.TypeComboBoxCurSel = findIndexTContrato(objCont.PlanoRenovCont(i).TipoContrato)

            GrelhaPlano.Col = 3
            GrelhaPlano.Row = i

            GrelhaPlano.TypeComboBoxCurSel = findIndexSituacao(objCont.PlanoRenovCont(i).Situacao)

            .SetText 4, i, objCont.PlanoRenovCont.Edita(i).Duracao
            .SetText 5, i, objCont.PlanoRenovCont.Edita(i).AvisoCadFunc
            .SetText 6, i, objCont.PlanoRenovCont.Edita(i).AvisoCadEmp
            .SetText 7, i, objCont.PlanoRenovCont.Edita(i).AvisoIntFunc
            .SetText 8, i, objCont.PlanoRenovCont.Edita(i).AvisoIntEmp
            .SetText 9, i, objCont.PlanoRenovCont.Edita(i).CompensCaducidade


            VerificaContrato (i)
        End With
    Next

The employee object does not contain an object with the plans information, the employees table stores the value of the work contract in the "Contract" field.

This field is later used to fill the grid as follows:

  • Relate item checks which contract is in the "Contract" field of the "Employees" table.
  • Relate item loads object from work contract "RhpBConnect Work".
  • Relate the item fills the grid with the information found in this work contract.
  • (Code sent in response)

    After updating the new work contract, the grid is loaded with the information in the table "NetResetFun". This data can be loaded with the following code:

            objPlanoRenovFunc As RhpBEPlanoRenovFunc
    
            Set mPlanoRenovFunc = BSO.RecursosHumanos.PlanoRenovFunc.ListaPlanoFuncionario(sChave)
    
                For i = 1 To objPlanoRenovFunc.NumItens
    
                //Preenche grelha com a informação do plano de renovações
    
                With objPlanoRenovFunc.Edita(i)
    
                    GrelhaPlano.Col = 2
                    GrelhaPlano.Row = i
                    Grelha.TypeComboBoxCurSel = .TipoContrato
    
                GrelhaPlano.Col = 3
                GrelhaPlano.Row = i
                GrelhaPlano.TypeComboBoxCurSel = .Situacao
                GrelhaPlano.SetText 4, i, .Duracao
                GrelhaPlano.SetText 5, i, .AvisoCadFunc
                GrelhaPlano.SetText 6, i, .AvisoCadEmp
                GrelhaPlano.SetText 7, i, .AvisoIntFunc
                GrelhaPlano.SetText 8, i, .AvisoIntEmp
                GrelhaPlano.SetText 9, i, .CompensCaducidade
                GrelhaPlano.SetText 10, i, DevolvePeriodoExtenso(.CompensCaducidadePeriodo)
                GrelhaPlano.SetText 11, i, .DataNovoRegime
            End With
        Next
    
        
    21.05.2018 / 19:27
    0

    Good morning,

    Follow the finished code of what I intended. This Code is generic. Anyone using VB.NET will be able to use it.

    The only input parameter is the employee's object.

    ->

    Private Sub UpdateContract (ByRef ObjFunctional As RhpBFunctional)

        Dim objPlanoRenovacaoFuncionario As New RhpBEPlanoRenovFunc
        Dim objLinhaRenovacaoFuncionario As RhpBELinhaRenovacaoF
        Dim objContratoTrabalho As RhpBEContratoTrabalho
        Dim i As Short = 0
    
        Try
    
            BSO.RecursosHumanos.PlanoRenovFunc.RemovePlanosFuncionario(ObjFuncionario.Funcionario)
    
            objContratoTrabalho = BSO.RecursosHumanos.ContratosTrabalho.Edita(ObjFuncionario.Contrato)
    
            For i = 1 To objContratoTrabalho.PlanoRenovCont.NumItens
    
                objLinhaRenovacaoFuncionario = New RhpBELinhaRenovacaoF
    
                With objLinhaRenovacaoFuncionario
                    .AvisoCadEmp = objContratoTrabalho.PlanoRenovCont(i).AvisoCadEmp
                    .AvisoCadFunc = objContratoTrabalho.PlanoRenovCont(i).AvisoCadFunc
                    .AvisoIntEmp = objContratoTrabalho.PlanoRenovCont(i).AvisoIntEmp
                    .AvisoIntFunc = objContratoTrabalho.PlanoRenovCont(i).AvisoIntFunc
                    .CompensCaducidade = objContratoTrabalho.PlanoRenovCont(i).CompensCaducidade
                    .Duracao = objContratoTrabalho.PlanoRenovCont(i).Duracao
                    .Funcionario = ObjFuncionario.Funcionario
                    .IDLinha = objContratoTrabalho.PlanoRenovCont(i).IDLinha
                    .Situacao = objContratoTrabalho.PlanoRenovCont(i).Situacao
                    .TipoContrato = objContratoTrabalho.PlanoRenovCont(i).TipoContrato.ToString
                    .CompensCaducidadePeriodo = objContratoTrabalho.PlanoRenovCont(i).CompensCaducidadePeriodo.ToString
                End With
    
                BSO.RecursosHumanos.PlanoRenovFunc.Actualiza(objLinhaRenovacaoFuncionario)
    
            Next
    
        Catch ex As Exception
            Throw ex
        End Try
    
    End Sub
    
        
    07.06.2018 / 14:03