Send the item master to a 3PL in AX 2012

So this post didn’t end up exactly the way I thought it would when I started it. Earlier this week we were talking about setting up integration with a 3PL, and we need to send that company a copy of the item master from one of our Dynamics AX companies. I remembered doing this a year or so ago for another company which was integrating Dynamics AX with a manufacturing shop floor production control system. My memory was that we’d used a standard Dynamics AX function with no customisation – but my memory was playing tricks, we’d done three minor enhancements to the standard process, which I’ll mention as we walk through the setup and process.

There’s a standard function that can send your items as an XML message, and the first thing that we need to do is to deploy that service as a Service group. Open the AOT and create a new Service group:


Then drag the Service InventItemService into that group, giving:


And then Right-click > Deploy the service group – that can take a while. Then close the AOT.

Now we need an outbound port. Systems administration > Setup > Services and Application Integration Framework > Outbound ports:


For this port I’m using a folder (and the File system adapter) and, as you can see above, I’ve created a folder I can write these outbound messages to. Next click on Service operations and select the InventItemService.find service operation:


Close the Select service operations window and tick the ‘Customise documents’ checkbox and click on the Data policies button, and a form opens which allows you to select which fields are going to be exported:


However, there are a few fairly glaring omissions from this service: the item name (which of course is held on the Product master); and Barcodes; and Product dimensions (config, size, colour, style, if you’re’ using those). There are separate AIF services for Barcodes and Products, but the best action here is to customise this service to add in any ‘missing’ fields which you require. In case you’re counting, that’s the second customisation.

There aren’t a lot of other setup options:


I’ve added logging but probably that’s not necessary. OK. Activate the outbound port:


Next navigate to your items, Product information management > Common > Released products, and click on the ‘General’ action tab, and click on the ‘Send …’ button.

Incidentally, if you haven’t done the setup above, when you click the send button you’ll see an error message like this:


But if everything is setup correctly you’ll get:


The first time you open this form you’ll have to select your Outbound port name (which of course defines the folder you’re writing to). Then you have to setup the filter query to select the items which will be exported, and oddly this form doesn’t remember the filter query you previously used; nor does it default to the item selected when you click the Send button, and it doesn’t have a Batch tab to setup this function up as a recurring batch job. That’s the third customisation that’s required. Set your filter and click the OK button:


The system writes a trigger record into the AIF queue. Systems administration > Inquires > Services and Application Integration Framework > Queue manager:


AIF messages are processed by an AIF batch job, and this consists of four batch tasks. As I’ve said before there’s a good example of the batch job you need in the demo data. Systems administration > Inquires > Batch jobs > Batch jobs:


(If you setup your own job remember to setup the processing conditions so that the tasks process one after another in this sequence).

So we wait for the job to run, and hey presto a file appears in our outbound folder:


It’s an XML file with a unique date/time stamp file name. In this case the message looks like this:


If you don’t have a taste for the customisations required to export additional fields and convert this function to a recurring batch job check out this post: A simple outbound interface for Dynamics AX 2012.

Advertisements

AIF inbound port file processing in AX 2012

Now here’s a funny thing. There’s a TechNet article here which talks about sequential and parallel processing options in the Dynamics AX AIF inbound port.

Before I lose you, we’re talking about this setup, Systems administration > Setup > Services and Application Integration Framework > Inbound ports:


In this screenshot we can’t change the Processing options because the port is active. To make the change we have to Deactivate the port, make the change, and then Activate it.

If you clicked on the link above you’ll have seen reference to the fact that there is a hard-coded limit built into the AIF via a macro:


What’s much less obvious (so much less obvious that I can’t find it anywhere) is that there is also a limit for sequential processing – and that is 100 messages!

So our scenario went like this: we’re synchronising Dynamics AX to another system and using the AIF to create Products and Items (Released products). The system that’s sending the information to Dynamics AX is creating one message per item, and we’re using a File system interface, because it’s nice and simple and easy to monitor. We’ve setup the traditional AIF recurring batch job with the familiar four tasks:


