Thursday, July 7, 2011

Upper- / lowercase oddity in AIF

Have you ever wondered why the name of batch id tag must start with a capital letter, i.e. , when using the InventDim table in an AIF service? The field in the table starts with a lowercase i.

Well, the reason is that AIF uses the names of the methods in the AX class (AxInventDim in this case) for the naming in the schema and of other artifacts it generates. On the AX class the method for this field is named “parmInventDimId”. So here the name starts with a capital letter.

Okay, that’s not really very odd and you could probably have figured this out just by making a qualified guess.

But then, why must the tag for the Serial Id start with a lower case s? The field name in the table starts with a lowercase s, and the method name is “parmInventSerialId”. So according to the logic above, the Serial Id tag should also start with an uppercase character.

This is where it gets interesting. In the \Classes\AxInternalBase\parmMethods method AX generates a list of fieldnames based on the parm methods of the AX class. The underlying class handing out the names is DictClass.
DictClass actually returns a wrong name, or at least not what you see in the AOT, for the parmInventSerialId method. It returns the name as parminventSerialId, which matches the casing of the table field and, voila, the tag can be named exactly as the table field.

Here is a job showing the names handed out by (Sys)DictClass:
static void AIF(Args _args)
    SysDictClass            dc = new SysDictClass(5790);
    Map                     methods;
    MapEnumerator           me;

    methods = dc.objectMethods2ClassId(true);
    me      = methods.getEnumerator();

    while (me.moveNext())
        if (substr(me.currentKey(),1,strlen('parm')) == 'parm')
            info (me.currentKey());