Vous êtes sur la page 1sur 13

Boolean

Meaning - Boolean logic is a type of decision making utilized by computers to decide if a statement is true or false. Scope of Boolean in SAP - The same Boolean logic we apply for writing business rules in SAP. Operators The following are the operators used in Boolean as well as in SAP.
1. AND - True if both operands are true. 2. OR - True if any one operand is true. 3. ! - True if an operand is false.

Note: An operand is a mathematical expression which can be a number, a variable, or any other expression. Examples 1. A and B It means both A and B will be true. 2. A or B It means either A or B is true. 3. ! A It signifies Not of A/Reverse of A which means A is false.

Points to remember while writing rules in SAP:


a) We can not use OR in restriction part of the rule. b) We can not use ! (Not of) in restriction part of the rule. c) We can not use AND keyword in the restriction part, so we have to use , (comma) in place of AND to apply the same logic. d) It is preferable to split the rule in parts when we have OR in the condition part. e) When we write the reverse of a rule then Condition becomes restriction and viceversa. f) While writing reverse rule in SAP, OR in the condition part becomes AND in the restriction part and vice-versa. In rules, we will use the following variables to refer to characteristics of SAP. C1 = char1, e.g: T_X_C_MENU C2 = char2, e.g. T_X_C_PRODUCT A = Result

RULES
1) C1 or C2 => A Here, C1 and C2 are operands (Variables) Or is an operator Condition: C1 or C2 Restriction: A The above expression signifies that either C1 or C2 give A as a result.

Reverse
When we write reverse of a rule then Condition becomes restriction and vice versa. For example for the above case reverse would be: ! A => ! C1 and ! C2 Condition: ! A Restriction: ! C1 and !C2

SAP example Rule: IF YN_BOOTS = YES OR YN_PADLOCK = NO THEN


YN_BOOTS_MULTIHEAD = NO

Straight (C1 or C2 => A)


Objects: ?o is a (300) D_GCR_003_. Condition: ?o.YN_BOOTS = YES OR ?o.YN_PADLOCK = NO Restrictions: ?o.YN_BOOTS_MULTIHEAD = NO Inferences: ?o.YN_BOOTS_MULTIHEAD.

REVERSE (!A = ! C1 and !C2)


Objects: ?o is a (300) D_GCR_003. Condition: ?o.YN_BOOTS_MULTIHEAD = YES Restrictions: ?o.YN_BOOTS = NO, ?o.YN_PADLOCK = YES Inferences: ?o.YN_BOOTS, ?o.YN_PADLOCK. 2) C1 and C2 => A Condition: C1 and C2 Restriction: A The above expression signifies that both C1 and C2 together give A as result. Reverse: The rule with and in the condition part are written by the following logic. 1st reverse - ! A and C1 => ! C2 2nd reverse - ! A and C2 => ! C1 In both the reverse rule, we take reverse of restriction part (! A), keeping 1 condition of the straight rule as same (C1) which results in reverse of 2nd condition of straight rule (! C2).

SAP example Rule: IF T_X_C_MENU not in (DOUBLE_HEAD, ILLUM_DOUBLE_HEAD,


TRIPLE_HEAD) and T_X_C_MENU <> E_STOP THEN YN_BOOT_MULTI_HEAD = NO

Straight (C1 and C2 => A)

Objects: ?o is a (300) D_GCR_003_. Condition: Not ?o. T_X_C_MENU in (DOUBLE_HEAD, ILLUM_DOUBLE_HEAD, TRIPLE_HEAD) AND ?o. T_X_C_MENU <> E_STOP Restrictions: ?o.YN_BOOTS_MULTIHEAD = NO Inferences: ?o.YN_BOOTS_MULTIHEAD. REVERSE

1st reverse (! A and C1 => ! C2)


Objects: ?o is a (300) D_GCR_003_. Condition: ?o.YN_BOOTS_MULTIHEAD = YES AND Not ?o. T_X_C_MENU in (DOUBLE_HEAD, ILLUM_DOUBLE_HEAD, TRIPLE_HEAD) Restrictions: ?o.T_X_C_MENU = E_STOP Inferences: ?o.T_X_C_MENU.

2nd reverse (! A and C2 => ! C1)


Objects: ?o is a (300) D_GCR_003_. Condition: ?o.YN_BOOTS_MULTIHEAD = YES AND ?o.T_X_C_MENU <> E_STOP

Restrictions: ?o. T_X_C_MENU in (DOUBLE_HEAD, ILLUM_DOUBLE_HEAD, TRIPLE_HEAD). Inferences: ?o.T_X_C_MENU. 3) C1 or C2 or C3 => A Condition: C1 or C2 or C3 Restriction: A The above expression signifies that either C1 or C2 or C3 give A as result. Reverse ! A = ! C1 and ! C2 and !C3

