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

If...elseif statement...

Former Member
0 Likes
20,309

Hi,

I am selecting the data to an itab gi_output.I have 3 checkboxes in my selection screen(p_wgt and p_wgt and p_dimen).so according to the checkboxes selected the data should be deleted from gi_output.

if p_wgt = 'X'.

delete gi_output where tarag NE '0.000' and magew NE '0.000'

and ntgew NE '0.000' and brgew NE '0.000'.

elseif p_ippc = 'X'.

delete gi_output where vegr1 NE ' '.

elseif p_dimen = 'X'.

delete gi_output where laeng NE '0.000'

and breit NE '0.000'

and hoehe NE '0.000'.

elseif p_wgt = 'X' and P_ippc = 'X'.

delete gi_output where tarag NE '0.000' and magew NE '0.000'

and ntgew NE '0.000' and brgew NE '0.000'

or vegr1 NE ' '.

when 1 checkbox is selected..my coding is working fine..but when 2 checkboxes are selected (suppose p_wgt and P_ippc),the control is checking 1st if statement(P_wgt = 'X')than after that it is coming out of if statement block....any idea..

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
7,549

Hello,

You need to write all possible combination for check boxes.

if p_wgt = 'X' AND p_ippc = 'X' AND p_dimen = 'X'.

<your deletion code>

endif.

if p_wgt = 'X' AND p_ippc = 'X' .

<your deletion code>

endif.

if p_ippc = 'X' AND p_dimen = 'X'.

<your deletion code>

endif.

if p_wgt = 'X' AND p_dimen = 'X'.

<your deletion code>

endif.

if p_wgt = 'X' .

<your deletion code>

endif.

if p_ippc = 'X' .

<your deletion code>

endif.

if p_dimen = 'X'.

<your deletion code>

endif.

Regards

Arindam

8 REPLIES 8
Read only

Former Member
0 Likes
7,549

Hi Priya,

Please understand the key words properly.

IF statements executes for the first logical expression where it satisfied the condions mentiond and skips other else conditions.

this is the NATURE of IF statement.

if you want all the three to be checked.

you need to write combinations.

if f_chek is 'X' AND

S_CHEK IS 'X' AND

T_CHEK IS 'X'.

ELSEIF

ELSEIF.

or use anyother logic.

for further help please go throught the key word documentaion.

regards

Ramchander Rao.K

Read only

0 Likes
7,549

so,

what can i use for multiple checkbox selection.?

Read only

0 Likes
7,549

hi

use case endcase .

Read only

Former Member
0 Likes
7,550

Hello,

You need to write all possible combination for check boxes.

if p_wgt = 'X' AND p_ippc = 'X' AND p_dimen = 'X'.

<your deletion code>

endif.

if p_wgt = 'X' AND p_ippc = 'X' .

<your deletion code>

endif.

if p_ippc = 'X' AND p_dimen = 'X'.

<your deletion code>

endif.

if p_wgt = 'X' AND p_dimen = 'X'.

<your deletion code>

endif.

if p_wgt = 'X' .

<your deletion code>

endif.

if p_ippc = 'X' .

<your deletion code>

endif.

if p_dimen = 'X'.

<your deletion code>

endif.

Regards

Arindam

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
7,549

easy to work it out...HMmmm

if p_wgt = 'X'.

delete gi_output where tarag NE '0.000' and magew NE '0.000'

and ntgew NE '0.000' and brgew NE '0.000'.

endif.

if p_ippc = 'X'.

delete gi_output where vegr1 NE ' '.

endif.

if p_dimen = 'X'.

delete gi_output where laeng NE '0.000'

and breit NE '0.000'

and hoehe NE '0.000'.

endif.

if p_wgt = 'X' and P_ippc = 'X'.

delete gi_output where tarag NE '0.000' and magew NE '0.000'

and ntgew NE '0.000' and brgew NE '0.000'

or vegr1 NE ' '.

endif.

this will work

Read only

0 Likes
7,549

Kheshu's right ... simplest and most effective

if p_wgt = 'X'.

*logic when checkbox1 is selected

endif.

if p_ippc = 'X'.

*logic when checkbox1 is selected

endif.

if p_dimen = 'X'.

*logic when checkbox1 is selected

endif.

and use combinations if different logic for various combinations of checkboxes is required.

Read only

Sougata
Active Contributor
0 Likes
7,549

Hi Priya,

For this specific scenario i.e. if you do not have any other requirements as far as logic behind these 3 checkboxes are concerned, you could write it like this:


IF p_wgt = 'X' AND p_ippc = 'X'.
* your logic
ELSEIF p_ippc = 'X'.
* your logic
ELSEIF p_dimen = 'X'.
* your logic
ELSE.
 delete gi_output where tarag NE '0.000' and magew NE '0.000' 
 and ntgew NE '0.000' and brgew NE '0.000'.
ENDIF.

Hope this solves the issue.

Cheers,

Sougata.

Read only

Former Member
0 Likes
7,549

Hi Priya,

Check boxes are viable to select more than one among hence you need to handle it for each check box selected. The best way to handle check boxes are to have independent IF...ENDIF condition for each.

IF..ELSEIF...statement is more suitable for 'Radiobuttons' as you will always select one among the group. So have indepedent IF...ENDIF condition for each check box.

If you will still wants to do only with IF...ELSEIF statements then you need to take care of coding for cominational conditions. Always have most feasible conidtion on TOP.

Check the below code.

if p_wgt = 'X' and P_ippc = 'X'.

delete gi_output where tarag NE '0.000' and magew NE '0.000'

and ntgew NE '0.000' and brgew NE '0.000'

or vegr1 NE ' '.

elesif p_wgt = 'X'.

delete gi_output where tarag NE '0.000' and magew NE '0.000'

and ntgew NE '0.000' and brgew NE '0.000'.

elseif p_ippc = 'X'.

delete gi_output where vegr1 NE ' '.

elseif p_dimen = 'X'.

delete gi_output where laeng NE '0.000'

and breit NE '0.000'

and hoehe NE '0.000'.

endif.

Thanks,

Vinay