Weather forecasting using X++

In todays competitive business world, there are many factors which determine the profit or loss.

Climatic conditions has its own impact and is becoming increasingly important for the corporates.

Like Demand forecast, weather forecast can be very helpful in business planning.

This Job is an attempt to predict the weather conditions in advance and organize things in such a way which will help the companies not
only to optimize their resources but also maximize their profits.

In the example, I used Yahoo released rss weather feeds: and XML programming to get the climatic conditions

The format of the URL for the feed is:

p is a US zip or a Yahoo! Weather location ID
u is the temp. units. ‘F’ for Fahrenheit (default) and ‘C’ for celcius

static void weatherForecast(Args _args)


XmlDocument         doc = new

XmlNamespaceManager ns;

XmlNodeList         nodes;

XmlNode                node;


container day(str _day)





case ‘Mon’ : return [1,’Monday’];

case ‘Tue’ : return [2,’Tuesday’];

case ‘Wed’ : return [3,’Wednesday’];

case ‘Thu’ : return [4,’Thursday’];

case ‘Fri’ : return [5,’Friday’];

case ‘Sat’ : return [6,’Saturday’];

case ‘Sun’ : return [7,’Sunday’];

Default : return connull();




    //addresszipCode = _args.record();

);// +
addresszipCode.ZipCode +’&u=c’);

    // Set
up namespace manager for XPath

    ns =
new XmlNamespaceManager(doc.nameTable());

ns.AddNamespace("yweather", "");

    // Get
forecast with XPath

= doc.SelectNodes("//rss/channel/item/yweather:forecast", ns);

    node =

setprefix("Weather forecast");






info( node.attributes().getNamedItem("text").InnerText());

info(‘Min :’    +

info(‘Max :’    +

if(dayofwk(today()) ==


info(‘Current :’ +




info(‘Current : NA’);


node = nodes.nextNode();




1) An essential pre-requisite for the code to work is the URL should not be blocked by the firewall.

2)We can directly use this job as an menuitemaction button by adding the job in menuitems under actions, Then add the button in the AddressZipcode form , for that make use of the commented code of AddressZipcode in the above Job.

Here are some example location IDs (do not include the city name) or use the existing Zipcodes of AX

  • Beijing: CHXX0008
  • Helsinki: FIXX0002
  • London: UKXX0085
  • Moscow: RSXX0063
  • Munich: GMXX0087
  • Paris: FRXX0076
  • Riyadh: SAXX0017
  • Tokyo: JAXX0085

For more details on the Yahoo! Weather RSS feed and other location IDs, please visit

" Don’t bother about weather"


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: