2012 Jan 09 9:14 AM
Can you please help me out how to make a http JSON service for the standard BAPI.
2012 Jan 09 9:25 AM
Hello,
I do not know if there is specific settings required for web service but to create a web service out of BAPI, you can follow:
SE37 -> display BAPI -> Utilities -> More Utilities -> Create Web Service -> From Function Module
And to see existing services for particular package, go to transaction SE84..
..
Thanks.
2012 Jan 09 9:29 AM
Krishnendu Laha ,
1.I am new to json, creation of webservice is ok then how can i proceed..
2. I need the output of the bapi in the json format .
3. How could i do it and what are the steps for that .
2012 Apr 26 11:05 AM
hi, did you already recieve an answer on this ?
I have to do the same thing and don't know where to start
thanks,
2013 Feb 26 2:59 PM
Hi,
This wiki can be a part of your answer : http://wiki.sdn.sap.com/wiki/display/Snippets/JSON+and+ABAP
But you will face of a performances issue if to process large data because there is double convertion : Table to XML and XML to JSON.
Regards,
2014 Dec 01 5:36 PM
Hi,
I recently created a small tool to allow easy json usage of sap BAPIs using sap jco.
You can find the code here https://github.com/dhorions/jcoSon.
Example :
Input :
{
"BANKKEY": "083000108",
"BANKCOUNTRY": "US"
}
java code :
jcoSon jco = new jcoSon(destination.getRepository().getFunction("BAPI_BANK_GETDETAIL"));
jco.setParameters("{\"BANKKEY\":\"083000108\",\"BANKCOUNTRY\":\"US\"}");
String resultJson = jco.execute(destination);
System.out.println("Results :"+ resultJson);
Output:
{
"BANK_ADDRESS": {
"BANK_NAME": "First Union Bank & Trust",
"REGION": "IL",
"STREET": "500 Main Street",
"CITY": "Chicago",
"SWIFT_CODE": "",
"BANK_GROUP": "",
"POBK_CURAC": "",
"BANK_NO": "083000108",
"POST_BANK": "",
"BANK_BRANCH": "Main Office",
"ADDR_NO": ""
},
"BANK_DETAIL": {
"CREAT_DATE": "Fri Jan 03 00:00:00 CET 1997",
"CREATOR": "GRAVEN",
"METHOD": "",
"FORMATTING": "",
"BANK_DELETE": ""
}
}
2016 Mar 08 3:22 PM
Also possible using SAP Open Source Connectors, for Python, nodejs or GO.
nodejs uses JSON natively and Python and GO have built-in support. Here two examples:
Python
result = conn.call('BAPI_USER_GET_DETAIL', USERNAME=abap['user'])
js = simplejson.dumps(result, default=json_serial)
return Response(js, status=200, mimetype='application/json')
nodejs (example from node-rfc test)
client.invoke('BAPI_USER_GET_DETAIL', { USERNAME: 'DEMO' },
function(err, res) {
should.not.exist(err);
res.should.be.an.Object;
res.should.have.properties(
'ADDRESS', 'ACTIVITYGROUPS',
'DEFAULTS', 'GROUPS','ISLOCKED', 'LOGONDATA',
'PARAMETER','PROFILES', 'RETURN'
);
done();
});