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: 

Refreshing ALV List View Checkboxes

Former Member
0 Kudos

Hi!

I am currently working on an ALV list report that uses checkboxes. Two of the functions of the report are the Select/Deselect All. When Select All is pressed, all the checkboxes should be ticked, and when Deselect All is pressed, all checkboxes should be unticked. When I tested my command, the internal table shows that the 'SEL' field (the checkbox field) is marked 'X', but it does not reflect on the report itself.

Are there any other things I should set up in order for the report to output correctly, like a refresh list?

Thanks in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

see the below program :

REPORT Z_GET_REFRESH no standard page heading.

type-pools : slis.

tables : makt,

mara.

data : i_fieldcat type slis_t_fieldcat_alv.

CONSTANTS :

gc_refresh TYPE syucomm VALUE '&REFRESH'.

data : begin of i_makt occurs 0,

matnr like makt-matnr,

maktx like makt-maktx,

end of i_makt.

data : v_repid like sy-repid,

g_user_command type slis_formname value 'USER_COMMAND',

g_status_set type slis_formname value 'SET_PF_STATUS',

lt_event_exit TYPE slis_t_event_exit,

ls_event_exit TYPE slis_event_exit.

DATA:LC_GLAY TYPE LVC_S_GLAY.

select-options s_matnr for mara-matnr .

start-of-selection.

select matnr maktx from makt into table i_makt

where matnr in s_matnr.

end-of-selection.

  • Fill the fieldcatlog

perform fill_field.

  • Call the FM

perform call_fm.

&----


*& Form fill_field

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fill_field.

data wa_fieldcat type slis_fieldcat_alv.

clear : wa_fieldcat.

wa_fieldcat-tabname = 'I_MAKT'.

wa_fieldcat-fieldname = 'MATNR'.

wa_fieldcat-outputlen = '18'.

wa_fieldcat-seltext_l = 'Material #'.

wa_fieldcat-col_pos = '1'.

append wa_fieldcat to i_fieldcat.

clear : wa_fieldcat.

wa_fieldcat-tabname = 'I_MAKT'.

wa_fieldcat-fieldname = 'MAKTX'.

wa_fieldcat-outputlen = '40'.

wa_fieldcat-seltext_l = 'Material Desc'.

wa_fieldcat-col_pos = '2'.

append wa_fieldcat to i_fieldcat.

ENDFORM. " fill_field

&----


*& Form call_fm

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM call_fm.

v_repid = sy-repid.

LC_GLAY-EDT_CLL_CB = 'X'.

CLEAR ls_event_exit.

ls_event_exit-ucomm = gc_refresh. " Refresh

ls_event_exit-after = 'X'.

APPEND ls_event_exit TO lt_event_exit.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = v_repid

I_CALLBACK_PF_STATUS_SET = g_status_set

I_CALLBACK_USER_COMMAND = g_user_command

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

I_GRID_SETTINGS = LC_GLAY

  • IS_LAYOUT =

IT_FIELDCAT = i_fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

IT_EVENT_EXIT = lt_event_exit

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_ADD_FIELDCAT =

  • IT_HYPERLINK =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IT_EXCEPT_QINFO =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = i_makt

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " call_fm

----


  • FORM USER_COMMAND *

----


FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield. "#EC CALLED

data i_RSPARAMS like RSPARAMS occurs 0.

CASE R_UCOMM.

WHEN '&IC1'.

read table i_makt index rs_selfield-tabindex.

SET PARAMETER ID 'MAT' FIELD i_makt-matnr.

if not i_makt-matnr is initial.

call transaction 'MM02' and skip first screen.

endif.

when '&REFRESH'.

CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'

EXPORTING

CURR_REPORT = v_repid

  • IMPORTING

  • SP =

TABLES

SELECTION_TABLE = i_RSPARAMS

EXCEPTIONS

NOT_FOUND = 1

NO_REPORT = 2

OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

submit z_get_refresh with selection-table i_RSPARAMS.

rs_selfield-refresh = 'X'.

*

ENDCASE.

MOVE '&REFRESH' TO r_ucomm.

ENDFORM.

----


  • FORM set_pf_status *

----


FORM SET_PF_STATUS USING rt_extab TYPE slis_t_extab.

DELETE Rt_extab WHERE fcode = gc_refresh.

SET PF-STATUS 'STANDARD_FULLSCREEN' OF PROGRAM 'SAPLKKBL'

EXCLUDING Rt_extab.

*SET PF-STATUS 'STANDARD' EXCLUDING rt_extab.

SET TITLEBAR sy-tcode.

ENDFORM.

this is for refresh alv

Thanks

Seshu

6 REPLIES 6

Former Member
0 Kudos

see the below program :

REPORT Z_GET_REFRESH no standard page heading.

type-pools : slis.

tables : makt,

mara.

data : i_fieldcat type slis_t_fieldcat_alv.

CONSTANTS :

gc_refresh TYPE syucomm VALUE '&REFRESH'.

data : begin of i_makt occurs 0,

matnr like makt-matnr,

maktx like makt-maktx,

end of i_makt.

data : v_repid like sy-repid,

