‎2007 Jun 04 1:52 PM
hi all ,
i have a simple report where i have displayed data using WRITE statements
with that i have also displayed a checkbox against each record
now after report is displayed the user can select or deselect any of the records
using checkboxes ..how can i find out whether the check box is selected or not
in front of each record
‎2007 Jun 04 1:57 PM
Hi Shah,
Check the below code.....
tables:
spfli. " Flight details
*"Selection screen elements............................................
select-options
s_carrid for spfli-carrid.
*" Data declarations...................................................
"----
data: w_check1 type c value ' '.
"----
field string declaration of the structure of flight details *
"----
data: begin of fs_spfli,
carrid type spfli-carrid, " carrier id
connid type spfli-connid, " Connection id
airpfrom type spfli-airpfrom, " Departure airport
airpto type spfli-airpto, " Arrival airport
deptime type spfli-deptime, " Departure time
arrtime type spfli-arrtime, " arrival time
end of fs_spfli.
"----
field string declaration of the structure of flight scheduledetails *
"----
data: begin of fs_sflight,
carrid type sflight-carrid,
connid type sflight-connid,
fldate type sflight-fldate,
seatsmax type sflight-seatsmax,
seatsocc type sflight-seatsocc,
end of fs_sflight.
"----
Internal table to populate flight details *
"----
data:
t_spfli like
standard table
of fs_spfli.
"----
Internal table to populate flight schedule details *
"----
data:
t_sflight like
standard table
of fs_sflight.
"----
Field string for structure to store flight schedule details *
"----
data:
begin of fs_spflidup ,
carrid like spfli-carrid,
connid like spfli-connid,
end of fs_spflidup.
"----
Internal table to populate to store flight schedule details *
"----
data t_spflidup like
standard table
of fs_spflidup.
data:
lw_lines type i,
lw_lineno type i value 3,
lw_count type i.
"----
START-OF-SELECTION EVENT *
"----
start-of-selection.
perform list_output.
set pf-status 'LIST'.
"----
AT USER-COMMAND EVENT *
"----
at user-command.
case sy-ucomm.
when 'GET'.
perform get_sflightdata.
when 'SELECTALL'.
perform select_all.
when 'DESELECTAL'.
perform deselect_all.
endcase.
----
FORM GET_SFLIGHTDATA *
----
This subroutine gets the line data from the list and then gets the *
corresponding flightdata and seats allocated. *
----
There are interface parameters to be passed to this subroutine. *
*----
form get_sflightdata .
describe table t_spfli lines lw_lines.
do lw_lines times.
read line lw_lineno
field value w_check1 into w_check1
fs_spfli-carrid into fs_spfli-carrid
fs_spfli-connid into fs_spfli-connid .
if sy-subrc eq 0.
if w_check1 eq 'X'.
add 1 to lw_count.
w_check1 = ' '.
sy-lisel+2(1) = '*'.
modify current line field value w_check1.
modify current line
field format w_check1 input off.
fs_spflidup-carrid = fs_spfli-carrid.
fs_spflidup-connid = fs_spfli-connid.
append fs_spflidup to t_spflidup.
clear fs_spfli.
endif. " IF W_CHECK1
endif. " IF SY-SUBRC
add 1 to lw_lineno.
enddo. " DO LW_LINES
if lw_count eq 0.
message 'Select atleast one record'(001) type 'I'.
else.
select sflight~carrid " Carrier Id
sflight~connid " Connection Id
sflight~fldate " Flight Date
sflight~seatsmax " Seats Available
sflight~seatsocc " Seats occupied
from sflight
into table t_sflight
for all entries
in t_spflidup
where carrid eq t_spflidup-carrid
and connid eq t_spflidup-connid.
if sy-subrc eq 0.
loop at t_sflight into fs_sflight.
write :/20 fs_sflight-fldate,
fs_sflight-seatsmax,
fs_sflight-seatsocc.
endloop. " IF SY-SUBRC
else.
message 'No data found'(002) type 'S'.
endif. " IF SY-SUBRC
endif. " IF LW_COUNT
lw_lineno = 3.
clear t_spflidup[].
clear t_sflight[].
lw_count = 0.
endform. " GET_SFLIGHT_DATA
----
FORM LIST_OUTPUT *
----
This subroutine gets the table data from the flightr table *
----
There are interface parameters to be passed to this subroutine. *
*----
form list_output.
select spfli~carrid " Carrier id
spfli~connid " Connection Id
spfli~airpfrom " Departure city
spfli~airpto " Arrival city
spfli~deptime " Departure time
spfli~arrtime " Arrival time
from spfli
into table t_spfli
where carrid in s_carrid.
loop at t_spfli into fs_spfli.
write: /5 w_check1 as checkbox input on,
10 fs_spfli-carrid,
20 fs_spfli-connid,
30 fs_spfli-airpfrom,
40 fs_spfli-airpto,
50 fs_spfli-deptime,
60 fs_spfli-arrtime.
endloop. " LOOP AT T_SPFLI
endform. " LIST_OUTPUT
----
FORM SELECT_ALL *
----
This subroutine checks all the connection ids in flight table *
----
There are interface parameters to be passed to this subroutine. *
*----
form select_all.
describe table t_spfli lines lw_lines.
do lw_lines times.
read line lw_lineno
field value w_check1 into w_check1.
if sy-subrc eq 0.
if w_check1 ne 'X'.
w_check1 = 'X'.
sy-lisel+2(1) = ' '.
modify line lw_lineno field value w_check1 .
modify line lw_lineno field format w_check1 input on.
endif. " IF W_CHECK1
endif. " IF SY_SUBRC
add 1 to lw_lineno.
enddo. " DO LW_LINES
lw_lineno = 3.
endform. " SELECT_ALL
----
FORM DeSELECT_ALL *
----
This subroutine dechecks all the connection ids in flight table *
----
There are interface parameters to be passed to this subroutine. *
*----
form deselect_all.
describe table t_spfli lines lw_lines.
do lw_lines times.
read line lw_lineno
field value w_check1 into w_check1.
if sy-subrc eq 0.
if w_check1 eq 'X'.
w_check1 = ' '.
sy-lisel+2(1) = ' '.
modify line lw_lineno field value w_check1 .
endif. " IF W_CHECK1
endif. " IF SY_SUBRC
add 1 to lw_lineno.
enddo. " DO LW_LINES
lw_lineno = 3.
endform. " DESELECT_ALL
Reward if it is help ful...
Regards,
Omkar.
‎2007 Jun 04 2:21 PM
Hi Tarang Shah,
You simple use read line.. check this code in this cb is a check box and wa_e-e_id = first field whose value i want in further selction. declare cb1 as any length of type c. in cb1 the value of e_id of selected checkbox is come.
CASE sy-ucomm.
WHEN 'SUBMIT'.
DO .
READ LINE sy-index FIELD VALUE cb wa_e-e_id INTO cb1.
IF sy-subrc EQ 0.
IF cb EQ 'X'.
READ TABLE itab_e INTO wa_e WITH KEY e_id = cb1.
IF sy-subrc EQ 0.
wa_e-total_sal = wa_e-total_sal + ( wa_e-total_sal * '0.10' ).
MODIFY itab_e FROM wa_e INDEX sy-tabix TRANSPORTING total_sal.
ENDIF.
ENDIF.
ELSE.
EXIT.
ENDIF.
ENDDO.
Update zemployee from table itab_e.
if sy-subrc = 0.
message 'ROWS SUCCESSFULLY UPDATED In TABLE ZEMPLOYEE.' type 'I'.
endif.
‎2007 Jun 04 2:21 PM
HI...
CHECK THE DEMO PROGRAM <b>demo_list_modify_field_format</b> .
You can use check boxes for user interaction in lists. When user selects the check box the check box value will be 'X' other wise it will be ' ' .Depending on the value of check box you can run the program at execution time.
regards,
veeresh