Skip to content

Instantly share code, notes, and snippets.

@js1972
Created September 25, 2014 05:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save js1972/0d76d1216069fe1789e1 to your computer and use it in GitHub Desktop.
Save js1972/0d76d1216069fe1789e1 to your computer and use it in GitHub Desktop.
Example ABAP code using sql host variables (@) which is the standard as of 7.40 and showing the SAP standard way to do JSON conversion.
report y_test_json_output.
DATA purchaseorders TYPE STANDARD TABLE OF ekko.
SELECT * FROM ekko
INTO TABLE @purchaseorders
where bukrs = '2000'
and ernam = 'JSCOTT'.
DATA(lo_json_writer) = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ).
CALL TRANSFORMATION id SOURCE itab = purchaseorders RESULT XML lo_json_writer.
cl_demo_output=>display_json( lo_json_writer->get_output( ) ).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment