SAP ABAP ST JSON TABLE ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_JSON - Simple Transformation for Internal Tables
The example demonstrates the Simple Transformation of an internal table to JSON data.

ABAP_SOURCE_CODE
DEMO CL_DEMO_ST_JSON_TABLE

ABAP_DESCRIPTION
An internal table carrier_tab is filled with data from the database table SCARR and is transformed twice using the Simple Transformation DEMO_ST_JSON_TABLE. The ST program is as follows:
TRNS DEMO_ST_JSON_TABLE
The transformation is written in such a way that the new XML data has 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 directly 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 usually creates XML data in XML 1.0 format. The output shows that it is the JSON XML created by the transformation.
Finally, a demonstration that:
The Simple Transformation is symmetrical. To do this, the JSON data is passed to the transformation. The result matches the source 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 class.