SAP ABAP ST JSON TABLE ABEXA

Get Example source ABAP code based on a different SAP table
  


ARTICLE

JSON, Simple Transformation for Internal Tables
The example demonstrates the simple transformation of an internal table intoJSON data.

ABAP_SOURCE_CODE
ABAP_EXEC

ABAP_DESCRIPTION
An internal table, carrier_tab, is filled with data from the database table SCARR and is transformed two times using the simple transformation DEMO_ST_JSON_TABLE. The ST program is as follows:
TRNS DEMO_ST_JSON_TABLE
The transformation is written in a way that means the generated XML data have a valid JSON XML format.
When the transformation is called for the first time, a JSON writer is specified as the result. The JSON data can be retrieved from this result and added to the json string, where the data can be output.
When the transformation is called for the second time, an inline declared byte string xml is specified as the result. This is usually used to generate XML data in XML 1.0 format. The output shows that it is the JSON XML generated by the transformation.
Finally, a demonstration that:
the simple transformation is symmetrical. The JSON data is passed to the transformation. The result matches the starting table.
An additional JSON writer creates the same JSON data in xml from the JSON XML, as when the transformation is called. Specifying a JSON writer as the result of a transformation means that JSON XML does not need to be explicitly handled in the ABAP program.