This part of the Code I used to create Sales order lines with Dimension.
public void createSalesLine(SalesType _salesType,SalesId _salesId, TransactionId _importid)
{
Struct struct = new Struct();
container ledgerDimension;
DimensionDefault DimensionDefault;
;
salesLine.clear();
salesTable = SalesTable::find(_salesId);
salesLine.initValue(_salesType);
salesLine.initFromSalesTable(salesTable);
salesLine.SalesId = _salesId;
salesLine.ItemId = ‘itemid’;
salesLine.initFromInventTable(InventTable::find(salesLine.ItemId));
salesLine.SalesQty = 1;
//Dimensions
struct.add(‘Department’, ‘Department parameter’);
ledgerDimension += struct.fields();
ledgerDimension += struct.fieldName(1);
ledgerDimension += struct.valueIndex(1);
DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
salesLine.DefaultDimension = DimensionDefault;
//End Dimensions Part
inventDim.clear();
inventDim.InventSiteId = ‘Site Parameter’;
inventDim.InventLocationId = ‘Location Parameter’;
inventDim = InventDim::findOrCreate(inventDim);
salesLine.InventDimId = inventDim.inventDimId;
salesLine.createLine(
NoYes::Yes, // Validate
NoYes::Yes, // initFromSalesTable
NoYes::Yes, // initFromInventTable
NoYes::Yes, // calcInventQty
NoYes::Yes, // searchMarkup
NoYes::Yes); // searchPrice
}