AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 14.04.2012, 02:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,617 / 848 (80) +++++++
Регистрация: 28.10.2006
emeadaxsupport: Product Configurator - Calculating Decimal BOM Quantities
Источник: http://blogs.msdn.com/b/axsupport/ar...uantities.aspx
==============

The constraint based product configurator was released in Dynamics AX 2012. The bulk of the constraint logic can be built using Microsoft Solver Foundation logic, as described in the following technet article.

http://technet.microsoft.com/EN-US/l.../hh278332.aspx

There are some limitations to what can be accomplished through the solver foundation. For example, product configurator does not support the use of decimal values in constraint calculations and as a result prohibits many calculations involving multiplication and division.

One way to meet these requirements is to make use of the newly introduced PCAdaptor class. The following example shows how to use this class to calculate a decimal quantity for a BOM Line as the square of an integer divided by 3. In many cases this
type of calculation would result in decimal values, so it could not be accommodated using the solver foundation logic.

Our calculation will be:

BOM Quantity = (Integer1^2)/3

We will be using a very basic product configuration that consists of one attribute and no constraints. This example uses the contoso USA demo data .

Basic Product Model Setup

Product Model: CalculationExample

Attributes

Name

Solver Name

Description

Attribute Type

INTEGER1

INTEGER1

INTEGER1

IntegerDomainHTSLight



BOM Lines

Name

Description

Item Number

Quantity

1101 Name

1101Description

1101

1



X++ Code to calculate the required quantity.

In order to call the API we will need to create a new class in the AOT that extends the PCAdaptor class.
I’ve created a new class called ModelCalcExample. The classDeclaration method for this class is shown below. Note that the
PCAdaptorExtensionAttribute must be used to indicate that this class is associated with my CalculationExample product model.

[PCAdaptorExtensionAttribute('CalculationExample')]//Model Name

public class ModelCalcExample extends PCAdaptor

{

}

Next I will need to include some code in the run method of my class. This code will execute after I
have made all attribute selections and click on the Ok button.

public void run()

{

str 100 INT1;

real QTY;


PCAdaptorAttribute attr;
PCAdaptorRootComponent rootComponent;

rootComponent = this.parmProductConfigurationModel().getRootComponent();

attr = rootComponent.getAttribute('INTEGER1');

INT1 = attr.getValueAsLocalizedString();

QTY = (str2int(INT1)*str2int(INT1))/3;

if(QTY)

{
rootComponent.getBOMLine('1101 Name').parmturnoverquantity(QTY);

}

}



Now that we’ve written this code, we can test the results. If you assign this product
configuration model to a configurable item, and test using an integer value of
13 you should get a 1 line BOM for your item that contains Item Number 1101
with a quantity of 56.3333.

This is only one example of what can be done using the API with constraint base product models. There are many other parameter values that can
be set on both BOM’s and Routes. Some examples include calculating the run time of a route operation, setting the
scrap factor on a BOM line, and setting route operation priority. You can get a feel for the possibilities by
reviewing the methods within the PCAdaptorBOMLine and PCAdaptorRouteOperation classes.




Источник: http://blogs.msdn.com/b/axsupport/ar...uantities.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
emeadaxsupport: AX2012 purchasing posting types “Purchase Expenditure for product” and “Purchase expenditure, un-invoiced" Blog bot DAX Blogs 0 15.02.2012 07:13
DynamicsAxSCM: Product-item data management services Blog bot DAX Blogs 0 06.07.2011 17:11
dynamics-ax: Product Management with Microsoft Dynamics AX 2012 - Part III Blog bot DAX Blogs 0 17.05.2011 17:11
dynamics-ax: Product Management with Microsoft Dynamics AX 2012 - Part II Blog bot DAX Blogs 0 11.05.2011 06:15
dynamics-ax: Product Management with Microsoft Dynamics AX 2012 - Part I Blog bot DAX Blogs 0 26.04.2011 07:12

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 16:44.