2023 Dec 28 9:13 PM
Dear Experts,
I'm on ECC 6.0 and have the requirement to save a json file, obtained from an internal table thanks to the method
/ui2/cl_json=>serialize()
Could you please help highlighting a way to save the json string obtained above to the SAP application server, so that it can be seen with AL11?
Many thanks for any help and suggestions
With best regards,
Jepy
2023 Dec 29 9:04 AM
Many same questions, if you consider that saving JSON or whatever format works always the same, here:
abap save file to application server site:sap.com
2023 Dec 29 11:38 AM
Hi sandra.rossi, thanks for the hit, I've tried with open dataset:
data itab type standard table of scarr.
data l_json type string.
select * from scarr into table itab.
l_json = /ui2/cl_json=>serialize(
data = itab
compress = abap_true
pretty_name = /ui2/cl_json=>pretty_mode-camel_case
).
** cl_demo_output=>display( l_json ).
open dataset l_dataset for output in text mode encoding default.
transfer l_json to l_dataset.
close dataset l_dataset.
however, the saved file is a single, long string, as follows:
while if it's displayed, it looks nicely formatted:
is there any option to save to AL11 the nicely formatted version?
thanks again,
Jepi
2023 Dec 29 11:45 AM
You have only one way of saving a text string.
What you want is to format your text string. It's called "beautifying", "pretty print", etc.
"/ui2/cl_json" pretty print site:sap.com
Beautifying is increasing the size of the text.
So, according to me, beautifying or pretty print should be done only when displaying; you'd better store a small file, and use software to beautify the data.