Application Development and Automation 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: 
Read only

Selection screen checkbox - clarification needed

former_member699182
Participant
0 Likes
1,690


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.

14 REPLIES 14
Read only

former_member201275
Active Contributor
0 Likes
1,665

Please post your code here as that makes not much sense.

Read only

0 Likes
1,665

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.

Read only

0 Likes
1,665

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.

Read only

0 Likes
1,665

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.

Read only

Former Member
0 Likes
1,665

Hi,

Use separate if endif block for each checkbox and in it assign the relevant field of function module.

Regards,

Ashish

Read only

0 Likes
1,665

Thank you Ashish. Does that mean my code above is the only way we can go about it?


Read only

0 Likes
1,665

Hi Gita,

You may use FM RS_SELECTIONSCREEN_READ to read selection screen .

Pass report name and screen number.

Thanks

Read only

0 Likes
1,665

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.

Read only

0 Likes
1,665

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

Read only

0 Likes
1,665

Logical.

Thanks a lot.

Read only

Former Member
0 Likes
1,665

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.

Read only

Former Member
0 Likes
1,665

Hi Gita,

           Glen anthnony's code is short and best one, it reduces multiple if statments as in  your code.

Thanks & Regards

Prakash.

Read only

Former Member
0 Likes
1,665

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.

Read only

former_member699182
Participant
0 Likes
1,665

Thanks all for the helpful answers.