This function is used to define the automatic journal variables that can be used in the automatic journal line formulas.
The use of a variable in a formula can be useful when the initialization of a field in a posting line is complex and it cannot be reduced to a simple expression. In this case, the call to a variable will be translated by a call to a sub-program that will have the role of evaluating the variable and to allow the generator to initialize the contents of the field in the accounting line.
Each automatic journal variable is associated with a code and can be used with any automatic journal line.
The call to a variable in a formula will translate to a call to a sub-program defined in a process where the names are to be parameterized in the fields provided.
Each variable :
Can contain a certain number of parameters ‘by value’ necessary to the evaluation of the variable (these variables are passed like parameters in the sub-program).
Must contain a mandatory parameter ‘by address’. This parameter corresponds to the result of the variable evaluation.
Return, other than the evaluation parameter, a variable of the type integer that is used to define an error code. This parameter cannot be defined in the list of the parameters, but it is automatically added in the call to the sub-program : the code for the sub-program must therefore include it.
Example :
In certain automatic journal lines, it is necessary to know the VAT rate to be applied taking into account the tax code, the accounting date and the company. The VAT variable has been introduced as standard to allow the evaluation of the tax rate and contains the following parameters:
Three parameters by "value" necessary for the evaluation of the tax rate : the company (CPY) type ‘Char’, the tax code (TAX) type ‘Char’, the date (DAT) type ‘Date’
A parameter by "address" corresponding to the result : the tax rate (VATRAT) type ‘Decimal’
Refer to documentation Implementation
Presentation
Each variable can be used in the formulas grid associated with the fields in the posting lines by means of the syntax V_XXXXX (XXXXX being the variable code). The entry of a variable triggers the opening of a small window in which the user must specify the value of each parameter necessary to the variable evaluation (parameter of the type "Value"). The value specified for each parameter must be of the correct type.
It should be noted that the parameters transmitted during the call to the sub-program can be constants, variables or complex expressions including on-line variables.
Example :
If it is necessary to pass in a formula associated with the automatic journal BPCIN, the journal code found in this table as a variable, the formula [F:SIH]JOU is used in the parameter.
It should be noted that a formula for an automatic journal line can use several automatic journal variables.
Example :
V_CONVERT-ar2(V_CONVERT/(1+V_VAT)), where V_CONVERT must return the amount ex-tax, V_VAT must return the tax rate and where the complete formula must return the VAT amount.
The reference to a variable on an automatic journal line generates in the WMGAUYYYYY process (YYYYY being the automatic journal code) the call to the sub-programme in question with :
The variable parameters in the order in which they have been entered in the parameterization of the automatic journal variable.
A parameter ‘STAT’ of the type ‘Integer’ that can be used to return the return status to the automatic journal generator. If on return, the STAT variable is equal to 98, the automatic journal will not be generated and the error displayed will contained in the global variable GMESSAGE.
Note in addition that, in the processes generated by the accounting of the automatic journals, the principal table is open not under its own abbreviation, but under the abbreviation [F:TB0] ; the line table is itself open under the abbreviation [F:TB1]. This has no impact on the formulas entered or on the parameter expressions passed to the automatic journal parameterization. It is possible to continue to use the normal abbreviations of the principal tables, the validation of the automatic journal automatically carries out the abbreviation substitutions in the expressions. On the other hand, if the process called by the variable must call on the fields in the principal table or to the table of lines for the current record (if for example, the process tests the fields in these records that have not been passed as an argument), it will then be necessary to use the abbreviations [TB0] and [TB1] in the process.
Exemple : The reference to the variable ‘TVA’ in line 11 of the automatic journal ‘PRINC’ generates in the WMGAUPRINC process the following call :
Call LECTAUX([F:TB0]CPY,[F :TB1]VATLIN,[F:TB0]ACCDAT,[L]VATRAT,STAT) From CPTINIVAR
TB0 being the abbreviation for the triggering table (table PAYMENTH for the automatic journal PRINC) ;
TB1 being the abbreviation for the "general" table (table PAYMENTD) ;
The parameters [F:TB0]CPY, [F :TB1]VATLIN, [F:TB0]ACCDAT corresponding to the ‘by value’ parameters ;
The parameter [L]VATRAT corresponding to the "by address" parameter ;
The parameter STAT for the return status.
The sub-program that will evaluate the variable must be appropriate with the parameters that are passed for its call, that is to say it must contain in order :
The parameters of the variable in the order in which they have been entered in the variable parameterization and with the correct type (Char, Integer, Date or Decimal)
A parameter ‘STAT’ of the type ‘Integer’ that can be used to return the return status to the automatic journal generator. If an error in the variable evaluation (read error for example) prevents the creation of the automatic journal, the sub-programme must set the STAT variable to 98 and load the GMESSAGE global variable that will contain the error that will prevent the creation of the automatic journal.
For instance:
Subprog LECTAUX(SOC,TAX,DAT,TAUX,STAT)
Value Char SOC()
Value Char TAX()
Value Date DAT
Variable Decimal TAUX
Variable Integer STAT
If clalev([F:TRA])=0 : Local File TABRATVAT [TRA] : Endif
Filter [TRA] Where CPY=SOC & VAT=TAX & STRDAT<=DAT
Read [TRA]TRA0 Last
If fstat>2
Filter [TRA] Where CPY="" & VAT=TAX & STRDAT<=DAT
Read [TRA]TRA0 Last
If !fstat
TAUX = [F:TRA]VATRAT/100
Endif
Filter [TRA]
Endif
If fstat>2
STAT = 98
GMESSAGE = “Error in the evaluation of the tax rate“-TAX
Endif
End
Close
Fields
The following fields are present on this tab :
Header
|
  |
|
  |
Block number 2
|
  |
Subprograms
|
  |
|
  |
Grid Parameters
|
  |
|
  |
|
  |
|
  |
|
  |
Description
|
  |
Close