Passing Internal Table / Deep Structure in Submit program

In the world of ABAP development, we often encounter the need to pass data between programs. Recently, I faced a requirement to transfer an internal table from one report program to another. After extensive research, I realized there wasn’t a straightforward method available online. Therefore, I devised a solution that involves converting the table data into JSON format and passing it as a string parameter to the called program, which then converts it back into a table. I believe this approach could be beneficial to others, and here’s how I implemented it:

In the Caller Program:

  1. Convert the Internal Table to JSON:

    DATA(lv_json) TYPE string.
    lv_json = /ui2/cl_json=>serialize( data = lt_data ).
  2. Pass the JSON Data to the Called Program:

    SUBMIT z_submit WITH p_data = lv_json
      AND RETURN.

In the Called Program (z_submit):

  1. Create a Report with a String Parameter:

    REPORT z_submit.
    PARAMETERS: p_data TYPE string.
  2. Define the Table Type: (Here, you would define the structure of your internal table/ Deep Structure that matches the JSON data structure.)

  3. Convert JSON Data (String Parameter) Back to Internal Table:

    DATA: lt_data TYPE <your_table_type>.
    /ui2/cl_json=>deserialize(
      EXPORTING
        json = p_data
      CHANGING
        data = lt_data
    ).

This method is particularly useful when dealing with large datasets that need to be passed between programs without the use of global variables or database persistence. It’s a clean and efficient way to serialize and deserialize data.

I hope this technique proves to be useful. If you have any insights or know of a more straightforward method, please feel free to share your thoughts!

#abap

 

Scroll to Top