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

Using IF statement with a select-option

Former Member
0 Likes
7,159

This is killing me and I am sure that it is something simple but for some reason, I can't get it to work.

I have a select options field. I need to compare it to a field from a structure. For some reason, even though the if should work, it is not working. What can the problem be?

IF structure-field NOT IN select_options.

    delete something.

Endif.

10 REPLIES 10
Read only

Former Member
0 Likes
3,546

Hi Car

I'm sure someone may have a better response.

But my option would be to loop through select_options and perform your check on each entry.

If at the end of the loop, the required condition is met/not met, perform your deletion of the "Somethings"

Regards

Arden

Read only

custodio_deoliveira
Active Contributor
0 Likes
3,546

Hi Car,

There's absolute no reason this IF doesn't work, so my guess is it works, but your content is "problematic". Please share the actual contents of the structure field AND the select-options and we might help.

Cheers,

Custodio

Read only

0 Likes
3,546

The only thing we are doing to the value entered is adding leading zeroes to it since that is how the table is saving the data. This could be a problem? When I debug, the value in the table and the value from the select options is the same (with the leading zeroes both) so I don't know why it is failing.

Read only

0 Likes
3,546

If the values are the same probably not the problem but I insist, if you share the EXACTLY values (including sign, option, low and high for select-options) it would be easier for us to help.

Read only

0 Likes
3,546

The select options has IEQ000714 and the value in the table is 000714.

Read only

0 Likes
3,546

So that's why the IF "is not working" (actually it is).

IF structure-field (000714) NOT IN select_options (Include equal 000714).

Obviously it will not get into the if.


you can fix it 3 ways:


- use EEQ00714

- use INE000714

- use IF structure-field NOT IN select_options.


Cheers,

Custodio

Read only

0 Likes
3,546

My problem is that it is entering the delete statement when they are the same. My code is like your third suggestion.

IF structure-field NOT IN select_options.

delete

ENDIF.

It should not enter when they are the same.

Read only

0 Likes
3,546

Sorry, I meant to say IF structure-field IN select_options.

Anyway, is this value IEQ00714 in the select-option header line only or as a line in the select option "internal table" (it should be).

Read only

Former Member
0 Likes
3,546

Hi Car,

please check, that there is always '000714', Because 'OOO714', 'O00714' ... may look like it.

Please check the hex content of the structure field and the select option in debugger. Are they identical?

Regards,

Klaus

Read only

Former Member
0 Likes
3,546

use same type.