on 01-24-2006 10:45 AM
My questin is very simple, why can't I use XOR statement in ABAP? Some like this:
IF wa_lt_op_exist-status EQ 'PDST' XOR wa_lt_op_pos-status EQ 'PDST'.
Is there any similar function?
thanx!
Hi Fer fer,
You can perform XOR only on bit-operands. It is not supported for logical operators. U need to use general rule for XOR as logical expressions in ABAP statements.
A XOR B = ((A OR B) AND NOT(A AND B))
In ur case,
A = wa_lt_op_exist-status EQ 'PDST' and
B = wa_lt_op_pos-status EQ 'PDST'.
For this part IF wa_lt_op_exist-status EQ 'PDST' XOR wa_lt_op_pos-status EQ 'PDST'
just replace the following part in ur report
IF ((wa_lt_op_exist-status EQ 'PDST' <b>OR</b> wa_lt_op_pos-status EQ 'PDST') <b>AND</b> (<b>NOT</b>(wa_lt_op_exist-status EQ 'PDST' <b>AND</b> wa_lt_op_pos-status EQ 'PDST')))
Thanks
Vinay
Message was edited by: Vinaykumar Gorrela
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You need to validate the two expressions using xor right.
<b>XOR Function:</b>
For eg. log_exp1 XOR log_exp2
1. if log_exp1 & log_exp2 are different it returns 1.
2. if log_exp1 & log_exp2 are same then it returns 0.
You can create a function which takes input parameters as 2 logical expressions and return 0 or 1 based on the processing in the functional module.
For Eg.
if log_exp1 = log_exp2.
result = 0.
else.
result = 1.
endif.
<i>Here make log_exp1 & log_exp2 as input parameters and
make result as the output parameter.</i>
By making this you can use this function in any of your programs. This is the powerful feature of ABAP.
You can create your own functional module in se37.
A sample functional module.
http://www.sap-img.com/abap/function-to-return-next-business-day.htm
Hope it helps.
Regards,
Maheswaran.B
Message was edited by: Maheswaran B
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
there isn't an ABAP XOR statememt for boolean expressions. The thing you can do is translate XOR statement with an expression containing OR and AND
consider the following:
A B (a|B) (a&B) NOT(A&B) (A|B)& NOT(A&B)
T T T T F F
T F T F T T
F T T F T T
F F F F T F
so A XOR B = ((A OR B) AND NOT(A AND B))
I hope this can be useful.
Regards, Manuel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi fer fer,
This is an excerpt from the abap documentation.
"COMPUTE - Bit Expression
Variant 2
COMPUTE x = bitexp.
Effect
The bit expression bitexp is calculated and the result placed in field x.
You can use the four bit operators BIT-NOT, BIT-AND, BIT-XOR and BIT-OR. The operands are linked according to the table below.
The priority is normal: BIT-NOT has priority over BIT-AND, followed by BIT-XOR, and then BIT-OR. You can use any number of parentheses.
All operands in bitexp, and the result field x, must have type X or type XSTRING.
The ABAP keyword COMPUTE is optional.
Relationship table
x y | BIT-NOT x x BIT-AND y x BIT-XOR y x BIT-OR y
-
0 0 | 1 0 0 0
0 1 | 1 0 1 1
1 0 | 0 0 1 1
1 1 | 0 1 0 1
Note
If the field lengths of the operands (on the right side of the expression) are different, they are all changed to the length of the result field x using MOVE X TOX. This means that shorter operands are filled with hexadecimal 0 characters on the right. Then the result field is filled. This also happens using MOVE X TOX. If the result field is of the type XSTRING, then the length is automatically adjusted.
Example
DATA: X1(1) TYPE X VALUE '30', " 0011 0000 BIT-XOR
X2(1) TYPE X VALUE '50'. " 0101 0000 =
X1 = X1 BIT-XOR X2. " 0110 0000
WRITE X1.
Output: 60
"
REgards,
Ravi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.