Hi Andre,
No i mean i did the performance more the than once. the first two times i did it, i got no error and everything got created.
However, the third time i did it, it created let's say 80 records and it said that 4 failed with the error i showed above ( these 4 didn't get created)
1. So i got confused why would the third test fail? could it be because of my code?
Here's the code:
class XXOrderService
{
public XXResContract getDetails(XXReqContract _Ids)
{
XXDetailLineResContract responseLine;
XXResContract orderCreationResponse;
XXDetailResContract resultSet = new XXDetailResContract();
XXOrderCreationService orderCreationService = new XXOrderCreationService();
int startLine = infologLine() 1;
AmountCur total = 0;
str errorMsg;
try
{
if(_Ids)
{
orderCreationResponse = orderCreationService.createOrder(_Ids,true); // LOOK AT THIS METHOD PLEASE
if(orderCreationResponse && orderCreationResponse.ErrorCode() == null)
{
Table1 table1;
Table2 table2;
Table3 table3;
select table1 where table1.Id == orderCreationResponse.Id();
if(table1)
{
while select table2 where table2.Id == orderCreationResponse.Id()
outer join table3 where table3.Id2 == table2.Id2
{
if(lineNum != rentLine.LineNum)
{
responseLine = new XXDetailLineResContract();
responseLine.ItemId(table2.ItemId);
responseLine.Name(table2.Name);
responseLine.Qty(rentLine.Qty);
lineNum = table2.LineNum;
response.addEnd(responseLine);
}
if(table3)
{
total = (table3.Percent * table2.LineAmount)/100;
}
}
}
resultSet.DetailLineResContract(response);
resultSet.Total(total);
}
else
{
resultSet.ErrorCode(orderCreationResponse.ErrorCode());
resultSet.ErrorMessage(orderCreationResponse.ErrorMessage());
}
}
}
catch(Exception::Error)
{
resultSet = new XXDetailResContract();
errorMsg = '';
SysInfologEnumerator sysInfologEnumerator = SysInfologEnumerator::newData(infolog.copy(startLine,Global::infologLine()));
while (sysInfologEnumerator.moveNext())
{
switch (sysInfologEnumerator.currentException())
{
case Exception::Error:
errorMsg = sysInfologEnumerator.currentMessage() '\n';
break;
}
}
resultSet.ErrorCode('AX_Error');
resultSet.ErrorMessage(errorMsg);
}
catch(Exception::DuplicateKeyException)
{
resultSet = new XXDetailResContract();
errorMsg = '';
SysInfologEnumerator sysInfologEnumerator = SysInfologEnumerator::newData(infolog.copy(startLine,Global::infologLine()));
while (sysInfologEnumerator.moveNext())
{
switch (sysInfologEnumerator.currentException())
{
case Exception::Error:
errorMsg = sysInfologEnumerator.currentMessage() '\n';
break;
}
}
resultSet.ErrorCode('AX_DuplicateKey');
resultSet.ErrorMessage(errorMsg);
}
catch
{
resultSet = new XXDetailResContract();
SysInfologEnumerator sysInfologEnumerator = SysInfologEnumerator::newData(infolog.copy(startLine,Global::infologLine()));
while (sysInfologEnumerator.moveNext())
{
switch (sysInfologEnumerator.currentException())
{
case Exception::Info:
resultSet.ErrorCode('AX_Info');
resultSet.ErrorMessage(sysInfologEnumerator.currentMessage());
break;
case Exception::Warning:
resultSet.ErrorCode('AX_Warning');
resultSet.ErrorMessage(sysInfologEnumerator.currentMessage());
break;
}
}
}
return resultSet;
}
}public XXOrderCreationResContract createOrder(XXOrderCreationReqContract _orderReq, NoYesId _retrive = false)
{
List orderLines = new List(Types::Class);
XXOrderCreationResContract resContract = new XXOrderCreationResContract();
Table1 table1;
int currentLine;
int startLine;
str errorMsg;
str stage = '';
boolean valid = true;
try
{
orderLines = _orderReq.OrderLines();
if(!orderLines||!orderLines.elements())
{
throw error('No line records found for this order');
}
if(valid)
{
ttsbegin;
XXCreate create = new XXCreate();
table1 = create.create(_orderReq, orderLines);
this.updateTable1(table1, _orderReq);
ttscommit;
if(!_retrive)
{
if(_orderReq.Auto())
{
const int retryCount = 2;
this.confirmOrder(table1);
try
{
ttsbegin;
this.auto(table1);
ttscommit;
}
catch
{
if(xSession::currentRetryCount() >= retryCount)
{
if(table1.Id)
{
this.cancelOrder(table1);
}
errorMsg = '';
for (currentLine = startLine 1; currentLine <= Global::infologLine(); currentLine )
{
errorMsg = stage ' : ' infolog.text(currentLine) '\n';
}
startLine=currentLine-1;
resContract= new XXOrderCreationResContract();
resContract.Id(table1.Id);
resContract.Id3(_orderReq.Id3());
resContract.ErrorCode('AX_Error');
resContract.ErrorMessage(errorMsg);
}
else
{
retry;
}
}
}
else if(_orderReq.Status() == enum2Str(Status::Approved))
{
this.confirmOrder(table1);
}
}
resContract.Id(table1.Id);
resContract.Id3(_orderReq.Id3());
}
}
catch(Exception::Error)
{
if(table1.Id && !_retrive)
{
this.cancelOrder(table1);
}
errorMsg = '';
for (currentLine = startLine 1; currentLine <= Global::infologLine(); currentLine )
{
errorMsg = stage ' : ' infolog.text(currentLine) '\n';
}
startLine=currentLine-1;
resContract= new XXrderCreationResContract();
resContract.Id(table1.Id);
resContract.Id3(_orderReq.Id3());
resContract.ErrorCode('AX_Error');
resContract.ErrorMessage(errorMsg);
}
catch(Exception::DuplicateKeyException)
{
if(table1.Id && !_retrive)
{
this.cancelOrder(table1);
}
errorMsg = '';
for (currentLine = startLine 1; currentLine <= Global::infologLine(); currentLine )
{
errorMsg = stage ' : ' infolog.text(currentLine) '\n';
}
startLine=currentLine-1;
resContract= new XXrderCreationResContract();
resContract.Id(table1.Id);
resContract.Id3(_orderReq.Id3());
resContract.ErrorCode('AX_Error');
resContract.ErrorMessage(errorMsg);
}
catch
{
if(table1.Id && !_retrive)
{
this.cancelOrder(table1);
}
errorMsg = '';
for (currentLine = startLine 1; currentLine <= Global::infologLine(); currentLine )
{
errorMsg = stage ' : ' infolog.text(currentLine) '\n';
}
startLine = currentLine - 1;
resContract= new XXrderCreationResContract();
resContract.Id(table1.Id);
resContract.Id3(_orderReq.Id3());
resContract.ErrorCode('AX_Error');
resContract.ErrorMessage(errorMsg);
}
return resContract;
}
2. how can i enhance the code? is there any possible dangers?
3. I don't think the setup is made for priority throttling. But in case it was how should i enhance the code to handle it. can you please explain?
4. should i catch system.exception errors?