Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to Display data from memory to ALV Grid via call function 'LIST_FROM_MEMORY

0 Kudos

Hello Experts,

I Have written a program to call the data from memory and it is displaying the data in ALV list perfectly.

But I want to disply the data in ALV Grid. Please guide me - how can I do it.

Also Searched on SCN, but failed to find relevant answer.

Thanks in advance.

Dev

report zrich_0003 .

data: begin of listout occurs 0,
      line(1024) type c,
      end of listout.

* Submit the report and export list to memory
submit zmytesting exporting list to memory and return.

* Get list from memory and convert to ascii
perform retrieve_list_from_memory tables listout.
sort listout DESCENDING.

    loop at listout.
      write:/ listout.
    endloop.

************************************************************************
* RETRIEVE_LIST_FROM_MEMORY
************************************************************************
form retrieve_list_from_memory tables reportlines.


data: list like abaplist occurs 0 with header line.
data: txtlines(1024) type c occurs 0 with header line.

      clear list.  refresh list.
      clear reportlines. refresh reportlines.

      call function 'LIST_FROM_MEMORY'
           tables
                listobject = list
           exceptions
                not_found  = 1
                others     = 2.

      check sy-subrc = 0.

      call function 'LIST_TO_ASCI'
           tables
                listobject         = list
                listasci           = txtlines
           exceptions
                empty_list         = 1
                list_index_invalid = 2
                others             = 3.

      check sy-subrc = 0.

      reportlines[] = txtlines[].

      call function 'LIST_FREE_MEMORY'.

    endform.
2 REPLIES 2

raymond_giuseppi
Active Contributor
0 Kudos

If zmytesting display some ALV grid, better use class cl_salv_bs_runtime_info to get the data (and layout) back. Else go to splitting the data into columns using all your skill using some split at '|' and code to identify header ignoring statistics and other header data of spool. (or find the sample that existed in a previous version of sdn.)

Regards,
Raymond

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Well you would need to take that listout internal table and parse the report string at certain character positions, and put those values into columns of a structured internal table, then display that internal table as ALV Grid. Most work would be parsing out the row into columns.

Cheers,

Rich Heilman