How to Convert JSON Data Structure to ABAP Structure without ABAP Code or SE11?

How to Convert JSON Data Structure to ABAP Structure without ABAP Code or SE11

Introduction

Let’s answer How to Convert JSON Data Structure to ABAP Structure without ABAP Code or SE11? Reconciliation with SAP Framework was generally there however with the developing complex business situations of the clients, incorporation with outsiders SAP and Non-SAP framework is the standard of present circumstances. With the appearance of S/4HANA this large number of incorporations are for the most part continuous. Thus, we have RestAPI, OData Administrations and other ongoing associations. What’s more, in such joining projects, playing with JSON information is the bread and butter of all Advanced Days ABAP Designers.

So switching ABAP inward tables over completely to JSON type and tight clamp versa JSON construction to ABAP interior table is a typical prerequisite. Today in this instructional exercise we will discuss a straightforward stunt to switch JSON information over completely to ABAP structures with practically no ABAP Code or manual construction creation in SE11. We will follow a few straightforward advances and online instruments and one standard SAP Utility program to meet our necessity.

Back to our point for this instructional exercise. SAP has proactively given a few utility classes/UI2/CL_JSON (or CL_ACRS_JSON_UTILITY in certain frameworks) which de-serialize the JSON information utilizing DeSerialize technique or produce dynamic ABAP structure from JSON document utilizing Create strategy.

Be that as it may, generally speaking we maintain that the actual designs should be made in information word reference from JSON. The above class produces ABAP inner table design at run-time. What we need is something which we can see in SE11 and yet again use. All things considered “Finding in Accepting”. Main question is How to Convert JSON Data Structure to ABAP Structure without ABAP Code or SE11?

Possible Approaches (How to Convert JSON Data Structure to ABAP Structure without ABAP Code or SE11)

Approach-1

Scope: SAP Development System only.

We don’t have to re-create the group. Our kindred SAP Master Łukasz Pęgiel has proactively accomplished the difficult work which impeccably creates the neighborhood ABAP types construction of the info JSON record.

Approach-2

Scope: Till SAP Production Environment.
On the off chance that the created profound design isn’t replicated to another Z-Construction, then the degree is till the creation climate, as this will produce Worldwide SPROXY/DDIC objects.

In the event that you have at any point consumed an outside web administration in SAP, you would know how to produce the DDIC structures utilizing the Intermediary. This is an old style way, where we create the Undertaking Administration – Administration Customer from the XSD/WSDL records. In this assistance object, the DDIC profound construction gets produced naturally relating to the XSD/WSDL record.

Stand by, What? XSD/WSDL? We assumed we were discussing JSON record, right?

Indeed, you saw it right. We will switch the JSON over completely to WSDL and create the DDIC structure progressively. What’s more, trust us, it will be a smooth ride. You won’t perspire by any means. There are various free web-based apparatuses that can assist us with changing over the JSON document to XML with practically zero changes.

We should talk about this methodology exhaustively.

High Level Design

  1. Convert JSON to XML.
  2. Convert XML to XSD.
  3. Convert XSD to WSDL. Make sure both the XSD and WSDL file are in the same folder.
  4. Create the Enterprise Service – Service Consumer from the above WSDL file.

Step-0 or Preparation Step – Make an example JSON record/information. On the off chance that you don’t have any genuine JSON information/document at this point, for testing reason, utilize the accompanying JSON information. It is a profound construction having records as an inside table with 2 levels.

[
{
"Company_ID": "CID-1000",
"Name": "elearningsolutions",
"Type": "Education and Training",
"Description": "elearningsolutions is the source of learning for SAP Technical & related topics. We make learning complex SAP concepts Fun.",
"Address": {
"Street1": "Test Street 1",
"Street2": "Test Street 2",
"PIN": "1234567890",
"City": "Test City",
"State": "Test State",
"Country": "Test Country"
}
},
{
"Company_ID": "CID-1001",
"Name": "elearningsolutions Services",
"Type": "IT Services",
"Description": "elearningsolutions Services is an IT Service Company",
"Address": {
"Street1": "Test Street 1",
"Street2": "Test Street 2",
"PIN": "1234567890",
"City": "Test City",
"State": "Test State",
"Country": "Test Country"
}
}
]

Step-1 – JSON to XML

We are involving an online converter for the equivalent. You can utilize some other client-supported device to change over something similar.

In the below screenshot, you can see that we just pasted the above JSON file data in Option-1 box, changed the Name of the root element to “Companies” for easy identification.

After pressing the CONVERT JSON TO XML button, you will get the converted XML as below

Duplicate the above code – From this File

Step-2 – XML to XSD

Now, we will change over the above XML record to XSD Mapping utilizing the XSD Generator

Click on Create XSD button above. This will create the XSD record as beneath:


Note: Ensure you have the targetNamespace boundary in your XSD Diagram as underneath:
targetNamespace=”http://www.w3.org/2001/XMLSchema/” like targetNamespace=”http://www.w3.org/2001/XMLSchema/Organizations” for our situation.

Copy the above code – From this File

Presently, save the above XSD construction as anyName.xsd document in an envelope in your nearby machine.

Step-3 – XSD to WSDL file

Make a dummy.wsdl document in a similar envelope made previously.

Open your SAP AS framework. Go to exchange SE38 and execute program SPROX_XSD2WSDL

When you execute the above program, you will see that your dummy.WSDL file is populated with some WSDL content as follows.

You might duplicate the above code – From this File

Step-4 – Create the Enterprise Service – Service Consumer from the above WSDL file

Allow us to utilize the above WSDL document to make our Endeavor Administration – Administration Buyer object.

Note: Ensure your XSD and WSDL document are in same envelope.

  1. Go to transaction SE80.
  2. Type your package on the left hand side.
  3. Right click on your package name. Select Create –> Enterprise Service.

4. Select Service Consumer and then continue.

5. Select “External WSDL/Schema” and then continue.

6. Select Local File and then continue.

7. Provide path to your WSDL file and then continue.

8. Provide your package name, Transport Request No. and a prefix starting from Z/Y and then continue.

9. Press Complete, continuing to create Enterprise Service.

After the production of the above Big business Administration Buyer, you would have to Actuate something very similar to see your DDIC structure.

In your “Outside View” Tab, you can explore to your Profound design made as underneath:

Conclusion of How to Convert JSON Data Structure to ABAP Structure without ABAP Code or SE11

Now you have gotten answer on How to Convert JSON Data Structure to ABAP Structure without ABAP Code or SE11? There’s nothing more to it. You can utilize these designs like some other information word reference structures. Since it is in the bundle and transport, you can move it to every one of the frameworks of your scene. In spite of the fact that it seems to be many advances, yet assuming you attempt it, they are straight forward and not inclined to any blunder. Along these lines, we learned 2 methods for making the ABAP Type structure from the JSON document/information.

Ensure you generally cross-check your XSD record prior to making a WSDL document of something very similar.

Things to check:
Whether right settled structures/table sorts are made or not? For instance, a field that alludes to a table sort will have the accompanying credits in its tag: maxOccurs=”unbounded” minOccurs=”0″.
In this way, make a propensity for twofold really taking a look at it.

Presently we need to hear from you. Do you are aware of whatever other strategies which you can share? JSON Type to Drain Information Word reference Designs.

 

YOU MAY LIKE THIS

A Deep Dive into the SAP API Hub

Building APIs with SAP Tools and Technologies

Optimizing SAP for the Automotive Sector: A Comprehensive Guide

Best Practices for SAP ABAP Development: A Comprehensive Guide

 

 

X
WhatsApp WhatsApp us