Páginas filhas
  • CTBA102 - Automatic Routine Options

CONTENTS

  1. Overview
  2. Example of use
    1. Addition
    2. Addition with more than one entry
    3. Editing
  3. Tables


01. OVERVIEW


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


02. EXAMPLE OF USE

See below some examples of use.


Warning

Automatic Execution is available only for Addition and Editing of accounting entries.

Important

When using execAuto, consider the following criteria:

 - Fill out field CT2_CONVER as 15555, other currencies must be done by adding a new aItens

 - To edit a record, enter aCab again



Addition:


myctba102inc
#INCLUDE "PROTHEUS.CH"

//-------------------------------------------------------------------
/*/{Protheus.doc} MyCTBA102Inc    

 Automatic Entry Addition CTBA102

@author Totvs
@since 29/11/2013
@version 1.0

/*/
//-------------------------------------------------------------------

User Function MyCTBA102Inc()

Local nX
Local aArea         := GetArea()
Local nDoc            := 1
Local lRet            := .T.
Local aCab            := {}
Local aItens        := {}
Local aLinha         := {}
Local dDataLanc     := ctod("11/28/2013")  
Local nLinha        := '001'


Private lMsErroAuto     := .F.
Private lMsHelpAuto     := .T.
Private CTF_LOCK        := 0
Private lSubLote         := .T.


PREPARE COMPANY ENVIRONMENT "T1" BRANCH "D MG 01 " MODULE "CTB" TABLES "CT2"

    aCab := {}
    aItem := {}



    aAdd(aCab,  {'DDATALANC'     ,dDataBase        ,NIL} )
    aAdd(aCab,  {'CLOTE'         ,'333333'         ,NIL} )
    aAdd(aCab,  {'CSUBLOTE'         ,'001'         ,NIL} )
    aAdd(aCab,  {'CDOC'             ,'000001'         ,NIL} )
    aAdd(aCab,  {'CPADRAO'         ,''             ,NIL} )
    aAdd(aCab,  {'NTOTINF'         ,0                 ,NIL} )
    aAdd(aCab,  {'NTOTINFLOT'     ,0                 ,NIL} )

    

    aAdd(aItens,{  {'CT2_FILIAL'      ,'0101   '     , NIL},;
                   {'CT2_LINHA'      , nLinha        , NIL},;
                   {'CT2_MOEDLC'      ,'01'          , NIL},;
                   {'CT2_DC'           ,'3'          , NIL},;
                   {'CT2_DEBITO'      ,'101010100'   , NIL},;
                   {'CT2_CREDIT'      ,'201010100'   , NIL},;
                   {'CT2_VALOR'      , 3000          , NIL},;
                   {'CT2_ORIGEM'     ,'MSEXECAUT'    , NIL},;
                   {'CT2_HP'           ,''           , NIL},;
                   {'CT2_CONVER'    ,'11'         	 , NIL},;
                   {'CT2_HIST'       ,'MSEXECCT2'    , NIL} } )         

    MSExecAuto({|x, y,z| CTBA102(x,y,z)}, aCab ,aItens, 3)

    If lMsErroAuto
        lMsErroAuto := .F.
        MsgAlert("Entry ERROR" , "Load Test CT2")
		mostraErro()
        Exit
    Endif
RestArea(aArea)

RESET ENVIRONMENT

Return


Addition with More than One Entry:


MyCTBA102Inc()
User Function MyCTBA102Inc() 

Local nX
Local aArea := GetArea()
Local nDoc := 1
Local lRet := .T.
Local aCab := {}
Local aItens := {}
Local aLinha := {}
Local dDataLanc := ctod("11/28/2013") 


Private lMsErroAuto := .F.
Private lMsHelpAuto := .T.
Private CTF_LOCK := 0
Private lSubLote := .T.


PREPARE COMPANY ENVIRONMENT "T1" BRANCH "D MG 01 " MODULE "CTB" TABLES "CT2"

aCab := {}


aAdd(aCab, {'DDATALANC' ,dDataBase ,NIL} )
aAdd(aCab, {'CLOTE' ,'333333' ,NIL} )
aAdd(aCab, {'CSUBLOTE' ,'001' ,NIL} )
aAdd(aCab, {'CDOC' ,'000001' ,NIL} )
aAdd(aCab, {'CPADRAO' ,'' ,NIL} )
aAdd(aCab, {'NTOTINF' ,0 ,NIL} )
aAdd(aCab, {'NTOTINFLOT' ,0 ,NIL} )

