CONTENT
CONTEÚDO
- Visão Geral
- Exemplo de utilização
- Tabelas utilizadas
01.
...
Em alguns cenários específicos o sistema necessita que os campos FILORIG estejam preenchidos e existe a possibilidade desses campos estarem vazios em virtude do registro ser mais antigo que a criação da coluna.
...
OVERVIEW
In some specific scenarios, the fields FILORIG must be completed. These fields must be blank as the record is older than the creation of this column.
...
This rdmake records the field E5_FILORIG according to the bill origin branch (E1_FILORIG or E2_FILORIG), filtering the transactions whose record has the E5_TIPODOC equal to
'VL', 'VM','BA','CP','LJ','V2'
...
or E5_TIPODOC = 'ES'.
Somente serão afetados os registros em que o campo E5_FILORIG não possui gravação.
...
Only the records in which this field E5_FILORIG is affected are not saved.
If the posting payment has records in the tables FK1, FK2 e FK5, the fields FK1_FILORI, FK2_FILORI
...
and FK5_FILORI
...
will also have the records adjusted.
02.
...
EXAMPLE OF USE
Card documentos |
---|
Informacao | O Rdmake foi desenvolvido através do que foi especificado na "Visão geral", sendo disponibilizada a correção somente para este cenário. Caso seja encontrado outros cenários a função de usuário está disponível nesta documentação para personalização. |
---|
Titulo | IMPORTANTE! |
---|
|
Como utilizar:
...
The Rdmake was developed through what was specified in the “Overview”, and the adjustment is available only for this scenario. If you find other scenarios, the user function is available in this document for customization. | Titulo | IMPORTANT! |
---|
|
How to use:
We suggest to execute in the staging environment first, and then after validation, in the production environment.
1 - Realize um backup da base de dadosBackup of the database;
2 - Copiar o exemplo do rdmake abaixo e compilar no ambiente a ser processadoCopy the rdmake example below and compile it in the environment to be processed;
3 - No programa inicial no In the initial program, in the SmartClient, preencha enter "U_FIXE5FORIG" e clique em then click "OK";
4 - Clicar em Click "FinalizarFinalize";
5 - Na mensagem para confirmação da rotina, clicar em "SimIn the message to confirm the routine, click "Yes";
6 - Após a execução, será exibida a mensagem de PROCESSAMENTO FINALIZADO. Clicar em After execution, the message PROCESSING FINALIZED is displayed. Click OK;
7 - Se clicar em "Não", a rotina não será processada e será exibida a mensagem de PROCESSAMENTO CANCELADO;
...
If you click "No", the routine is not processed and the message PROCESSING CANCELED displayed;
Only re records with E5_TIPODOC equal to 'VL', 'VM','BA','CP','LJ','V2''
...
or E5_TIPODOC = 'ES’ will be updated.
For the records with ES'.Para os registros que possuam o E5_MOVFKS = 'S', os campos the fields FK1_FILORI, FK2_FILORI e and FK5_FILORI serão preenchidos com o conteúdo dos camposare completed with the content of the fields E1_FILORIG/E2_FILORIG.
RDKAME
Bloco de código |
---|
language | js |
---|
theme | Midnight |
---|
firstline | 001 |
---|
linenumbers | true |
---|
| ##INCLUDE "PROTHEUS.CH"
#INCLUDE "APWIZARD.CH"
Static __oQrySE5 := NIL
//-------------------------------------------------------------------------------
/*/{Protheus.doc} FIXE5FORIG
FIX parato gravarsave othe E5_FILORIG, FK1_FILORI, FK2_FILORI eand FK5_FILORI,
combased on basethe nocontent conteudoof dosthe camposfields E1_FILORIG/E2_FILORIG doof the títulobill.
@return nil
@author totvs
@since 10/12/2020
@version P12
/*/
//-------------------------------------------------------------------------------
User Function FIXE5FORIG()
Private oWizard
Private lOk := .T.
oWizard := APWizard():New( "AssistenteWizard parato Ajusteadjust de base." ,"Atenção “Attention!"” ,;
"",;
"EsteThis assistentewizard temaims como finalidade acertar o campoat adjusting FILORIG daof the tabelatable SE5 (nãonot preenchidoscompleted) ";
+CHR(10)+CHR(13)+"comwith the ocontent conteúdoof dothe campofield E1_FILORIG/E2_FILORIG.";
+CHR(10)+CHR(13)+"- You can Somenteonly rodarrun estethis ajusteadjustment emin modoexclusive exclusivomode!";
+CHR(10)+CHR(13)+"- RealizarExecute the backup doof bancodatabase de dados antes da atualizaçãobefore updating.";
+CHR(10)+CHR(13)+"- Rodar a atualização primeiramente em base de homologaçãoFirst run the updating in the staging base.",;
{|| .T.}, {|| ProcessaProcess({|lEnd| lOk := FinExecFix(),Iif(lOk,MSGINFO("PROCESSAMENTO FINALIZADO !!","PROCESSO"),MSGINFO("PROCESSAMENTO CANCELADO !!","PROCESSO")) }),.T.},,,,,)
ACTIVATE WIZARD oWizard CENTERED WHEN {||.T.}
Return
//-------------------------------------------------------------------------------
/*/{Protheus.doc} FinExecFix
Grava campoIt saves the field E5_FILORIG emin brancoblank parafor osthe registrosrecords baixadosdownloaded.
@return lRet, LógicoLogic indicadoindicated sein acase query foiwas executadaproperly corretamenteexecuted
@author totvs
@since 10/12/2020
@version P12
/*/
//-------------------------------------------------------------------------------
Static Function FinExecFix()
Local aArea As Array
Local cEmpUlt As Character
Local lRet As Logical
Local aRetSM0
Local nInc As Numeric
aArea:= GetArea()
lRet := .F.
If MsgYesNo("ADatabase baseis deedited dadosafter seráthis alteradaconfirmation! apósDo estayou confirmação!really Temwant certezato que deseja atualizá-laupdate it?")
lRet := .T.
cEmpUlt := ""
OpenSM0()
SM0->(dbGotop())
aRetSM0 := FWLoadSM0()
For nInc := 1 To Len( aRetSM0 )
If aRetSM0[nInc][1] <> cEmpUlt
RpcSetType(3)
RpcSetEnv( aRetSM0[nInc][1], aRetSM0[nInc][2] )
FnE5Filori()
RpcClearEnv()
If __oQrySE5 <> NIL
__oQrySE5:Destroy()
EndIf
__oQrySE5 := NIL
Endif
cEmpUlt := aRetSM0[nInc][1]
Next
Endif
RestArea(aArea)
Return(lRet)
//-------------------------------------------------------------------------------
// FK5BUSCA
//FunçãoFunction parato localizarfind FK5 a partir do movimentofrom transaction SE5
//-------------------------------------------------------------------------
Static Function FK5BUSCA(cChave, lEstorno)
Local uRet := ""
Local cQuery := ""
Default cChave := ''
Default lEstorno := .F.
cQuery := "SELECT FK5.FK5_IDMOV URET"
cQuery += "FROM "+RetSqlName("SE5")+" SE5 "
cQuery += "INNER JOIN "+RetSqlName("FKA")+" FKA1 ON FKA1.FKA_FILIAL = SE5.E5_FILIAL AND FKA1.FKA_IDORIG = SE5.E5_IDORIG "
cQuery += " LEFT JOIN "+RetSqlName("FKA")+" FKA2 ON FKA2.FKA_FILIAL = FKA1.FKA_FILIAL AND FKA2.FKA_IDPROC = FKA1.FKA_IDPROC "
cQuery += "INNER JOIN "+RetSqlName("FK5")+" FK5 ON FK5.FK5_FILIAL = FKA2.FKA_FILIAL AND FKA2.FKA_TABORI = 'FK5' AND FK5.FK5_IDMOV = FKA2.FKA_IDORIG "
If lEstorno
cQuery += "AND FK5.FK5_TPDOC = 'ES' "
Else
cQuery += "AND FK5.FK5_TPDOC <> 'ES' "
EndIf
cQuery += "WHERE "
cQuery += "SE5.E5_FILIAL || SE5.E5_PREFIXO || SE5.E5_NUMERO || SE5.E5_PARCELA || SE5.E5_TIPO || SE5.E5_CLIFOR || SE5.E5_LOJA || SE5.E5_SEQ = '" + cChave + "'"
If lEstorno
cQuery += "AND SE5.E5_TIPODOC = 'ES' "
Else
cQuery += "AND FK5.FK5_TPDOC <> 'ES' "
EndIf
cQuery += "AND SE5.D_E_L_E_T_ = ' '"
cQuery := ChangeQuery(cQuery)
uRet := MpSysExecScalar(cQuery,"URET")
Return uRet
//-------------------------------------------------------------------------------
//FnE5Filori
//Grava campoIt saves the field E5_FILORIG emin brancoblank parafor osthe registrosrecords baixadosdownloaded.
//-------------------------------------------------------------------------------
Static Function FnE5Filori() As Logical
Local cQry1 As Character
Local cAlias1 As Character
Local cIdMovFK5 As Character
Local lRet As Logical
Local lEstorno As Logical
Local nTamSE5 As Numeric
cQry1 := ""
cAlias1 := ""
cIdMovFK5 := ""
lRet := .F.
lEstorno := .F.
nTamSE5 := Len(Alltrim(xFilial("SE5")))
//Query para buscar registros inconsistentes na tabela SE5
If __oQrySE5 == Nil
cQry1 := "SELECT SE5.R_E_C_N_O_ RECSE5,E5_MOVFKS MOVFKS, E2_FILIAL FILIAL, E2_FILORIG FILORIG, SE2.R_E_C_N_O_ RECSE "
cQry1 += "FROM " + RetSqlName("SE5") + " SE5 "
cQry1 += "INNER JOIN " + RetSqlName("SE2") + " SE2 "
cQry1 += "ON "
If nTamSE5 > 0
cQry1 += "SUBSTRING(SE5.E5_FILIAL,1," + Str(nTamSE5) + ") = SUBSTRING(SE2.E2_FILORIG,1," + Str(nTamSE5) + ") AND "
EndIf
cQry1 += "E5_PREFIXO = E2_PREFIXO "
cQry1 += "AND E5_NUMERO = E2_NUM "
cQry1 += "AND E5_PARCELA = E2_PARCELA "
cQry1 += "AND E5_TIPO = E2_TIPO "
cQry1 += "AND E5_CLIFOR = E2_FORNECE "
cQry1 += "AND E5_LOJA = E2_LOJA "
cQry1 += "AND E5_NATUREZ = E2_NATUREZ "
cQry1 += "AND SE2.D_E_L_E_T_ = ' ' "
cQry1 += "AND SE2.E2_FILORIG <> ' ' "
cQry1 += "WHERE E5_FILORIG = ' ' AND SE5.D_E_L_E_T_ = ' ' "
cQry1 += "AND ((E5_RECPAG = 'P' AND E5_TIPODOC IN ('VL','VM','BA','CP','LJ','V2')) OR (E5_RECPAG = 'R' AND E5_TIPODOC = 'ES')) "
cQry1 += "UNION "
cQry1 += "SELECT SE5.R_E_C_N_O_ RECSE5,E5_MOVFKS MOVFKS, E1_FILIAL FILIAL, E1_FILORIG FILORIG, SE1.R_E_C_N_O_ RECSE "
cQry1 += "FROM " + RetSqlName("SE5") + " SE5 "
cQry1 += "INNER JOIN " + RetSqlName("SE1") + " SE1 "
cQry1 += "ON "
If nTamSE5 > 0
cQry1 += "SUBSTRING(SE5.E5_FILIAL,1," + Str(nTamSE5) + ") = SUBSTRING(SE1.E1_FILORIG,1," + Str(nTamSE5) + ") AND "
EndIf
cQry1 += "E5_PREFIXO = E1_PREFIXO "
cQry1 += "AND E5_NUMERO = E1_NUM "
cQry1 += "AND E5_PARCELA = E1_PARCELA "
cQry1 += "AND E5_TIPO = E1_TIPO "
cQry1 += "AND E5_CLIFOR = E1_CLIENTE "
cQry1 += "AND E5_LOJA = E1_LOJA "
cQry1 += "AND E5_NATUREZ = E1_NATUREZ "
cQry1 += "AND SE1.D_E_L_E_T_ = ' ' "
cQry1 += "AND SE1.E1_FILORIG <> ' ' "
cQry1 += "WHERE E5_FILORIG = ' ' AND SE5.D_E_L_E_T_ = ' ' "
cQry1 += "AND ((E5_RECPAG = 'R' AND E5_TIPODOC IN ('VL','VM','BA','CP','LJ','V2')) OR (E5_RECPAG = 'P' AND E5_TIPODOC = 'ES')) "
cQry1 := ChangeQuery(cQry1)
__oQrySE5 := FWPreparedStatement():New(cQry1)
EndIf
cQry1 := __oQrySE5:GetFixQuery()
cAlias1 := MpSysOpenQuery(cQry1)
DbGotop()
While (cAlias1)->(!Eof())
SE5->(dbGoto( (cAlias1)->RECSE5 ))
Reclock("SE5",.F.)
SE5->E5_FILORIG := (cAlias1)->FILORIG
MsUnlock()
If (cAlias1)->MOVFKS == "S"
If SE5->E5_TABORI =="FK2"
FK2->(dbSetOrder(1))
If FK2->(dbSeek(SE5->E5_FILIAL+SE5->E5_IDORIG))
If Empty(FK2->FK2_FILORI)
Reclock("FK2",.F.)
FK2->FK2_FILORI := (cAlias1)->FILORIG
MsUnlock()
EndIf
EndIf
lEstorno := ( SE5->E5_RECPAG == "R" .And. SE5->E5_TIPODOC = 'ES' )
ElseIf SE5->E5_TABORI =="FK1"
FK1->(dbSetOrder(1))
If FK1->(dbSeek(SE5->E5_FILIAL+SE5->E5_IDORIG))
If Empty(FK1->FK1_FILORI)
Reclock("FK1",.F.)
FK1->FK1_FILORI := (cAlias1)->FILORIG
MsUnlock()
EndIf
EndIf
lEstorno := ( SE5->E5_RECPAG == "P" .And. SE5->E5_TIPODOC = 'ES' )
EndIf
cIdMovFK5 := FK5BUSCA(SE5->(E5_FILIAL+E5_PREFIXO+E5_NUMERO+E5_PARCELA+E5_TIPO+E5_CLIFOR+E5_LOJA+E5_SEQ),lEstorno)
FK5->(dbSetOrder(1))
If FK5->(dbSeek(SE5->E5_FILIAL+cIdMovFK5))
If Empty(FK5->FK5_FILORI)
Reclock("FK5",.F.)
FK5->FK5_FILORI := (cAlias1)->FILORIG
MsUnlock()
EndIf
EndIf
EndIf
(cAlias1)->(DbSkip())
EndDo
If Select(cAlias1) > 0
(cAlias1)->(DBCloseArea())
lRet := .T.
EndIf
Return(lRet)
|
|
---|
03.
...
TABLES
...
This Rdmake adjusts the tables SE5, FK1, FK2
...
and FK5 in the scenarios described in the topic "Example of use".
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>
|