Skip to Content
0
Former Member
Jul 31, 2007 at 08:27 AM

checkbox in alv report

158 Views

hi all,

i am facing one problem regarding checkbox in alv.

i have to buttons on alv report as 'select all' (to select all) and 'send mail'(as i have to send mail to selected record)

wat i have done till now is:

1. when i run the report and cleck on checkboxes the action is reflected in internal table..n i can capture the data.

2.when i click on select all button all the records get selected and i can capture the data again.

now the problem :

when i clcik on "select all" and all the record get selected ..but when i deselect any of those record..the changes in internal table lost i.e. the checkbox field because empty for all the record.....

PLZ GIVE SOLUTION FOR FUNCTION "REUSE_ALV_GRID_DISPLAY" ONLY...

now the code:

************LAYOUT**************

DATA: gd_layout TYPE SLIS_LAYOUT_ALV.

gd_layout-colwidth_optimize = 'X'.

  • gd_layout-zebra = 'X'.

gd_layout-box_fieldname = 'CHECKBOX'.

gd_layout-box_tabname = 'IT_CONF'.

****alv display*************

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_grid_title = 'Detailed List'

it_fieldcat = fieldcat

i_callback_program = sy-repid

i_callback_user_command = 'USER_CMD'

i_callback_pf_status_set = 'EMAILS'

IS_LAYOUT = gd_layout

TABLES

t_outtab = it_conf

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.

endif.

endform. "alv_display

  • &--------------------------------------------------------------------

*& Form sush1

&----


  • text

----


  • -->RT_EXTAB text

----


FORM emails USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'EMAILS'.

ENDFORM. "emails

&----


*& Form user_cmd

&----


  • text

----


  • -->P_UCOMM text

  • -->LS_SELFIELDtext

----


FORM user_cmd USING p_ucomm LIKE sy-ucomm ls_selfield type slis_selfield.

IF REF_GRID IS INITIAL.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

E_GRID = REF_GRID.

ENDIF.

IF NOT REF_GRID IS INITIAL.

CALL METHOD REF_GRID->CHECK_CHANGED_DATA.

ENDIF.

IF p_ucomm = 'EMAIL'.

loop at it_conf where checkbox = 'X'.

**[[[[[[[U MAY NOT SEE THIS THIS IS FOR MAIL PUPOSE]]]]]]]]]]]]*********

select single sachn telnr into (tc_name , tc_num ) from t526

where SACHX = it_conf-zztc

and werks = it_conf-werks .

  • ******find the emil of employee.

clear : p_0105,p_0105[].

CALL FUNCTION 'HR_READ_INFOTYPE'

EXPORTING

pernr = it_conf-pernr

infty = '0105'

BEGDA = pn-begda

ENDDA = pn-endda

TABLES

infty_tab = p_0105

EXCEPTIONS

infty_not_found = 1

OTHERS = 2.

if sy-subrc = 0.

read table p_0105 with key subty = 10.

move p_0105-USRID_LONG to email.

endif.

  • find immediate superior by Z FM.

clear pernr_s.

CALL FUNCTION 'ZHR_GET_IMMMED_SUPERIOR'

EXPORTING

pernr = it_conf-pernr

begda = '18000101'

endda = '99991231'

IMPORTING

v_pernr = pernr_s

EXCEPTIONS

not_found = 1

OTHERS = 2.

if sy-subrc = 0.

  • find the email of the immed. superiors personal number..

clear : p_0105,p_0105[].

CALL FUNCTION 'HR_READ_INFOTYPE'

EXPORTING

pernr = pernr_s

infty = '0105'

BEGDA = pn-begda

ENDDA = pn-endda

TABLES

infty_tab = p_0105

EXCEPTIONS

infty_not_found = 1

OTHERS = 2.

read table p_0105 with key subty = 10.

move p_0105-USRID_LONG to email_s.

endif.

if email <> ' '.

perform send_mail using it_conf-ename email email_s tc_name tc_num.

endif.

if email_s <> ' '.

perform send_mail using it_conf-ename email email_s tc_name tc_num.

endif.

****MAIL PART IS OVER*******************************************

endloop.

endif.

*****FOR "SELECT ALL " BUTTON**************

IF p_ucomm = 'SELECT'.

flag = 1.

loop at it_conf.

move 'X' to it_conf-checkbox.

MODIFY IT_CONF.

endloop.

ls_selfield-refresh = 'X'.

endif.