Páginas filhas
  • Travel Request - Financial - P12

Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

Also, you can select which participants will receive an advance in the Advances tab.
The calculated value is a forecast and is displayed only when it is parameterized:

03. AUTOMATIC ROUTINE

For the execution of the automatic routine, we illustrated some features such as Inclusion (MyFA666Inc), Edition (MyFA666Alt) and Exclusion (MyFA666Del), in the following examples:

Bloco de código
languagejava
themeMidnight
titleExample of automatic routine execution
collapsetrue
#INCLUDE "PROTHEUS.CH"
#INCLUDE "FWMVCDEF.CH"

//---------- Add travel request ----------//
User Function MyFA666Inc()

Local oModel := Nil
Local oModelFW3 := Nil
Local oModelFW4 := Nil
Local oModelFW5 := Nil
Local oModelFW6 := Nil
Local cFilAtu := ""

RpcSetEnv("T1","D MG 01 ","claudio.ribeiro","1") // Starts environment with requesting user

oModel := FWLoadModel("FINA666")
oModelFW3 := oModel:GetModel("FW3MASTER") // 
Travel header
oModelFW4 := oModel:GetModel("FW4DETAIL") // Services 
oModelFW5 := oModel:GetModel("FW5DETAIL") // Participants
oModelFW6 := oModel:GetModel("FW6DETAIL") // Cost center
cFilAtu := xFilial("FW3")

oModel:SetOperation(MODEL_OPERATION_INSERT)
oModel:Activate()
// Fill in the travel request header
oModelFW3:SetValue("FW3_FILIAL",cFilAtu)
oModelFW3:SetValue("FW3_NACION","1")
oModelFW3:SetValue("FW3_CODORI","SP")
oModelFW3:SetValue("FW3_CODDES","RJ")
oModelFW3:SetValue("FW3_DTINI",StoD("20190702"))
oModelFW3:SetValue("FW3_DTFIM",StoD("20190705"))
oModelFW3:SetValue("FW3_CLIENT","001 ")
oModelFW3:SetValue("FW3_LOJA","01")
oModelFW3:SetValue("FW3_STATUS","0") // Open, initial status
// Fill in the service grid included in the travel request
oModelFW4:SetValue("FW4_ITEM",StrZero(1,TamSX3("FW4_ITEM")[1]))
oModelFW4:SetValue("FW4_TIPO","1") // Aereo
oModelFW4:SetValue("FW4_OBS", “Customer visit")
// Fills grid of traveling participants
oModelFW5:SetValue("FW5_ITEM",StrZero(1,TamSX3("FW4_ITEM")[1]))
oModelFW5:SetValue("FW5_PARTIC","000001")
oModelFW5:SetValue("FW5_ADIANT",.T.) // Add advance to participant
oModelFW5:AddLine() // Add line for a second traveler
oModelFW5:SetValue("FW5_ITEM",StrZero(2,TamSX3("FW4_ITEM")[1]))
oModelFW5:SetValue("FW5_PARTIC","000002")
oModelFW5:SetValue("FW5_ADIANT",.T.) // Add advance to participant
// Fill in cost center grid
oModelFW6:SetValue("FW6_ITEM",StrZero(1,TamSX3("FW4_ITEM")[1]))
oModelFW6:SetValue("FW6_CC","002 ")
oModelFW6:SetValue("FW6_PORCEN",100)
oModelFW5:GoLine(1)
// Validation and recording of data, if consistent
If oModel:VldData() 
     oModel:CommitData()
     Conout("Travel request included successfully.")
Else 
     VarInfo("",oModel:GetErrorMessage())
     Conout("Validation error, travel request not included.")
EndIf

oModel:DeActivate()
oModel:Destroy()
RpcClearEnv()

Return


//---------- Travel Request change ----------//
User Function MyFA666Alt()

Local aKeyFW4 := {}
Local oModel := Nil
Local oModelFW5 := Nil
Local oModelFW6 := Nil
Local cSolic := "0000000010"

RpcSetEnv("T1","D MG 01 ","richard.santos","1") // Initialize environment with requesting user

dbSelectArea("FW3")
dbSetOrder(1)
dbSeek(xFilial("FW3")+cSolic)
// Load data model with travel request positioned
oModel := FWLoadModel("FINA666")
oModelFW5 := oModel:GetModel("FW5DETAIL") // Participants
oModelFW6 := oModel:GetModel("FW6DETAIL") // Cost center
// Participant search key within the travel request
aKeyFW4 := { {"FW5_FILIAL",xFilial("FW5")},{"FW5_SOLICI",cSolic},{"FW5_ITEM","01"},{"FW5_PARTIC","000002"} }

oModel:SetOperation(MODEL_OPERATION_UPDATE)
oModel:Activate()
// Remove one of the travelers, in this case, participant 000002
If oModelFW5:SeekLine(aKeyFLE)
     oModelFW5:DeleteLine()
Else
     Conout("Traveler not found in this travel request.")
EndIf
// Change the cost center (automatically positioned on the first grid)
oModelFW6:SetValue("FW6_CC","003 ")

// Validation and recording of data, if consistent
If oModel:VldData() 
     oModel:CommitData()
     Conout("Travel request edited successfully.")
Else 
     VarInfo("",oModel:GetErrorMessage())
     Conout("Validation error, travel request not edited.")
EndIf

oModel:DeActivate()
oModel:Destroy()
RpcClearEnv()

Return


//---------- Delete travel request ----------//
User Function MyFA666Del()

Local oModel := Nil
Local cSolic := "0000000010"

RpcSetEnv("T1","D MG 01 ","claudio.ribeiro","1") // Starts environment with requesting user

dbSelectArea("FW3")
dbSetOrder(1)
dbSeek(xFilial("FW3")+cSolic)
// Load data model with travel request positioned
oModel:= FWLoadModel("FINA666")
oModel:SetOperation(MODEL_OPERATION_DELETE)
oModel:Activate()

// Validating and saving deletion
If oModel:VldData() 
     oModel:CommitData()
     Conout("Travel request deleted successfully.")
Else 
     VarInfo("",oModel:GetErrorMessage())
     Conout("Validation error, travel request not deleted.")
EndIf

oModel:DeActivate()
oModel:Destroy()
RpcClearEnv()

Return


...

04. TABLES USED

  • FW3 - Request Header
  • FW4 - Services (items)
  • FW5 - Employees
  • FW6 - Cost Entities


HTML
<!-- esconder o menu --> 


<style>
div.theme-default .ia-splitter #main {
    margin-left: 0px;
}
.ia-fixed-sidebar, .ia-splitter-left {
    display: none;
}
#main {
    padding-left: 10px;
    padding-right: 10px;
    overflow-x: hidden;
}

.aui-header-primary .aui-nav,  .aui-page-panel {
    margin-left: 0px !important;
}
.aui-header-primary .aui-nav {
    margin-left: 0px !important;
}
</style>