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

ALV + WRITE_LIST

Former Member
0 Likes
655

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

1 ACCEPTED SOLUTION
Read only

basarozgur_kahraman
Contributor
0 Likes
517

Hi John,

Define a LIST_STATUS which has BACK/CANCEL/EXIT fcode, to handle write_list screen events

And Change your code as below:

  1. FORM user_command USING pv_ucomm    LIKE sy-ucomm 
  2.                         pf_selfield TYPE slis_selfield. 
  3.  
  4.   DATA: ls_out LIKE LINE OF gt_out. 
  5.  
  6.   READ TABLE gt_out INTO ls_out INDEX pf_selfield-tabindex. 
  7.   CALL FUNCTION 'WRITE_LIST' 
  8.     EXPORTING 
  9.       write_only = ' ' 
  10.     TABLES 
  11.       listobject = ls_out-list 
  12.     EXCEPTIONS 
  13.       empty_list = 1 
  14.       OTHERS     = 2
  15.   
  16. SET PF-STATUS 'LIST_STATUS'.
  17. LEAVE TO LIST-PROCESSING.
  18. pf_selfield-refresh    = 'X'.
  19. pf_selfield-row_stable = 'X'.
  20. pf_selfield-col_stable = 'X'.

  21. ENDFORM.                    "user_command 

* Handle LIST_STATUS events

AT USER-COMMAND.

   CASE sy-ucomm.

     WHEN 'BACK'

            OR 'EXIT'

            OR 'CANCEL'.

       LEAVE to SCREEN 0.

     WHEN OTHERS.

   ENDCASE.


2 REPLIES 2
Read only

basarozgur_kahraman
Contributor
0 Likes
518

Hi John,

Define a LIST_STATUS which has BACK/CANCEL/EXIT fcode, to handle write_list screen events

And Change your code as below:

  1. FORM user_command USING pv_ucomm    LIKE sy-ucomm 
  2.                         pf_selfield TYPE slis_selfield. 
  3.  
  4.   DATA: ls_out LIKE LINE OF gt_out. 
  5.  
  6.   READ TABLE gt_out INTO ls_out INDEX pf_selfield-tabindex. 
  7.   CALL FUNCTION 'WRITE_LIST' 
  8.     EXPORTING 
  9.       write_only = ' ' 
  10.     TABLES 
  11.       listobject = ls_out-list 
  12.     EXCEPTIONS 
  13.       empty_list = 1 
  14.       OTHERS     = 2
  15.   
  16. SET PF-STATUS 'LIST_STATUS'.
  17. LEAVE TO LIST-PROCESSING.
  18. pf_selfield-refresh    = 'X'.
  19. pf_selfield-row_stable = 'X'.
  20. pf_selfield-col_stable = 'X'.

  21. ENDFORM.                    "user_command 

* Handle LIST_STATUS events

AT USER-COMMAND.

   CASE sy-ucomm.

     WHEN 'BACK'

            OR 'EXIT'

            OR 'CANCEL'.

       LEAVE to SCREEN 0.

     WHEN OTHERS.

   ENDCASE.


Read only

0 Likes
517

DearNot Active Contributor thank you for your response. It solved my problem and it made me realize the main differences between working with list processing and ALV.