======7.1. Custom Layout Printing======
Report printing can be customized in Produmex Scan by using the customization technology described in: [[implementation:scan:customizationtechnology|Customization Technology for Produmex Scan]]. A report can be printed with user queries in the following cases:
* The report is defined in SAP Business One, or
* The report is located in a folder Produmex Service Broker can access.
=====7.1.1. Import the report=====
Use the [[http://builds.produmex.name/Utils/Standalone_HanaReportSettingTool/Standalone_HanaReportSettingTool.zip|HanaReportSettingTool]] to configure the correct connection of the report file in HANA environment. You can read more about the tool in the [[http://builds.produmex.name/Utils/Standalone_HanaReportSettingTool/HANA%20Report%20Setting%20Tool.docm|UserGuide]]
Import the report in SAP Business One with the //Report and Layout Import Wizard//. Select //‘Inventory > Inventory Reports’// as the location.
{{ :implementation:scan:custom:print:print_layout_importlayout.png |Import the report}}
To see the details of the report, open the Report and Layout Manager and select the report from the Inventory Reports. The report ID will identify the report in the user queries.
{{ :implementation:scan:custom:print:print_layout_reportid.png |Report and layout manager}}
=====7.1.2. Examples=====
**Example 1:**
//Add customization on the ''Done'' button event for the Create GR PO screen//
Create the user Query in the Query Manager. The name of the user query must be the name of the Produmex Scan event.
Include the report ID and the report parameters in the user query.
{{ :implementation:scan:custom:print:print_layout_cr.png |Report parameters}}
Query name: //BXMobileWH9_CreateGoodsReceiptPOQuantitiesNormalScreen_OK_clicked// \\
Example query:
SQL
SELECT
'RCRI0012' "PrintLayout$",
SUBSTRING ($[TextItem], 1 , CHARINDEX ('*', $[TextItem]) - 2 ) "Print_ItemCode",
SUBSTRING ($[TextItem], CHARINDEX ('*', $[TextItem]) + 2, LEN ($[TextItem])- CHARINDEX ('*', $[TextItem])) "Print_Item_ItemName",
'' "Print_SerialNumber",
'' "Print_BatchNumber",
$[DataRepeater.SelectedUIOnHandQuantity] "Print_Quantity",
'PDFCreator' "PrintPrinter$",
'Document PRINTING' "Message$", 'I' "MessageType$"
HANA
SELECT
'RCRI0012' "PrintLayout$",
SUBSTRING ($[TextItem] , 1 , LOCATE ($[TextItem], '*') - 2 ) "Print_ItemCode",
SUBSTRING ($[TextItem], LOCATE ($[TextItem], '*') + 2, LENGTH ($[TextItem])- LOCATE ($[TextItem], '*') ) "Print_Item_ItemName",
'' "Print_SerialNumber",
'' "Print_BatchNumber",
$[DataRepeater.SelectedUIOnHandQuantity] "Print_Quantity",
'PDFCreator' "PrintPrinter$",
'Document PRINTING' "Message$", 'I' "MessageType$"
FROM DUMMY
The user query does the following: \\
Sets the parameters of the selected report to the values entered on the screen and sends it to the defined printer. Then displays the ‘Document printing’ message.
Report parameters in the example:
* Item code and name
* On hand quantity
* Batch number
* Serial number
Adjust the example query.
* Replace the //PrintLayout$// value with the Report ID (in the example the report ID is RCRI0012). \\
* Replace the //PrintPrinter$// value with your printer name (in the example the printer name is PDFCreator).
The label will be printed with the printer set in the user query regardless of the default printer of the employee.
By default only one label is printed. Adjust the value of the labels with the //PrintCopies$// parameter. \\
The label is printed after the ‘Done’ button is pressed on the Create GR PO Quantities screen.
{{ :implementation:scan:custom:print:print_layout_done.png |Printing}}
\\
**Example 2:** //Print label for the delivery selected on the Delivery field after the report ID is added on the Packing screen//
Add a new custom //‘Label’// field. Insert the following record to the [[implementation:scan:customizationtechnology|Customization Fields user table]]:
^Field Name^Labels^Screen^
|RPTCode|Label|PackingScreen|
Create two new user queries in the Query Manager.
The first query will trigger the printing if the Label field is not empty. Link this user query to the RPTCode field validation event. \\
After the report ID is added to the field, a confirmation message will pop up. Press the ''Yes'' button to print the label.
Query name: //BXMobileWH9_PackingScreen_RPTCode_validate//
IF $[RPTCode]<>'' AND $[TextDeliveryDocNum]<>''
SELECT
'Print labels: ' + $[RPTCode] AS 'Message$',
'YM' AS 'MessageType$'
{{ :implementation:scan:custom:print:print_label.png |Printing message}}
The second query will define the printer and the report parameter values. \\
Link this user query to the //validation_after// event of the custom Label field. The query will run if the user presses the ‘Yes’ button on the confirmation message screen.
Query name: //BXMobileWH9_PackingScreen_RPTCode_validate_after//
IF $[RPTCode]<>'' AND $[TextDeliveryDocNum]<>''
SELECT $[RPTCode] AS PrintLayout$,
(SELECT DocEntry FROM ODLN WHERE DocNum=$[TextDeliveryDocNum]) AS [Print_DocKey@],
'PDFCreator' AS PrintPrinter$,
'Report print: '+ $[RPTCode] AS 'Message$', 'I' AS 'MessageType$'
Replace the //PrintPrinter$// value with your printer name (in the example the printer name is PDFCreator).