Вы находитесь на странице: 1из 4

Manage printer settings for SSRS Report in AX 2012

JULY 1, 2013MARTINABERGAMO SSRS REPORTS 6 COMMENTS


Goal: how to manage the printer settings for reports in AX 2012.
The following example is based on the new report Quality Orders in the Invent Mo
dule.
STEP 1
Create the SSRS Report
Report name: InventQualityOrder
Contract name: InventQualityOrderTableContract
Controller name: InventQualityOrderTableController
STEP 2
Add new values to the BaseEnums:
PrintMgmtNodeType; add QualityOrders
PrintMgmtDocumentType; add QualityOrders
STEP 3
Create an extension of the PrintMgmtNode class:

public class PrintMgmtNode_QualityOrder extends PrintMgmtNode
public List getDocumentTypes()
{
List docTypes = new List(Types::Enum);

docTypes.addEnd(PrintMgmtDocumentType::QualityOrders);

return docTypes;
}

public RefTableId getReferencedTableId()
{
return tablenum(InventQualityOrderTable);
}
STEP 4
Modify the following classes:
PrintMgmtNode
1) Add the following code to the method construct:
case PrintMgmtNodeType::QualityOrdersWCH:
return new PrintMgmtNode_QualityOrderWCH();
A PrintMgmtNode class defines a level at which Print Management information can
be associated.
PrintMgmtDocType
1) Method getDefaultReportFormat()
case PrintMgmtDocumentType::QualityOrders:
return ssrsReportStr(InventQualityOrder, Report);
2) Method getQueryRangeFields()
case PrintMgmtDocumentType::QualityOrders:
fields.addEnd(fieldNum(InventQualityOrderTable, QualityOrderId));
break;
3) Method getQueryTableId()
case PrintMgmtDocumentType::QualityOrders:
tableId = tableNum(InventQualityOrderTable);
break;
The PrintMgmtDocType class represents the document types that are available in p
rint management.
PrintMgmtHierarchy_Invent
1) Method getNodesImplementation()
supportedNodes.addEnd(PrintMgmtNodeType::QualityOrders);
2) Method getParentImplementation()
case PrintMgmtNodeType::QualityOrders:
result.parmReferencedTableBuffer(null);
result.parmNodeDefinition(PrintMgmtNode::construct(PrintMgmtNodeType::Invent));
break;
PrintMgmtNode_Invent
1) Method getDocumentTypes()
docTypes.addEnd(PrintMgmtDocumentType::QualityOrders);
The PrintMgmtNode_Invent class is responsible for managing print management sett
ings at the module level in the inventory module. Add the new document type in t
he method getDocumentTypes().
STEP 5
Create an extension of the FormLetterReport class:
class InventFormLetterReport_QualityOrder extends FormLetterReport
{
InventTransType transType;
}

protected container getDefaultPrintJobSettings(PrintSetupOriginalCopy _printCopy
Original)
{
return new PrintJobSettings().packPrintJobSettings();
}

protected PrintMgmtDocumentType getPrintMgmtDocumentType()
{
return PrintMgmtDocumentType::QualityOrders;
}

protected PrintMgmtHierarchyType getPrintMgmtHierarchyType()
{
return PrintMgmtHierarchyType::Invent;
}

protected PrintMgmtNodeType getPrintMgmtNodeType()
{
return PrintMgmtNodeType::QualityOrders;
}
STEP 6
Modify the FormLetterReport class:
1) Method construct()
case PrintMgmtDocumentType::QualityOrders:
return new InventFormLetterReport_QualityOrder();
The FormLetterReport class controls the printing of documents.
STEP 7
Create the controller, which extends the TradeDocumentReportController class, wh
ich allows to manage multiple prints.

The following dialog aims to provide the possibility to choose printer settings
that are different from the ones defined in the standard configuration (Inventor
y and warehouse management > Setup > Inventory and warehouse management paramete
rs > Print management):

The dialog offers two scenarios:
- Use print management destination is flagged in this case the system takes the se
ttings from Inventory and warehouse management parameters
- Otherwise, the system takes the printer settings from the dialog (Current print
destination).

In any case, it is necessary to overwrite the following methods in the controlle
r:

initFormLetterReport()
protected void initFormLetterReport()
{
printCopyOriginal = this.parmArgs().parmEnum();

this.initializeJournalLists(this.parmArgs());

formLetterReport = FormLetterReport::construct(PrintMgmtDocumentType::Qualit
yOrders);

formLetterReport.parmPrintType(printCopyOriginal);

if (printCopyOriginal == PrintCopyOriginal::OriginalPrint)
{
// Always use the print mgmt destinations when reprinting for the Origin
alPrint case.
formLetterReport.parmUsePrintMgmtDestinations(true);
}

super();
}

output()
This method is called from the runPrintManagement method, for every selected jou
rnal.
protected void output()
{
InventQualityOrderTableContractWCH rdpContract = this.parmReportContract().p
armRdpContract() as InventQualityOrderTableContractWCH;

//If the flag is not set, I set the current print destination in case of ori
ginal/copy printing
if (!rdpContract.parmUsePrintManagementSettings())
{
formLetterReport.parmDefaultCopyPrintJobSettings(this.parmReportContract
().parmPrintSettings()); formLetterReport.parmDefaultOriginalPrintJobSettings(th
is.parmReportContract().parmPrintSettings());
formLetterReport.parmUsePrintMgmtDestinations(false);
}

// load the new setup for printing the report
formLetterReport.loadPrintSettings(inventQualityOrderTable, inventQualityOrde
rTable, CompanyInfo::languageId());
this.parmReportContract().parmRdlContract().parmLanguageId(CompanyInfo::langu
ageId());

super();
}