//http://daxtechies.blogspot.com.tr/2013/12/ax2012-r2-creating-product-or-product.html
if ( InventTable::find(itemId).ItemId != "" )
this.updateProduct();
else
this.newProduct();
itemRecId = EcoResProduct::findByDisplayProductNumber(itemId).RecId;
this.updateInventTable();
private void newProduct(EcoResProductSubtype _subType = EcoResProductSubtype::Product)
{
EcoResProductService erProdSvc;
EcoResEcoResProduct ecoResProd;
EcoResEcoResProduct_Product_Master prodMaster;
EcoResEcoResProduct_Translation translation;
EcoResEcoResProduct_Identifier identifier;
EcoResEcoResProduct_ProductDimGroup prodDimGroup;
EcoResEcoResProduct_Product_Distinct distMaster;
EcoResEcoResProduct_StorageDimGroup storDimGroup;
EcoResEcoResProduct_TrackingDimGroup tracDimGroup;
InventTable inventTable;
erProdSvc = EcoResProductService::construct();
ecoResProd = new EcoResEcoResProduct();
if (_subType == EcoResProductSubtype::ProductMaster) //varyantlı ürün
{
prodMaster = new EcoResEcoResProduct_Product_Master();
prodMaster.parmDisplayProductNumber(itemId);
prodMaster.parmProductType(EcoResProductType::Item);
prodMaster.parmSearchName(nameAlias);
prodMaster.parmVariantConfigurationTechnology(EcoResVariantConfigurationTechnologyType::PredefinedVariants);
translation = prodMaster.createTranslation().addNew();
identifier = prodMaster.createIdentifier().addNew();
prodDimGroup = prodMaster.createProductDimGroup().addNew();
prodDimGroup.parmProduct(itemId);
prodDimGroup.parmProductDimensionGroup(dimGroup);
storDimGroup = prodMaster.createStorageDimGroup().addNew();
tracDimGroup = prodMaster.createTrackingDimGroup().addNew();
}
if (_subType == EcoResProductSubtype::Product) //varyantsız ürün
{
distMaster = new EcoResEcoResProduct_Product_Distinct();
distMaster.parmDisplayProductNumber(itemId);
distMaster.parmProductType(EcoResProductType::Item);
distMaster.parmSearchName(nameAlias);
translation = distMaster.createTranslation().addNew();
identifier = distMaster.createIdentifier().addNew();
storDimGroup = distMaster.createStorageDimGroup().addNew();
tracDimGroup = distMaster.createTrackingDimGroup().addNew();
}
translation.parmDescription(itemName);
translation.parmLanguageId(SystemParameters::getSystemLanguageId());
translation.parmName(itemName);
storDimGroup.parmProduct(itemId);
storDimGroup.parmStorageDimensionGroup(storeGroup);
tracDimGroup.parmProduct(itemId);
tracDimGroup.parmTrackingDimensionGroup(trackingGroup);
identifier.parmProductNumber(itemId);
if (_subType == EcoResProductSubtype::ProductMaster) //varyantlı ürün
ecoResProd.createProduct().add(prodMaster);
if (_subType == EcoResProductSubtype::Product) //varyantsız ürün
ecoResProd.createProduct().add(distMaster);
erProdSvc.create(ecoResProd);
EcoResProductReleaseManagerBase::releaseProduct(EcoResProduct::findByProductNumber(itemId).RecId,CompanyInfo::find().RecId);
}
private void updateProduct()
{
InventTableModule inventModule;
EcoResProductTranslation translation;
update_recordSet inventModule setting unitId = unitId
where inventModule.ItemId == itemId;
update_recordSet translation
setting Description = itemName,
Name = itemName
where translation.Product == itemRecId &&
translation.LanguageId == SystemParameters::getSystemLanguageId();
}
private void updateInventTable()
{
InventTable inventTable;
InventModelGroupItem modelGroup;
update_recordSet inventTable
setting NetWeight = netWeight,
TaraWeight = taraWeight,
GrossDepth = depth,
GrossWidth = width,
GrossHeight = height,
UnitVolume = volume
where
inventTable.Product == itemRecId;
if (inventModelGroupId == "")
delete_from modelGroup
where modelGroup.ItemId == itemId && modelGroup.ItemDataAreaId == curext() &&
modelGroup.ModelGroupDataAreaId == curext();
else
{
select firstOnly forUpdate modelGroup
where modelGroup.ItemId == itemId && modelGroup.ItemDataAreaId == curext() &&
modelGroup.ModelGroupDataAreaId == curext();
modelGroup.ItemId = itemId;
modelGroup.ItemDataAreaId = curext();
modelGroup.ModelGroupDataAreaId = curext();
modelGroup.ModelGroupId = inventModelGroupId;
if (modelGroup.RecId == 0)
modelGroup.insert();
else
modelGroup.update();
}
}
Blog Listem
30 Kasım 2015 Pazartesi
16 Kasım 2015 Pazartesi
AXAPTA - Kod içinde şirket değiştirmek
Kod içinde şirket değiştirmek kolay. Ancak iki ufak noktaya dikkat etmek gerekiyor; select/SQL kullanılıyorsa select/SQL için kullanılan yerel tablo adını nulllamak gerekiyor. Query kullanılıyorsa da queryin loop içinde her seferinde yeniden oluşturulması gerekiyor. Query.reset() bu konuda bir işe yaramıyor:
Query:
changeCompany(dataArea.Id)
{
qRun = new QueryRun(q);
while (qRun.next())
{
custTable = qRun.get(tablenum(CustTable));
...
}
}
Select/SQL:
changeCompany(dataArea.Id)
{
custTable = null;
subSegmentGroup = null;
while select AccountNum from custTable
...
Query:
changeCompany(dataArea.Id)
{
qRun = new QueryRun(q);
while (qRun.next())
{
custTable = qRun.get(tablenum(CustTable));
...
}
}
Select/SQL:
changeCompany(dataArea.Id)
{
custTable = null;
subSegmentGroup = null;
while select AccountNum from custTable
...
13 Kasım 2015 Cuma
AXAPTA - Kodla security check kontrolü
Bazen kodla security check yapmak gerekir (Display metod vb.. durumlarda):
SecurityKeySet securityKeys = new SecurityKeySet();
;
securityKeys.loadUserRights(curuserid());
if (securityKeys.access(securitykeynum("KRC_CrossCompany")) == AccessType::NoAccess)
chkCrsCompany.value(NoYes::No);
SecurityKeySet securityKeys = new SecurityKeySet();
;
securityKeys.loadUserRights(curuserid());
if (securityKeys.access(securitykeynum("KRC_CrossCompany")) == AccessType::NoAccess)
chkCrsCompany.value(NoYes::No);
12 Kasım 2015 Perşembe
AXAPTA - SysInfoAction sınıfıyla info fonksiyonuna ekstra görev getirme
Bu sınıf ile bir formu çağırmanın iki yolu var:
info(strfmt("Satış siparişi oluşturuldu: %1",salesTable.SalesId),"",
SysInfoAction_TableField::newBuffer(salesTable));
Yukarıdaki yöntemin aşağıdakinden farklı bir record datası göndermemesi:
SysInfoAction_FormRun infoAction = SysInfoAction_FormRun::newFormName(formStr(SalesTable));
;
infoAction.parmCallerBuffer(salestable);
info(strfmt("Satış siparişi oluşturuldu: %1",salesTable.SalesId),"",
infoaction);
info(strfmt("Satış siparişi oluşturuldu: %1",salesTable.SalesId),"",
SysInfoAction_TableField::newBuffer(salesTable));
Yukarıdaki yöntemin aşağıdakinden farklı bir record datası göndermemesi:
SysInfoAction_FormRun infoAction = SysInfoAction_FormRun::newFormName(formStr(SalesTable));
;
infoAction.parmCallerBuffer(salestable);
info(strfmt("Satış siparişi oluşturuldu: %1",salesTable.SalesId),"",
infoaction);
Kaydol:
Kayıtlar (Atom)