[CMR RDP] RDP Report CMR, multilanguage, printSettings, prePromtModifyContract, preRunModifyContract, runPrintMgnt #rdp #report #multilanguage
[DataContractAttribute]
public class A_TMSCMRContract
{
RecId recId;
PrintMgmtIdentificationTxt printMgmtIdentificationTxt;
String255 documentTitle;
recId recordId;
}
[DataMemberAttribute('DocumentTitle')]
public String255 parmDocumentTitle(String255 _documentTitle = documentTitle)
{
documentTitle = _documentTitle;
return documentTitle;
}
[
DataMemberAttribute('IdentificationText')
]
public PrintMgmtIdentificationTxt parmIdentificationText(PrintMgmtIdentificationTxt _value = printMgmtIdentificationTxt)
{
printMgmtIdentificationTxt = _value;
return printMgmtIdentificationTxt;
}
[DataMemberAttribute('RecordId')]
public recId parmRecordId(recId _recordId = recordId)
{
recordId = _recordId;
return recordId;
}
public class A_TMSCMRController extends SrsPrintMgmtController
{
A_TMSCMRTable a_TMSCMRTable;
A_TMSCMRContract contract;
PrintCopyOriginal printCopyOriginal;
recId recId;
PrintMgmtIdentificationTxt identificationTxt;
}
protected str documentTitle()
{
str docTitleTxt;
docTitleTxt = literalStr("@RDX293");
return docTitleTxt;
}
private void getPrintSettings(PrintMgmtDocInstanceType _printMgmtDocInstanceType = PrintMgmtDocInstanceType::Copy)
{
PrintMgmtSettings printMgmtSettings;
PrintMgmtDocInstance printMgmtDocInstance;
PrintMgmtReportFormat printMgmtReportFormat;
SRSPrintDestinationSettings srsPrintDestinationSettings;
select * from printMgmtReportFormat
where printMgmtReportFormat.Name == this.parmReportName()
outer join * from printMgmtDocInstance
where printMgmtDocInstance.DocumentType == PrintMgmtDocumentType::A_CMR
&& printMgmtDocInstance.PrintType == _printMgmtDocInstanceType
outer Join * from printMgmtSettings
where printMgmtSettings.ReportFormat == printMgmtReportFormat.RecId &&
printMgmtSettings.ParentId == printMgmtDocInstance.RecId;
if(_printMgmtDocInstanceType == PrintMgmtDocInstanceType::Copy)
{
srsPrintDestinationSettings = new SRSPrintDestinationSettings(printMgmtSettings.PrintJobSettings);
srsPrintDestinationSettings.numberOfCopies(printMgmtSettings.NumberOfCopies);
printMgmtReportRun.parmDefaultCopyPrintJobSettings(srsPrintDestinationSettings);
}
else
{
srsPrintDestinationSettings = new SRSPrintDestinationSettings(printMgmtSettings.PrintJobSettings);
srsPrintDestinationSettings.numberOfCopies(printMgmtSettings.NumberOfCopies);
printMgmtReportRun.parmDefaultOriginalPrintJobSettings(srsPrintDestinationSettings);
}
//CUP Model.sn by AH on 19/09/2018 - ALT_DR_289_CMR_Layout - start
//contract.parmIdentificationText(PrintMgmtIdentificationText::find(printMgmtSettings.RecId, a_TMSCMRTable.LanguageId).IdentificationText);
contract.parmIdentificationText(PrintMgmtIdentificationText::find(printMgmtSettings.RecId, a_TMSCMRTable.reportLanguage()).IdentificationText);
//CUP Model.sn by AH on 19/09/2018 - ALT_DR_289_CMR_Layout - end
identificationTxt = contract.parmIdentificationText();
}
protected recId getRecordId()
{
return a_TMSCMRTable.RecId;
}
protected void initPrintMgmtReportRun()
{
printMgmtReportRun = PrintMgmtReportRun::construct(PrintMgmtHierarchyType::TMS,
PrintMgmtNodeType::A_CMR,
PrintMgmtDocumentType::A_CMR);
printMgmtReportRun.parmReportRunController(this);
recId = a_TMSCMRTable.RecId;
}
public void loadPrintSettings(Common _jourTable, Common _transTable, str _languageId, str _documentKeyValue = '')
{
boolean isValidReference(Common _referencedTableBuffer)
{
PrintMgmtNodeInstance nodeInstance = new PrintMgmtNodeInstance();
nodeInstance.parmNodeDefinition(PrintMgmtNode::construct(PrintMgmtNodeType::A_CMR));
nodeInstance.parmReferencedTableBuffer(_referencedTableBuffer);
return nodeInstance.isValidReference();
}
void setSettingDetail(PrintMgmtDocInstanceType _type, SRSPrintDestinationSettings _defaultSettings)
{
PrintMgmtPrintSettingDetail printSettingDetail = new PrintMgmtPrintSettingDetail();
printSettingDetail.parmReportFormatName(PrintMgmtReportFormat::findSystem(PrintMgmtDocumentType::A_CMR).Name);
printSettingDetail.parmType(_type);
printSettingDetail.parmInstanceName(enum2str(_type));
// Since this will be reported to the screen, one copy is the only thing that makes sense
//printSettingDetail.parmNumberOfCopies(1);
printSettingDetail.parmPrintJobSettings(_defaultSettings);
printSettingDetail.parmNumberOfCopies(_defaultSettings.numberOfCopies());
printMgmtReportRun.loadSettingDetail(printSettingDetail, _documentKeyValue);
this.parmReportContract().parmRdpContract().parmIdentificationText(printSettingDetail.parmIdentificationText());
}
if (printCopyOriginal == PrintCopyOriginal::OriginalPrint && isValidReference(_transTable))
{
// Print an original
printMgmtReportRun.load(_jourTable, _transTable, _languageId, _documentKeyValue);
}
else if (printCopyOriginal == PrintCopyOriginal::Copy)
{
// Print a copy
setSettingDetail(PrintMgmtDocInstanceType::Copy, printMgmtReportRun.parmDefaultCopyPrintJobSettings());
}
else
{
// Print an original. We also default to print one original when we are trying to
// print using Print Mgmt information, but don't have a valid table reference.
// This covers the reprint case where the original transaction record may not be present.
setSettingDetail(PrintMgmtDocInstanceType::Original, printMgmtReportRun.parmDefaultOriginalPrintJobSettings());
}
if (!printMgmtReportRun.more())
{
checkFailed("@SYS78951");
}
}
protected void outputReport()
{
A_TMSCMRContract ctr = this.parmReportContract().parmRdpContract();
//CUP Model.sn by AH on 19/09/2018 - ALT_DR_289_CMR_Layout - start
//orig: this.parmReportContract().parmRdlContract().parmLanguageId(a_TMSCMRTable.LanguageId);
this.parmReportContract().parmRdlContract().parmLanguageId(a_TMSCMRTable.reportLanguage());
//CUP Model.sn by AH on 19/09/2018 - ALT_DR_289_CMR_Layout - end
this.parmReportContract().parmReportName(ssrsReportStr(A_TMSCMRReport, Report));
ctr.parmIdentificationText(printMgmtReportRun.settingDetail().parmIdentificationText());
super();
}
public PrintCopyOriginal parmPrintType(PrintCopyOriginal _parmPrintType = printCopyOriginal)
{
printCopyOriginal = _parmPrintType;
return PrintCopyOriginal;
}
public SRSCatalogItemName parmReportName(SRSCatalogItemName _reportName = reportName)
{
if(_reportName != reportName)
{
if(!_reportName)
{
throw error(strFmt("@SYS318601", @"_reportName"));
}
else
{
reportName = _reportName;
}
}
return reportName;
}
protected void prePromptModifyContract()
{
contract = this.parmReportContract().parmRdpContract();
//ALT_DR_178_DriverCheckInCheckOut AHI 13/09/2018 +
if (a_TMSCMRTable.RecId)
{
contract.parmRecordId(a_TMSCMRTable.RecId);
}
else
{
if (contract.parmRecordId())
{
a_TMSCMRTable = A_TMSCMRTable::findByRecId(contract.parmRecordId());
recId = a_TMSCMRTable.recid;
}
}
//ALT_DR_178_DriverCheckInCheckOut AHI 13/09/2018 -
contract.parmDocumentTitle("@RDX293");
super();
}
protected void preRunModifyContract()
{
if (!contract)
{
contract = this.parmReportContract().parmRdpContract();
}
super();
contract.parmRecordId(recId);
contract.parmDocumentTitle("@RDX293");
if (!contract.parmIdentificationText())
{
contract.parmIdentificationText(identificationTxt);
}
if (printMgmtReportRun.settingDetail() && !printMgmtReportRun.settingDetail().parmIdentificationText())
{
printMgmtReportRun.settingDetail().parmIdentificationText(identificationTxt);
}
}
/// <summary>
/// Runs the print report.
/// </summary>
protected void runPrintMgmt()
{
boolean runSucceed = true;
str errorMessage;
Common printMgmtReferencedTable;
printMgmtReportRun.parmReportRunController(this);
if (printCopyOriginal == PrintCopyOriginal::Copy)
{
this.getPrintSettings();
}
else
{
this.getPrintSettings(PrintMgmtDocInstanceType::Original);
}
if (!this.parmReportName())
this.parmReportName(ssrsReportStr(A_TMSCMRReport, Report));
if (!a_TMSCMRTable)
{
throw error("@SYS26348");
}
printMgmtReferencedTable = a_TMSCMRTable;
//CUP Model.sn by AH on 19/09/2018 - ALT_DR_289_CMR_Layout - start
//orig: this.loadPrintSettings(a_TMSCMRTable, printMgmtReferencedTable, a_TMSCMRTable.LanguageId);
this.loadPrintSettings(a_TMSCMRTable, printMgmtReferencedTable, a_TMSCMRTable.reportLanguage());
//CUP Model.sn by AH on 19/09/2018 - ALT_DR_289_CMR_Layout - end
//formLetterReport.loadPrintSettings(a_TMSCMRTable, printMgmtReferencedTable, a_TMSCMRTable.LanguageId);
try
{
this.outputReports();
}
catch (Exception::Error)
{
runSucceed = false;
errorMessage = SrsReportRunController::getErrorMessage();
error(errorMessage);
}
//super();
}
protected void setDataContractRecord(Common _common)
{
a_TMSCMRTable = _common;
recId = a_TMSCMRTable.recid;
}
public static A_TMSCMRController construct()
{
return new A_TMSCMRController();
}
public static void main(Args _args)
{
str reportName = ssrsReportStr(A_TMSCMRReport, Report);
A_TMSCMRController formLetterController = A_TMSCMRController::construct();
formLetterController.parmReportName(reportName);
formLetterController.parmArgs(_args);
formLetterController.parmPrintType(_args.parmEnum());
formLetterController.setDataContractRecord(_args.record());
formLetterController.parmShowDialog(false);
formLetterController.startOperation();
}
public static SrsReportDataContract newDataContract(Args _args)
{
A_TMSCMRController formLetterController = A_TMSCMRController::construct();
if (_args.dataset() != tableNum(A_TMSCMRTable))
{
throw error(strFmt("@SYS19306",funcName()));
}
return formLetterController.parmReportContract();
}
[
SRSReportParameterAttribute(classStr(A_TMSCMRContract))
]
public class A_TMSCMRDP extends SrsReportDataProviderPreProcess
{
A_TMSCMRTable a_TMSCMRTable;
A_TMSCMRLine a_TMSCMRLine;
A_TMSCMRHeaderTmp a_TMSCMRHeaderTmp;
A_TMSCMRDetailsTmp a_TMSCMRDetailsTmp;
CustFormletterDocument custFormletterDocument;
CustFormletterParameters custFormletterParameters;
RecId recId;
CompanyInfo companyInfo;
A_TMSCMRContract objContract;
}
[
SRSReportDataSetAttribute(tableStr(A_TMSCMRDetailsTmp))
]
public A_TMSCMRDetailsTmp getA_TMSCMRDetailsTmp()
{
select * from a_TMSCMRDetailsTmp;
return a_TMSCMRDetailsTmp;
}
[
SRSReportDataSetAttribute(tableStr(A_TMSCMRHeaderTmp))
]
public A_TMSCMRHeaderTmp getA_TMSCMRHeaderTmp()
{
select firstonly * from a_TMSCMRHeaderTmp;
return a_TMSCMRHeaderTmp;
}
[SysEntryPointAttribute]
public void processReport()
{
a_TMSCMRHeaderTmp.setConnection(this.parmUserConnection());
a_TMSCMRDetailsTmp.setConnection(this.parmUserConnection());
custFormletterDocument = CustFormletterDocument::find();
custFormletterParameters = CustFormletterParameters::find();
companyInfo = CompanyInfo::find();
objContract = this.parmDataContract() as A_TMSCMRContract;
recId = objContract.parmRecordId();
if (recId)
{
a_TMSCMRTable = A_TMSCMRTable::findByRecId(recId);
}
ttsBegin;
delete_from a_TMSCMRHeaderTmp;
delete_from A_TMSCMRDetailsTmp;
ttsCommit;
if (a_TMSCMRTable)
{
this.setA_TMSCMRHeaderTmp();
while select a_TMSCMRLine
where a_TMSCMRLine.ConsignmentNoteId == a_TMSCMRTable.ConsignmentNoteId
{
this.setA_TMSCMRDetailsTmp();
}
}
}
protected void setA_TMSCMRDetailsTmp()
{
a_TMSCMRDetailsTmp.Markings = a_TMSCMRLine.Markings;
a_TMSCMRDetailsTmp.NumberOfPackages = a_TMSCMRLine.NumberOfPackages;
a_TMSCMRDetailsTmp.Packaging = a_TMSCMRLine.Packaging;
a_TMSCMRDetailsTmp.ProductNature = a_TMSCMRLine.ProductNature;
a_TMSCMRDetailsTmp.NetWeight = a_TMSCMRLine.NetWeight;
a_TMSCMRDetailsTmp.GrossWeight = a_TMSCMRLine.GrossWeight;
a_TMSCMRDetailsTmp.Volume = a_TMSCMRLine.Volume;
a_TMSCMRDetailsTmp.insert();
a_TMSCMRDetailsTmp.clear();
}
protected void setA_TMSCMRHeaderTmp()
{
a_TMSCMRHeaderTmp.LoadId = a_TMSCMRTable.LoadId;
a_TMSCMRHeaderTmp.ConsignmentNoteId = a_TMSCMRTable.ConsignmentNoteId;
a_TMSCMRHeaderTmp.PrintMgmtIdentificationTXT = objContract.parmIdentificationText();
a_TMSCMRHeaderTmp.CMRImage = A_CompanyImageParameter::find().CMRImage();
a_TMSCMRHeaderTmp.CarrierId = a_TMSCMRTable.CarrierId;
a_TMSCMRHeaderTmp.CarrierTxt = a_TMSCMRTable.carrierTxt();
a_TMSCMRHeaderTmp.ConsignorInstruction = a_TMSCMRTable.ConsignorInstruction;
a_TMSCMRHeaderTmp.Conveyor = a_TMSCMRTable.Conveyor;
a_TMSCMRHeaderTmp.conveyorTxt = a_TMSCMRTable.conveyorTxt();
a_TMSCMRHeaderTmp.CustAccount = a_TMSCMRTable.CustAccount;
a_TMSCMRHeaderTmp.CustomerTxt = a_TMSCMRTable.customerTxt();
a_TMSCMRHeaderTmp.DeliveryPoint = a_TMSCMRTable.DeliveryPoint;
a_TMSCMRHeaderTmp.DeliveryPointTxt = a_TMSCMRTable.DeliveryPointTxt();
a_TMSCMRHeaderTmp.Incoterm = a_TMSCMRTable.Incoterm;
a_TMSCMRHeaderTmp.ParticularCondition = a_TMSCMRTable.ParticularCondition;
a_TMSCMRHeaderTmp.ShippingName = a_TMSCMRTable.ShippingName;
a_TMSCMRHeaderTmp.ShippingNameTxt = a_TMSCMRTable.shippingNameTxt();
a_TMSCMRHeaderTmp.LoadPlaceDateTxt = a_TMSCMRTable.LoadPlaceDateTxt();
a_TMSCMRHeaderTmp.unloadPlaceDateTxt = a_TMSCMRTable.unloadPlaceDateTxt();
a_TMSCMRHeaderTmp.DlvTermTxt = DlvTerm::find(a_TMSCMRTable.Incoterm).Txt;
a_TMSCMRHeaderTmp.insert();
a_TMSCMRHeaderTmp.clear();
}