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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 22.03.2015, 01:28   #1  
Kabardian is offline
Kabardian
Талантливый разгвоздяй
Аватар для Kabardian
 
424 / 338 (12) ++++++
Регистрация: 14.12.2008
Адрес: Москва
Записей в блоге: 14
AX 2012 R2, R3: Утверждение спланированных заказов и Договоры
AX 2012 R2 CU7, R3 CU8.

При утверждении спланированных заказов в AX 2012 R2, R3 есть возможность группировать заказы по договорам, если включены соответствующие параметры сводного планирования. Хочу разобраться по какому принципу системы подбирает наиболее подходящий договор, но столкнулся с отсутствуем документации по теме. Копнул глубже и нашел такой нетленный код:
\Data Dictionary\Tables\AgreementLine\Methods\getAgreementLinesForOrderLine
X++:
/// <summary>
///    Retrieves the list of the agreement lines that match to the sales or purchase line.
/// </summary>
/// <param name="_salesPurchLine">
///    The sales or purchase line for which to find the agreement lines.
/// </param>
/// <param name="_matchingAgreement">
///    The record ID of the agreement header.
/// </param>
/// <param name="_getAll">
///    A Boolean value that indicates whether to retrieve all agreement lines that match; optional.
/// </param>
/// <returns>
///    The list of the found agreement lines packed into the container.
/// </returns>
/// <remarks>
///    If the <paramref name="_getAll" /> parameter is false, the optimization will be done. The agreement
///    lines will not be added to the list if they have lower priority than the lines already added to the
///    list. The item based agreement lines have more priority than the category based agreement lines.If
///    the <paramref name="_getAll" /> parameter is true, all found agreement lines will be added to the
///    list.
/// </remarks>
public server static container getAgreementLinesForOrderLine(SalesPurchLine       _salesPurchLine,
                                                             AgreementHeaderRecId _matchingAgreement,
                                                             boolean              _getAll = false)
{
    SalesLine                        salesLine;
    PurchLine                        purchLine;
    date                             expDate;
    ProjId                           projId;

    AgreementLineQuantityCommitment  agreementLineQuantity;
    AgreementLineVolumeCommitment    agreementLineVolume;
    AgreementHeader                  agreementHeader;
    PurchAgreementHeader             purchAgreementHeader;
    SalesAgreementHeader             salesAgreementHeader;
    Common                           salesPurchAgreementHeader;
    fieldId                          custVendAccountFieldId;
    CustVendAC                       custVendAccount;
    InventDim                        inventDim;
    InventDim                        salesPurchLineInventDim = _salesPurchLine.inventDim();

    EcoResCategoryId                 category = _salesPurchLine.Category;
    EcoResCategoryId                 rootCategory;
    EcoResCategoryNamedHierarchyRole hierarchyRole;

    List                             resultList       = new List(Types::Record);
    List                             categoryList     = new List(Types::Record);
    List                             rootCategoryList = new List(Types::Record);


#localmacro.AgreementLineSelect
//%1 AgreementLine subtype table
select %1
    where (!_matchingAgreement || %1.Agreement       == _matchingAgreement)
        && %1.IsDeleted              == NoYes::No
        && %1.expirationDate         >= expDate
        && %1.effectiveDate          <= expDate
        && ((_salesPurchLine.TableId == tablenum(PurchLine) && (%1.ProjectProjId == projId || %1.ProjectProjId == ''))
         || (_salesPurchLine.TableId == tablenum(SalesLine) && %1.ProjectProjId == projId))
        && %1.InventDimDataAreaId    == appl.company().dataArea(tablenum(InventDim))
        && ((_salesPurchLine.ItemId
                && %1.ItemId         == _salesPurchLine.ItemId
                && %1.ItemDataAreaId == appl.company().dataArea(tablenum(InventTable)))
            || (!%1.ItemId
                && (%1.Category      == category
                    || %1.Category   == rootCategory)))
#endmacro

#localmacro.AgreementLineQuantityCommitmentCondition
         (_salesPurchLine.LineDeliveryType != LineDeliveryType::OrderLineWithMultipleDeliveries
            || AgreementLineQuantity.IsMaxEnforced == NoYes::No
            || AgreementLineQuantity.ProductUnitOfMeasure == _salesPurchLine.PurchSalesUnit)
#endmacro

#localmacro.AgreementLineHeaderExistsJoin
//%1 AgreementLine subtype table
    exists join agreementHeader
    where agreementHeader.RecId == %1.Agreement
        && agreementHeader.IsDeleted == NoYes::No
        && agreementHeader.AgreementState == AgreementState::Effective
#endmacro

#localmacro.AgreementVendCustAccountExistsJoin
//%1 - AgreementLine subtype table
            exists join salesPurchAgreementHeader
                where salesPurchAgreementHeader.RecId == %1.Agreement
                    && (_matchingAgreement || (salesPurchAgreementHeader.(custVendAccountFieldId) == custVendAccount))
#endmacro


    void addToList(AgreementLine _aLine)
    {
        if (_getAll)
        {
            resultList.addEnd(_aLine);
        }
        else
        {
            if (_aLine.ItemId)
            {
                resultList.addEnd(_aLine);
            }
            else if (resultList.empty()) //do not add the category agreement lines if item agreement lines are already found
            {
                if (_aLine.Category != rootCategory)
                {
                    categoryList.addEnd(_aLine);
                }
                else if (categoryList.empty()) //do not add the root category agreement lines if category agreement lines are already found
                {
                    rootCategoryList.addEnd(_aLine);
                }
            }
        }
    }

    switch (_salesPurchLine.TableId)
    {
        case tableNum(SalesLine):
            salesLine                 = _salesPurchLine;
            expDate                   = salesLine.ShippingDateRequested ? salesLine.ShippingDateRequested : systemDateGet();
            projId                    = salesLine.ProjId;
            hierarchyRole             = EcoResCategoryNamedHierarchyRole::Sales;
            salesPurchAgreementHeader = salesAgreementHeader;
            custVendAccount           = salesLine.CustAccount;
            custVendAccountFieldId    = fieldNum(SalesAgreementHeader, CustAccount);
            break;
        case tableNum(PurchLine):
            purchLine                 = _salesPurchLine;
            expDate                   = purchLine.DeliveryDate ? purchLine.DeliveryDate : systemDateGet();
            projId                    = purchLine.ProjId;
            hierarchyRole             = EcoResCategoryNamedHierarchyRole::Procurement;
            salesPurchAgreementHeader = purchAgreementHeader;
            custVendAccount           = purchLine.VendAccount;
            custVendAccountFieldId    = fieldNum(PurchAgreementHeader, VendAccount);
            break;
    }

    if (!category)
    {
        category = EcoResProductCategory::findByItemIdCategoryHierarchyRole(_salesPurchLine.ItemId, hierarchyRole).Category;
    }

    rootCategory = EcoResCategory::getRoot(EcoResCategoryHierarchyRole::getHierarchiesByRole(hierarchyRole).CategoryHierarchy).RecId;

    while #AgreementLineSelect(AgreementLineQuantity)
         && #AgreementLineQuantityCommitmentCondition
         #AgreementInventDimExistsJoin(AgreementLineQuantity.InventDimId, inventDim, salesPurchLineInventDim)
         #AgreementLineHeaderExistsJoin(AgreementLineQuantity)
         && (agreementLineQuantity.IsPriceInformationMandatory == NoYes::No
            || agreementHeader.Currency == _salesPurchLine.CurrencyCode)
         #AgreementVendCustAccountExistsJoin(AgreementLineQuantity)
    {
        addToList(agreementLineQuantity);
    }

    while #AgreementLineSelect(AgreementLineVolume)
         #AgreementInventDimExistsJoin(agreementLineVolume.InventDimId, inventDim, salesPurchLineInventDim)
         #AgreementLineHeaderExistsJoin(AgreementLineVolume)
         && agreementHeader.Currency == _salesPurchLine.CurrencyCode
         #AgreementVendCustAccountExistsJoin(AgreementLineVolume)
    {
        addToList(agreementLineVolume);
    }

    if (_getAll || !resultList.empty())
    {
        return resultList.pack();
    }

    if (!categoryList.empty())
    {
        return categoryList.pack();
    }

    return rootCategoryList.pack();
}
Конкретно смутил вот этот кусок кода, т. к. несмотря на отсутствие определения макроса #AgreementInventDimExistsJoin код компилируется успешно:
X++:
while #AgreementLineSelect(AgreementLineQuantity)
         && #AgreementLineQuantityCommitmentCondition
         #AgreementInventDimExistsJoin(AgreementLineQuantity.InventDimId, inventDim, salesPurchLineInventDim)
         #AgreementLineHeaderExistsJoin(AgreementLineQuantity)
         && (agreementLineQuantity.IsPriceInformationMandatory == NoYes::No
            || agreementHeader.Currency == _salesPurchLine.CurrencyCode)
         #AgreementVendCustAccountExistsJoin(AgreementLineQuantity)
    {
        addToList(agreementLineQuantity);
    }
