on 07-31-2007 10:13 AM
Hi,
I have a list. In that list I have checkboxes corresponding to the rows of internal table. I also have a select all button. I want to check all the checkboxes at select all button click,
Please guide me.
Thanks,
Saroj
Hi
Write the following for that button SELECT ALL
FORM select_all .
CLEAR v_lisel.
DO.
READ LINE sy-index FIELD VALUE v_chk.
IF sy-subrc NE 0.
EXIT.
ENDIF.
READ LINE sy-index FIELD VALUE sy-lisel INTO v_lisel.
IF v_lisel+2(1) = ' ' AND sy-index GT 5.
v_lisel+2(1) = 'X'.
MODIFY LINE sy-index FIELD VALUE sy-lisel FROM v_lisel.
ENDIF.
ENDDO.
ENDFORM. " select_all
<b>Reward points for useful Answers</b>
Regards
Anji
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi saroj,
to select all the check boxes use the menu interface by giving the SET PF-STATUS and give the related code for that as given below.
EXAMPLE:
DATA : C1 TYPE C,
LNO TYPE I.
|
|
|
SET PF-STATUS 'ZMENU'.
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'SELECTALL'.
LNO =1.
DO.
READLINE LNO FIELD VALUE C1.
IF SY-SUBRC<>0.
EXIT.
ENDIF.
C1='X'.
MODIFYLINE LNO FIELD VALUE C1.
LNO = LNO+1.
ENDDO.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi, you ve check box in the internal table (table control) in the dialog programming screen. which ve option as attribute at last of screen attributes .
the option as
line sel and column sel ve single select ,multiple select and none.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The below code gives an example for given requirement
TYPES : begin of ty_cond_type,
check,
f ield1,
field2,
End of ty_cond_type.
data: it_cond_type type standard table of ty_cond_type.
data: wa_cond-type type ty_cond_type.
loop at it_cond_type into wa_cond_type.
wa_cond_type-check = 'X'.
Update the Itab.
MODIFY it_cond_type
FROM wa_cond_type
TRANSPORTING check
endloop.
Thanks & regard\
venkat
Message was edited by:
venkat v G murali mohan M
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
REPORT zprem_interactive .
TYPES : BEGIN OF ty_test,
code TYPE i,
name(10) TYPE c,
amount TYPE p DECIMALS 2,
END OF ty_test.
DATA : it_test TYPE STANDARD TABLE OF ty_test WITH HEADER LINE INITIAL SIZE 10.
DATA : wa TYPE ty_test,
chk1 TYPE c,
fldname(30), fldval(50).
*set pf-status 'PF01'.
*set titlebar 'PF01'.
*
INITIALIZATION.
it_test-code = 300.
it_test-name = 'Ramesh'.
it_test-amount = 5500.
APPEND it_test.
wa-code = 207.
wa-name = 'Prem'.
wa-amount = 5000.
APPEND wa TO it_test.
it_test-code = 117.
it_test-name = 'James Bond'.
it_test-amount = 9900.
INSERT it_test INDEX 3.
it_test-code = 217.
it_test-name = 'Sivaraman'.
it_test-amount = 9900.
INSERT it_test INDEX 3.
it_test-code = 201.
it_test-name = 'Saravanan'.
it_test-amount = 1000.
APPEND it_test.
it_test-code = 210.
it_test-name = 'Shanmugam'.
it_test-amount = 6000.
APPEND it_test.
WRITE : / 'Loop Display ( Appended rows ) :-'.
LOOP AT it_test.
WRITE : / chk1 AS CHECKBOX,
sy-tabix, sy-vline, it_test-code, it_test-name, it_test-amount.
HIDE : it_test-code, it_test-name.
ENDLOOP.
SKIP.
END-OF-SELECTION.
CLEAR : it_test-code, it_test-name.
WRITE : / 'this from end of selection'.
&----
*& Form DISP1
&----
text
----
FORM disp1.
WINDOW STARTING AT 15 10
ENDING AT 80 15.
DO.
CLEAR chk1.
READ LINE sy-index FIELD VALUE chk1.
IF sy-subrc NE 0.
EXIT.
ELSE.
CHECK chk1 NE space.
WRITE : / it_test-code, it_test-name.
MODIFY CURRENT LINE :
FIELD VALUE chk1 FROM ' '
FIELD FORMAT chk1 INPUT OFF.
ENDIF.
ENDDO.
ENDFORM. "DISP1
***line double click ****
AT LINE-SELECTION.
CHECK sy-lsind = 1.
WINDOW STARTING AT 5 4
ENDING AT 85 20.
WRITE: / 'THE USER DOUBLE-CLICKED A LINE IN THE REPORT'.
WRITE: / sy-lisel.
WRITE : / 'Sometime ',it_test-name, ' is good '.
WRITE : / 'Sometime ',it_test-name, ' is bad '.
WRITE : / 'Sometime ',it_test-name, ' is rich '.
WRITE : / 'Sometime ',it_test-name, ' is poor '.
WRITE : / 'Who knows, who is ',it_test-name, ' ? '.
WRITE : /, / 'we can also use this in SELECT statement'.
CLEAR : it_test-code, it_test-name.
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ULINE.
SKIP.
SKIP.
WRITE : / 'Below from Get Cursor Field...'.
GET CURSOR FIELD fldname VALUE fldval.
CONDENSE fldname.
CONDENSE fldval.
WRITE : / 'You have clicked ', fldname, ' & its value is ', fldval.
***function key press F6 ****
AT PF06.
PERFORM disp1.
*AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'STOP' OR 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN 'TESTME'.
PERFORM DISP1.
ENDCASE.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Check the code..
TYPES : begin of ty_cond_type,
check,
f ield1,
field2,
End of ty_cond_type.
data: it_cond_type type standard table of ty_cond_type.
data: wa_cond-type type ty_cond_type.
loop at it_cond_type into wa_cond_type.
wa_cond_type-check = 'X'.
Update the Itab.
MODIFY it_cond_type
FROM wa_cond_type
TRANSPORTING check
endloop.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
" Please see the code of myin in the 'SELECT' & 'DESELECT'.
case save_ok.
when 'EXIT'.
perform exit_program.
when 'SELECT'.
perform select_all_entries changing gt_outtab[].
when 'DESELECT'.
perform deselect_all_entries changing gt_outtab[].
when 'RESET'.
perform reset_selected_entries changing gt_outtab[].
when 'SWITCH'.
perform switch_activation changing gt_outtab[].
endcase.
form select_all_entries changing pt_outtab type standard table.
data: ls_outtab type gs_outtab.
data: l_valid type c,
l_locked type c.
*§A4ad. Before you (a)set, reset or (d)evaluate checkboxes,
* you must check the input cells.
*
* If all entries are ok, ALV transferes new values to the output
* table which you then can modify.
call method g_grid->check_changed_data
importing
e_valid = l_valid.
if l_valid eq 'X'.
loop at pt_outtab into ls_outtab.
perform check_lock using ls_outtab
changing l_locked.
if l_locked is initial
and not ls_outtab-checkbox eq '-'.
ls_outtab-checkbox = 'X'.
endif.
modify pt_outtab from ls_outtab.
endloop.
call method g_grid->refresh_table_display.
endif.
endform.
form check_lock using ps_outtab type gs_outtab
changing p_locked.
data ls_celltab type lvc_s_styl.
loop at ps_outtab-celltab into ls_celltab.
if ls_celltab-fieldname = 'CHECKBOX'.
if ls_celltab-style eq cl_gui_alv_grid=>mc_style_disabled.
p_locked = 'X'.
else.
p_locked = space.
endif.
endif.
endloop.
endform.
form deselect_all_entries changing pt_outtab type standard table.
data: ls_outtab type gs_outtab.
data: l_valid type c,
l_locked type c.
*§A4ad. Before you (a)set, reset or (d)evaluate checkboxes,
* you must check the input cells.
*
* If all entries are ok, ALV transferes new values to the output
* table which you then can modify.
call method g_grid->check_changed_data
importing
e_valid = l_valid.
if l_valid eq 'X'.
loop at pt_outtab into ls_outtab.
perform check_lock using ls_outtab
changing l_locked.
if l_locked is initial
and not ls_outtab-checkbox eq '-'.
ls_outtab-checkbox = ' '.
endif.
modify pt_outtab from ls_outtab.
endloop.
call method g_grid->refresh_table_display.
endif.
reward points if it is usefull ......
Girish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
you could loop the internal table and modify the checkbox field, when the select all button is pressed.
Regards,
Alexandros.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.