We are currently integrated with Manhatten SCALE warehouse management solution and we needed a way to post the service items only to packing slip status so our normal invoice batch job could pick them up and post them normally.
We could have created a packing slip batch job that only post service items, but the business decided they wanted this done when the interface from SCALE sends the order back to us (so we know the warehouse is finished with the order), The following is a job that updates a sales orders service items to packing slip posted.. You could easily imagine this being used on the interface back up from SCALE.
Some things that are interesting about this is it uses a query to limit what will get posted instead of using just the parameters available. Also, interesting is that it adds a datasource that is not included in the default query and uses relationship to limit the query.
static void ptn2478_RunTestPackslipPost(Args _args)
{
SalesFormLetter salesFormLetter;
QueryRun queryRun;
Query query;
str strSalesTable = '0009430007';
QueryBuildDataSource qbdsSalesTable, qbdsSalesLine, qbdsInventTable;
;
salesFormLetter = SalesFormLetter::construct(DocumentStatus::PackingSlip);
query = new Query(QueryStr(SalesUpdate));
//Add Tables to the datasource that are not already there
qbdsSalesTable = query.dataSourceTable(tablenum(SalesTable));
qbdsSalesLine = query.dataSourceTable(tablenum(SalesLine));
qbdsInventTable = qbdsSalesLine.addDataSource(tableNum(InventTable));
//add relations
qbdsSalesLine.relations(true);
qbdsInventTable.relations(true);
//add ranges (where clause)
qbdsSalesTable.addRange(fieldnum(SalesTable, SalesId)).value(strSalesTable);
qbdsInventTable.addRange(fieldnum(InventTable, ItemType)).value(strFmt('%1',itemType::Service));
queryRun = new QueryRun(query);
salesFormLetter.chooseLinesQuery(queryRun);
salesFormLetter.transDate(systemdateget());
salesFormLetter.specQty(SalesUpdate::All);
salesFormLetter.printFormLetter(false);
salesFormLetter.createParmUpdate();
salesFormLetter.chooseLines(null,true);
salesFormLetter.reArrangeNow(true);
salesFormLetter.run();
info('complete');
}
No comments:
Post a Comment