SAP example Rule: IF T_SHAPE_OF_SIGNALING_UNIT_HEAD <> ROUND OR


YN_BOOT_MULTI_HEAD = YES OR T_X_C_MENU <> PUSHBUTTON THEN YN_BOOTS = NO

Straight (C1 or C2 or C3 => A)


Objects: ?o is a (300) D_GCR_003_. Condition: ?o. T_SHAPE_OF_SIGNALING_UNIT_HEAD <> ROUND OR ?o. YN_BOOT_MULTI_HEAD = YES OR ?o. T_X_C_MENU <> PUSHBUTTON . Restrictions: ?o.YN_BOOTS = NO Inferences: ?o. YN_BOOTS.

REVERSE (! A = ! C1 and ! C2 and !C3) Objects: ?o is a (300) D_GCR_003_. Condition: ?o.YN_BOOTS = YES Restrictions: ?o.T_SHAPE_OF_SIGNALING_UNIT_HEAD = ROUND, ?o.YN_BOOT_MULTI_HEAD = NO, ?o.T_X_C_MENU = PUSHBUTTON. Inferences: ?o. T_SHAPE_OF_SIGNALING_UNIT_HEAD, ?o.YN_BOOT_MULTI_HEAD, ?o.T_X_C_MENU .

4) C1 and C2 and C3 => A Condition: C1 and C2 and C3 Restriction: A The above expression signifies that C1 and C2 and C3 altogether give A as result. Reverse: - In this case the logical reverse has or in the restriction part but in SAP we can not have or in restriction part so the logical reverse is split in 3 parts. Logical reverse - ! A => ! C1 or ! C2 or ! C3 SAP reverse - a) ! A and C1 and C2 = ! C3 b) ! A and C2 and C3 = ! C1 c) ! A and C1 and C3 = ! C2

SAP example Rule: IF T_SHAPE_OF_SIGNALING_UNIT_HEAD <> ROUND AND


YN_BOOT_MULTI_HEAD = YES AND T_X_C_MENU <> PUSHBUTTON THEN YN_BOOTS = NO

Straight (C1 and C2 and C3 => A)


Objects: ?o is a (300) D_GCR_003_. Condition: ?o. T_SHAPE_OF_SIGNALING_UNIT_HEAD <> ROUND AND ?o. YN_BOOT_MULTI_HEAD = YES AND ?o. T_X_C_MENU <> PUSHBUTTON. Restrictions: ?o.YN_BOOTS = NO Inferences: ?o. YN_BOOTS. REVERSE

1st reverse (! A and C1 and C2 = ! C3)


Objects: ?o is a (300) D_GCR_003_. Condition: ?o.YN_BOOTS = YES AND ?o. T_SHAPE_OF_SIGNALING_UNIT_HEAD <> ROUND AND ?o. YN_BOOT_MULTI_HEAD = YES Restrictions: ?o. T_X_C_MENU = PUSHBUTTON Inferences: ?o. T_X_C_MENU.

2nd reverse (! A and C2 and C3 = ! C1)


Objects: ?o is a (300) D_GCR_003_. Condition:

?o.YN_BOOTS = YES AND ?o. YN_BOOT_MULTI_HEAD = YES AND ?o. T_X_C_MENU <> PUSHBUTTON. Restrictions: ?o. T_SHAPE_OF_SIGNALING_UNIT_HEAD = ROUND Inferences: ?o. T_SHAPE_OF_SIGNALING_UNIT_HEAD.

3rd reverse (! A and C1 and C3 = ! C2)


Objects: ?o is a (300) D_GCR_003_. Condition: ?o.YN_BOOTS = YES AND ?o. T_SHAPE_OF_SIGNALING_UNIT_HEAD <> ROUND AND ?o. T_X_C_MENU <> PUSHBUTTON. Restrictions: ?o. YN_BOOT_MULTI_HEAD = NO Inferences: ?o. YN_BOOT_MULTI_HEAD. 5) C1 and (C2 or C3) => A The above expression signifies that C1 with C2 or C3 give A as result. It can be written in the following way to make it easily readable. Equivalent expression: C1 and C2 => A (1) C1 and C3 => A (2) Logical Reverse: ! A => ! C1 or ! C2 (1) ! A => ! C1 or ! C3 (2) The logical reverse of the rule will have or in the restriction part which is not possible in SAP. So the reverse of this rule will be split into 4 parts.

1) 2) 3) 4)

! A and C1 => ! C2 (1) ! A and C2 => ! C1 (1) ! A and C1 => ! C3 (2) ! A and C3 => ! C1 (2)

SAP example Rule: IF T_SHAPE_OF_SIGNALING_UNIT_HEAD <> ROUND AND


