I have modified the code as per you suggested and still getting the same issue.
class OEI1INStagingStockTransferService
{
[AifCollectionTypeAttribute('return', Types::Class, classStr(OEI1INStagingStockTransferHirarchyJSONResponse))]
public List processStockTransfer(OEI1INStagingStockTransferJSONRequest _stockTransferRequest)
{
Query query = new Query(queryStr(OEI1INStagingStockTransferQuery));
//QueryRun qrun;
//QueryBuildDataSource qbdsCustCode;
//QueryBuildRange qbr;
//int iCnt = 0;
//Notes JSONstring = "";
//OEI1INStagingStockTransferHirarchyJSONResponse mainJsonResponse = new OEI1INStagingStockTransferHirarchyJSONResponse();
//OEI1INStagingStockTransferHirarchyJSONResponse mainJsonResponseList = new OEI1INStagingStockTransferHirarchyJSONResponse();
//OEI1INStagingStockTransferRootSerializer rootJSonResponse = new OEI1INStagingStockTransferRootSerializer();
//OEI1INStgStockTransferJSRes jsonResSTR,jsonResSTRRec;
//OEI1INStagingStockTransferHeader stagingStockTFHeader,stockTransferHeaderUpdate;
//OEI1INStagingStockTransferCustomer stagingStockTFCustomer,stockTransferCustomerUpdate;
//OEI1INStagingStockTransferItem stagingStockTFItem,stockTransferItemUpdate;
//OEI1INStagingStockTransferContract requestStockTransfer;
//ListIterator listIterator;
//List list = new List(Types::Class);
//List headerlist = new List(Types::Class);
//List custlist = new List(Types::Class);
////List itemlist = new List(Types::Class);
//ListEnumerator lEnum,lEnumCust,lEnumItem;
List itemList = new List(Types::Class);
ListEnumerator requestEnumerator = _stockTransferRequest.OEI1INStagingStockTransferContract().getEnumerator();
while (requestEnumerator.moveNext())
{
OEI1INStagingStockTransferContract requestStockTransfer = requestEnumerator.current();
try
{
QueryBuildDataSource transferCustDs = query.dataSourceTable(tableNum(OEI1INStagingStockTransferCustomer));
if (requestStockTransfer.parmCustomerCode())
{
QueryBuildRange custCodeRange = SysQuery::findOrCreateRange(transferCustDs, fieldNum(OEI1INStagingStockTransferCustomer, CustomerCode));
custCodeRange.value(queryValue(requestStockTransfer.parmCustomerCode()));
}
QueryRun queryRun = new QueryRun(query);
while (queryRun.next())
{
//OEI1INStagingStockTransferHeader stagingStockTFHeader = queryRun.get(tableNum(OEI1INStagingStockTransferHeader));
OEI1INStagingStockTransferCustomer stagingStockTFCustomer = queryRun.get(tableNum(OEI1INStagingStockTransferCustomer));
//OEI1INStagingStockTransferItem stagingStockTFItem = queryRun.get(tableNum(OEI1INStagingStockTransferItem));
OEI1INStagingStockTransferHirarchyJSONResponse responseItem = this.createResponse(stagingStockTFCustomer.TransferOrderNo,
stagingStockTFCustomer.CustomerCode);
// Here we add the item to a list
itemList.addEnd(responseItem);
// TODO: don't forget to think about database transactions. The current implementation could lead to data inconsistency.
//OEI1INStagingStockTransferHeader::updateOBProcessed(stagingStockTFHeader.RecId);
//OEI1INStagingStockTransferCustomer::updateOBProcessed(stagingStockTFCustomer.RecId);
//OEI1INStagingStockTransferItem::updateOBProcessed(stagingStockTFItem.RecId);
}
}
catch (Exception::Error)
{
// TODO: implement
}
}
//OEI1INStagingStockTransferJSONResponse jSonResponse = new OEI1INStagingStockTransferJSONResponse();
//// Initialize the interface iterator
//listIterator = new ListIterator(_stockTransferRequest.OEI1INStagingStockTransferContract());
// while (listIterator.more())
// {
// requestStockTransfer = listIterator.value();
// try
// {
// if (requestStockTransfer.parmcustomerCode() != "")
// {
// qbdsCustCode = query.dataSourceTable(tableNum(OEI1INStagingStockTransferCustomer));
// qbr = qbdsCustCode.addRange(fieldNum(OEI1INStagingStockTransferCustomer,CustomerCode));
// qbr.value(SysQuery::value(requestStockTransfer.parmcustomerCode()));
// qrun = new QueryRun(query);
// while (qrun.next())
// {
// //stagingStockTFHeader = qrun.get(tableNum(OEI1INStagingStockTransferHeader));
// stagingStockTFCustomer = qrun.get(tableNum(OEI1INStagingStockTransferCustomer));
// //stagingStockTFItem = qrun.get(tableNum(OEI1INStagingStockTransferItem));
// headerlist = mainJsonResponse.parmTOHeader(OEI1INStagingStockTransferJSONSerializerHeader::serializeJSON(stagingStockTFHeader,
// stagingStockTFCustomer,
// stagingStockTFItem));
// custlist = mainJsonResponse.parmTOCustomers(OEI1INStagingStockTransferJSONSerializer::serializeJSON(stagingStockTFHeader,
// stagingStockTFCustomer,
// stagingStockTFItem));
// itemlist = mainJsonResponse.parmTOLines(OEI1INStagingStockTransferJSONSerializerItems::serializeJSON(stagingStockTFHeader,
// stagingStockTFCustomer,
// stagingStockTFItem));
// if (mainJsonResponse)
// {
// OEI1INStagingStockTransferHeader::updateOBProcessed(stagingStockTFHeader.RecId);
// OEI1INStagingStockTransferCustomer::updateOBProcessed(stagingStockTFCustomer.RecId);
// OEI1INStagingStockTransferItem::updateOBProcessed(stagingStockTFItem.RecId);
// }
// }
// }
// else
// {
// qrun = new QueryRun(query);
// while (qrun.next())
// {
// stagingStockTFHeader = qRun.get(tableNum(OEI1INStagingStockTransferHeader));
// stagingStockTFCustomer = qRun.get(tableNum(OEI1INStagingStockTransferCustomer));
// stagingStockTFItem = qRun.get(tableNum(OEI1INStagingStockTransferItem));
// mainJsonResponse.parmTOHeader(OEI1INStagingStockTransferJSONSerializerHeader::serializeJSON(stagingStockTFHeader,
// stagingStockTFCustomer,
// stagingStockTFItem));
// mainJsonResponse.parmTOCustomers(OEI1INStagingStockTransferJSONSerializer::serializeJSON(stagingStockTFHeader,
// stagingStockTFCustomer,
// stagingStockTFItem));
// mainJsonResponse.parmTOLines(OEI1INStagingStockTransferJSONSerializerItems::serializeJSON(stagingStockTFHeader,
// stagingStockTFCustomer,
// stagingStockTFItem));
// if (mainJsonResponse)
// {
// OEI1INStagingStockTransferHeader::updateOBProcessed(stagingStockTFHeader.RecId);
// OEI1INStagingStockTransferCustomer::updateOBProcessed(stagingStockTFCustomer.RecId);
// OEI1INStagingStockTransferItem::updateOBProcessed(stagingStockTFItem.RecId);
// }
// }
// }
// }
// catch (Exception::Error)
// {
// // mainJsonResponse.parmSuccessMessage(false);
// //mainJsonResponse.parmOrderMessage(OEI1INLogInterfacesExceptions::getErrorMessage());
// }
// listIterator.next();
// }
////list.addEnd(mainJsonResponse);
//mainJsonResponseList.parmTOHeader(headerlist);
//mainJsonResponseList.parmTOCustomers(custlist);
//mainJsonResponseList.parmTOLines(itemlist);
//list.addEnd(mainJsonResponseList);
//rootJSonResponse.parmMainJson(list);
return itemList;
}
public OEI1INStagingStockTransferHirarchyJSONResponse createResponse(String20 _transferOrderNo,CustAccount _custAcc)
{
OEI1INStagingStockTransferHirarchyJSONResponse jsonResponse = new OEI1INStagingStockTransferHirarchyJSONResponse();
OEI1INStagingStockTransferHeaderJSONResponse header = new OEI1INStagingStockTransferHeaderJSONResponse();
OEI1INStagingStockTransferItemJSONResponse item = new OEI1INStagingStockTransferItemJSONResponse();
OEI1INStagingStockTransferCustomerJSONResponse customer = new OEI1INStagingStockTransferCustomerJSONResponse();
OEI1INStagingStockTransferHeader headerStaging;
OEI1INStagingStockTransferCustomer customersStaging;
OEI1INStagingStockTransferItem itemsStaging;
List headerList = new List(Types::Class);
List itemsList = new List(Types::Class);
List customerList = new List(Types::Class);
//TO Header
Query query = new Query();
QueryBuildDataSource qbds;
QueryBuildRange qbr;
QueryRun qRun;
qbds = query.addDataSource(tableNum(OEI1INStagingStockTransferHeader));
qbr = qbds.addRange(fieldNum(OEI1INStagingStockTransferHeader,TransferOrderNo));
qbr.value(SysQuery::value(_transferOrderNo));
qRun = new QueryRun(query);
while (qRun.next())
{
headerStaging = qrun.get(tableNum(OEI1INStagingStockTransferHeader));
header.parmTransferOrderNo(headerStaging.TransferOrderNo);
header.parmTransferOrderDate(headerStaging.TransferOrderDate);
header.parmTripNo(headerStaging.TripNO);
header.parmVehicleNo(headerStaging.VehicleNo);
header.parmType(headerStaging.Type);
headerList.addEnd(header);
}
//TO Items
Query queryItems = new Query();
QueryBuildDataSource qbdsItems;
QueryBuildRange qbrItems;
QueryRun qRunItems;
qbdsItems = queryItems.addDataSource(tableNum(OEI1INStagingStockTransferItem));
qbrItems = qbdsItems.addRange(fieldNum(OEI1INStagingStockTransferItem,TransferOrderNo));
qbrItems.value(SysQuery::value(_transferOrderNo));
qRunItems = new QueryRun(queryItems);
while (qRunItems.next())
{
itemsStaging = qRunItems.get(tableNum(OEI1INStagingStockTransferItem));
item.parmItemCode(itemsStaging.ItemCode);
item.parmProductHierarchyCode(itemsStaging.ProductHierarchyCode);
item.parmLegacyCode(itemsStaging.LegacyCode);
item.parmMRP(itemsStaging.MRPConfig);
item.parmBatchNo(itemsStaging.Batch);
item.parmMFGDate(itemsStaging.MFGdate);
item.parmExpiryDate(itemsStaging.ExpiryDate);
item.parmCrateQty(itemsStaging.CrateQty);
item.parmBottleQty(itemsStaging.BottleQty);
item.parmQty(itemsStaging.QTY);
item.parmTenantCode(itemsStaging.TenantCode);
item.parmTransferOrderNo(itemsStaging.TransferOrderNo);
item.parmTransferOrderDate(itemsStaging.TransferOrderDate);
item.parmItemType(itemsStaging.ItemType);
itemsList.addEnd(item);
}
//TO Customer
Query queryCust = new Query();
QueryBuildDataSource qbdsCust;
QueryBuildRange qbrCust,qbrCust1;
QueryRun qRunCust;
qbdsCust = queryCust.addDataSource(tableNum(OEI1INStagingStockTransferCustomer));
qbrCust = qbdsCust.addRange(fieldNum(OEI1INStagingStockTransferCustomer,TransferOrderNo));
qbrCust1 = qbdsCust.addRange(fieldNum(OEI1INStagingStockTransferCustomer,CustomerCode));
qbrCust.value(SysQuery::value(_transferOrderNo));
qbrCust1.value(SysQuery::value(_custAcc));
qRunItems = new QueryRun(queryCust);
while (qRunItems.next())
{
customersStaging = qRunItems.get(tableNum(OEI1INStagingStockTransferCustomer));
customer.parmTransferOrderNo(customersStaging.TransferOrderNo);
customer.parmCustomerCode(customersStaging.CustomerCode);
customer.parmCustomerOrderNo(customersStaging.CustomerOrderNo);
customer.parmCustomerOrderDate(customersStaging.CustomerOrderDate);
customer.parmRouteNo(customersStaging.RouteNo);
customer.parmType(customersStaging.Type);
customerList.addEnd(customer);
}
jsonResponse.parmTOHeader(headerList);
jsonResponse.parmTOLines(itemsList);
jsonResponse.parmTOCustomers(customerList);
return jsonResponse;
}
}
Please suggest if I am doing some thing wrong here...