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

01. OVERVIEW

Execution examples via automatic routine in Extemporaneous Accounting Entries (CTBS460) routine, showing examples of use and related tables.

02. EXAMPLE

See below some examples of use.


Note

The Automatic Executions stated below are only an example.


Addition



MyCtbs460Inc
#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 MyCtbs460Inc() 
Local lNotFound := .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. lNotFound == .F.
	CSQ->(dbSetOrder(1))
    lNotFound  :=  !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 lNotFound
		Loop
	else
		CT2->( dbSkip() )
	Endif
	
Enddo

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

__oModelAut:SetOperation(MODEL_OPERATION_INSERT)
__oModelAut:Activate()

oModelCSQ := __oModelAut:GetModel('CSQMASTER')
oModelCSQ:SetValue("CSQ_FILIAL",CT2->CT2_FILIAL)
oModelCSQ:SetValue("CSQ_DATA",CT2->CT2_DATA)
oModelCSQ:SetValue("CSQ_LOTE",CT2->CT2_LOTE)
oModelCSQ:SetValue("CSQ_SBLOTE",CT2->CT2_SBLOTE)
oModelCSQ:SetValue("CSQ_DOC",CT2->CT2_DOC)
oModelCSQ:SetValue("CSQ_LINHA",CT2->CT2_LINHA)
oModelCSQ:SetValue("CSQ_EMPORI",CT2->CT2_EMPORI)
oModelCSQ:SetValue("CSQ_FILORI",CT2->CT2_FILORI)
oModelCSQ:SetValue("CSQ_DTEXT",Stod("20230723"))
oModelCSQ:SetValue("CSQ_NATLCT","1") // 1 - Entry in Equity Accounts/ 2 - Entry in Income Statement Accounts

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 )


Editing



MyCtbs460Alt
#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
#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 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_DELETE)
__oModelAut:Activate()

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 )


03. TABLES

  • CT2 - Accounting Entries
  • CSQ - Extemporaneous Entry       

04. OTHER SUBJECTS