Hi,
This is little more modification with my previous question under the following link.
There are few more modifications that needs to be added for the same after making couple more changes for the same.
Currently we have a the output results looking as:
H!,0,US39693,11/29/16,0,11/29/16,RT113298
D!,1,US39693,96296,100,Ea,RT113298
D!,2,US39693,00012,4,PK,RT113298
D!,3,US39693,00028,1,PK,RT113298
D!,4,US39693,00265,2,PK,RT113298
Whereas, the desired change of the new request is to show the output as:
H!,0,US39693,11/29/16,0,11/29/16,RT113298
D!,1,US39693,96296f,50,Ea,RT113298
D!,2,US39693,96296r,50,Ea,RT113298
D!,3,US39693,00012,4,PK,RT113298
D!,4,US39693,00028,1,PK,RT113298
D!,5,US39693,00265,2,PK,RT113298
The condition is depend on if the InventTable.ManufacturedId = 'per batch' then show the item as two different lines i.e. don't sum the quantity and show the item id as ItemId + first letter of InventDim.InventBatchId.
Here, the item id 96296 has the condition as Manufactured Id = 'per batch' so the item is displayed as 96296f and 96296r where f and r are the first letter of InventBatchId.
The code looks like:
private void runExport()
{
//Variables.
TextIo writeFile;
Set permissionSet;
int linenum;
Qty qty;
SalesUnit unit;
str filename = strReplace(networkPath + "AX" + date2str(today(),213, 2, 0, 2, 0, 2) + strReplace(time2StrHM(timeNow()), ":", "") + ".txt", " ", "");
str SOstr;
//Tables
InventItemSalesSetup inventItemSalesSetup;
CustTable custTable;
;
permissionSet = new Set(Types::Class);
permissionSet.add(new FileIoPermission(filename, 'w'));
permissionSet.add(new InteropPermission(InteropKind::ClrInterop));
CodeAccessPermission::assertMultiple(permissionSet);
writeFile = new TextIo(filename, "w");
writeFile.outFieldDelimiter(",");
while select wmsPickingRoute
join salesTable
where salesTable.SalesId == wmsPickingRoute.transRefId
&& wmsPickingRoute.transType == 0
&& (salesTable.CustGroup == "230" || salesTable.CustGroup == "240" || salesTable.CustGroup == "250")
&& salesTable.ShippingDateConfirmed == confirmedShipDate //Change requested from Ian.
&& salesTable.InventLocationId == whse
{
linenum = 0;
SOstr = subStr(wmsPickingRoute.pickingRouteID,strLen(wmsPickingRoute.pickingRouteID), -8);
custTable = salesTable.custTable_CustAccount();
//Write the header line if lines exist.
select firstOnly wmsOrderTrans
where wmsOrderTrans.routeId == wmsPickingRoute.pickingRouteID
&& wmsOrderTrans.fullPallet == 0
&& (wmsOrderTrans.expeditionStatus == WMSExpeditionStatus::Picked || wmsOrderTrans.expeditionStatus == WMSExpeditionStatus::Complete)
join salesLine
where salesLine.inventTransId == wmsOrderTrans.inventTransId;
if (wmsOrderTrans)
{
writeFile.writeExp(['H!', 0, custTable.LSH_QADCustomer, date2str(salesTable.ShippingDateConfirmed, 213, 2, 4, 2 , 4, 2), 0, date2str(today(), 213, 2, 4, 2, 4, 2), SOstr]);
}
while select sum(qty) from wmsOrderTrans
group by inventTransId
where wmsOrderTrans.routeId == wmsPickingRoute.pickingRouteID
&& wmsOrderTrans.fullPallet == 0
&& (wmsOrderTrans.expeditionStatus == WMSExpeditionStatus::Picked || wmsOrderTrans.expeditionStatus == WMSExpeditionStatus::Complete)
join itemId, SalesUnit from salesLine
group by itemId, SalesUnit
where salesLine.inventTransId == wmsOrderTrans.inventTransId
{
inventItemSalesSetup = inventItemSalesSetup::find(salesLine.ItemId, "AllBlank", false);
//Specced as incremental number so that is why I don't use linenum from the trans, that is also a real that can contain .5 values.
linenum++;
if (inventItemSalesSetup.LowestQty > 1)
{
qty = wmsOrderTrans.Qty / inventItemSalesSetup.LowestQty;
unit = "PK";
}
else
{
qty = wmsOrderTrans.Qty;
unit = salesLine.SalesUnit;
}
//Write the detail lines.
writefile.writeExp(["D!", linenum, custTable.LSH_QADCustomer, salesLine.ItemId, qty, unit, SOstr]);
}
}
writeFile.writeExp([""]);
writeFile.finalize();
CodeAccessPermission::revertAssert();
info("Export complete");
}