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.

Recurring batch job import in AX 2012 R3

I was reading an article about the Data import export framework in the new Dynamics AX (AX 7) and it mentioned that the DIXF can be setup with an input folder. Any file placed in the input folder is processed and imported. Then it was pointed out to me that that function is also available in Dynamics AX 2012 – I’d just never noticed the setup options.

Mostly when we’re using the DIXF we’re setting up a new system, and most of our imports are “one-off’s” (although if you get away with as few as three data import cycles you’re doing well). But there are some business processes that rely on fairly regular data imports – for instance sales forecasts and sales prices are routinely imported into Dynamics AX and count as a ‘business as usual’ BAU import. So you might want to set these BAU imports up based on recurring batch jobs.

I’m doing this example based on a Price discount journal.

First I’ll check/setup my Target entity. Data import export framework > Setup > Target entity:


I’m going to do this example using a CSV file format import – but just a reminder that the DIXF can also import from XML or Excel files.

So next I need a processing group. I create a new processing group and use the Entities button to setup the target entity and import format. Data import export framework > Common > Processing group > Entities:


Next I’m going to define my import format and customise it slightly to simplify the import using the techniques I’ve described before ( here and here ).

I end up with mapping which looks like this:


And an input file which looks like this:


And when I preview my source file I see:


Excellent – my journal number and line number and Relation have defaulted correctly.

Now we are going to set this up as a recurring batch job – and that is done back on the processing group when you Get staging data:


Although you are offered a default Job ID you can enter your own, and a description:


Then click OK:


Now for the clever bit – we have ‘Processing directory’, ‘Completed directory’ and ‘Error directory’ parameters, but to make these active we first have to change the import Type from ‘File’ to ‘Directory’, that changes our ‘File path’ field to be a ‘Folder path’. I’ve got an input folder ready to use, and Processing, Completed, and Error directories:


And just to save another processing step I’m going to tick ‘Execute target step’, so that after my data is imported to the staging table, it’ll be copied to the target table automatically.

Now let’s set this up as a recurring batch job, and put it through its paces. Click Run and the familiar batch job setup form appears – you know what to do:


And of course when we click OK we get:


Incidentally you’ll notice that I’ve got into the habit of embedding the Company name in the job description – just makes it easier to search for. Systems administration > Inquires > Batch jobs:


First, let’s see what happens when the batch job runs and the input folder is empty:


I’m not sure that an error message is called for here, I would have thought an Information messages would suffice, and it looks like there’s already a fix available on LCS for this (KB3161169).

Although in my example the batch job history logs an error, the job keeps recurring, so now let’s place a file in the input folder, and wait patiently for the batch job to run again:


With a file to process we get a nice Infolog. And we can also see that in the Execution history of our Processing group:


The processing group execution history is cleaner than the batch job history, because here we’re only seeing the recurrences which processed files. Incidentally I did another test where I placed two files in the import folder, and both were processed exactly as I would have expected, but I don’t think you can rely on the DIXF processing the files in any particular sequence if you have multiple files.

Finally let’s just go and check that our sales price trade agreement journal got imported and is ready to post.

Sales and marketing > Journals > Price/discount agreement journals:


Perfect!

And of course we have our original input file now sitting in our ‘Completed directory’:


In order to make this a fully finished business process you’ll want to add in another job which will delete the staging data – you could do that as a second task in this batch job; and also you’ll want to tidy up the batch job execution history log by deleting those records after a few days. Housekeeping has become a bit of a hot topic in our office recently, and we’re all paying more attention to keeping the system neat and tidy.

Reduction key fixed month in Dynamics AX

The Reduction key is the period table for forecasting and master planning.

Most companies forecast in monthly buckets, a few get down to weeks, and I worked with a company once where the forecast was loaded in for every 2 weeks. Once the forecast is loaded, the typical process is that sales orders are netted off against forecast. If we’re going to do that we need to know which forecast relates to which sales order.

Dynamics AX master planning uses the Reduction key table. That was the only option in AX 2009. There’s a setup option on the Master plan:


Both the ‘Percent’ and ‘Purchase/sales order’ Reduction principle are driven by Reduction keys.

But AX 2012 offers a fourth option ‘Transactions – dynamic period’:


‘Transactions – dynamics period’ doesn’t use a Reduction key. The forecast records themselves define the period – a forecast period starts on a forecast record, and ends on the next period.

But whenever a company tells me that they forecast in calendar months I still tend to use Reduction keys, because it’s a simple and robust setup for monthly forecasting.

The Reduction key is defined on the Coverage group. It’s an optional field, but don’t leave it blank or you will find that sales orders aren’t netted off against forecast (the demands are just added together).


Where did that Reduction key come from? Master planning > Setup > Coverage > Reduction keys:


As you can see there’s a Wizard. Click the button and step through the setup. Not much to do on the first screen except click Next:


The next form lets you define the length of your buckets (e.g. months); the number of buckets (periods or reduction key lines) you wish to create; and whether the periods have a fixed start date or start on the current date.

This week I learnt to leave the Opening date blank, and I normally set the number of periods so that I’ve covered the forward time horizon for master planning, with plenty to spare, (although really when you think about it, you really only have to cover the forward time horizon of your open sales orders, not forecasts):


On the next form you define the Reduction key ID and a Description:


Then we’re given a preview:


… and a summary:


And Finish creates the Key and the Lines:


Now for the clever bit. As I said, until this week I never used to leave the Opening date blank. I suppose I was conditioned by the AX 2009 demo data which looked like this:


And then I reminded everyone that the Reduction key setup Opening date needs to be re-set once a year.

But as you can see from my AX 2012 screenshot above – you don’t have to enter an opening date. Leave it blank and the system just uses 1st January of the current year. Simple! But don’t setup the Reduction key with only 12 monthly periods, because that’ll give you issues as you get into December (or earlier if you have a long forward open order book).