(YN_BOOT_MULTI_HEAD = YES OR T_X_C_MENU <> PUSHBUTTON) THEN YN_BOOTS = NO

Straight 1st (C1 and C2 => A (1))


Objects: ?o is a (300) D_GCR_003_. Condition: ?o. T_SHAPE_OF_SIGNALING_UNIT_HEAD <> ROUND AND ?o. YN_BOOT_MULTI_HEAD = YES Restrictions: ?o.YN_BOOTS = NO Inferences: ?o. YN_BOOTS.

2nd (C1 and C3 => A (2))


Objects: ?o is a (300) D_GCR_003_. Condition: ?o. T_SHAPE_OF_SIGNALING_UNIT_HEAD <> ROUND AND ?o. T_X_C_MENU <> PUSHBUTTON. Restrictions: ?o.YN_BOOTS = NO Inferences: ?o. YN_BOOTS.

REVERSE:

1st reverse - ! A and C1 => ! C2 (1)


Objects: ?o is a (300) D_GCR_003_. Condition: ?o. YN_BOOTS = YES AND ?o. T_SHAPE_OF_SIGNALING_UNIT_HEAD <> ROUND Restrictions: ?o. YN_BOOT_MULTI_HEAD = NO Inferences: ?o. YN_BOOT_MULTI_HEAD

2nd reverse - ! A and C2 => ! C1 (1)


Objects: ?o is a (300) D_GCR_003_. Condition: ?o. YN_BOOTS = YES AND ?o. YN_BOOT_MULTI_HEAD = YES Restrictions: ?o. T_SHAPE_OF_SIGNALING_UNIT_HEAD = ROUND Inferences: ?o. T_SHAPE_OF_SIGNALING_UNIT_HEAD

3rd reverse - ! A and C1 => ! C3 (2)


Objects: ?o is a (300) D_GCR_003_. Condition: ?o. YN_BOOTS = YES AND ?o. T_SHAPE_OF_SIGNALING_UNIT_HEAD <> ROUND

Restrictions: ?o. T_X_C_MENU = PUSHBUTTON Inferences: ?o. T_X_C_MENU.

4th reverse - ! A and C3 => ! C1 (2)


Objects: ?o is a (300) D_GCR_003_. Condition: ?o. YN_BOOTS = YES AND ?o. T_X_C_MENU <> PUSHBUTTON Restrictions: ?o. T_SHAPE_OF_SIGNALING_UNIT_HEAD = ROUND Inferences: ?o. T_SHAPE_OF_SIGNALING_UNIT_HEAD. 6) C1 or (C2 and C3) => A Equivalent expression: C1 => A (1) C2 and C3 => A (2) SAP reverse: !A => ! C1 (1) !A and C2 => !C3 (2) !A and C3 => !C2 (2)

SAP example Rule: IF T_SHAPE_OF_SIGNALING_UNIT_HEAD <> ROUND OR


(YN_BOOT_MULTI_HEAD = YES AND T_X_C_MENU <> PUSHBUTTON) THEN YN_BOOTS = NO

Straight 1st (C1 => A)


Objects: ?o is a (300) D_GCR_003_. Condition:

?o. T_SHAPE_OF_SIGNALING_UNIT_HEAD <> ROUND Restrictions: ?o.YN_BOOTS = NO Inferences: ?o. YN_BOOTS.

2nd (C2 And C3 => A)


Objects: ?o is a (300) D_GCR_003_. Condition: YN_BOOT_MULTI_HEAD = YES AND T_X_C_MENU <> PUSHBUTTON Restrictions: ?o.YN_BOOTS = NO Inferences: ?o. YN_BOOTS. REVERSE

1st reverse - ! A => ! C1 (1)


Objects: ?o is a (300) D_GCR_003_. Condition: ?o.YN_BOOTS = YES Restrictions: ?o. T_SHAPE_OF_SIGNALING_UNIT_HEAD = ROUND Inferences: ?o. T_SHAPE_OF_SIGNALING_UNIT_HEAD.

2nd reverse - !A and C2 => ! C3 (2)

Objects: ?o is a (300) D_GCR_003_. Condition: ?o.YN_BOOTS = YES AND ?o. YN_BOOT_MULTI_HEAD = YES Restrictions: ?o. T_X_C_MENU = PUSHBUTTON. Inferences: ?o. T_X_C_MENU.

3rd reverse - !A and C3 => !C2 (2)


Objects: ?o is a (300) D_GCR_003_. Condition: ?o.YN_BOOTS = YES AND ?o. T_X_C_MENU <> PUSHBUTTON. Restrictions: ?o. YN_BOOT_MULTI_HEAD = NO Inferences: ?o. YN_BOOT_MULTI_HEAD.

Vous aimerez peut-être aussi