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

Multiple logic expression not working

p24time
Explorer
0 Likes
860

HI expert,

when i am featching records from internal table on base of logical expression.. multiple logic expression not working..

below is my expression..

IF ls_glset-type = text-042.     
              IF ( ls_glset-shortname = text-025 OR
                  ls_glset-shortname = text-032 OR
                  ls_glset-shortname = text-033 OR
                  ls_glset-shortname = text-034 OR
                  ls_glset-shortname = text-035 ) AND
                 ( ( ls_faglflext-activ NE 'COFI' AND ls_faglflext-pprctr NE '11ITMIS' ) OR
                  ( ls_faglflext-activ NE 'RKP1' AND ls_faglflext-prctr NE '11ITMIS') ).
in above condition "     ( ls_faglflext-activ NE 'RKP1' AND ls_faglflext-prctr NE '11ITMIS')  " this logic expression is not working...
please check & revert..
thnkx
prakash

7 REPLIES 7
Read only

Sandra_Rossi
Active Contributor
0 Likes
832

Important question : could you please explain what you want to do? (don't answer you want it to work)

By the way, using translatable texts (text-xxx) as a means of defining constants is a very bad idea! (hopefully SAP never does that, it would be fun to see the result!) Better use either constants (key word CONSTANTS) or text literals (like 'COFI') depending on the context.

Read only

0 Likes
832

Hi Ryan,

in decision "AND" statement is not working after condition change below is logical expression.

IF ( ls_glset-shortname = 'FREIGHT_FORW' OR

                   ls_glset-shortname = 'RENT' OR

                   ls_glset-shortname = 'TRAVL_CONVNC' OR

                   ls_glset-shortname = 'SALPF_BONUS' OR

                   ls_glset-shortname = 'OTHEREXPENSES' ) AND

                  (  ls_faglflext-activ <> 'RKP1' AND ls_faglflext-prctr <> '11ITMIS' ).

above logic working on both condition if ls_faglflext-activ <> 'RKP1' or faglflext-prctr <> '11ITMIS'

it's treat like a "OR" not "AND"

Thnkx

Prakash

Read only

0 Likes
832

sorry Hi Sandra,

Read only

Ryan-Crosby
Active Contributor
0 Likes
832

Hi Prakash,

Seconded what Sandra has said regarding use of translatable texts in logical expressions.  Also, look closely at the the fields you have defined for the value '11ITMIS' - in one case you have the field as pprctr and the other is prctr which might only be a typo but it could also reflect two separate fields when you mean for them to be the same.

Regards,

Ryan Crosby

Read only

0 Likes
832

Hi Ryan,

in decision "AND" statement is not working after condition change below is logical expression.

IF ( ls_glset-shortname = 'FREIGHT_FORW' OR

                   ls_glset-shortname = 'RENT' OR

                   ls_glset-shortname = 'TRAVL_CONVNC' OR

                   ls_glset-shortname = 'SALPF_BONUS' OR

                   ls_glset-shortname = 'OTHEREXPENSES' ) AND

                  (  ls_faglflext-activ <> 'RKP1' AND ls_faglflext-prctr <> '11ITMIS' ).

above logic working on both condition if ls_faglflext-activ <> 'RKP1' or faglflext-prctr <> '11ITMIS'

it's treat like a "OR" not "AND"

Thnkx

Prakash

Read only

0 Likes
832

Hello Prakash,

Based on your code snipped the requirement looks like -

process the code inside the if block only if ls_glset-shortname is any of the literal values( 'FREIGHT_FORW' etc) and ls_faglflext-active is not 'RKP1' and ls_faglflext-prctr is not '11ITMIS'.

Here you can remove the parenthesis ( ) around the ls_faglflext conditions as it doesn't make any difference to the processing. Also did you check in debugging what's value you are getting for

ls_glset-shortname, ls_faglflext-active and ls_faglflext-prctr. Please shre with us the values you are getting during debugging for these variables.

Thanks,

Mainak

Read only

Former Member
0 Likes
832

Dear Prakash,

What is your input value that your logic not working ? 

Why do you use "shortname" field as the condition ? Is there not a GL Account ?

Because it is related with the Upper/lower letter and causes your condition will not be true.

Regards,

Yance