CTB220ALT changes the amount and the description of the accounting entry

Requirement Characteristics

Product Line:

Microsiga Protheus

Segment:

Services

Module:

Management Accounting

Routine:

Routine

Technical Name

CTBA220

General consolidation

Entry Point:

CTB220ALT

Countries:

All

Database:

All approved for stored procedures

Tables used:

CT1, CT2, CTT, CTD, CTH, CQ0, CQ1, CQ2, CQ3, CQ4, CQ5, CQ6, CQ7, CQ8, CQ9

Operating Systems:

All approved

Related ticket

TTQBV8

Version/Release:

12.1.6

Corrected version

12.1.6

Released Version

12.1.6 e 12.1.7

Entry Point

Description:

The entry point CTB220ALT allows changing the amount and the description/history of the accounting entry

Location:

Miscellaneous/Processing/General Consolidation

Events:

Informe o Título da rotina

Source Program:

CTBA220

Function:

Informe o Nome do(s) produto(s) a ser utilizado ou “Todos”

 

Example:

EP body created in the database. (SQLSERVER). Example of history and amount whose values will be changed within the EP (in orange)."

CREATE PROCEDURE CTB220ALT_T3 (

@IN_FILIAL Char( 8 ) ,
@IN_DATA Char( 8 ) ,
@IN_LINHA Char( 3 ) ,
@IN_TPSALD Char( 1 ) ,
@IN_EMPORI Char( 2 ) ,
@IN_FILORI Char( 8 ) ,
@IN_MOEDLC Char( 2 ) ,
@IN_LOTE Char( 6 ) ,
@IN_SBLOTE Char( 3 ) ,
@IN_DOC Char( 6 ) ,
@IN_HIST Char( 40 ) ,
@IN_VALOR Float ,
@OUT_HIST Char( 40 ) output ,
@OUT_VALOR Float output ) AS

-- Declaration of variables
DECLARE @cHist Char( 40 )
DECLARE @nValor Float
BEGIN

      SELECT @IN_HIST = 'CHANGED HISTORY'

      SELECT @IN_VALOR = @IN_VALOR * 0.3


      SET @OUT_HIST = @IN_HIST
     SET @OUT_VALOR = @IN_VALOR
END

In the example above, this is how the EP was created in the SQLSERVER database.

This EP will be called within the dynamic procedure (created at runtime) CT220C_XX, which performs the recording of consolidated accounting entries.

It will be called in the italicized section below. The variables @cFilial_CT2 , @cCT2_DATA , @cCT2_LINHA , @cCT2_TPSALD , @cCT2_EMPORI , @cCT2_FILORI , @cCT2_MOEDLC , 
@cCT2_LOTE , @cCT2_SBLOTE , @cCT2_DOC , @cCT2_HIST , @nCT2_VALOR  are the input variables and @cCT2_HISTDEST output , @nCT2_VALORDEST output are the output variables.

The input variables come with their respective values and will be passed into the EP. Within the EP, the output variables @cCT2_HISTDEST and @nCT2_VALORDES can be handled and/or modified, and these changes will then be recorded in the CT2 table.


Note, in green below, that the fields @cCT2_HIST and @cCT2_VALOR receive the contents of the EP’s output variables.

In the EP example above, the description to be saved in the CT2_HIST field will be 'CHANGED HISTORY', and the CT2_VALOR field will contain the originally received value multiplied by 0.3.

"
SET @cCT2_HISTDEST = ' '
SET @nCT2_VALORDEST = 0

EXEC CTB220ALT_T3 @cFilial_CT2 , @cCT2_DATA , @cCT2_LINHA , @cCT2_TPSALD , @cCT2_EMPORI , @cCT2_FILORI , @cCT2_MOEDLC ,
@cCT2_LOTE , @cCT2_SBLOTE , @cCT2_DOC , @cCT2_HIST , @nCT2_VALOR , @cCT2_HISTDEST output , @nCT2_VALORDEST output


SET @cCT2_HIST = @cCT2_HISTDEST
SET @nCT2_VALOR = @nCT2_VALORDEST


SET @iRecno = 0
SELECT @iRecno = MAX ( R_E_C_N_O_ ) FROM CT2T30
SET @iRecno = @iRecno + 1
IF (@iRecno = 0 or @iRecno is null ) BEGIN
    SET @iRecno = 1
END


