‎2014 Nov 04 7:58 AM
I have a checkbox group with 5 checkboxes in selection screen.
I want to see which of these checkbox is checked and assign it to a field I will be passing to a function module.
I know that the active checkbox value will be set to X.
But what if two checkboxes are checked at the same time?
Should I do a case-when or if-else?
Sorry this is quite a basic logic but am lil confused.
Please help.
Thanks.
‎2014 Nov 04 8:11 AM
‎2014 Nov 04 8:20 AM
Thanks. Right now i am doing it like the one below.
But I would like to know if there is any simpler way than this.
IF p_pln EQ 'X'.
ls_btcselect-prelim = 'X'.
ENDIF.
IF p_rel EQ 'X'.
ls_btcselect-schedul = 'X'.
ENDIF.
IF p_rdy EQ 'X'.
ls_btcselect-ready = 'X'.
ENDIF.
IF p_act EQ 'X'.
ls_btcselect-running = 'X'.
ENDIF.
IF p_fin EQ 'X'.
ls_btcselect-finished = 'X'.
ENDIF.
IF p_can EQ 'X'.
ls_btcselect-aborted = 'X'.
ENDIF.
CALL FUNCTION 'BP_JOB_SELECT'
EXPORTING
jobselect_dialog = 'N'
jobsel_param_in = ls_btcselect
TABLES
jobselect_joblist = lt_btcjob
EXCEPTIONS
no_jobs_found = 1
OTHERS = 2.
Thanks.
‎2014 Nov 04 8:27 AM
This is better/neater:
CASE 'X'.
WHEN p_pln.
ls_btcselect-prelim = 'X'.
WHEN p_rel.
ls_btcselect-schedul = 'X'.
WHEN p_rdy.
ls_btcselect-ready = 'X'.
WHEN p_act.
ls_btcselect-running = 'X'.
WHEN p_fin.
ls_btcselect-finished = 'X'.
WHEN p_can.
ls_btcselect-aborted = 'X'.
ENDCASE.
‎2014 Nov 05 1:48 AM
Thanks Glen. I tried this case-when method already and it just sets any one field to X and comes out of endcase. Is that how case-when works? Not sure. If endif worked fine for me though i would prefer case-when.
‎2014 Nov 04 8:16 AM
Hi,
Use separate if endif block for each checkbox and in it assign the relevant field of function module.
Regards,
Ashish
‎2014 Nov 04 8:23 AM
Thank you Ashish. Does that mean my code above is the only way we can go about it?
‎2014 Nov 04 8:27 AM
Hi Gita,
You may use FM RS_SELECTIONSCREEN_READ to read selection screen .
Pass report name and screen number.
Thanks
‎2014 Nov 04 8:45 AM
Hi,
You don't even have to put if endif block. Simply equate the checkboxes to the fields of the structure, those are checked will be assigned as 'X' in the structure and which are not ticked will be left blank.
ls_btcselect-prelim = p_pln.
ls_btcselect-schedule = p_rel.
Similarly for all fields.
Thus which are ticked will only be assigned as 'X' in the structure.
‎2014 Nov 05 1:54 AM
Hi Gita,
I would say Ashish Rawat's suggestion is the best way of doing it. i.e. just assign the checkboxes directly to the structure fields.
Thanks,
Naveen
‎2014 Nov 05 1:56 AM
‎2014 Nov 04 8:42 AM
Hi
The you have written now is ok.
When two check boxes selected then two fields wil be filled with 'X'.
for ex: p_pln and p_rel are selected then
ls_btcselect-prelim = 'X'.
ls_btcselect-schedul = 'X'.
will be passed to FM.
regards.
laxman.
‎2014 Nov 04 8:42 AM
Hi Gita,
Glen anthnony's code is short and best one, it reduces multiple if statments as in your code.
Thanks & Regards
Prakash.
‎2014 Nov 04 8:45 AM
Hi,
You can attach a USER-COMMAND to all the checkboxes in order to receive the values of the particular checked box and capture those values AT SELECTION SCREEN OUTPUT.
for e.g.
TABLES SSCRFIELDS .
DATA : SCOMM TYPE SSCRFIELDS-UCOMM.
PARAMETERS: P_PLN AS CHECKBOX USER-COMMAND UC1.
PARAMETERS: P_REL AS CHECKBOX USER-COMMAND UC2.
PARAMETERS: P_RDY AS CHECKBOX USER-COMMAND UC3.
PARAMETERS: P_ACT AS CHECKBOX USER-COMMAND UC4.
PARAMETERS: P_FIN AS CHECKBOX USER-COMMAND UC5.
PARAMETERS: P_CAN AS CHECKBOX USER-COMMAND UC6.
AT SELECTION-SCREEN OUTPUT.
CASE SCOMM.
WHEN 'UC1'.
ls_btcselect-prelim = 'X'.
WHEN 'UC2'.
ls_btcselect-schedul = 'X'.
WHEN 'UC3'.
ls_btcselect-ready = 'X'.
WHEN 'UC4'
ls_btcselect-running = 'X'.
WHEN 'UC5'.
ls_btcselect-finished = 'X'.
WHEN 'UC6'.
ls_btcselect-aborted = 'X'.
ENDCASE.
‎2014 Nov 05 1:49 AM