The batch job recurrence is set to 10 minutes but we saw that the message files weren’t all processed. There weren’t a huge number of message files, we were synchronising about 2,500 products, but obviously the system takes its time to chew through 5,000 files if it only does 100 every 10 minutes.

Fortunately the fix was simple, and effective – one tick equals 10 times the performance.
If only other things in life followed this pattern …

How to demonstrate the AIF and inbound purchase orders AX 2012 R3 demo hyper-v.

I’ve just stumbled across a nice little ‘Easter Egg’ in the standard demo Hyper-V image: it’s all setup to import inbound customer purchase orders as sales orders in the AIF.

The setup is sitting there ready to go. Systems administration > Setup > Services and Application Integration Framework > Inbound ports:


So this Inbound port is going to process any valid .xml message file in the C:\AIF\In folder.

Those nice people at Microsoft have created that folder for you, and have even created a small, but perfectly formed .xml message as the file “Sample AIF SalesOrder-In R3.txt”:


Open that file and you’ll see:


Let’s save it as TEST1.xml, (you’ll have to change the ‘Save as type’ from ‘Text document (*.txt)’ to ‘All files’. Then you should be able to open the .xml file with Internet Explorer, which makes reading the XML slightly easier:


So you can see that this XML message structure is really simple. There’s a Header that tells Dynamics AX how to process the file; then there’s a group of sales order header (SalesTable) fields; and finally in this example there’s a single sales order line (SalesLine) group of fields (Item number, Sales quantity and Sales unit of measure).

Now when we run the job to import this message as a sales order the batch job (below) will delete the file – so if you’ve got an .xml file as above, move the original .txt file to another folder (I use the parent c:\AIF\ folder, but you can move/copy it to anywhere). Also the AIF will process .txt and .xml files so you can save the message you want to import in either format, whatever is simplest for you to view or edit.

And the last and final bit of setup has also been done. We need a recurring batch job to process the inbound and outbound AIF message. You’ll find the batch job at Systems administration > Inquires > Batch jobs > Batch jobs:


Click on ‘View tasks’ and you’ll see that it runs the four AIF processes, in sequence) – nice job Sara:


We’re going to run the job – but before we do I check the recurrence, and set the job to run just once (so that I’ve got some control over when and how often it runs):


Click OK to close the Recurrence form, then select the job and Functions > Change status:


Click on the Waiting status to set that, and the job will process after a minute or so:


Once it has run the status will set to ‘Ended’:


And we can go take a look at our sales order. To make it easier to find my orders I add the ‘Customer requisition’ field to the overview grid


Success! How easy was that?

So next you’ll want to play. Change the Customer requisition (SalesTable:PurchOrderFormNum) each time you create a new message to import. The standard AIF sales order import function detects a duplicate customer purchase order and creates another sales order of type Journal. You’re bright enough to have spotted the alignment between the .xml message fields and the Dynamics AX tables that are being populated. For instance if you want to add in the Sales origin your .XML will look like this:


Note. If you add new fields in a table group make sure you add them in alphabetical order. You’ll also have to de-activate the Inbound port, click on Data policies and ‘Enabled’ any field you want to import:


(or simply enable all fields).

Don’t forget to Activate the inbound port again once you’ve made your changes.

Obviously you make this a multi-line purchase order by simple copy’n’paste of all the SalesLine fields.

Keep a copy of the original example. Change one thing at a time, and if your message doesn’t create a sales order check Systems administration > Periodic > Services and Application Integration Framework > Exceptions. Remember that each time the batch job processes the inbound file it’ll delete it from the C;\AIF\In folder, so you’ll have to copy a freash file back in, then re-run the job. Hopefully the error message will make sense. In this example I’ve ‘deliberately’ forgotten to check that the sales origin code I added to the XML message actually exists in the main table.

 


Happy AIF’ing.