Google Search - Blog...........

Showing posts with label 'LIST_TO_ASCI' retriving list from memory. Show all posts
Showing posts with label 'LIST_TO_ASCI' retriving list from memory. Show all posts

ABAP - Working With List Memory

report ztest .

data: it_ascilines type char255 occurs 0 with header line,
it_list type table of abaplist with header line,
it_msg type table of soli initial size 0 with header line.

*---start of selection
start-of-selection.

*--output of the list.
do 10 times.
write:/ sy-index.
enddo.
*----saving this list to memory
call function 'SAVE_LIST'
tables
listobject = it_list
exceptions
list_index_invalid = 1
others = 2 .

*----retriving list from memory
call function 'LIST_TO_ASCI'
tables
listobject = it_list
listasci = it_ascilines
exceptions
empty_list = 1
list_index_invalid = 2
others = 3.

check sy-subrc = 0.
it_msg[] = it_ascilines[].

*---displaying the list retrived from memory
loop at it_msg.
write:/ it_msg-line.
endloop.

the output is like this:

Transfer Report Program Output To Internal Table

report zcal_another_rep .


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

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

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

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 , reportlines .
refresh : list , 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.