Skip to Content
-3

JSON-to-ABAP Deserialize

Dear experts,

I want to deserialize JSON data to ABAP structures. The ERP system is SAP_BASIS 700 and the following class methods are not available:

  • /ui2/cl_json=>deserialize
  • cl_trex_json_deserializer

So I am using the class cl_hrpayfr_json_deserializer which has a method DESERIALIZE that has input a variable of type string and returns a parameter of type ANY.

I want to deserialize the data to a structure and I understand that the return parameter of type ANY is a field symbol (?)

When I execute the code I get a runtime error of an unassigned field symbol although prior to calling the deserialize method I assign the target structure to the return parameter of type ANY.

Has anyone used the above method or used another method of deserializing?

Kind regards,

Konstantinos

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Nov 20, 2017 at 01:09 PM

    No, of course you can't use a field symbol that you didn't assign first (ABAP basics).

    Probably this parameter should be a complex structure data object corresponding to the input JSON (structure field names should probably be equal to the names in the JSON).

    Maybe, instead of using this unreleased class cl_hrpayfr_json_deserializer (might be deleted in a future release, I don't have it in my ECC 6.0 EHP 7), you could use an open project, for instance https://github.com/cesar-sap/abap_fm_json . Of course, probably you will have to downport the code to ABAP 7.0.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 20, 2017 at 01:31 PM

    "I want to deserialize the data to a structure and I understand that the return parameter of type ANY is a field symbol (?)"

    I fear, you have to understand typing of parameters and the concept of field symbols first.

    Add comment
    10|10000 characters needed characters exceeded