Ха, а вот такой джоб
X++:
static void reproOrigBug3_MRC(Args _args)
{
CompanyInfo companyInfo;
DirPartyTable dirPartyTable;
DirOrganizationBase dirOrganizationBase;
Common common5;
Common common5_orig;
Common common6;
Common common6_orig;
anytype anytypeVar;
;
common5 = null;
common6 = null;
select firstOnly companyInfo;
info(strFmt("companyInfo.Name = %1", companyInfo.Name));
info(strFmt("companyInfo.orig().Name = %1", companyInfo.orig().Name));
dirOrganizationBase = companyInfo as DirOrganizationBase;
info(strFmt("dirOrganizationBase.Name = %1", dirOrganizationBase.Name));
info(strFmt("dirOrganizationBase.orig().Name = %1", dirOrganizationBase.orig().Name));
dirPartyTable = companyInfo as DirPartyTable;
info(strFmt("dirPartyTable.Name = %1", dirPartyTable.Name));
info(strFmt("dirPartyTable.orig().Name = %1", dirPartyTable.orig().Name));
common5 = companyInfo as DirPartyTable; // здесь отладчик покажет что common5 - тип companyInfo
info(strFmt("common5.(fieldNum(dirPartyTable, Name)) = %1", common5.(fieldNum(dirPartyTable, Name))));
//info(strFmt("common5.orig().(fieldNum(dirPartyTable, Name)) = %1", common5.orig().(fieldNum(dirPartyTable, Name)))); // не компилируется
common5_orig = common5.orig();
info(strFmt("common5_orig.(fieldNum(dirPartyTable, Name)) = %1", common5_orig.(fieldNum(dirPartyTable, Name))));
info("");
info("А так работает (с приведением типа)");
anytypeVar = new SysDictTable(tableNum(DirPartyTable)).makeRecord(); // здесь отладчик покажет что anytypeVar - тип DirPartyTable
anytypeVar = companyInfo; // и здесь anytypeVar - остался с типом DirPartyTable хотя присваивали companyInfo - ну не может проинициализированная переменная anyType сменить тип.
common6 = anytypeVar; // тоже тип DirPartyTable
info(strFmt("common6.(fieldNum(dirPartyTable, Name)) = %1", common6.(fieldNum(dirPartyTable, Name))));
//info(strFmt("common6.orig().(fieldNum(dirPartyTable, Name)) = %1", common6.orig().(fieldNum(dirPartyTable, Name)))); // не компилируется
common6_orig = common6.orig();
info(strFmt("common6_orig.(fieldNum(dirPartyTable, Name)) = %1", common6_orig.(fieldNum(dirPartyTable, Name))));
}
дат такой выхлоп:
Цитата:
companyInfo.Name = Company Dat
companyInfo.orig().Name =
dirOrganizationBase.Name = Company Dat
dirOrganizationBase.orig().Name = icName
dirPartyTable.Name = Company Dat
dirPartyTable.orig().Name = Company Dat
common5.(fieldNum(dirPartyTable, Name)) = Company Dat
common5_orig.(fieldNum(dirPartyTable, Name)) =
А так работает (с приведением типа)
common6.(fieldNum(dirPartyTable, Name)) = Company Dat
common6_orig.(fieldNum(dirPartyTable, Name)) = Company Dat
т.е. если приводить табличный буфер к табличному типу из середины иерархии то просто мусор может в значении придти.
в моем случае в поле companyInfo.name лежит значение "Company Dat"
если начитанный буфер привести к типу dirOrganizationBase то dirOrganizationBase.orig().Name вернет вообще мусор ! Будет возвращено значение "icName" вместо "Company Dat" !!!