Convert JSON to ABAP Internal Table

Preface – This post is part of the ABAP Programs series.

        BEGIN OF t_entry,
          access_token TYPE string,
          token_type   TYPE string,
          expires_in   TYPE n LENGTH 8,
          scope        TYPE string,
          jti          TYPE string,
        END OF t_entry .
        t_entry_map TYPE SORTED TABLE OF t_entry WITH UNIQUE KEY access_token.
      DATA: m_entries TYPE t_entry.

      DATA: lr_instance  TYPE REF TO  /ui5/cl_json_parser.
      CREATE OBJECT lr_instance.
      CALL METHOD me->get_token.
      IF gv_token IS NOT INITIAL.

*        data: itab TYPE TABLE OF string.
*        data: access_tok type string.
*        SPLIT gv_token at '"' INTO TABLE itab.
*        try.
*            lv_auth2 = itab[ 4 ].
*          catch cx_sy_itab_line_not_found.
*        ENDTRY.

        EXPORTING json = gv_token pretty_name = /ui2/cl_json=>pretty_mode-camel_case CHANGING data = m_entries ).
        lv_auth2 = m_entries-access_token.
        gv_token = gv_token+17.



  • Barry Allen

    A Full Stack Developer with 10+ years of experience in different domain including SAP, Blockchain, AI and Web Development.

    View all posts


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.