views:

25

answers:

1

I want to have one XPO, and have the same code work on AX4 and AX5. I am looking for a precompiler directive to check the version, sort of like:

#if define AX4
  thisCode(...)
#else
  thatCode(...)
#endif
A: 

It looks like the SysDataExpImp macro library may have a version based macro called expFormat which you could use like this:

#SysDataExpImp
#if.expFormat('EXPFORMAT VER. 5.0')
info('Microsoft Dynamics AX 2009');
#endif
#if.expFormat('EXPFORMAT VER. 4.01')
info('Microsoft Dynamics AX 4.0 SP1');
#endif

You could also use a macro that is only found in AX 2009. The AotExport macro library has macros for each type of AOT object and Data Sets were introduced in 2009:

#AotExport
#if.expDataSet
info('Microsoft Dynamics AX 2009');
#endif
#ifnot.expDataSet
info('older than Microsoft Dynamics AX 2009');
#endif
Jay Hofacker