The code to create the journal is as follows:
void clicked()
{
WMSJournalTable wmsJournalTable;
WMSJournalTrans wmsJournalTrans;
WMSJournalName wmsJournalName;
{
WMSJournalTable wmsJournalTable;
WMSJournalTrans wmsJournalTrans;
WMSJournalName wmsJournalName;
JournalTableData journalTableData;
JournalCheckPost journalCheckPost;
JournalCheckPost journalCheckPost;
InventTrans inventTrans;
NumberSeq numberSeq;
str journalNum;
str journalName;
str journalName;
int lineNum = 1;
int logPointerLast;
int lineBeforeCLRError;
int logPointerLast;
int lineBeforeCLRError;
boolean errors;
;
;
journalName = WMSParameters::find().receptionJournalNameId;
numberSeq = NumberSeq::newGetNumFromCode(NumberSequenceReference::find(1523).NumberSequence);
journalNum = numberSeq.num();
wmsJournalName = WMSJournalName::find(journalName);
ttsbegin;
wmsJournalTable.initFromWMSJournalName(wmsJournalName);
wmsJournalTable.JournalNameId = journalName;
wmsJournalTable.JournalId = journalNum;
wmsJournalTable.journalType = WMSJournalType::Reception;
wmsJournalTable.insert();
wmsJournalTable.JournalId = journalNum;
wmsJournalTable.journalType = WMSJournalType::Reception;
wmsJournalTable.insert();
journalTableData = JournalTableData::newTable(wmsJournalTable);
inventTrans = InventTrans::findTransId(inventQuarantineOrder.InventTransId);
wmsJournalTrans.clear();
wmsJournalTrans.initFromWMSJournalTable(wmsJournalTable);
wmsJournalTrans.JournalId = journalNum;
wmsJournalTrans.LineNum = lineNum;
wmsJournalTrans.TransDate = today();
wmsJournalTrans.ItemId = inventQuarantineOrder.ItemId;
wmsJournalTrans.Qty = inventQuarantineOrder.Qty * -1;
wmsJournalTrans.InventDimId = inventQuarantineOrder.InventDimId;
wmsJournalTrans.vendAccount = PurchTable::find(inventQuarantineOrder.TransRefId).InvoiceAccount;
wmsJournalTrans.inventTransType = inventQuarantineOrder.TransType;
wmsJournalTrans.inventTransRefId = inventQuarantineOrder.TransRefId;
wmsJournalTrans.inventTransId = inventQuarantineOrder.InventTransIdRef;
wmsJournalTrans.checkPickingLocation = NoYes::No;
wmsJournalTrans.createQuarantineOrder = NoYes::No;
wmsJournalTrans.inventDimId = inventQuarantineOrder.InventDimId;
wmsJournalTrans.insert();
wmsJournalTrans.LineNum = lineNum;
wmsJournalTrans.TransDate = today();
wmsJournalTrans.ItemId = inventQuarantineOrder.ItemId;
wmsJournalTrans.Qty = inventQuarantineOrder.Qty * -1;
wmsJournalTrans.InventDimId = inventQuarantineOrder.InventDimId;
wmsJournalTrans.vendAccount = PurchTable::find(inventQuarantineOrder.TransRefId).InvoiceAccount;
wmsJournalTrans.inventTransType = inventQuarantineOrder.TransType;
wmsJournalTrans.inventTransRefId = inventQuarantineOrder.TransRefId;
wmsJournalTrans.inventTransId = inventQuarantineOrder.InventTransIdRef;
wmsJournalTrans.checkPickingLocation = NoYes::No;
wmsJournalTrans.createQuarantineOrder = NoYes::No;
wmsJournalTrans.inventDimId = inventQuarantineOrder.InventDimId;
wmsJournalTrans.insert();
journalCheckPost = WMSJournalCheckPostReception::newTypeJournalTable(JournalCheckPostType::Post,wmsJournalTable);
journalCheckPost.parmAutoBlock(true);
journalCheckPost.run();
errors = journalTableData.hasErrors();
if(errors)
error(infolog.text(logPointerLast+1));
error(infolog.text(logPointerLast+1));
ttscommit;
info(strfmt("Journal # %1 created",journalNum));
}
}
Aucun commentaire:
Enregistrer un commentaire