Árvore de páginas

Versões comparadas

Chave

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

...

Para os registros que possuam o E5_MOVFKS = 'S', os campos FK1_FILORI, FK2_FILORI e FK5_FILORI serão preenchidos com o conteúdo dos campos E1_FILORIG/E2_FILORIG.

Bloco de código
languagejava
themeMidnight
titleCódigo fonte:
collapsetrue
---------------------------------------------------------------------
    Deleta referencias incorretas da FK6
---------------------------------------------------------------------
/*/
Static Function AtuFK6(cIDFK2 As Character, cFK2Atu As Character, lEstFK6)

	Local aArea		As Array

	Default cIDFK2  := cFK2Atu:= FK2->FK2_IDFK2
	Default lEstFK6	:= .F.

	aArea := GetArea()

	FK6->(dbSetOrder(3))
	If FK6->(dbSeek(FK2->FK2_FILIAL+cIDFK2+"FK2"))
		While FK6->(!EOF()) .and. FK6->FK6_FILIAL == FK2->FK2_FILIAL .and.;
			  FK6->FK6_IDORIG == cIDFK2 .and. FK6->FK6_TABORI == "FK2"

			
			RecLock("FK6")
			If FK6->FK6_TPDOC == "CM" .And. !lEstFK6
				FK6->(DBDelete())
			Else
				FK6->FK6_IDORIG := cFK2Atu
			EndIf
			FK6->(MsUnLock())
			
			FK6->(dbSkip())
		EndDo
	EndIf

	RestArea(aArea)

Return Nil

/*/
---------------------------------------------------------------------
    Deleta referencias incorretas da FK7
---------------------------------------------------------------------
/*/
Static Function CleanFK7()

	If !SE2->(dbSeek(STRTRAN(FK7->FK7_CHAVE, "|", "")))
		If FK7->(!EoF())	
			RecLock("FK7")
			FK7->(DbDelete())
			FK7->(MsUnLock())
		EndIf
	EndIf

Return Nil

/*/
---------------------------------------------------------------------
    Atualiza sequencia dos movimentos da SE5
---------------------------------------------------------------------
/*/
Static Function SeqRecord(cSeq As Character)

	If SE5->(!EoF())	
		RecLock("SE5",.F.)
		SE5->E5_SEQ    := cSeq
		SE5->(MsUnlock())

		//FlagMov()
	EndIf

Return Nil

/*/
---------------------------------------------------------------------
    Verifica se existe movimentos complementares
---------------------------------------------------------------------
/*/
Static Function ChkMovCompl(cSeq As Character)

	Local aTipoDoc As Array

	Default cSeq := SE5->E5_SEQ

	aTipoDoc := {}

	DO CASE
		CASE SE5->E5_VLJUROS > 0
			aAdd(aTipoDoc,"JR")

		CASE SE5->E5_VLMULTA > 0
			aAdd(aTipoDoc,"MT")

		CASE SE5->E5_VLCORRE > 0
			aAdd(aTipoDoc,"CM")
	ENDCASE
		
	If !Empty(aTipoDoc)
		AtuMovCompl(aTipoDoc,cSeq)
	EndIf

Return Nil

/*/
---------------------------------------------------------------------
    Atualiza os movimentos complementares
---------------------------------------------------------------------
/*/
Static Function AtuMovCompl(aTipoDoc As Array, cSeq As Character)

	Local aArea 	As Array
	Local cChvParc1 As Character
	Local cChvParc2 As Character
	Local cData		As Character
	Local cIdOrig	As Character
	Local cFil		As Character
	Local nX		As Numeric

	Default aTipoDoc := {}
	Default cSeq	 := SE5->E5_SEQ

	cChvParc1	:= SE5->(E5_PREFIXO + E5_NUMERO + E5_PARCELA + E5_TIPO)
	cChvParc2	:= SE5->(E5_CLIFOR + E5_LOJA)
	cData 		:= DTOS(SE5->E5_DATA)
	cIdOrig		:= SE5->E5_IDORIG
	cFil		:= SE5->E5_FILIAL
	nX			:= 1

	aArea := SE5->(GetArea())

	SE5->(dbSetOrder(2))
	For nX := 1 to Len(aTipoDoc)
		If SE5->(dbSeek(cFil+aTipoDoc[nX]+cChvParc1+cData+cChvParc2))
			If SE5->E5_IDORIG == cIdOrig
				SeqRecord(cSeq)
				CleanSE5()	
			Endif
		EndIf
	Next nX

	RestArea(aArea)

Return Nil

/*/
---------------------------------------------------------------------
    Limpa referencias das FKs na SE5 para rodar migrador
---------------------------------------------------------------------
/*/
Static Function CleanSE5()

	Local aArea As Array

	aArea := __SE5->(GetArea())
	__SE5->(dbGoTo(SE5->(Recno())))

	If __SE5->(!EoF())
		RecLock("__SE5",.F.)
		__SE5->E5_IDORIG := ""
		__SE5->E5_TABORI := ""
		__SE5->E5_MOVFKS := ""
		__SE5->(MsUnlock())
	Else
		RestArea(aArea)
	EndIf

Return Nil

/*/
---------------------------------------------------------------------
    Deleta os Statements temporarios
---------------------------------------------------------------------
/*/
Static Function DelTmps(oTmp As Object)

	If oTmp != NIL
		oTmp:Destroy()
		oTmp := NIL
	Endif

Return Nil 
/*/
---------------------------------------------------------------------
    Monta tela para selecao do grupo de empresas
---------------------------------------------------------------------
/*/
Static Function SelCompany() As Character

	Local aRet     As Array
	Local oDlg     As Object
	Local oGrpEmp  As Object
	Local oFilial  As Object
	Local oSay     As Object
	Local cEmp 	   As Character
	Local cFil 	   As Character

	aRet     := {}
	cEmp 	 := "  "
	cFil 	 := "        "

	Define MSDialog  oDlg Title "FA340FIX" From 0, 0 To 170, 326 Pixel

	oDlg:cToolTip := "Definicao do grupo de empresas que sera processado"
	oDlg:cTitle   := "Inicializacao do ambiente"

	@ 14, 37 Say  oSay Prompt "Informe o codigo do grupo de empresa" Size  55, 20 Of oDlg Pixel
	@ 16, 91 MSGet  oGrpEmp Var  cEmp Size  05, 05 Of oDlg Pixel Picture "@!" 

	@ 34, 37 Say  oSay Prompt "Informe uma filial deste grupo de empresas" Size  55, 20 Of oDlg Pixel
	@ 36, 94 MSGet  oFilial Var  cFil Size  05, 05 Of oDlg Pixel Picture "@!" 

	Define SButton From 63, 73 Type 1 Action ( oDlg:End() ) OnStop "Confirma"  Enable Of oDlg
	Activate MSDialog  oDlg Center

	Aadd(aRet,cEmp)
	Aadd(aRet,AllTrim(cFil))

Return aRet


03. TABELAS UTILIZADAS

Este Rdmake realiza a correção nas tabelas SE5, FK1, FK2 e FK5 nos cenários descritos no tópico "Exemplo de utilização".

...