Вопросы:
  1. У кого-нибудь без напильника взлетел стандартный функционал с утверждением спланированных заказов по договорам?
  2. Есть ли какая-то документация, по какому алгоритму система подбирает договоры? По коду и так можно разобраться, но хотелось понимать как должен работать стандарт.
  3. Почему код выше компилируется несмотря на отсутствие определения макроса?

Последний раз редактировалось Kabardian; 22.03.2015 в 02:06. Причина: Восстановление темы
Старый 22.03.2015, 09:42   #2  
Alex_KD is offline
Alex_KD
Участник
AxAssist
MCBMSS
Соотечественники
 
522 / 362 (14) ++++++
Регистрация: 06.07.2006
Адрес: Melbourne, Down Under
3. Определение в \Macros\AgreementInventDimExistsJoin
__________________
AxAssist 2012 - Productivity Tool for Dynamics AX 2012/2009/4.0/3.0
За это сообщение автора поблагодарили: Kabardian (1).
Старый 22.03.2015, 11:38   #3  
Kabardian is offline
Kabardian
Талантливый разгвоздяй
Аватар для Kabardian
 
424 / 338 (12) ++++++
Регистрация: 14.12.2008
Адрес: Москва
Записей в блоге: 14
Цитата:
Сообщение от Alex_KD Посмотреть сообщение
3. Определение в \Macros\AgreementInventDimExistsJoin
Может я чего подзабыл, разве перед использованием макросов не обязательно их в объявлять сначала?
Старый 22.03.2015, 12:13   #4  
Alex_KD is offline
Alex_KD
Участник
AxAssist
MCBMSS
Соотечественники
 
