Skip to Content
avatar image
-1
Former Member

JSON to ABAP Conversion

Hi Experts

I am trying to Upload JSON file into SAP internal table and perform some actions on it.

I have referred already to these links:

https://blogs.sap.com/2013/01/07/abap-and-json/

https://answers.sap.com/questions/195916/complex-json-structure-to-abap.html and

https://archive.sap.com/discussions/thread/3817827

However, there is no information on how to UPLOAD a json file directly into an internal table.

Any pointers will be appreciated.


Regards

Dinesh

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Nov 20, 2017 at 07:13 AM

    Hi..

    Thanks for helping.. Solved the issue on own by reading character by character. In actual the json file was pretty complex and Standard SAP was taking a lot of time to deserialize.

    Thanks

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 16, 2017 at 04:29 PM

    Hi dear.

    Follow this example, if it's what I imagined.

    First, you have to create a structure like your json response;

    
    TYPES:
    
    TY_T_NAMES TYPE TABLE OF STRING WITH EMPTY KEY,
    
    BEGIN OF TY_ROOT,
    MESSAGE TYPE STRING,
    NAMES   TYPE TY_T_NAMES,
    END OF TY_ROOT.
    
    DATA RESULT TYPE TY_ROOT.
    
      DATA(_JSON) = '{' &&
                       '"Message":"Hello",' &&
                       '"Names":["John","Julie","Mark","Juan"]' &&
                    '}'.

    After that, you can use this method to deserialize the data;

    /UI2/CL_JSON=>DESERIALIZE( 
     EXPORTING 
       JSON = _JSON 
     CHANGING 
       DATA = RESULT ).

    Check it

    Enio,

    Regards;

    Add comment
    10|10000 characters needed characters exceeded