g_user_command type slis_formname value 'USER_COMMAND',

g_status_set type slis_formname value 'SET_PF_STATUS',

lt_event_exit TYPE slis_t_event_exit,

ls_event_exit TYPE slis_event_exit.

DATA:LC_GLAY TYPE LVC_S_GLAY.

select-options s_matnr for mara-matnr .

start-of-selection.

select matnr maktx from makt into table i_makt

where matnr in s_matnr.

end-of-selection.

  • Fill the fieldcatlog

perform fill_field.

  • Call the FM

perform call_fm.

&----


*& Form fill_field

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fill_field.

data wa_fieldcat type slis_fieldcat_alv.

clear : wa_fieldcat.

wa_fieldcat-tabname = 'I_MAKT'.

wa_fieldcat-fieldname = 'MATNR'.

wa_fieldcat-outputlen = '18'.

wa_fieldcat-seltext_l = 'Material #'.

wa_fieldcat-col_pos = '1'.

append wa_fieldcat to i_fieldcat.

clear : wa_fieldcat.

wa_fieldcat-tabname = 'I_MAKT'.

wa_fieldcat-fieldname = 'MAKTX'.

wa_fieldcat-outputlen = '40'.

wa_fieldcat-seltext_l = 'Material Desc'.

wa_fieldcat-col_pos = '2'.

append wa_fieldcat to i_fieldcat.

ENDFORM. " fill_field

&----


*& Form call_fm

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM call_fm.

v_repid = sy-repid.

LC_GLAY-EDT_CLL_CB = 'X'.

CLEAR ls_event_exit.

ls_event_exit-ucomm = gc_refresh. " Refresh

ls_event_exit-after = 'X'.

APPEND ls_event_exit TO lt_event_exit.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = v_repid

I_CALLBACK_PF_STATUS_SET = g_status_set

I_CALLBACK_USER_COMMAND = g_user_command

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

I_GRID_SETTINGS = LC_GLAY

  • IS_LAYOUT =

IT_FIELDCAT = i_fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

IT_EVENT_EXIT = lt_event_exit

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_ADD_FIELDCAT =

  • IT_HYPERLINK =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IT_EXCEPT_QINFO =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = i_makt

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " call_fm

----


  • FORM USER_COMMAND *

----


FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield. "#EC CALLED

data i_RSPARAMS like RSPARAMS occurs 0.

CASE R_UCOMM.

WHEN '&IC1'.

read table i_makt index rs_selfield-tabindex.

SET PARAMETER ID 'MAT' FIELD i_makt-matnr.

if not i_makt-matnr is initial.

call transaction 'MM02' and skip first screen.

endif.

when '&REFRESH'.

CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'

EXPORTING

CURR_REPORT = v_repid

  • IMPORTING

  • SP =

TABLES

SELECTION_TABLE = i_RSPARAMS

EXCEPTIONS

NOT_FOUND = 1

NO_REPORT = 2

OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

submit z_get_refresh with selection-table i_RSPARAMS.

rs_selfield-refresh = 'X'.

*

ENDCASE.

MOVE '&REFRESH' TO r_ucomm.

ENDFORM.

----


  • FORM set_pf_status *

----


FORM SET_PF_STATUS USING rt_extab TYPE slis_t_extab.

DELETE Rt_extab WHERE fcode = gc_refresh.

SET PF-STATUS 'STANDARD_FULLSCREEN' OF PROGRAM 'SAPLKKBL'

EXCLUDING Rt_extab.

*SET PF-STATUS 'STANDARD' EXCLUDING rt_extab.

SET TITLEBAR sy-tcode.

ENDFORM.

this is for refresh alv

Thanks

Seshu

Former Member
0 Kudos

Hi,

The simplest solution is:

The 'select all' and 'deselect all' buttons will have an associated OK_CODE rt?

In REUSE_ALV_GRID_DISPLAY function call,

Provide a name for the i_callback_user command and create the form

with the following code inside that

CASE SY-UCOMM.

WHEN 'SEL_ALL'.

loop at it_outtab (output table).

set the check box field with the 'X' value.

endloop.

WHEN 'DES_ALL'.

loop at it_outtab.

Clear the check box fields.

endloop.

This simple algorith should work perfectly for your requirement.

Reply in case you need more inputs.

Regards,

Anil Kumar V

0 Kudos

Thank you for the replies. Actually I already did this. in my USER_COMMAND form, when the sy-ucomm is Select/Deselect, i loop at my internal table and set the fields to 'X' or blank. When I check the internal table, the records are updated accordingly.

My problem is with the report output. Thanks again.

0 Kudos

have you refreshed the ALV

FORM USER_COMMAN p_selfield type ....

CASE.

ENDCASE.

<b>p_selfield-refresh = 'X'.</b>

ENDFORM

Former Member
0 Kudos

since u will maintain a particular field for the checkboxes, u can loop at the internal table and make that column empty(clear that column) everytime before u display the alv

Hope this will solve ur problem..

<b><u>Dont forget to reward all the useful replies</u></b>

Sudheer

Former Member
0 Kudos

I just used the Standard Select/Deselect Function, which can be found in the PF-STATUS 'STANDARD'.