AIF X++ generate xml example code

AIF X++ generate XML example code

As part of AIF Document Service related examples, here you can find how I generate an XML using an enhanced file system outbound port. I will have a detailed description that will link to this code.

static void JAD_SCOGenerateXmlVendInvoice(Args _args)
{
AxdSendContext axdSendContext = AxdSendContext::construct();
AifEntityKey aifEntityKey = AifEntityKey::construct();
AifEntityKeyList aifEntityKeyList = AifEntityKeyList::construct();
Map keyData;
AifConstraintList aifConstraintList = new AifConstraintList();
AifConstraint aifConstraint = new AifConstraint();
JAD_VendInvoiceInfoTable vendIIT;
int i,j;
JADSCOVendInvoiceService poService = JADSCOVendInvoiceService::construct();

vendIIT = JAD_VendInvoiceInfoTable::findRecId(5637152829);
keyData = SysDictTable::getKeyData(vendIIT);
aifEntityKey.parmTableId(vendIIT.TableId);
aifEntityKey.parmRecId(vendIIT.RecId);
aifEntityKey.parmKeyDataMap(keyData);
aifEntityKeyList.addEntityKey(aifEntityKey);
axdSendContext.parmXMLDocPurpose(XMLDocPurpose::Original);
axdSendContext.parmSecurity(false);
aifConstraint.parmType(AifConstraintType::NoConstraint) ;
aifConstraintList.addConstraint(aifConstraint) ;
AifSendService::SubmitDefault( classnum(JADSCOVendInvoiceService),
aifEntityKey,
aifConstraintList,
AifSendMode::Async,
axdSendContext.pack());
info(“done”);
}

Process outbound

After running the code above, there will be a new record waiting in the AIF Queue (System administration/Periodic/Services and Application Integration Framework/Queue manager).

You also need to call the following code to get the XML document generated.

static void JAD_ProcessOutbound(Args _args)
{
AifOutboundProcessingService aifOutboundProcessingService = new AifOutboundProcessingService();
aifOutboundProcessingService.run();
}

After executing the process outbound, click refresh and if you are fast enough or the batch for processing the queue is not yet set up, you will see this in the:

You can get the XML with the buttons of this form, or if the queue is empty than it was most probably processed and the document is in the outbound folder.

Leave a Reply

Your email address will not be published. Required fields are marked *