AIMP3 script: Reports

IMPRIME

The IMPRIME entry point is called just before the choice of printer. The only action available is to define the value of the GPE variable which, if different from zero, prohibits the entry of a printer.

Context and operating mode

The following tables are online:

Table

Significant content

Table description

AREPORT [ARP]

Yes

Report dictionary

The parameters are stored in the PARAMETRE variable with the indices 1 to NBPAR. Each value is a string in the form of parameter=value without any other separator. The report parameters are divided into 4 classes:

  • Those that start with a double underscore. These are the parameters destined for X3, they are not transmitted to the report.

  • Those that start with a single underscore. These are the parameters destined for Crystal Reports, they are not transmitted to the report.

Note - informationThe values of these parameters are necessarily prefixed by chr$(1).
  • Those that start with X3. These are the context parameters transmitted to the report and automatically initialized by the supervisor.

  • Those that are described in the report dictionary. When the dictionary contains a parameter ending with deb or str another parameter with the same route ending with fin or end is automatically added.

The print server name is not a parameter. It is defined in the SERVER(char(30)) local variable.

Parameter list:

__REPORT: Crystal reports report name

__DESTINATION: 0=preview, 1=print, 2=e-mail, 3=file

__TYPDBA60: Database type (menu local 23)

__DBSERVER: ODBC name

__DBDATABASE: Database name

__DBUSER: DB user

__DBPASSWORD: Password

__WSTATION (*140): Print server port number

__CDUSER (*140): User code

__APPLICATION: Folder; machine; service (from where the print is launched)

__APPRPT: Folder; machine; service (from where the report is found)

__REQUETE: Request number

_PreVisuOptions: Preview options (non operational)

_PrinterName: Print name

_Orientation:0=portrait, 1=landscape

_PrinterDriver (*): Printer driver name

_PrinterPort (*): Printer port

_PrinterDescription (*): Printer characteristics

_FormatExport: Export file format (menu local 91)

_FormatDelString: String deliminator if CSV format

_FormatDelRecord: Field separator if CSV format

_ExportFile: Name of the exported file

X3DOS: Folder ;machine ;service ;version ;language (*140 version + language)

X3CLI: Customer name

X3EDT: Copyright

X3ETA: Report code

X3TIT: Report name

X3USR: (*130) User code

X3LAN: (*140) Report language directory

X3FCY: (*Warehousing) Site

X3FCY: (*Warehousing) Depositor

X3OPE: User name

X3SIT1: (*120) Authorized sites

X3SIT1: (*120) Prohibited sites

X3PRF: (*130) Function profile

X3FCT: (*130) Function associated with the report

X3SIT: List of prohibited sites

(*): These parameters are dependent on the printer and cannot be described. They are normally recovered by the selimp instruction (make an attempt on a given printer and note the values of these parameters).

(*120): Available in V110 and V120, but not longer available in later versions.

(*130): Available starting from V130.

Open tables

Only the AREPORT table containing the report in the process of being printed is significant.

Copy

Example of the use of the entry points in AIMP3 processing

