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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 13.06.2020, 05:30   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
General journals log update bugs
Источник: http://alexvoy.blogspot.com/2020/06/...date-bugs.html
==============


I found a couple questionable things in General journal log updating.

First, Log field limit of 255 characters. It is evidently not enough for relatively long information to be stored for eventual analysis.

Second, the way to update journal logs by copying lines from Infolog afterwards.

Anyway the standard methods meant to shorten the log content do not work properly. Let's see why.


And the method to find a voucher number can speak one language only.



So, we get a poorly built journal log.


It can be fixed by two extensions.

First, let's gather all lines in a set so that they would be present once only.


///
/// Extension of LedgerJournalCheckPost to fix a bug
///
[ExtensionOf(classStr(LedgerJournalCheckPost))]
final class CDPLedgerJournalCheckPost_Extension
{

///
/// Updates the infolog for the given transaction.
///
/// The transaction.
public void updateTransInfoLog(LedgerJournalTrans _ledgerJournalTrans)
{
this.cdpUpdateTransInfoLog(_ledgerJournalTrans);
// transLogPoint is already moved forward; therefore the next call will do no change to the log
next updateTransInfoLog(_ledgerJournalTrans);
}

///
/// Updates the infolog for the given transaction.
///
/// The transaction.
private void cdpUpdateTransInfoLog(LedgerJournalTrans _ledgerJournalTrans)
{
#Define.UserTab('\t')

Log logTxt;
Integer x = transLogPoint;
Integer y = infolog.num(0);
str currentLine;
str strLine;
Voucher voucher;
List list;
ListEnumerator listEnumerator;
Set setAllLines = new Set(Types::String);
//
Log tableLogTxt;
#ISOCountryRegionCodes
boolean countryRegion_RU = SysCountryRegionCode::isLegalEntityInCountryRegion([#isoRU]);
//

if (postingResults)
{
postingResults.parmLedgerPostingMessageLog(ledgerPostingMessageCollection);
}

while (x < y)
{
x++;
// parse all the lines if there are some prefixes
currentLine = infolog.text(x);
list = strSplit(currentLine, #UserTab);
listEnumerator = list.getEnumerator();
while (listEnumerator.moveNext())
{
currentLine = listEnumerator.current();
if(setAllLines.in(currentLine))
{
continue;
}
setAllLines.add(currentLine);
//
if (countryRegion_RU)
{
logTxt = currentLine + '\r\n';
tableLogTxt += logTxt;
}
else
{
//
logTxt += currentLine + '\r\n';
//
}
//

if (logTxt && postingResults != null)
{
if (_ledgerJournalTrans.Voucher == '')
{
voucher = LedgerJournalCheckPostResults::getVoucherFromLogText(currentLine);
if (voucher == '')
{
// continue because calling the LedgerJournalCheckPostResults.updateErrorLog
// method with a blank voucher has terrible performance and will not change the results
continue;
}
}
else
{
voucher = _ledgerJournalTrans.Voucher;
}

postingResults.updateErrorLog(voucher, logTxt);
}
}
}

//
if (countryRegion_RU)
{
logTxt = tableLogTxt;
}
//

if (logTxt)
{
tableErrorLog += logTxt;
}

transLogPoint = y;
}

}


Second, teach the voucher searching method to speak any language and do not return rubbish instead of a real voucher number.


///
/// Extension of LedgerJournalCheckPostResults to fix a bug
///
[ExtensionOf(classStr(LedgerJournalCheckPostResults))]
final class CDPLedgerJournalCheckPostResults_Extension
{
///
/// See the description for the standard method
///
/// log text
/// Voucher text
public static Voucher getVoucherFromLogText(Log _logText)
{
// this standard function does not works correctly
next getVoucherFromLogText(_logText);
return LedgerJournalCheckPostResults::CDPGetVoucherFromLogText(_logText);
}

///
/// Finds voucher numbers as it should be in all languages
///
/// Log text
/// Voucher text
private static Voucher cdpGetVoucherFromLogText(Log _logText)
{
List list;
ListEnumerator listEnumerator;
Voucher voucher;
str strLine;
const str voucherText = '@GeneralLedger:Voucher';
int voucherLen = strLen(voucherText);

list = strSplit(_logText, ',');

listEnumerator= list.getEnumerator();
while (listEnumerator.moveNext())
{
strLine = listEnumerator.current();
if (strContains(strLine, voucherText))
{
// delete the word VOUCHER in any language as well as all the spaces around
voucher = strLRTrim(strDel(strLine, 1, voucherLen));
break;
}
}
return voucher;
}

}


Now it looks much better and contains condensed information.


For storing more information, a new memo field can be a solution.

Hope, Microsoft will eventually come up with an optimized approach.

Good logging!




Источник: http://alexvoy.blogspot.com/2020/06/...date-bugs.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 15 Blog bot Dynamics CRM: Blogs 1 10.02.2016 10:26
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 17 Blog bot Dynamics CRM: Blogs 0 10.05.2014 06:30
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 16 Blog bot Dynamics CRM: Blogs 0 23.01.2014 03:15
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 14 Blog bot Dynamics CRM: Blogs 0 12.07.2013 07:13
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 13 Blog bot Dynamics CRM: Blogs 0 27.03.2013 22:12
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

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

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

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