Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Save json file to AS (AL11)

jepi_flanders
Participant
0 Kudos

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

3 REPLIES 3

Sandra_Rossi
Active Contributor
0 Kudos

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

jepi_flanders
Participant
0 Kudos

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

Sandra_Rossi
Active Contributor
0 Kudos

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.