2017 Jun 29 2:05 PM
Hi guys.
I'm using cl_http_client=>create_by_url and user can choose the service internet to receive data.
my problem is the services have diferent rest formats (field order) .
how can i create a code to receive diferent formats and pass to one internal table format?
If i use call transformation i need to create one diferent xslt program by service and i want to avoid it.
2017 Jun 30 2:02 PM
What format do you get from the REST service? JSON, XML, YAML,... ?
(there is no such thing like a REST format)
Cheers, Uwe
2017 Jun 30 7:46 PM
2017 Jun 30 8:18 PM
Hi Ronaldo,
If I understand your request, I can propose you this solution.
https://blogs.sap.com/2013/03/05/json-adapter-for-abap-function-modules/
You can call function modules with a URL and a JSON, PERL, XML and YAML representation of ABAP data.
Best Regards,
Xavier
2017 Jul 01 9:06 AM
2017 Jul 01 9:16 AM
I don't understand why you don't want to use transformations ("If i use call transformation i need to create one diferent xslt program by service and i want to avoid it."), because anyway, if you structure your ABAP code, you will have "to create one different method by service". What's the difference with transformations? If ST/XSLT language and ABAP are both mastered, then transformations are usually easier to use than ABAP code.
2017 Jul 03 1:37 PM
Hi Sandra.
OK i agree with you but the client wants to choose diferent services and in the future if they can discover a new service they want the program receive this data but they don´t want change the program for all new service discovered the program must accept diferents formats.It is my necessity.
2017 Jul 04 5:11 AM
"Receiving in internal table format" is not clear. If it's just to store in an internal table, then you should tell us what structure and format you expect. There is for instance the format suggested by SMUM_XML_PARSE for XML language:
<?xml version="1.0"?><A F="f"><b><c>cc</c></b><b>dd</b></A>
would be converted into this internal table:
HIER TYPE CNAME CVALUE
1 A
1 A F f
2 b
3 V c cc
2 V b dd
If it's what you need, then convert the JSON into XML, and call SMUM_XML_PARSE. There are lots of answers in the forum how to do it.