//entry 1
aAdd(aItens,  { {'CT2_FILIAL' ,'0101 ' , NIL},;
{'CT2_LINHA' , '001' , NIL},;
{'CT2_MOEDLC' ,'01' , NIL},;
{'CT2_DC' ,'3' , NIL},;
{'CT2_DEBITO' ,'101010100' , NIL},;
{'CT2_CREDIT' ,'201010100' , NIL},;
{'CT2_VALOR' , 3000 , NIL},;
{'CT2_ORIGEM' ,'MSEXECAUT' , NIL},;
{'CT2_HP' ,'' , NIL},;
{'CT2_CONVER' ,'11' , NIL},;
{'CT2_HIST' ,'MSEXECCT2' , NIL} } )

//entry 2
aAdd(aItens, { {'CT2_FILIAL' ,'0101 ' , NIL},;
{'CT2_LINHA' , '002' , NIL},;
{'CT2_MOEDLC' ,'01' , NIL},;
{'CT2_DC' ,'3' , NIL},;
{'CT2_DEBITO' ,'101010100' , NIL},;
{'CT2_CREDIT' ,'201010100' , NIL},;
{'CT2_VALOR' , 4000 , NIL},;
{'CT2_ORIGEM' ,'MSEXECAUT' , NIL},;
{'CT2_HP' ,'' , NIL},;
{'CT2_CONVER' ,'11' , NIL},;
{'CT2_HIST' ,'MSEXECCT2LINHA2' , NIL} })

//add to the aItens array the needed quantity of entries you want to make

MSExecAuto({|x, y,z| CTBA102(x,y,z)}, aCab ,aItens, 3)

If lMsErroAuto
lMsErroAuto := .F.
MsgAlert("Entry ERROR" , "Load Test CT2")
mostraErro()
Exit
Endif
RestArea(aArea)

RESET ENVIRONMENT

Return 


Editing:

myctba102Alt
#INCLUDE "PROTHEUS.CH"

//-------------------------------------------------------------------
/*/{Protheus.doc} MyCTBA102Alt    
 Automatic Entry Addition CTBA102

@author Totvs
@since 11/29/2013
@version 1.0
/*/
//-------------------------------------------------------------------

User Function MyCTBA102Alt()

Local nX
Local aArea         := GetArea()
Local nDoc            := 1
Local lRet            := .T.
Local aCab            := {}
Local aItens        := {}
Local aLinha         := {}
Local dDataLanc     := ctod("11/28/2013")  
Local nLinha        := '001'


Private lMsErroAuto     := .F.
Private lMsHelpAuto     := .T.
Private CTF_LOCK        := 0
Private lSubLote         := .T.

PREPARE COMPANY ENVIRONMENT "T1" BRANCH "D MG 01 " MODULE "CTB" TABLES "CT2"

	aCab     := {}
    aItens     := {}
    aLinha := {}

    aAdd(aCab,  {'DDATALANC'     ,dDataBase        ,NIL} )
    aAdd(aCab,  {'CLOTE'         ,'333333'         ,NIL} )
    aAdd(aCab,  {'CSUBLOTE'         ,'001'         ,NIL} )
    aAdd(aCab,  {'CDOC'             ,'000001'         ,NIL} )
    aAdd(aCab,  {'CPADRAO'         ,''             ,NIL} )
    aAdd(aCab,  {'NTOTINF'         ,0                 ,NIL} )
    aAdd(aCab,  {'NTOTINFLOT'     ,0                 ,NIL} )

   

    aAdd(aItens,{      {'CT2_FILIAL'      ,'0101   '           , NIL},;
                       {'CT2_LINHA'      , nLinha              , NIL},;
                       {'CT2_MOEDLC'      ,'01'               , NIL},;
                       {'CT2_DC'          ,'3'               , NIL},;
                       {'CT2_DEBITO'      ,'101010100'         , NIL},;
                       {'CT2_CREDIT'      ,'201010100'         , NIL},;
                       {'CT2_VALOR'      , 6000              , NIL},;
                       {'CT2_ORIGEM'     ,'MSEXECAUT'        , NIL},;
                       {'CT2_HP'          ,''                   , NIL},;
                       {'CT2_EMPORI'     ,'01'                 , NIL},;
                       {'CT2_FILORI'      ,'0101001'            , NIL},;                       
                       {'CT2_HIST'       ,'MSEXECCT2-1'    , NIL},;
                       {'LINPOS'            ,'CT2_LINHA'        ,nLinha}})  
                   

    MSExecAuto({|x, y,z| CTBA102(x,y,z)}, aCab ,aItens, 4)



    If lMsErroAuto
        lMsErroAuto := .F.
        MsgAlert("Entry ERROR" , "Load Test CT2")
        Exit
    Endif

RestArea(aArea)
RESET ENVIRONMENT
Return 



03. TABLES

  • CT2 - Accounting Entries