This website has been archived, it is working in read-only mode.

This website has been archived, it is working in read-only mode.

I want to generate JSON content to be used in a web application doing AJAX calls to the SAP server. What are the options to generate the JSON using ABAP?

asked 17 Jul '12, 05:07

pedrolima's gravatar image

pedrolima ♦♦
1.1k232840
accept rate: 32%


The XML CALL TRANSFORMATION call now supports JSON natively using destination type IF_SXML=>CO_XT_JSON.

 lcl_writer = cl_sxml_string_writer=>create( if_sxml=>co_xt_json ).
 CALL TRANSFORMATION id SOURCE text = l_source  RESULT XML lcl_writer.
 l_xstring_json = lcl_writer->get_output( ).

Alternatively you can also have a look at CL_TREX_JSON_SERIALIZER, although I found it rather broken.

(I eventually wrote my own two-way parser since we had to support pre-7.00 versions of SAP.)

permanent link

answered 23 Aug '13, 08:10

Marius%20Piedallu%20van%20Wyk's gravatar image

Marius Pieda...
1612411
accept rate: 33%

edited 23 Aug '13, 08:11

Yes this is probably the best way now, but needs version 7.4 of the ABAP layer.

(25 Aug '13, 07:49) pedrolima ♦♦

SAP has an add-on product named Gateway that one can install in ECC and other Netweaver products that simplifies the creation of REST interfaces. The latest releases also support JSON (orginally it was only XML).

But there is also the great JSON Document Class contributed by Uwe Fetzer to the Code Exchange that allows easy generation of JSON from typical ABAP data structures. It is so good that it was included in recent Netweaver releases.

permanent link

answered 17 Jul '12, 05:09

pedrolima's gravatar image

pedrolima ♦♦
1.1k232840
accept rate: 32%

Halle Berry on pregnancy: 'Biggest surprise of my life' (CNN) -- Halle Berry is talking about becoming a mother for the second time at 46. "I feel fantastic. This has been the biggest surprise of my life to tell you the truth," said Berry in an interview with CNN's Alina Cho. Related Article:http://www.tauramall.com/Toddler-Boy-Summer-Outdoor-Casual-Short-Pants-p1995.html

permanent link

answered 14 Apr '13, 22:02

onsapya's gravatar image

onsapya
(suspended)
accept rate: 0%

The TV Column: New shows for Fall 2013 Fox, NBC, CBS and the CW announced the new television shows coming to these networks this fall last week. Michael J. Fox, Blair Underwood, Sean Hayes and Andy Samberg return to the small screen, while J.J. Related Article: http://www.tauramall.com/Toddler-Boy-Summer-Outdoor-Casual-Short-Pants-p1995.html

permanent link

answered 30 May '13, 23:06

tryrrt's gravatar image

tryrrt
(suspended)
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×28
×6

question asked: 17 Jul '12, 05:07

question was seen: 25,872 times

last updated: 25 Aug '13, 07:49