Skip to Content
-1

Receiving Rest data and passing to internal table.

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.

Add comment
10|10000 characters needed characters exceeded

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

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

  • JSON ("jason" is only the pronunciation)

  • Get RSS Feed

2 Answers

  • Jun 30, 2017 at 07:18 PM
    -2

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 04, 2017 at 04: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.

    Add comment
    10|10000 characters needed characters exceeded