on 11-14-2013 4:04 PM
Hi all,
I have an MII transaction where I receive a JSON string as input. This string contains all field value pairs that are needed by the RFC on R3 that I want to call from MII. The RFC input consists of a table which can contain multiple lines (with data from the JSON string).
What are the possible ways of handling this or what is the best practice for handling this and where can I find some information/guidelines on how to do this.
Many Thanks in advance,
Joery
Hello Joery,
If you are using SAP MII 14.0 then you can use Json_To_XML_Converter action block available in MII workbench.
For example if your input JSON string is as below
{
"geometries" :
[{
"xmin" : -4,
"ymin" : -60,
"xmax" : 25,
"ymax" : -41
}
]
}
Then on using Json_To_XML_Converter will provide you an XML output shown as below.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<root>
<geometries>
<element>
<xmin>-4</xmin>
<ymin>-60</ymin>
<xmax>25</xmax>
<ymax>-41</ymax>
</element>
</geometries>
</root>
Then you can do an XSLT transformation on the above output XML to generate the RFC/BAPI request structure. May be something like below which is just an indicative xml and not the actual RFC structure.
<RFC_READ_TABLE>
<TABLE>
<item>
<xmin>-4</xmin>
<ymin>-60</ymin>
<xmax>25</xmax>
<ymax>-41</ymax>
</item>
</TABLE>
</RFC_READ_TABLE>
Hope this helps !
Regards,
Prashant Mittal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thx for the answers Padma and Prashant.
Both answers are helpfull and I will try to use the second method as it seems the cleaner solution.
For the first method there is the problem that it is (by my knowledge) not possible to itterate over json elements.
For the second I already well on my way. I have trired to convert the json to xml by using an xsl file but that was resulting in a rather complex xsl file. Then I used the json to XML convertor to get an xml file (as these are easier to work with in MII). So all that is left now is to write an xsl file to get the xml in the right format to pass to the RFC.
Thx a lot guys.
Hi,
It is certainly possible to iterate over JSON elements using a "for in" loop:
var x = {
"a":"element a",
"b":"element b"
};
for (var key in x) {
alert(key + " -> " + x[key]);
}
The main question to answer is on your architecture : Do you create simple basic MII transactions that will be reused by others or should MII do the main calculations and transformations and keep the client side complexity minimal?
Hello again,
I have solved the problem.
Sorry for the somewhat late update here but it has been kind of a hectic week.
The client side complexity has to be minimal for the project.
That said most processing happens on MII and R3.
The solution I used is ass follows:
I needed to create an MII document instead of using the first normal xml because i had to add another input parameter for the RFC besides the table.
Create transaction parameters which is of same type as RFC item and table, Repeat on your json string and assign to trx parameters.
You can refer below link to do that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
7 | |
3 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.