passing string255 value from Form to the class as
PaymentAdviceSettlementEmail.parmSpecTransRecIdRange(orgRange);
PaymentAdviceSettlementEmail.run();
.................................................................................................................................
class PaymentAdviceSettlementEmail extends RunBaseBatch
{
String255 recIdRange;
}
............
public void deleteReportFile(str _reportPath)
{
if(!_reportPath)
warning('No file in local to remove');
else
System.IO.File::Delete(@_reportPath);
}
..................
private Integer fileSizeInByte(FilePath _filePath)
{
return WinAPI::filesize(_filePath);
}
.........................
Public void parmSpecTransRecIdRange(String255 _range)
{
recIdRange = _range;
}
.............
public NoYesBlank PaymentAdviceEmail(String255 _specTrans)
{
str ccsMailAddr,specRecId;
int64 specRecIdInt;
SpecTrans specTrans;
VendTable vendTable;
VendTrans vendTrans;
Map parameterMap = new Map(Types::String, Types::String);
Email requester;
FilenameOpen attachmentFilename;
LogisticsElectronicAddress logisticsElectronicAddress;
DirPartyLocation dirPartyLocation;
VendPurchOrderJour vendPurchOrderJour;
;
attachmentFilename = this.runAndSaveSSRSReport(_specTrans);
specRecId = subStr(_specTrans,1,10);
specRecIdInt = str2int64(specRecId);
select specTrans where specTrans.RecId == specRecIdInt;
select vendTable where vendTable.dataAreaId == specTrans.SpecCompany && vendTable.TableId == specTrans.SpecTableId && vendTable.RecId == specTrans.SpecRecId;
select RecId from dirPartyLocation
where dirPartyLocation.Party == VendTable::find(vendTable.AccountNum).Party
join logisticsElectronicAddress
where logisticsElectronicAddress.Location == dirPartyLocation.Location &&
logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Email &&
logisticsElectronicAddress.EcomEmailType == EcomEmailType::PaymentAdvice;
if (logisticsElectronicAddress.Locator)
{
requester = logisticsElectronicAddress.Locator;
}
else
{
requester = LogisticsElectronicAddress::findRecId(DirPartyTable::findRec(
VendTable::find(vendTable.AccountNum).Party).PrimaryContactEmail).Locator;
}
select vendTrans where vendTrans.AccountNum == vendTable.AccountNum;
parameterMap.insert('VendorName', VendTable::find(vendTable.AccountNum).name());
parameterMap.insert('VendorCode', vendTable.AccountNum);
//parameterMap.insert('InvoiceDate', date2str(vendTrans.TransDate, 123, 2, DateSeparator::Slash, 2, DateSeparator::Slash, 4,DateFlags::None));
ccsMailAddr = SysEmailTable::find(VendParameters::find().EcomPayAdviceEmailId).EcomReceiverCCs;
try
{
SysEmailTable::sendMail(VendParameters::find().EcomPayAdviceEmailId, SysEmailTable::find(VendParameters::find().EcomPayAdviceEmailId).DefaultLanguage,
requester, parameterMap, attachmentFilename, '', true, curUserId(), true, strLTrim(strRTrim(ccsMailAddr)),
BaseEmailDocument::PaymentAdvice,"");
this.deleteReportFile(attachmentFilename);
}
catch
{
throw Error('Unable to send the E-mail.');
}
return NoYesBlank::Yes;
}
////////////////////////////////////////////////////////////////
public void run(Args _args = null)
{
this.PaymentAdviceEmail(recIdRange);
}
......................................
public str runAndSaveSSRSReport(String255 _specTrans)
{
str reportPath, attachmentFolder;
SrsReportRunController ssrsController = new SrsReportRunController();
Alle_PaymentAdviceVendContract contract = new Alle_PaymentAdviceVendContract();
SRSPrintDestinationSettings printerSettings;
;
attachmentFolder = SysEmailParameters::find().AttachmentsPath;
reportPath = attachmentFolder + "\\" + "PaymentAdvice" +'.pdf';
ssrsController.parmReportName(ssrsReportStr(Alle_PaymentAdviceVendReport, PaymentAdviceVendReport));
ssrsController.parmExecutionMode(SysOperationExecutionMode::Synchronous);
ssrsController.parmShowDialog(false);
contract.parmString(_specTrans);
ssrsController.parmReportContract().parmRdpContract(contract);
//link the printer settings to the controller
printerSettings = ssrsController.parmReportContract().parmPrintSettings();
//print to pdf and always overwrite if the file exists
printerSettings.printMediumType(SRSPrintMediumType::File);
printerSettings.fileFormat(SRSReportFileFormat::PDF);
printerSettings.overwriteFile(true);
printerSettings.fileName(@ReportPath);
//run & save the report
ssrsController.runReport();
if ((SysEmailParameters::find().EcomCheckPDFMinSize == NoYes::Yes) && (this.fileSizeInByte(@ReportPath) < SysEmailParameters::find().EcomMinPDFSize))
throw error('Please check the report manually.');
return reportPath;
}
..................................................
server static ALE_PaymentAdviceSettlementEmail construct()
{
return new ALE_PaymentAdviceSettlementEmail();
}
..................................
static void main(Args _args)
{
ALE_PaymentAdviceSettlementEmail paymentAdviceSettlementEmail = new ALE_PaymentAdviceSettlementEmail();
if (paymentAdviceSettlementEmail.prompt())
{
paymentAdviceSettlementEmail.run(_args);
}
}
.............................................
now report classess
[DataContractAttribute]
class PaymentAdviceVendContract
{
String255 settleRecId;
}
....................
public String255 parmString(String255 _settleRecId = settleRecId)
{
settleRecId = _settleRecId;
return settleRecId;
}
.......................
[
SRSReportParameterAttribute(classStr(PaymentAdviceVendContract))
]
class Alle_PaymentAdviceVendDP extends SrsReportDataProviderPreProcessTempDB
{
TransDate fromDate,toDate;
VendAccount vendorAccount;
PaymentAdviceVendTmp PaymentAdviceVendTmp;2018
}
/..............................
[
SRSReportDataSetAttribute(tableStr(PaymentAdviceVendTmp))
]
public aymentAdviceVendTmp getPurchaseRegisterTmp()
{
select PaymentAdviceVendTmp;
return PaymentAdviceVendTmp;
}
...............
/
[
SysEntryPointAttribute(false)
]
public void processReport()
{
SpecTrans specTrans;
container convertStr2Int64;
String255 settledRedIdLoc;
int64 settleRecIdLoc,settleRecIdRange;
int i;
PaymentAdviceVendContract paymentAdviceVendContract;
paymentAdviceVendContract = this.parmDataContract() as PaymentAdviceVendContract;
settledRedIdLoc = paymentAdviceVendContract.parmString();
convertStr2Int64 = str2con(settledRedIdLoc,",",true);
for(i=1;i <= conlen(convertStr2Int64); i++)
{
settleRecIdRange = conpeek(convertStr2Int64, i);
if(settleRecIdRange)
{
while select specTrans where specTrans.RecId == settleRecIdRange
{
this.insertTmpTable(specTrans);
}
}
}
}
.............................
private void insertTmpTable(SpecTrans _spectrans)
{
VendTransOpen vendtransopen;
VendTrans vendTrans;
BankAccountTrans bankAccountTrans;
select firstOnly RefRecId, AccountNum, AmountCur, TDSAmount_IN from vendtransopen
where vendtransopen.TableId == _spectrans.RefTableId && vendtransopen.RecId == _spectrans.RefRecId;
select firstOnly Voucher, AccountNum, Invoice, CurrencyCode from vendTrans
where vendTrans.RecId == vendtransopen.RefRecId && vendTrans.AccountNum == vendtransopen.AccountNum;
select firstOnly AccountId from bankAccountTrans
where bankAccountTrans.Voucher == vendTrans.Voucher;
PaymentAdviceVendTmp.Voucher = vendTrans.Voucher;
PaymentAdviceVendTmp.insert();
}
...............................................................................................................
Controller class
public class PaymentAdviceVendController extends SrsReportRunController
{
Map SpecTransRecId;
String255 recIdRange;
MapEnumerator mapEnumerator;
#define.ReportName('PaymentAdviceVendReport.PaymentAdviceVendReport')
}
......................
Public void parmSpecTransRecIdRange(String255 _range)
{
recIdRange = _range;
}
....
...
protected void prePromptModifyContract()
{
//this.setRanges(this.parmReportContract().parmQueryContracts().lookup(this.getFirstQueryContractKey()));
this.setRanges(this.getFirstQuery());
}
.......
protected void preRunModifyContract()
{
#ISOCountryRegionCodes
SrsReportDataContract contract;
contract = this.parmReportContract() as SrsReportDataContract;
}
...
public void ReportRun(String255 _rangeLoc)
{
Alle_PaymentAdviceVendController controller = new Alle_PaymentAdviceVendController();
controller.parmReportName('Alle_PaymentAdviceVendReport.PaymentAdviceVendReport');
recIdRange = _rangeLoc;
controller.parmSpecTransRecIdRange(recIdRange);
controller.parmShowDialog(false);
controller.startOperation();
}
....
public void setRanges(Query _query)
{
QueryBuildDataSource qbds;
QueryBuildRange qbr;
qbds = _query.dataSourceTable(tableNum(SpecTrans));
qbds.clearRanges();
qbr = qbds.addRange(fieldNum(SpecTrans, RecId));
qbr.value(recIdRange);
}
...
/// <summary>
/// Sets the report query ranges based on the caller.
/// </summary>
/// <param name="_query">
/// The hold the <c>Query</c> object of the report.
/// </param>
public void setRangesNew(Query _query)
{
QueryBuildDataSource qbds;
VendTrans vendTrans;
FormDataSource fds;
Set s;
;
qbds = _query.dataSourceTable(tablenum(VendTrans));
while (qbds.findRange(fieldNum(VendTrans, RecId)))
{
qbds.clearRange(fieldNum(VendTrans, RecId));
}
if (this.parmArgs())
{
vendTrans = this.parmArgs().record();
if (vendTrans.isFormDataSource() && vendTrans.dataSource())
{
s = new Set(Types::Int64);
fds = vendTrans.dataSource(); // guaranteed to exist
for (vendTrans = fds.getFirst(fds.anyMarked()); vendTrans; vendTrans = fds.getNext())
{
if (!s.in(vendTrans.RecId)) // check if ProdId already exists in set
{
qbds.addRange(fieldNum(vendTrans, RecId)).value(int642str(vendTrans.RecId));
s.add(vendTrans.RecId);
}
}
}
else
{
qbds.addRange(fieldNum(VendTrans, RecId)).value(int642str(vendTrans.RecId));
}
}
}
.................................................................
public static void main(Args _args)
{
Alle_PaymentAdviceVendController controller = new Alle_PaymentAdviceVendController();
controller.parmReportName('Alle_PaymentAdviceVendReport.PaymentAdviceVendReport');
controller.parmArgs(_args);
controller.parmShowDialog(false);
controller.startOperation();
}
....................................................