begin tran
INSERT INTO CT2T30 (CT2_FILIAL , CT2_DATA , CT2_LOTE , CT2_SBLOTE , CT2_DOC , CT2_LINHA , CT2_MOEDLC , CT2_DC , CT2_DEBITO ,
CT2_CREDIT , CT2_DCD , CT2_DCC , CT2_VALOR , CT2_MOEDAS , CT2_HP , CT2_HIST , CT2_CCD , CT2_CCC , CT2_ITEMD ,
CT2_ITEMC , CT2_CLVLDB , CT2_CLVLCR , CT2_ATIVDE , CT2_ATIVCR , CT2_EMPORI , CT2_FILORI , CT2_INTERC , CT2_IDENTC ,
CT2_TPSALD , CT2_SEQUEN , CT2_MANUAL , CT2_ORIGEM , CT2_ROTINA , CT2_AGLUT , CT2_LP , CT2_SEQHIS , CT2_SEQLAN ,
CT2_DTVENC , CT2_SLBASE , CT2_DTLP , CT2_DATATX , CT2_TAXA , CT2_VLR01 , CT2_VLR02 , CT2_VLR03 , CT2_VLR04 ,
CT2_VLR05 , CT2_CRCONV , CT2_CRITER , CT2_KEY , CT2_SEGOFI , CT2_DTCV3 , CT2_SEQIDX , CT2_CONFST , CT2_OBSCNF ,
CT2_USRCNF , CT2_DTCONF , CT2_HRCONF , CT2_MLTSLD , CT2_CTLSLD , CT2_CODPAR , CT2_NODIA , CT2_DIACTB , CT2_MOEFDB ,
CT2_MOEFCR , CT2_USERGI , CT2_USERGA , CT2_AT01DB , CT2_AT01CR , CT2_AT02DB , CT2_AT02CR , CT2_AT03DB , CT2_AT03CR ,
CT2_AT04DB , CT2_AT04CR , CT2_LANCSU , CT2_GRPDIA , CT2_CODCLI , CT2_CODFOR , CT2_LANC , CT2_CTRLSD , R_E_C_N_O_ )
VALUES (@cFilial_CT2 , @cCT2_DATA , @cCT2_LOTE , @cCT2_SBLOTE , @cCT2_DOC , @cCT2_LINHA , @cCT2_MOEDLC , @cCT2_DC ,
@cCT2_DEBITO , @cCT2_CREDIT , @cCT2_DCD , @cCT2_DCC , @nCT2_VALOR , @cCT2_MOEDAS , @cCT2_HP , @cCT2_HIST , @cCT2_CCD ,
@cCT2_CCC , @cCT2_ITEMD , @cCT2_ITEMC , @cCT2_CLVLDB , @cCT2_CLVLCR , @cCT2_ATIVDE , @cCT2_ATIVCR , @cCT2_EMPORI ,
@cCT2_FILORI , @cCT2_INTERC , @cCT2_IDENTC , @cCT2_TPSALD , @cCT2_SEQUEN , @cCT2_MANUAL , @cCT2_ORIGEM , @cCT2_ROTINA ,
@cCT2_AGLUT , @cCT2_LP , @cCT2_SEQHIS , @cCT2_SEQLAN , @cCT2_DTVENC , @cCT2_SLBASE , @cCT2_DTLP , @cCT2_DATATX ,
@nCT2_TAXA , @nCT2_VLR01 , @nCT2_VLR02 , @nCT2_VLR03 , @nCT2_VLR04 , @nCT2_VLR05 , @cCT2_CRCONV , @cCT2_CRITER ,
@cCT2_KEY , @cCT2_SEGOFI , @cCT2_DTCV3 , @cCT2_SEQIDX , @cCT2_CONFST , @cCT2_OBSCNF , @cCT2_USRCNF , @cCT2_DTCONF ,
@cCT2_HRCONF , @cCT2_MLTSLD , @cCT2_CTLSLD , @cCT2_CODPAR , @cCT2_NODIA , @cCT2_DIACTB , @cCT2_MOEFDB , @cCT2_MOEFCR ,
@cCT2_USERGI , @cCT2_USERGA , @cCT2_AT01DB , @cCT2_AT01CR , @cCT2_AT02DB , @cCT2_AT02CR , @cCT2_AT03DB , @cCT2_AT03CR ,
@cCT2_AT04DB , @cCT2_AT04CR , @cCT2_LANCSU , @cCT2_GRPDIA , @cCT2_CODCLI , @cCT2_CODFOR , @cCT2_LANC , @cCT2_CTRLSD ,
@iRecno );
commit tran
FETCH CUR_CTB220A