lonelymo
lonelymo

Reputation: 4202

How do I store nested JSON objects directly in ABAP DDIC?

ABAP Databases, oracle, MaxDB et al., are mostly RDBMS. Right now, I have a JSON structure that cannot be normalised and hence I want to store it as is. So, I want a MongoDB like Object store in ABAP.

What's the best way to achieve this? Is data cluster an option? Perhaps the only option?

Upvotes: 0

Views: 2553

Answers (3)

Sandra Rossi
Sandra Rossi

Reputation: 13686

To say it shortly:

You can simply store JSON in a LOB column of any RDBMS, which corresponds to the data types STRING (characters/CLOB) or RAWSTRING (bytes/BLOB) in the ABAP Dictionary.

That's it.


PS: concerning the two other answers:

  • Don't use LCHR which is limited to 32000 characters (nor LRAW which is limited to 32000 bytes)
  • I don't see a good reason to use Data Cluster (if it's to compress JSON, use ZIP or whatever standard format, not SAP-proprietary format). The question was not about manipulating/transforming JSON, only storing JSON in an RDBMS.

Upvotes: 0

szako
szako

Reputation: 1301

Data cluster is one option, but you can simply use a binary type DB field for storing the JSON data.

There is a method called transformation in ABAP, which converts from ABAP data to XML/JSON data and vice-versa.

There's a simple example on the following blog: https://blogs.sap.com/2013/07/04/abap-news-for-release-740-abap-and-json/

Comments on the blog page contain more info.

Upvotes: 1

Anton Krosnev
Anton Krosnev

Reputation: 4132

I don't think you can connect to some other then supported DBs directly from ABAP. If you have Netweaver Java, you can call some custom Java application, which accesses MongoDB. You can check SAP Hana if there is something similar. In ABAP you interact with RDBMS via ABAP Dictionary. It supports data types like LCHR, STRING, RAWSTRING. Checkout docs for more details.

Upvotes: 1

Related Questions