2012 Nov 09 11:16 AM
Hello everyone,
I am facing a problem showing a list in a ALV using function mudule WRITE_LIST. My program reads a file, and submits it’s content to a program, and I read the result in a list, like this:
SUBMIT zfi_clear WITH p_belnr EQ ls_file-belnr
WITH p_gjahr EQ ls_file-gjahr
WITH p_bukrs EQ ls_file-bukrs
WITH p_buzei EQ ls_file-buzei
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.
gs_out-icon = icon_green_light.
gs_out-lista = list_tab.
ENDIF.
My gs_out is a structure of gt_out which is used to display the contents of my internal table
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_user_command = lv_user_comm
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
i_save = 'A'
TABLES
t_outtab = gt_out
EXCEPTIONS
program_error = 1
OTHERS = 2.
In my user_command form I do this:
FORM user_command USING pv_ucomm LIKE sy-ucomm
pf_selfield TYPE slis_selfield.
DATA: ls_out LIKE LINE OF gt_out.
READ TABLE gt_out INTO ls_out INDEX pf_selfield-tabindex.
CALL FUNCTION 'WRITE_LIST'
EXPORTING
write_only = ' '
TABLES
listobject = ls_out-list
EXCEPTIONS
empty_list = 1
OTHERS = 2.
ENDFORM. "user_command
Although sy-subrc variable is initial no list is displayed. Does anyone faced this problem?
Thanks in advance
2012 Nov 09 12:29 PM
Hi John,
Define a LIST_STATUS which has BACK/CANCEL/EXIT fcode, to handle write_list screen events
And Change your code as below:
* Handle LIST_STATUS events
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'BACK'
OR 'EXIT'
OR 'CANCEL'.
LEAVE to SCREEN 0.
WHEN OTHERS.
ENDCASE.
2012 Nov 09 12:29 PM
Hi John,
Define a LIST_STATUS which has BACK/CANCEL/EXIT fcode, to handle write_list screen events
And Change your code as below:
* Handle LIST_STATUS events
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'BACK'
OR 'EXIT'
OR 'CANCEL'.
LEAVE to SCREEN 0.
WHEN OTHERS.
ENDCASE.
2012 Nov 17 1:21 PM
Dear
Basar thank you for your response. It solved my problem and it made me realize the main differences between working with list processing and ALV.