Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Receiving Rest data and passing to internal table.

ronaldo_aparecido
Contributor
0 Kudos
1,597

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.

7 REPLIES 7

UweFetzer_se38
Active Contributor
0 Kudos
432

What format do you get from the REST service? JSON, XML, YAML,... ?

(there is no such thing like a REST format)

Cheers, Uwe

ronaldo_aparecido
Contributor
0 Kudos
432

I receive in Jason.

former_member215526
Active Participant
0 Kudos
432

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

Sandra_Rossi
Active Contributor
0 Kudos
432

JSON ("jason" is only the pronunciation)

Sandra_Rossi
Active Contributor
432

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.

ronaldo_aparecido
Contributor
0 Kudos
432

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.

Sandra_Rossi
Active Contributor
0 Kudos
432

"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.