$ACTION
                ACTION example
                When "IMPRIME" : Gosub IMPRIME
                When "PARAM" : Gosub PARAM
                Endcase
                Return
                $IMPRIME
                If [F:ARP]RPTCOD="REPORT1","REPORT2","REPORT3"): # List of reports to be processed
                GPE = 1: #Prevents the entry of a printer
                Endif
                Return
                $PARAM

                ## The parameters are contained in the PARAMETRE(1..NBPAR) variable)
                ## but the sub-programmes GETPARAM and SETPARAM of Trt REPORT
                ## makes it easier to access them

                Local Char XPARAM(250)(1..10) , XPAR(50) , XVAL(50) , XETAT(20)
                Local Integer XNB , XK , XI

                ## Has the print been requested on the printer?

                Call GETPARAM("__DESTINATION",NBPAR,PARAMETER,XVAL) From ETAT
                If XVAL<>"1"
                Return : # No, then nothing is done
                Endif

                ## Determining the printer as a function of the report

                Call GETPARAM("X3ETA",NBPAR,PARAMETER,XETAT) From ETAT
                Case XETAT
                When "REPORT1" : XIMP = "my_printer"
                When "REPORT2" : XIMP = "laser_printer"
                When "REPORT3" : XIMP = "dot-matrix_line_printer"
                When Default : Return
                Endcase

                ## Allocation of the print server

                SERVER = "the_machine_that_prints"

                ## Recovery of the default parameters for the printer

                XNB = 0
                XNB += 1 : XPARAM(XNB) = "_PrinterName=" + chr$(1) + XIMP : # Name of printer to be allocated
                XNB += 1 : XPARAM(XNB) = "_Orientation=" + chr$(1) + "1" : #Landscape mode
                XNB += 1 : XPARAM(XNB) = "_NoVisible=" + chr$(1) + "1" : # No entry
                Selimp XPARAM = "" With XPARAM(1..XNB) : #Reading of default parameters
                XNB = stat1
                For XI=1 To XNB
                XK = instr(1,XPARAM(XI),"=")
                If XK
                XPAR = left$(XPARAM(XI),XK-1)
                XVAL = right$(XPARAM(XI),XK+1)
                # If the default parameters are not wanted
                # it is also possible to reassign them here
                # If XPAR="_PrinterPort" : XVAL = "my_port" : Endif
                Case XPAR
                When "_PrinterName" , "_PrinterDriver" , "_PrinterPort"
                , "_PrinterDescription" , "_Orientation"
                Call SETPARAM(XPAR,NBPAR,PARAMETER,XVAL) From ETAT
                Endcase
                Endif
                Next XI
            Return

PARAM

The PARAM entry point is used to modify any parameter in the report.

Context and operating mode

The following tables are online:

Table

Significant content

Table description

AREPORT [ARP]

Yes

Report dictionary

REPORT

The REPORT entry point is used to start a process after the report has been printed. This entry point is executed just after the print order sent to the client (or the server). In the case of a print or file, it can be used to start a process on the generated file.

Context and operating mode

The following tables are on line:

Table

Significant content

Table description

AREPORT [ARP]

Yes

Report dictionary

REPORT_ZPL

The REPORT_ZPL entry point is used to start a process after the ZPL report has been printed. This entry point is executed just after the print order sent to the client (or the server). In the case of a print or file, it can be used to start a process on the generated file.

Context and operating mode

The following tables are online:

Table

Significant content

Table description

AREPORT [ARP]

Yes

Report dictionary

This entry point is executed just after the creation of the ZPL report.

UPDSQLSTAT: To manage performance of printouts in AREPORTM

This entry point is called just before the printing action. It will allow to execute a SQL script to update the database, especially the AREPORTM table.

Context and operating mode

Sometimes in MSSQL server database the AREPORTM table is not correctly updated before printing and some parameters are incorrect when we print a report. To fix this problem, you can execute an update statistics request to force the database to update tables.

Copy

Example of a script to update the AREPORTM table with a MSSQL server database.

$UPDATE_STAT
                Local Char MYQUERY (100)(1..4)
                Local Tinyint QRYLIN, I
                Local Char    CRLF(2) : CRLF = " "+chr$(10)
                [L]QRYLIN+=1 : [L]MYQUERY([L]QRYLIN)="BEGIN"+[L]CRLF
                [L]QRYLIN+=1 : [L]MYQUERY([L]QRYLIN)="  SET NOCOUNT ON;"+[L]CRLF
                [L]QRYLIN+=1 : [L]MYQUERY([L]QRYLIN)="  UPDATE STATISTICS "nomap".[AREPORTM] AREPORTM_ARM0 WITH FULLSCAN;"+[L]CRLF
                [L]QRYLIN+=1 : [L]MYQUERY([L]QRYLIN)="END"+[L]CRLF
                Execsql From DB_CONFIG.GET_DATABASE_TYPE() Sql [L]MYQUERY(1..20)
            Return

Open tables

Table Significant content Table description
AREPORT Yes Report dictionary

AREPORTM

Yes

Temporary print key table