4 BASES DE DISEÑO 39
5.2 EXTRACCIÓN CON AGUA 64
5.2.1 Indicadores Ambientales 64
This section provides a detailed description of the changes required to enable a report for sending using Zetadocs. Understanding how it works will make it much easier when trying to enable a report which is in an unusual format. An explanation as to the function of each piece of code that needs to be added to a report is given to help understanding. To make the process simpler and faster there is also the template report in the Zetadocs for NAV installation pack which contains the elements that are to be added to an existing report to enable it for sending. It is recommended that you complete the previous sections of this
installation document before attempting to create a Zetadocs for NAV report, because much of the code to be added to an existing report depends upon other Zetadocs for NAV objects.
Please note that these instructions appear long and are written to accommodate people with little NAV development experience. Once understood, modifying a report should only take a matter of minutes.
(i)Report Overview
The goal in editing a report to enable it for Zetadocs is to build a list of embedded commands to be written on a separate page at the start of each record report. So for a report which is run for 4 records there will be 1 page inserted before each record output totaling 4 pages in all. There are a number of options for where the code provided is added into a report, what follows is our suggestion as it will work with most of the reports supported.
Required Code Overview:
Send Results Generation call
o All records passed to Zetadocs codeunit to resolve Document Set rules for sending settings and recipient information.
Error and user specified record skipping
o Code to skip records which have a send results error or records marked by the user to be explicitly skipped.
Embedded Command Generation call
o For each record generating the required embedded commands from the send results. Zetadocs Embedded Commands Section
o An area in the report to put textboxes where the embedded commands will be written. Optional code Overview:
Print for Zetadocs option
o Request Form radio buttons. Report option to allow user to choose output format of the report, normal or Zetadocs.
o Additional code to suppress output of embedded commands when printing report normally.
(ii)Import the Template Zetadocs for NAV Report
Ensure that the Zetadocs for NAV report template has been imported into the object designer. Report 9009959
‚<CD Drive>:\Zetadocs NAV Server Components\Zetadocs for NAV V2.1 Additions Report 9009959.txt‛
We will refer to this report from now on as the template and to the report you are editing as the report. NOTE: The template is based on the ‚Sales Header‛ table as an example. You must edit the code to use the table your report is based on as instructed.
(iii)Global, Local and Text Constants
Zetadocs for NAV Configuration Guide APPENDIX: – Step by Step
Select all global variables (Ctrl + A), right-click and select Copy Open the report and view the C/AL Globals
Scroll to the bottom of any existing globals in your report and select the blank global variable row, right-click and select Paste to paste the additional Zetadocs Globals into the report.
You must now repeat the above steps for the Text Constants:
(iv)Code Segments
Next you need to copy the code from the template to your report
Open the template in the Report Designer again and select an empty data item row.
Figure 53 – Zetadocs Template Report in Report Designer
Press F9 or View C/AL Code to view the PreReport Triggers. Report – OnPreReport
The code here initializes the Zetadocs codeunit and passes each record being sent to query the rules tables and sets the appropriate send information for each record.
Copy and paste the code below for the Report – OnPreReport function into the top of the same function in your report.
Now edit the function parameters and function calls in place. These are signified by <param description> in the code below.
o <Report No.> - The ID of your report.
o <Main DataItem Name> - This is the name of the first DataItem in your report. Typically it is the name of the table upon which your report is based.
Code:
ZetadocsSend := TRUE; noError := TRUE;
IF NOT ZetadocsSendResultGen.Initialize(<Report No.>) THEN BEGIN
CLEAR(ZetadocsUtilities); CLEAR(ZetadocsSendResultGen); CLEAR(ZetadocsPrnRem); CurrReport.QUIT;
Zetadocs for NAV Configuration Guide APPENDIX: – Step by Step
END ELSE BEGIN
IF <Main DataItem Name>.FIND('-') THEN REPEAT
BEGIN
// Get the RecordID IF noError THEN BEGIN
RecRef.GETTABLE(<Main DataItem Name>);
IF NOT ZetadocsSendResultGen.AddRecord(RecRef.RECORDID) THEN BEGIN noError := FALSE; CLEAR(ZetadocsUtilities); CLEAR(ZetadocsSendResultGen); CLEAR(ZetadocsPrnRem); CurrReport.QUIT; END; END; END;
UNTIL <Main DataItem Name>.NEXT = 0; IF noError THEN
IF NOT ZetadocsSendResultGen.ResolveSendInfo() THEN BEGIN CLEAR(ZetadocsUtilities); CLEAR(ZetadocsSendResultGen); CLEAR(ZetadocsPrnRem); CurrReport.QUIT; END; END; Report – OnPostReport
The code here clears automation variables used during sending.
Copy and paste the code below for the Report – OnPostReport function into the top of the same function in your report.
Code:
CLEAR(ZetadocsUtilities); CLEAR(ZetadocsSendResultGen); CLEAR(ZetadocsPrnRem);
Zetadocs Embedded Commands Data Item
This data item is added to provide a location to put the Zetadocs Embedded commands text box. The goal is to insert a page before each record report which will contain the embedded commands to be read by the Zetadocs Client. This page will then be removed from the resulting document and therefore should not contain any report data. For some reports such as the ‚Statement‛ report, where each page has a recurring header which contains the customer address information then placement of the Zetadocs embedded command text box may need to be different and resized to force all report data to be printed from page 2 onwards.
Action:
1. In the report designer select an empty row and create a new data item of type ‚Integer‛ called ‚Zetadocs Embedded Commands‛.
Move the data item up to just below your main data item and indent once so that it will be the first page of output in your report.
Select the Zetadocs Embedded Commands data item in your report and press Shift + F4 or View Properties.
Set the properties DataItemTableView to ‚SORTING(Number)‛ or alternatively cut and paste this property value from the equivalent in the template.
Zetadocs for NAV Configuration Guide APPENDIX: – Step by Step
Return to the template report designer select View Sections.
Select the three textboxes called ‚ZetadocsEmbComms‚, ‚ZetadocsCustComms‛ and
‚ZetadocsMultRecComms‛ in the Zetadocs Embedded Commands section and copy to clipboard (Ctrl + C).
View the sections on your report and paste (Ctrl + V) the textbox into the Zetadocs Embedded Command section.
Zetadocs Embedded Commands, Body(1) – OnPreSection
As we are adding an additional page which will be removed from the final document we need to decrement the page numbers. This must be done in this section trigger OnPreSection
Open the report designer for the template. Select View Sections from the main menu.
Select the Zetadocs Embedded Commands, Body(1) section and press F9 to view the code. Copy the code below for the Zetadocs Embedded Commands, Body(1) – OnPreSection function. Paste the code into the top of the same function in your report.
Code:
CurrReport.PAGENO := CurrReport.PAGENO – 1;
Figure 54 – Adding Zetadocs Embedded Commands DataItem
Zetadocs Embedded Commands – OnPreDataItem
Ensures we only write one set of embedded commands per record. Return to the report designer for the template.
Select the DataItem Zetadocs Embedded Commands and press F9 to view the code. Copy the code below for the Zetadocs Embedded Commands – OnPreDataItem function . Paste the code into the top of the same function in your report.
Code:
SETRANGE(Number,1,1);
Zetadocs Embedded Commands – OnAfterGetRecord
The code here queries the Zetadocs Send Results Gen codeunit for the embedded commands to be written onto the report page in the Zetadocs Embedded Commands textboxes. The first textbox created will contain the standard set of embedded commands recognized by Zetadocs. The second textbox will contain any custom commands that have been created for a specific system, and the third textbox will contain addressing information for the any additional recipients.
Zetadocs for NAV Configuration Guide APPENDIX: – Step by Step
Paste the code into the top of the same function in your report.
Now edit the function parameters and function calls in place. These are signified by <param description> in the code below.
o <Main DataItem Name> - This is the name of the first DataItem in your report. Typically it is the name of the table upon which your report is based.
Code:
RecRef.GETTABLE(<Main DataItem Name>);
ZetadocsEmbComms:= ZetadocsSendResultGen.GetRecordEmbComms(RecRef.RECORDID, ZetadocsEmbCommsAction); CASE ZetadocsEmbCommsAction OF ZetadocsEmbCommsAction::Error: BEGIN CLEAR(ZetadocsUtilities); CLEAR(ZetadocsSendResultGen); CLEAR(ZetadocsPrnRem); CurrReport.QUIT; END END; //CASE ZetadocsCustComms := ZetadocsSendResultGen.GetRecordCustComms(RecRef.RECORDID, ZetadocsEmbCommsAction); CASE ZetadocsEmbCommsAction OF ZetadocsEmbCommsAction::Error: BEGIN CLEAR(ZetadocsUtilities); CLEAR(ZetadocsSendResultGen); CLEAR(ZetadocsPrnRem); CurrReport.QUIT; END END; //CASE ZetadocsMultRecComms := ZetadocsSendResultGen.GetRecordMultRecComms(RecRef.RECORDID, ZetadocsEmbCommsAction); CASE ZetadocsEmbCommsAction OF ZetadocsEmbCommsAction::Error: BEGIN CLEAR(ZetadocsUtilities); CLEAR(ZetadocsSendResultGen); CLEAR(ZetadocsPrnRem); CurrReport.QUIT; END END; //CASE
Zetadocs Embedded Commands – OnPostDataItem
Copy the code below for the Zetadocs Embedded Commands – OnPostDataItem function. Paste the code into the top of the same function in your report.
Code:
CurrReport.NEWPAGE;
CopyLoop
If your report contains a copy loop data item that outputs more than one copy of the report per print, then you must edit the loop to only output one copy when sending using Zetadocs. An example of the standard copy loop with the additional logic is in the template. The easiest way is to ensure
Zetadocs for NAV Configuration Guide APPENDIX: – Step by Step
Sample Code: IF (NoOfLoops <= 0) THEN NoOfLoops := 1; IF (ZetadocsSend) THEN NoOfLoops := 1; SETRANGE(Number,1,NoOfLoops);
Main DataItem – OnAfterGetRecord
The code here controls whether or not to output the current records report based on errors or skip commands from the Zetadocs Send Results Gen codeunit.
Select the main section in the template. This is the first data item in the report designer view, for example ‚Sales Header‛.
Press F9 or View C/AL Code.
Copy the code below for the OnAfterGetRecord function. Paste the code into the top of the same function in your report.
Now edit the function parameters and function calls in place. These are signified by <param description> in the pasted code.
o <Main DataItem Name> - This is the name of the first DataItem in your report. Typically it is the name of the table upon which your report is based.
Code:
RecRef.GETTABLE(<Main DataItem Name>);
IF ZetadocsSendResultGen.IsToBeSkipped(RecRef.RECORDID) THEN BEGIN
CurrReport.SKIP; END;
Figure 55 – Report Designer
(v)Report Properties
This prevents our send errors dialog and the printer status dialog being shown at the same time. Zetadocs also has its own printing progress dialog.
Open the report designer for your report.
Select the empty section row at the bottom of the section list. Press Shift + F4 or click View Properties.
Set the ShowPrinterStatus to No.
(vi)Completed Report
Shown here is a working report of three records. Note the inserted pages with the Zetadocs embedded commands at pages 1,3 and 5.
Zetadocs for NAV Configuration Guide APPENDIX: Optional Zetadocs Report Format
Figure 56 - Zetadocs Enabled Report Preview