Skip to Content

Convert ABAP data to JSON with camelCase Names.

Hi all,

I'm looking to find the simplest method to take ABAP table data in SAP and format it into a json payload that apparently only accepts a variantion of camel case names. Examples being load, referenceNumbers, addressLine, etc.

Before I was aware of this restriction I created an abap structure with nested table types and used 'call transformation id' with a cl_sxml_string_writer created for json. This works fine other than all the structure fields are stored in uppercase so the json comes out that way. I could potentially do a find and replace on every field, but this seems like a poor solution. I've also read posts to the effect of using simple transformations, but I'm not very familiar with those and am having difficultly understanding how this would be helpful/implemented.

If anyone is willing to nudge me in right direction I would greatly appreciate it.

-Chris

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jan 31 at 03:25 PM

    /UI2/CL_JSON is pretty handy class to create JSON string from ABAP data.

    It supports camelCase (pretty_name = /ui2/cl_json=>pretty_mode-camel_case).

    Example:

    In ABAP: test_name TYPE string.
    In JSON: "testName"

    or

    In ABAP: test__name TYPE string.
    In JSON: "test_name"
    Add comment
    10|10000 characters needed characters exceeded

  • Jan 31 at 04:05 PM
    Add comment
    10|10000 characters needed characters exceeded