Adding extra elements to XML string in AIF

Well let me start like this…
In an integration scenario you have to send some data to other system which is coming from some calculations… say item price which may come from lots of calculations… And you need to send this information along with the item information how are you going to acheive this… here is are a few methods..
Method 1: Create a temporary table with required fields. Then create an Axd class for this table to serialize the XML and write logic to fill this temporary table before sending the data along with the logic to calculate applicable item price.
This may seem to be a bit cumbersome task as it requires creation of temporary table and then Axd and AxBC classes and logic to fill in the temporary table.
Lets look at other method which I found while doing one such integration.
Method 2: Traverse to the AxInventTable AxBC class and add an extra parm method say ‘parmItemPrice’ and then write the logic to calculate the applicable item price and return this price. Done. This will add another element in the XML and the correct price infomration will be added to the XML.
Ok this is the way you can tweak the XML string related to table data. Now if you need to add some properties for the whole document itself how do you go about doing this stuff…
This is also very simple…
Firstly note that there are two standard property elements for any document, they are
  • DocPurpose
  • SenderId

Now if you need to add a third property then add a parm method in the AxdBase class and write the suitable logic to return the value for this property.

Let me explain you this with an example…

If you want the current user id also to appear along with DocPurpose and SenderId, traverse to AxdBase class in AOT and then add method by name ‘parmUserId’ add following code to this parm method

public UserId parmUserId(UserId _userId = curuserid())
    return curuserid();

Now generate an XML and you can see another element <UserId> CurUser </UserId>.


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