0

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?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
lonelymo
  • 3,972
  • 6
  • 28
  • 36
  • 2
    It is one option. A simple LOB field would be another. You are certain you don't need database support when accessing the contents? – vwegert Mar 24 '17 at 14:01
  • You are certain you don't need database support when accessing the contents? That's certainly necessary. CRUD operations should be possible on this JSON. – lonelymo Mar 24 '17 at 14:08
  • @vwegert: how about creating a DDIC table MANDT type MANDT JSON-IDENTIFYING-KEY1 type CHAR10 JSON-IDENTIFYING-KEY2 type CHAR10 JSON_STRING type STRING/XSTRING This way I can store the JSON in a normal DDIC table. – lonelymo Mar 24 '17 at 19:48
  • What is your underlying database? If it supports json type natively then you can consider using [ADBC](http://help-legacy.sap.com/abapdocu_702/en/abenadbc.htm). – Jagger Mar 25 '17 at 09:01
  • 1
    If CRUD operations are certainly necessary, then you should edit the question. *As is* and *CRUD* are contradictory statements. Though, dunno, what CRUD ops can you apply to JSON. – Suncatcher Mar 25 '17 at 11:10

3 Answers3

1

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.

Anton Krosnev
  • 3,964
  • 1
  • 21
  • 37
1

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.

szako
  • 1,271
  • 1
  • 9
  • 12
  • I cannot convert JSON to ABAP and vice versa. JSON object has to be stored as is. – lonelymo Mar 24 '17 at 18:58
  • 1
    Data in cluster tables are stored as raw, if you must edit the JSON, you have to convert it to an editable format, that's why I wrote a technical approach. – szako Mar 24 '17 at 19:50
  • RAW format perfectly fits for *as is*, dunno why this answer was downvoted. – Suncatcher Mar 25 '17 at 11:11
0

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.
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48