Páginas filhas
  • Extemporaneous Entries (CTBS460 - SIGACTB) - Automatic Routine Options

Versões comparadas

Chave

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

...

Bloco de código
languagepy
themeMidnight
titleMyCtbs460Alt
linenumberstrue
collapsetrue
#INCLUDE "PROTHEUS.CH"
#INCLUDE "FWMVCDEF.CH"
#INCLUDE "rwmake.ch"
#include 'totvs.ch'
#include 'tbiconn.ch'

Static __oModelAut := NIL //oModel variable to substitute msexecauto in MVC

User Function MyCtbs460Alt() 
Local lFound := .F.
Local oModelCSQ
Local nX
Local aLog
Local cLog :=""
Local lRet := .T.

PREPARE ENVIRONMENT COMPANY 'T1' BRANCH 'D MG 01' TABLES 'CSQ','CT2' MODULE 'CTB'

While CT2->(!Eof()) .AND. lFound == .F.
	CSQ->(dbSetOrder(1))
    lFound  :=  CSQ->(dbSeek(CT2->CT2_FILIAL+DTOS(CT2->CT2_DATA)+CT2->CT2_LOTE+CT2->CT2_SBLOTE+CT2->CT2_DOC+CT2->CT2_LINHA+CT2->CT2_EMPORI+CT2->CT2_FILORI))
	If lFound
	    Loop
	else
		CT2->( dbSkip() )
	Endif
	
Enddo

If __oModelAut == Nil //a single time loads the model CTBS460
__oModelAut := FWLoadModel( 'CTBS460' )
EndIf

__oModelAut:SetOperation(MODEL_OPERATION_UPDATE)
__oModelAut:Activate()

oModelCSQ := __oModelAut:GetModel('CSQMASTER')
oModelCSQ:SetValue("CSQ_DTEXT",Stod("20230823"))


If __oModelAut:VldData() //data validation by model

	__oModelAut:CommitData() //saving of data

Else
	aLog := __oModelAut:GetErrorMessage() //Recover error of model when it did not go through VldData
	//link to save in string cLog content of array aLog
	For nX := 1 to Len(aLog)
		If !Empty(aLog[nX])
			cLog += Alltrim(aLog[nX]) + CRLF
		EndIf
	Next nX

	lMsErroAuto := .T. //private variable arrow as error
	AutoGRLog(cLog) //save log to display with function mostraerro
	mostraerro()
	lRet := .F. //return false
Endif


__oModelAut:DeActivate() //deactivate model

Return( lRet )


Deletion

MyCtbs460Exl Expandir origem

...



Bloco de código
languagepy
themeMidnight
titleMyCtbs460Exl
linenumberstrue
collapsetrue
#INCLUDE "PROTHEUS.CH"

...


#INCLUDE "FWMVCDEF.CH"

...


#INCLUDE "rwmake.ch"

...


#include 'totvs.ch'

...


#include 'tbiconn.ch'

...



Static __oModelAut := NIL //oModel variable to substitute msexecauto in MVC

...



User Function MyCtbs460Exl()

...

 
Local lFound := .F.

...


Local nX

...


Local aLog

...


Local cLog :=""

...


Local lRet := .T.

...



PREPARE ENVIRONMENT COMPANY 'T1' BRANCH 'D MG 01' TABLES 'CSQ','CT2' MODULE 'CTB'

...



While CT2->(!Eof()) .AND. lFound == .F.

...


	CSQ->(dbSetOrder(1))

...


    lFound  :=

...

  CSQ->(dbSeek(CT2->CT2_FILIAL+DTOS(CT2->CT2_DATA)+CT2->CT2_LOTE+CT2->CT2_SBLOTE+CT2->CT2_DOC+CT2->CT2_LINHA+CT2->CT2_EMPORI+CT2->CT2_FILORI))

...


	If

...

          Loop

      else

...

 lFound
	    Loop
	else
		CT2->( dbSkip() )

...

      Endif

     

Enddo

...


	Endif
	
Enddo

If __oModelAut == Nil //a single time loads the model CTBS460

...


__oModelAut := FWLoadModel( 'CTBS460' )

...


EndIf

...



__oModelAut:SetOperation(MODEL_OPERATION_DELETE)

...


__oModelAut:Activate()

...



If __oModelAut:VldData() //data validation by model

...



	__oModelAut:CommitData() //saving of data

...

Else

...



Else
	aLog := __oModelAut:GetErrorMessage() //Recover error of model when it did not go through VldData

...


	//link to save in string cLog content of array aLog

...


	For nX := 1 to Len(aLog)

...


		If !Empty(aLog[nX])

...


			cLog += Alltrim(aLog[nX]) + CRLF

...

            EndIf

      Next nX

...


		EndIf
	Next nX

	lMsErroAuto := .T. //private variable arrow as error

...


	AutoGRLog(cLog) //save log to display with function mostraerro

...


	mostraerro()

...


	lRet := .F. //return false

...


Endif

...




__oModelAut:DeActivate() //deactivate model

...



Return( lRet )


03. TABLES

  • CT2 - Accounting Entries
  • CSQ - Extemporaneous Entry       

04. OTHER SUBJECTS