Application Development and Automation 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: 
Read only

How to work with Function Module Write_List

yes_sapteam
Participant
0 Likes
2,148

Hi.

I searched the forum and the web but I didn't get an answer to my question.

I have a Z program which is called by another Z program.

I would like to use the Function-modules "WRITE_LIST" and "LIST_FROM_MEMORY" but the problem I have is how to work the ABAPLIST type.

I have a table that includes numerous fields and I don't understand how to transfer such a table to ABAPLIST type table.

Any help will be appreciated.

Ayal Telem.

7 REPLIES 7
Read only

Former Member
0 Likes
1,377

Hi,

Please find the sample code.


data: list_tab type standard table of ABAPLIST with header line.

SUBMIT Zprg
WITH ...
EXPORTING LIST TO MEMORY
 AND RETURN.

    CALL FUNCTION 'LIST_FROM_MEMORY'
      TABLES
        listobject = list_tab
      EXCEPTIONS
        not_found  = 1
        OTHERS     = 2.

    IF sy-subrc = 0.
      CALL FUNCTION 'WRITE_LIST'
        TABLES
          listobject = list_tab.
    ENDIF.

Read only

Former Member
0 Likes
1,377

hai,

Refer to the given below code:

report zlist_to_memory.

data: begin of t_listout occurs 0,

line(1024) type c,

end of t_listout.

  • Submit the report and export list to memory

submit z_reqd_report exporting list to memory

and return.

  • Get list from memory and convert to ascii

perform retrieve_list_from_memory tables t_listout.

loop at t_listout.

write:/ t_listout.

endloop.

************************************************************************

  • Procedure to retrieve list from memory

************************************************************************

form retrieve_list_from_memory tables t_reportop.

data: t_list like abaplist occurs 0 with header line.

data: textlines(1024) type c occurs 0 with header line.

clear t_list. refresh t_list.

clear t_reportop. refresh t_reportop.

call function 'LIST_FROM_MEMORY'

tables

listobject = t_list

exceptions

not_found = 1

others = 2.

check sy-subrc = 0.

call function 'LIST_TO_ASCI'

tables

listobject = t_list

listasci = textlines

exceptions

empty_list = 1

list_index_invalid = 2

others = 3.

check sy-subrc = 0.

t_reportop[] = txtlines[].

call function 'LIST_FREE_MEMORY'.

endform.

Read only

Former Member
0 Likes
1,377

hai,

Refer to the given below code:

report zlist_to_memory.

data: begin of t_listout occurs 0,

line(1024) type c,

end of t_listout.

  • Submit the report and export list to memory

submit z_reqd_report exporting list to memory

and return.

  • Get list from memory and convert to ascii

perform retrieve_list_from_memory tables t_listout.

loop at t_listout.

write:/ t_listout.

endloop.

************************************************************************

  • Procedure to retrieve list from memory

************************************************************************

form retrieve_list_from_memory tables t_reportop.

data: t_list like abaplist occurs 0 with header line.

data: textlines(1024) type c occurs 0 with header line.

clear t_list. refresh t_list.

clear t_reportop. refresh t_reportop.

call function 'LIST_FROM_MEMORY'

tables

listobject = t_list

exceptions

not_found = 1

others = 2.

check sy-subrc = 0.

call function 'LIST_TO_ASCI'

tables

listobject = t_list

listasci = textlines

exceptions

empty_list = 1

list_index_invalid = 2

others = 3.

check sy-subrc = 0.

t_reportop[] = txtlines[].

call function 'LIST_FREE_MEMORY'.

endform.

Read only

Former Member
0 Likes
1,377

Hi Ayal,

data:

itab_list type abaplist.

loop at itab.

w_string = itab-field1.

concatenate itab_list-rfcrecord w_string into itab_list-rfcrecord.

w_string = itab-field2.

concatenate itab_list-rfcrecord w_string into itab_list-rfcrecord.

.... till the last field is appended.

endloop.

itab_list can be passed to the tables parameter LISTOBJECT of the function module WRITE_LIST.

Regards.

Read only

0 Likes
1,377

Dear Mdi.Deeba.

I tried to follow your code snippet but it looks like nothing is added the the ABAPLIST structure.

Any ideas?

Best regards.

Ayal Telem.

Read only

0 Likes
1,377

Hi All.

I would like to specify that this thread was not answered, but it shouldn't be.

It looks like I took a wrong approach here.

When I tried to replicate the issue I had and caused me to open this thread I could not, so I have to wait until the issue will re-surface and than I will be able to handle it.

Thank you all.

Ayal Telem.

Read only

yes_sapteam
Participant
0 Likes
1,377

Thanks a lot to all who have replied to this thread, but I'm afraid the point was missed - maybe I didn't explained well enough.

My problem is how to map a table with various fields of various types and length, to the ABAPLIST structure.

Should I do a concatenation to the ABAPLIST and than split from it?

Thank you.

Ayal Telem.