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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 27.01.2014, 16:28   #1  
EVGL is offline
EVGL
Banned
Соотечественники
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
 
4,445 / 3001 (0) ++++++++++
Регистрация: 09.07.2002
Адрес: Parndorf, AT
Effective "Date effectivness"
Дамы и господа, как вы считаете, можно ли запрограммировать следующий код в AX2012 лаконичнее:

X++:
public static void setStopped(
    InventItemOrderSetupMap     _inventItemOrderSetupMap,
    ItemStopped                 _stopped,
    date                        _effectiveDate = systemDateGet())
{

    InventItemSetupStopped  record;

    ttsBegin;

    record = InventItemSetupStopped::find(_inventItemOrderSetupMap.TableId, _inventItemOrderSetupMap.RecId, _effectiveDate);

    record.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);

    if (record && record.Stopped != _stopped)
    {
        while select forUpdate validTimeState(_effectiveDate) record
            where record.InventItemSetupRecId   == _inventItemOrderSetupMap.RecId
               && record.InventItemSetupTableId == _inventItemOrderSetupMap.TableId
               && record.ValidTo                != _effectiveDate
        {
            record.ValidTo = max(_effectiveDate-1, record.ValidFrom);
            if (record.validateWrite())
                record.update();
        }

    }

    select forUpdate validTimeState(_effectiveDate) record
        where record.InventItemSetupRecId   == _inventItemOrderSetupMap.RecId
           && record.InventItemSetupTableId == _inventItemOrderSetupMap.TableId
           && record.ValidTo                == _effectiveDate;

    record.initFromInventItemOrderSetupMap(_inventItemOrderSetupMap);
    record.ValidFrom = _effectiveDate;
    record.ValidTo = dateMax();
    record.Stopped = _stopped;

    if (record.validateWrite())
        record.write();

    ttsCommit;
}
Теги
ax2012

 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
emeadaxsupport: "An exchange rate cannot be found for exchange rate type XXX between currencies YYY and ZZZ on exchange date." when you attempt to process in Microsoft Dynamics AX 2012 Blog bot DAX Blogs 0 26.09.2012 07:15
dynamicscare: Updating Date Effective Tables in AX 2012 Blog bot DAX Blogs 0 01.05.2012 02:13
daxmusings: Valid Time State/Date Effective Framework - Part2 Blog bot DAX Blogs 6 07.10.2011 11:22
daxmusings: Valid Time State/Date Effective Framework - Part 1 Blog bot DAX Blogs 0 05.10.2011 14:11
daxsol: Axapta Kernel Functions Blog bot DAX Blogs 1 16.05.2009 19:22

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

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

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