New line in x++ :
=StrFmt("%1\r\n", PurchLine.PurchId);
example :
void CreatePR()
{
Salesid Salesid;
// Get Invendim
Inventtable _Inventtable;
InventItemOrdersetupType setupType = InventItemOrderSetupType::Invent;
Inventdim _Inventdim;
QueryRun _QueryRun;
Query _Query = new Query();
//====================================== getItemName()
ItemFreeTxt itemname;
real length;
ConfigId configId;
Name ConfigName;
Qty PCS;
Qty KG_PCS;
Real Real_KG_PCS;
configTable _ConfigTable;
Inventdimid inventdimid;
InventSizeId inventSizeId;
InventColorId inventColorId;
InventTransId inventTransId;
POCustomer POCustomer;
//====================================== getItemName()
;
_QueryRun = new QueryRUn(_Query);
Salesid = Sales.valueStr();
_salesline_pendek = Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum);
ttsbegin;
_purchreqtable.BIT_SalesId = Salesid;
_purchreqtable.update();
ttscommit;
ttsbegin;
while select crosscompany * from _SalesLine
order by linenum asc
where _salesline.SalesId == Salesid
&& _salesline.dataAreaId == Company.valueStr()
{
//============= GetItemName ==========
_configtable= Configtable::BIT_find(_salesline.ItemId, inventdim::BIT_find_crosscompany(_salesline.InventDimId).configId);
configId = inventdim::BIT_find_crosscompany(_salesline.InventDimId).configId;
ConfigName = _configtable.Name;
inventSizeId = inventdim::BIT_find_crosscompany(_salesline.InventDimId).InventSizeId;
inventColorId = inventdim::BIT_find_crosscompany(_salesline.InventDimId).InventColorId;
InventTransId = _salesline.InventTransId;
POCustomer = Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).POCustomer;
PCS = _salesline.SalesQty;
KG_PCS = _salesline.QtyOrdered/ _salesline.SalesQty;
length = Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).Soltius_LengthId;
if(!strltrim(strrtrim((Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).Name))))
itemname = InventTable::BIT_Find_CrossCompany(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).ItemId).ItemName;
else
itemname = Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).Name;
if(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).QtyOrdered == Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).Soltius_WeightedQty)
{
If ((InventTable::find(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).ItemId).ItemGroupId == 'Cons') ||
(InventTable::find(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).ItemId).ItemGroupId == 'SPR'))
itemname += " - " + configname + " - " + configId;
Else if(configId)
itemname += " - " + configId;
length = Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).Soltius_LengthId;
if(inventSizeId && strltrim(strrtrim(inventsizeid)) != "1")
{
if(Length || _salesline_pendek.ItemId == "PL/CO-REJECT" || InventTable::find(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).ItemId).Soltius_DiffSize)
itemname += "x" + InventSizeId;
else
{
if(!inventcolorid)
itemname += "x" + num2str(str2num(InventSizeId)*1000,1,0,1,0);
else
itemname += "x" + InventSizeId;
}
}
else
{
if(inventsizeid)
{
if(!Length)
{
if(!inventcolorid)
itemname += "x" + num2str(str2num(InventSizeId)*1000,1,0,1,0);
}
}
}
if(InventColorId)
itemname += "x" + InventColorId;
if(length)
{
if(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).SalesUnit != "MTR")
itemname += "x" + num2str(length * 1000, 1, 0, 1, 0);
else
itemname += "x" + num2str(length * 1000, 1, 0, 1, 0) + " MM";
}
}
else
{
if(!strltrim(strrtrim(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).Name)))
{
if(configId)
{
itemname += " / " + configId;
}
if(InventSizeId)
{
if(Length)
itemname += "x" + InventSizeId;
else
{
if(!InventColorId)
itemname += "x" + num2str(str2num(InventSizeId)*1000,1,0,1,0);
else
itemname += "x" + InventSizeId;
}
}
else
{
if(InventSizeId)
{
if(!length)
{
if(!InventColorId)
itemname += "x" + num2str(str2num(InventSizeId)*1000,1,0,1,0);
}
}
}
if(InventColorId)
itemname += "x" + InventColorId;
if(length)
{
if(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).SalesUnit != "MTR")
{
itemname += "x" + num2str(length * 1000, 1, 0, 1, 0);
}
else
itemname += "x" + num2str(length * 1000, 1, 0, 1, 0) + " MM";
}
}
}
//============= GetItemName ==========
_Purchreqline.clear();
_Purchreqline.initValue();
_Purchreqline.InventDimId = _salesline.InventDimId;
_Purchreqline.initFromPurchReqTable(_PurchreqTable);
_Purchreqline.ItemId = itemid.valueStr();
_purchreqline.RequisitionOrigin = _purchreqtable.PurchOrigin;
_purchreqline.LineNum = _salesline.LineNum;
if(POCustomer)
{
_purchreqline.externalitemid = strfmt("%1 \n-%2 \n%3Pcs@%4Kg",itemname, POCustomer, PCS, KG_PCS);
}
if(!POCustomer)
{
_purchreqline.externalitemid = strfmt("%1 \n%2Pcs@%3Kg",itemname, PCS, KG_PCS);
}
_Purchreqline.ActivityNumber = _salesline.ActivityNumber;
_Purchreqline.Name = _SalesLine.Name;
_Purchreqline.PurchUnit = inventtableModule::BIT_find_crosscompany(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).ItemId, ModuleInventPurchSales::Invent).UnitId;
if(!_Purchreqline.PurchUnit)
{
_Purchreqline.PurchUnit = "Kg";
}
_Purchreqline.ConfigName();
_Purchreqline.PurchQty = _salesline.QtyOrdered;
_PurchReqLine.QtyRemaining = _salesline.QtyOrdered;
_Purchreqline.CurrencyCode = _salesline.CurrencyCode;
_PurchReqLine.LedgerAccount = _salesline.LedgerAccount;
_Purchreqline.ProjCategoryId = _salesline.ProjCategoryId;
_Purchreqline.CancelQty = _salesline.Cancelqty();
_Purchreqline.ActivityNumber = activitynumber.valueStr();
_Inventdim.InventSiteId = site.valueStr();
_Inventdim.InventLocationId = location.valueStr();
_Inventdim = InventDim::findOrCreate(_Inventdim);
_Purchreqline.inventDimId = _Inventdim.inventDimId;
_Purchreqline.LineType = Purchreqlinetype::Item;
_Purchreqline.insert();
}
ttscommit;
if(_Purchreqline.Name != "")
{
Info(strfmt("Press f5 - Import SOP : %1 (%2) to PR : %3 (%4) has been succesfully", Salesid, Company.valueStr(), _purchreqtable.PurchReqId, curExt()));
}
}
=StrFmt("%1\r\n", PurchLine.PurchId);
example :
void CreatePR()
{
Salesid Salesid;
// Get Invendim
Inventtable _Inventtable;
InventItemOrdersetupType setupType = InventItemOrderSetupType::Invent;
Inventdim _Inventdim;
QueryRun _QueryRun;
Query _Query = new Query();
//====================================== getItemName()
ItemFreeTxt itemname;
real length;
ConfigId configId;
Name ConfigName;
Qty PCS;
Qty KG_PCS;
Real Real_KG_PCS;
configTable _ConfigTable;
Inventdimid inventdimid;
InventSizeId inventSizeId;
InventColorId inventColorId;
InventTransId inventTransId;
POCustomer POCustomer;
//====================================== getItemName()
;
_QueryRun = new QueryRUn(_Query);
Salesid = Sales.valueStr();
_salesline_pendek = Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum);
ttsbegin;
_purchreqtable.BIT_SalesId = Salesid;
_purchreqtable.update();
ttscommit;
ttsbegin;
while select crosscompany * from _SalesLine
order by linenum asc
where _salesline.SalesId == Salesid
&& _salesline.dataAreaId == Company.valueStr()
{
//============= GetItemName ==========
_configtable= Configtable::BIT_find(_salesline.ItemId, inventdim::BIT_find_crosscompany(_salesline.InventDimId).configId);
configId = inventdim::BIT_find_crosscompany(_salesline.InventDimId).configId;
ConfigName = _configtable.Name;
inventSizeId = inventdim::BIT_find_crosscompany(_salesline.InventDimId).InventSizeId;
inventColorId = inventdim::BIT_find_crosscompany(_salesline.InventDimId).InventColorId;
InventTransId = _salesline.InventTransId;
POCustomer = Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).POCustomer;
PCS = _salesline.SalesQty;
KG_PCS = _salesline.QtyOrdered/ _salesline.SalesQty;
length = Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).Soltius_LengthId;
if(!strltrim(strrtrim((Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).Name))))
itemname = InventTable::BIT_Find_CrossCompany(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).ItemId).ItemName;
else
itemname = Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).Name;
if(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).QtyOrdered == Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).Soltius_WeightedQty)
{
If ((InventTable::find(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).ItemId).ItemGroupId == 'Cons') ||
(InventTable::find(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).ItemId).ItemGroupId == 'SPR'))
itemname += " - " + configname + " - " + configId;
Else if(configId)
itemname += " - " + configId;
length = Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).Soltius_LengthId;
if(inventSizeId && strltrim(strrtrim(inventsizeid)) != "1")
{
if(Length || _salesline_pendek.ItemId == "PL/CO-REJECT" || InventTable::find(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).ItemId).Soltius_DiffSize)
itemname += "x" + InventSizeId;
else
{
if(!inventcolorid)
itemname += "x" + num2str(str2num(InventSizeId)*1000,1,0,1,0);
else
itemname += "x" + InventSizeId;
}
}
else
{
if(inventsizeid)
{
if(!Length)
{
if(!inventcolorid)
itemname += "x" + num2str(str2num(InventSizeId)*1000,1,0,1,0);
}
}
}
if(InventColorId)
itemname += "x" + InventColorId;
if(length)
{
if(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).SalesUnit != "MTR")
itemname += "x" + num2str(length * 1000, 1, 0, 1, 0);
else
itemname += "x" + num2str(length * 1000, 1, 0, 1, 0) + " MM";
}
}
else
{
if(!strltrim(strrtrim(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).Name)))
{
if(configId)
{
itemname += " / " + configId;
}
if(InventSizeId)
{
if(Length)
itemname += "x" + InventSizeId;
else
{
if(!InventColorId)
itemname += "x" + num2str(str2num(InventSizeId)*1000,1,0,1,0);
else
itemname += "x" + InventSizeId;
}
}
else
{
if(InventSizeId)
{
if(!length)
{
if(!InventColorId)
itemname += "x" + num2str(str2num(InventSizeId)*1000,1,0,1,0);
}
}
}
if(InventColorId)
itemname += "x" + InventColorId;
if(length)
{
if(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).SalesUnit != "MTR")
{
itemname += "x" + num2str(length * 1000, 1, 0, 1, 0);
}
else
itemname += "x" + num2str(length * 1000, 1, 0, 1, 0) + " MM";
}
}
}
//============= GetItemName ==========
_Purchreqline.clear();
_Purchreqline.initValue();
_Purchreqline.InventDimId = _salesline.InventDimId;
_Purchreqline.initFromPurchReqTable(_PurchreqTable);
_Purchreqline.ItemId = itemid.valueStr();
_purchreqline.RequisitionOrigin = _purchreqtable.PurchOrigin;
_purchreqline.LineNum = _salesline.LineNum;
if(POCustomer)
{
_purchreqline.externalitemid = strfmt("%1 \n-%2 \n%3Pcs@%4Kg",itemname, POCustomer, PCS, KG_PCS);
}
if(!POCustomer)
{
_purchreqline.externalitemid = strfmt("%1 \n%2Pcs@%3Kg",itemname, PCS, KG_PCS);
}
_Purchreqline.ActivityNumber = _salesline.ActivityNumber;
_Purchreqline.Name = _SalesLine.Name;
_Purchreqline.PurchUnit = inventtableModule::BIT_find_crosscompany(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).ItemId, ModuleInventPurchSales::Invent).UnitId;
if(!_Purchreqline.PurchUnit)
{
_Purchreqline.PurchUnit = "Kg";
}
_Purchreqline.ConfigName();
_Purchreqline.PurchQty = _salesline.QtyOrdered;
_PurchReqLine.QtyRemaining = _salesline.QtyOrdered;
_Purchreqline.CurrencyCode = _salesline.CurrencyCode;
_PurchReqLine.LedgerAccount = _salesline.LedgerAccount;
_Purchreqline.ProjCategoryId = _salesline.ProjCategoryId;
_Purchreqline.CancelQty = _salesline.Cancelqty();
_Purchreqline.ActivityNumber = activitynumber.valueStr();
_Inventdim.InventSiteId = site.valueStr();
_Inventdim.InventLocationId = location.valueStr();
_Inventdim = InventDim::findOrCreate(_Inventdim);
_Purchreqline.inventDimId = _Inventdim.inventDimId;
_Purchreqline.LineType = Purchreqlinetype::Item;
_Purchreqline.insert();
}
ttscommit;
if(_Purchreqline.Name != "")
{
Info(strfmt("Press f5 - Import SOP : %1 (%2) to PR : %3 (%4) has been succesfully", Salesid, Company.valueStr(), _purchreqtable.PurchReqId, curExt()));
}
}
0 comments:
Post a Comment