Возможно дело в названии ичточников данных, попробуйте использовать QueryBuildDataSource.name() при формировании связки.
Набросал тут упрощенную версию запроса по RAssetLocation:
X++:
static void jbRAssetLocationOR(Args _args)
{
RAssetLocation rAssetLocation ;
RAssetTransferTable rAssetTransferTable ;
QueryBuildDataSource qbdsRAssetLocation ;
QueryBuildDataSource qbdsRAssetTransfer ;
Range rangeRAsset ;
RAssetLocationId rAssetLocationId ;
Query query ;
QueryRun queryRun ;
;
rAssetLocationId = '1 01 01 11 00' ;
info( 'From X++ Select:' ) ;
while select rAssetLocation
where rAssetLocation.Location == rAssetLocationId
join rAssetTransferTable
where rAssetTransferTable.NewLocation == rAssetLocation.Location ||
rAssetTransferTable.OldLocation == rAssetLocation.Location
{
info( rAssetTransferTable.JournalNum ) ;
}
query = new Query() ;
qbdsRAssetLocation = query.addDataSource( tableNum( RAssetLocation ) ) ;
qbdsRAssetTransfer = qbdsRAssetLocation.addDataSource( tableNum( RAssetTransferTable ) ) ;
qbdsRAssetTransfer.relations( false ) ;
rangeRAsset = strfmt( '((%1.%2 == %4.%5) || (%1.%3 == %4.%5))' ,
qbdsRAssetTransfer.name() ,
fieldStr( RAssetTransferTable, NewLocation ),
fieldStr( RAssetTransferTable, OldLocation ),
qbdsRAssetLocation.name() ,
fieldStr( RAssetTable, Location ) ) ;
findOrCreateRange_W( qbdsRAssetLocation, fieldNum( RAssetLocation, Location ), SysQuery::value( rAssetLocationId ) ) ;
findOrCreateRange_W( qbdsRAssetTransfer, fieldNum( RAssetTransferTable, RecId ), rangeRAsset ) ;
info( 'From QueryRun:' ) ;
info( qbdsRAssetLocation.toString() ) ;
queryRun = new QueryRun( query ) ;
while( queryRun.next() )
{
rAssetTransferTable = queryRun.get( tableNum( RAssetTransferTable ) ) ;
info( rAssetTransferTable.JournalNum ) ;
}
}