|
18.08.2021, 11:13 | #1 |
Сенбернар
|
Перенос данных из компании в компанию
Очень коротко, задача: из одной таблички в исходной компании Аксы перенести данные ( с проверкой на дублирование, чтобы N раз не перенести) в целевую.
Что-то торможу... подтолкните, плз - как это правильно сделать? --- DAX2009, да
__________________
Best Regards, Roman Последний раз редактировалось RVS; 18.08.2021 в 11:23. |
|
18.08.2021, 12:16 | #2 |
Участник
|
Администрирование\Периодические операции\Экспорт/Импорт данных\Группы определения
Или можно написать простой job с использованием changecompany и нужными проверками. |
|
18.08.2021, 12:25 | #3 |
Сенбернар
|
Цитата:
2. changecompany, crosscompany... у меня фантазии не хватает, как это реализовать на практике. Потому, собственно, и вопрос задал...
__________________
Best Regards, Roman |
|
18.08.2021, 13:05 | #4 |
Banned
|
Ну, как-то так:
X++: static void eglaSMAServiceObjectTableReplicate(Args _args) { SMAServiceObjectTable object116, object101, father116, father101; smmBusRelTable busRel116, busRel101; DirPartyTable dirParty116, dirParty101; CustTable cust116, cust101; int record; SMAAgreementTable agreementTable; SMAAgreementLine agreementLine; SMAServiceObjectRelation objectRelation; ; try { changeCompany('101') { object101.skipDataMethods(true); object101.skipTTSCheck(true); while select forupdate object101 where object101.dataAreaId == '101' && (object101.ServiceObjectGroup like "FREIBAD*" || object101.ServiceObjectGroup like "HALLENB.*" || object101.ServiceObjectGroup like "THERAPIE*" || object101.ServiceObjectGroup like "WELLNESS*" || object101.ServiceObjectGroup like "WHIRLP.*" || object101.ServiceObjectGroup like "ZIERBECKEN") && ! (object101.ServiceObjectId like "*P") && object101.EcoObjectStatusId == "Verfügbar" { select firstonly RecId from agreementTable where (! agreementTable.EndDate || agreementTable.EndDate >= today()) && (! agreementTable.Suspended) exists join objectRelation where objectRelation.ServiceObjectId == object101.ServiceObjectId && objectRelation.RelKeyId == agreementTable.AgreementId && objectRelation.RelTableId == tableNum(SMAAgreementTable); if (agreementTable) { continue; } select firstonly RecId from agreementLine where (! agreementLine.EndDate || agreementLine.EndDate >= today()) && (! agreementLine.Suspended) join RecId from agreementTable where (! agreementTable.EndDate || agreementTable.EndDate >= today()) && agreementTable.AgreementId == agreementLine.AgreementId && (! agreementTable.Suspended) exists join objectRelation where objectRelation.ServiceObjectId == object101.ServiceObjectId && objectRelation.RelKeyId == agreementTable.AgreementId && objectRelation.RelTableId == tableNum(SMAAgreementLine); if (agreementLine) { continue; } object101.EcoObjectStatusId = "Gelöscht"; print object101.ServiceObjectId + " " + object101.EcoObjectStatusId; object101.doUpdate(); } } info(time2str(timenow(),-1,-1) + " " + curExt()); while select object116 order by EcoSMAServiceObjectFatherId asc where object116.dataAreaId == '116' && (object116.ServiceObjectGroup like "FREIBAD*" || object116.ServiceObjectGroup like "HALLENB.*" || object116.ServiceObjectGroup like "THERAPIE*" || object116.ServiceObjectGroup like "WELLNESS*" || object116.ServiceObjectGroup like "WHIRLP.*" || object116.ServiceObjectGroup like "ZIERBECKEN") outer join busRel116 where busRel116.BusRelAccount == object116.EcoBusRelAccount join dirParty116 where dirParty116.PartyId == busRel116.PartyId { cust116 = CustTable::findByPartyId(dirParty116.PartyId); father116 = SMAServiceObjectTable::find(object116.EcoSMAServiceObjectFatherId); changeCompany('101') { select firstonly busRel101 where busRel101.BusRelAccount == busRel116.BusRelAccount join dirParty101 where dirParty101.PartyId == busRel101.PartyId; if (dirParty116.Name != dirParty101.Name) { select firstonly cust101 where cust101.AccountNum == cust116.AccountNum join dirParty101 where dirParty101.PartyId == cust101.PartyId join busRel101 where busRel101.PartyId == dirParty101.PartyId; if (! busRel101) { select firstonly dirParty101 where dirParty101.Name like "*"+strReplace(strReplace(strltrim(strrtrim(busRel116.Name)),"Frau ",""),"Herr ","")+"*" join busRel101 where busRel101.PartyId == dirParty101.PartyId; } } ttsbegin; object101.clear(); object101 = SMAServiceObjectTable::find(object116.ServiceObjectId+"P", true); buf2Buf(object116, object101); object101.ServiceObjectId = object116.ServiceObjectId+"P"; if (! busRel101) { print dirParty116.Name; print dirParty101.Name; object101.EcoBusRelAccount = strRem(strReplace(strReplace(strltrim(strrtrim(busRel116.Name)),"Frau",""),"Herr","")," "); } else { object101.EcoBusRelAccount = busRel101.BusRelAccount; } if (object116.EcoSMAServiceObjectFatherId) { object101.EcoSMAServiceObjectFatherId = object116.EcoSMAServiceObjectFatherId+"P"; father101 = SMAServiceObjectTable::find(object101.EcoSMAServiceObjectFatherId); if (! father101 && father116) { buf2Buf(father116, father101); father101.ServiceObjectId = object101.EcoSMAServiceObjectFatherId; father101.EcoBusRelAccount = object101.EcoBusRelAccount; father101.Description += " Pool"; father101.write(); record++; } } print object101.ServiceObjectId; record++; object101.write(); ttscommit; } } } catch (Exception::Error) { warning(strFmt("Error at the object %1", object116.ServiceObjectId)); } info(time2str(timenow(),-1,-1) + " " + strFmt("Total objects - %1",record)); } |
|
18.08.2021, 13:50 | #5 |
Сенбернар
|
Спасибо. А вот это:
X++: while select object116 order by EcoSMAServiceObjectFatherId asc where object116.dataAreaId == '116'
__________________
Best Regards, Roman |
|
18.08.2021, 14:04 | #6 |
Banned
|
Нет, но это предотвратит попытку запустить из неправильной компании: запрос ничего не найдет. Это оказалось полезным.
|
|