To show a message in
infolog, use methods error(), warning() and info() - e.g. error("Something is wrong") or warning("@SYS116847"). You may also need strFmt() to format the string.
If
you want to throw an exception,
simply put "throw" before error(),
e.g. throw error("@SYS84785").
throw error("Excise
warehouse does not exist in warehouse master.");
info(strFmt("@DMS2535",purchTable.PurchId));
info('An error occurred while creating PO. Please contact
Helpdesk.');
poStagingErrorTable.ErrorLog = strFmt("%1 %2", execDateTime,strRem(infolog.text(infologLine()),'\t'));
poStagingErrorTable.update();
//-------------------------
public static void maintainLog(Name _legacyReferenceNo, infoLogData _infoLogData = [""])
{
PartnerCreationRequestTableLog partnerCreationRequestTableLog;
SysInfoLogEnumerator infoLogEnum;
str exceptionMessage;
SysInfologMessageStruct infoMessageStruct;
;
ttsBegin;
partnerCreationRequestTableLog.LegacyReferenceNo = _legacyReferenceNo;
partnerCreationRequestTableLog.LogRemarks = _infoLogData;
infoLogEnum = SysInfoLogEnumerator::newData(_infoLogData);
while(infoLogEnum.moveNext())
{
infoMessageStruct = SysInfologMessageStruct::construct(infoLogEnum.currentMessage());
exceptionMessage += infoMessageStruct.message() + ',';
}
partnerCreationRequestTableLog.RequestRemarks = exceptionMessage;
partnerCreationRequestTableLog.insert();
ttsCommit;
}
//-----------------------------
private void processData()
{
#OCCRetryCount
System.Exception ex; //to handle exception
try
{
this.getDataForDealerFromSql();
}
catch(Exception::Error)
{
if(appl.ttsLevel() >1)
{
ttsAbort;
}
DealerCreationUpdationRequestBatch::maintainLog(resultset.getString(4),infolog.cut());
info('Dealer Creation/Updation Request Creation fail');
}
catch(Exception::Deadlock)
{
retry;
}
catch (Exception::UpdateConflict)
{
if (appl.ttsLevel() == 0)
{
if (xSession::currentRetryCount() >= #RetryNum)
{
throw Exception::UpdateConflictNotRecovered;
}
else
{
retry;
}
}
else
{
throw Exception::UpdateConflict;
}
}
catch (Exception::CLRError)//N - system.exception declared on top of this method
{
ex = CLRInterop::getLastException();
if(ex != null)
{
ex = ex.get_InnerException();
if(ex != null)
{
error(strFmt('CLR Error : %1',ex.ToString()));
DealerCreationUpdationRequestBatch::maintainLog(resultset.getString(4),infolog.cut());
info('Dealer Creation/Updation Request Creation fail');
}
}
}
}
//-------------------------------------
public void
process()
{
SHEQARCOMSalesOrderHeader
headerCompany;
str message;
while select
headerCompany
group by
headerCompany.Company, headerCompany.ProcessStatus
where
headerCompany.ProcessStatus == SHProcessStatus::NotProcessed
{
changeCompany(headerCompany.Company)
{
SHEQARCOMSalesOrderHeader header;
header.clear();
while select forupdate header
where
header.Company ==
headerCompany.Company
&&
header.ProcessStatus == SHProcessStatus::NotProcessed
{
try
{
ttsbegin;
message = this.checkValidate(header);
if(message != "")
{
header.ProcessStatus = SHProcessStatus::Error;
header.LogMessage = message;
header.update();
ttscommit;
continue;
}
//Create Header
SalesTable
salesHeader = this.createSalesHeader(header);
//Create Lines
this.createSalesLine(salesHeader);
// Confirm
this.salesConfirmation(salesHeader);
// Invoice
this.salesInvoice(salesHeader,header);
CustInvoiceJour
custInvJourNew;
select firstonly
custInvJourNew where custInvJourNew.SalesId ==
salesHeader.SalesId;
// Auto Settlement
if(header.CreditNote
== NoYes::Yes && header.OriginalInvoice)
{
CustInvoiceJour
custInvJourOld;
select firstonly
custInvJourOld where
custInvJourOld.InvoiceId == header.OriginalInvoice;
SHEQARCOMSalesInvoiceProcessService::AutoSettlement(custInvJourOld,
custInvJourNew);
}
if (custInvJourNew)
{
header.CustInvoiceId =
custInvJourNew.InvoiceId;
header.SalesStatus = SalesStatus::Invoiced;
header.ProcessStatus = SHProcessStatus::Processed;
header.InvoiceJourAmount = custInvJourNew.InvoiceAmount;
header.LogMessage = "@YTEQAR:SH_SOCreatedInvoicedSuccessfully";
header.update();
}
ttscommit;
SalesTable
SalesTableloc;
select forupdate
SalesTableloc
where SalesTableloc.SalesId == salesHeader.SalesId;
if(SalesTableloc.RecId)
{
ttsbegin;
SalesTableloc.selectForUpdate(true);
SalesTableloc.SHInvoiceId = custInvJourNew.InvoiceId;
SalesTableloc.doUpdate();
ttscommit;
}
}
catch(Exception::Error)
{
ttsabort;
ttsBegin;
header.LogMessage="";
SysInfologEnumerator
sysInfologEnumerator = SysInfologEnumerator::newData(infolog.infologData());
while
(sysInfologEnumerator.moveNext())
{
header.LogMessage +=
strFmt("%1",
sysInfologEnumerator.currentMessage());
}
header.ProcessStatus = SHProcessStatus::Error;
header.update();
Info(strFmt("@YTEQAR:SH_ErrorOccurredforInvoice",header.InvoiceId));
ttsCommit;
}
catch(Exception::CLRError)
{
ttsabort;
ttsBegin;
header.LogMessage="";
SysInfologEnumerator
sysInfologEnumerator = SysInfologEnumerator::newData(infolog.infologData());
while
(sysInfologEnumerator.moveNext())
{
header.LogMessage +=
strFmt("%1",
sysInfologEnumerator.currentMessage());
}
header.ProcessStatus = SHProcessStatus::Error;
header.update();
Info(strFmt("@YTEQAR:SH_ErrorOccurredforInvoice",header.InvoiceId));
ttsCommit;
}
}
}
}
}