522 / 362 (14) ++++++
Регистрация: 06.07.2006
Адрес: Melbourne, Down Under
Цитата:
Сообщение от Kabardian Посмотреть сообщение
Может я чего подзабыл, разве перед использованием макросов не обязательно их в объявлять сначала?
Слово "обьявлять" не совсем коректно.
xpp компилятор заменяеть макрос из AOT на тело макроса перед компиляцией.

Далее копилирует то что получилось. Если у вас в макросе код, то компилятор вставит этот код в тело метода и откомпилирует то что получилось.
Если у вас в макросе кучу #define, тогда имеет смысл вставить их в начале метода, чтобы #define были видны во всем методе.

Посмотрите макросы начинающиеся на InventDim*.
__________________
AxAssist 2012 - Productivity Tool for Dynamics AX 2012/2009/4.0/3.0

Последний раз редактировалось Alex_KD; 22.03.2015 в 12:19.
Старый 22.03.2015, 12:33   #5  
Kabardian is offline
Kabardian
Талантливый разгвоздяй
Аватар для Kabardian
 
424 / 338 (12) ++++++
Регистрация: 14.12.2008
Адрес: Москва
Записей в блоге: 14
Цитата:
Сообщение от Alex_KD Посмотреть сообщение
Слово "обьявлять" не совсем коректно.
xpp компилятор заменяеть макрос из AOT на тело макроса перед компиляцией.
Век живи, век учись.. спасибо!
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
emeadaxsupport: AX Content: How to install CU7 for Microsoft Dynamics AX 2012 R2 Blog bot DAX Blogs 0 12.11.2013 01:12
dynamicsaxbi: Better together: Microsoft Dynamics AX 2012 R2 and SQL Server Power View Blog bot DAX Blogs 0 12.12.2012 13:11
DAX: A sneak peek tour: 4 Business Benefits of Microsoft Dynamics AX 2012 R2 Blog bot DAX Blogs 0 03.12.2012 11:11
emeadaxsupport: Preliminary Microsoft Dynamics AX 2012 R2 content now on TechNet and MSDN! Blog bot DAX Blogs 0 10.11.2012 08:20

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

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

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 07:59.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.