Frequently Used Code When creating purchase and sales orders, you need to find out which fields are mandatory. This code often needs to be copied and put here for a backup. Static Void Createpurchdirectly (ARGs _ ARGs)
{
Purchtable;
Purchline;
Inventdim;
;
Ttsbegin;
// Purchtable
// Purchid
Purchtable. purchid = Numberseq: newgetnum (purchparameters: numrefpurchid (). Num ();
Purchtble. purchasetype = purchasetype: purch;
Purchtable. initvalue ();
// Vend account
Purchtable. initfromvendtable (vendtable: Find ( ' 3000 ' ));
Purchtable. insert ();
// Purchline
Purchline. initfrompurchtable (purchtable );
// Itemid
Purchline. Itemid = ' B-pack1 ' ;
Purchline. initfrominventtable (inventtable: Find ( ' B-pack1 ' ));
// Qty
Purchline. purchqty = 100 ;
Purchline. qtyordered = 100 ;
Purchline. remaininventphysical = 100 ;
Purchline. remainpurchphysical = 100 ;
// Inventdim maybe shoshould add some other dimensions.
Inventdim. inventlocationid = ' GW ' ;
Purchline. inventdimid = Inventdim: findorcreate (inventdim). inventdimid;
Purchline. insert ();
Ttscommit;
}
Static Void Createpurchtablethroughaxpurch (ARGs _ ARGs)
{
Axpurchtable = New Axpurchtable ();
Axpurchline = New Axpurchline ();
Axinventdim_purchline axinventdim = New Axinventdim_purchline ();
;
// Purchtable
// Order Account
Axpurchtable. parmorderaccount ( " 3000 " );
Axpurchtable. Save ();
// Purchline
// Purchid
Axpurchline. axpurchtable (axpurchtable );
// Itemid
Axpurchline. parmitemid ( " B-pack1 " );
// Qty
Axpurchline. parmpurchqty ( 100 );
// Inventdim maybe shocould add some other dimensions
Axinventdim. axpurchline (axpurchline );
Axinventdim. parminventlocationid ( ' MW ' );
Axpurchline. axinventdim (axinventdim );
Axpurchline. Save ();
}