///
/// Vendor payment Emails Code
///
class OABPostEmail
{
///
/// VemdEmailID
///
/// VemdEmailID
/// Email
static LogisticsElectronicAddressLocator VendEmailId(VendAccount _vendAccount)
{
VendTable vendTable;
DirPartyTable partyTable;
LogisticsElectronicAddress logisticsElectronicAddress;
select Firstonly AccountNum ,party from vendTable where vendTable.AccountNum==_vendAccount
join Name,RecId from partyTable where partyTable.RecId==vendTable.Party
join Locator from logisticsElectronicAddress where logisticsElectronicAddress.RecId==partyTable.PrimaryContactEmail;
return logisticsElectronicAddress.Locator;
}
static InvoiceId VendSettleAmountInvoice(RecId _recId)
{
VendSettlement vendSettlement;
// Str1260 body;
InvoiceId invoiceId;
while select vendSettlement
where vendSettlement.TransRecId == _recId
{
invoiceId = vendSettlement.displayInvoiceId() ;
}
return invoiceId;
}
static AmountMST SettleAmountMST(RecId _recId)
{
VendSettlement vendSettlement;
// Str1260 body;
AmountMST amountMST;
while select vendSettlement
where vendSettlement.TransRecId == _recId
{
amountMST = vendSettlement.SettleAmountMST ;
}
return amountMST;
}
///
/// VendSettleAmountMST
///
/// VendSettleAmountMST
/// Body
static Str1260 VendSettleAmountMST(RecId _recId)
{
VendSettlement vendSettlement;
Str1260 body;
while select vendSettlement
where vendSettlement.TransRecId == _recId
{
body = strFmt("@OAB:OABVendEmailInvoice",vendSettlement.displayInvoiceId(), vendSettlement.SettleAmountMST);
}
return body;
}
///
/// Vendor payment Emails Code
///
/// Current Date
static void sendMail(TransDate _FromDate)
{
Str1260 body,Tbody;
SysEmailParameters EmailParameters = SysEmailParameters::find();
DirPartyTable partyTable;
VendTable vendTable;
VendTrans vendTrans;
VendAccount localvendAccount;
FromDate fromdate = _FromDate;
LogisticsElectronicAddress logisticsElectronicAddress;
SysMailerMessageBuilder mailer;
VendTrans vendTransGroup;
VendSettlement vendSettlementGroup;
boolean isinLoop;
while select AccountNum,RecId from vendTransGroup group by AccountNum,RecId
join RecId from vendSettlementGroup
where vendSettlementGroup.TransRecId==vendTransGroup.RecId &&
vendTransGroup.TransDate==fromdate
{
isinLoop = true;
if (localvendAccount != vendTransGroup.AccountNum)
{
if(localvendAccount!=null)
{
mailer.setBody(tbody,true) ;
SysMailerFactory::getNonInteractiveMailer().sendNonInteractive(mailer.getMessage()) ;
body ='';
}
str emails = OABPostEmail::VendEmailId(vendTransGroup.AccountNum);
mailer = new SysMailerMessageBuilder();
mailer.setFrom(EmailParameters.SMTPUserName);
mailer.addTo(emails);
mailer.setSubject(strFmt("@OAB:OABVendEmailSubject",OABPostEmail::VendAccountNum(vendTransGroup.AccountNum), OABPostEmail::VendAccountName(vendTransGroup.AccountNum)));
Tbody = strFmt(" %1:-   %2
", OABPostEmail::VendAccountNum(vendTransGroup.AccountNum), OABPostEmail::VendAccountName(vendTransGroup.AccountNum));
Tbody = "
Payment Date | Payment Amount | Settled Against Invoice Number | Settlement Amount Against Invoice Value |
---|
";
select firstonly AccountNum,TransDate,AmountMST from vendTrans where vendTrans.AccountNum==vendTransGroup.AccountNum && vendTrans.RecId==vendTransGroup.RecId;
Tbody = strFmt("
",vendTrans.TransDate,vendTrans.AmountMST,OABPostEmail::VendSettleAmountInvoice(vendTransGroup.RecId),OABPostEmail::SettleAmountMST(vendTransGroup.RecId));
}
else
{
select firstonly AccountNum,TransDate,AmountMST from vendTrans where vendTrans.AccountNum==vendTransGroup.AccountNum && vendTrans.RecId==vendTransGroup.RecId;
Tbody = strFmt("
",vendTrans.TransDate,vendTrans.AmountMST,OABPostEmail::VendSettleAmountInvoice(vendTransGroup.RecId),OABPostEmail::SettleAmountMST(vendTransGroup.RecId));
}
localvendAccount = vendTransGroup.AccountNum;
}
if (isinLoop)
{
mailer.setBody(Tbody,true) ;
SysMailerFactory::getNonInteractiveMailer().sendNonInteractive(mailer.getMessage()) ;
}
}
}

Here For Same Payment Amount there Are two Invoices and two settlement Amount but with my code here it is showing only one
according to need , second row should also come with same date and payment amount but other invoice and settlement amount. Cant understand how to do that Fyi printing rows Data in Line 113 using tbody .there are two fields from amountmst and transdate from vendtrans and other two fields from vendsettlement table calling in 113 using a static function i.e vendsettleAmountInvoice and vendsettleamount