Источник:
http://paruvella.spaces.live.com/Blo...4DB0!545.entry
==============
Again I am back with some AIF stuff.
Assume that if we have a requirement like, we need to send at least 10 records per XML as an outbound.
Have a look on the following example which gives an idea, how we can send 10 or some number of records in an XML as an outbound.
X++:
static void AIFSendChAccForRangeRec(Args _args)
{
AxdSendContext axdSendContext = AxdSendContext::construct();
AifConstraint aifConstraint = new AifConstraint() ;
AifConstraintList aifConstraintList = new AifConstraintList();
AifActionId actionId;
AifEndpointList endpointList;
Query query;
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange qbr;
RecId start;
RecId end;
LedgerTable ledgerTable;
;
//reading lowest recordId for a specific criteria
select firstonly RecId from ledgerTable where ledgerTable.AccountPlType == LedgerAccountType::Heading;
start = ledgerTable.RecId;
end = start + 100; // add some value to the recordId. This increment value we can change depends on req.
query = new Query(queryStr(AxdChartOfAccounts));
AxdSend::removeChildDs(query);
queryBuildDataSource = query.dataSourceTable(tablenum(LedgerTable));
queryBuildDataSource.addRange(fieldnum(LedgerTable, AccountPlType)).value(QueryValue(LedgerAccountType::Heading));
qbr = queryBuildDataSource.addRange(fieldnum(LedgerTable, RecId));
//here adding the records range condition, to filter the no.of records to send in XML
qbr.value(strfmt('( (%1 >= %2) && (%1 <= %3) )',
fieldstr(LedgerTable, RecId),
start,
end));
actionId = AifSendService::getDefaultSendAction(classnum(LedgerChartOfAccountsService), AifSendActionType::SendByQuery);
aifConstraint.parmType(AifConstraintType::NoConstraint);
aifConstraintList.addConstraint(aifConstraint);
endpointList = AifSendService::getEligibleEndpoints(actionId, aifConstraintList);
//implemented the AIF-Outbound using query object
AifSendService::submitFromQuery(actionId, endpointList, query, AifSendMode::Async);
}