New York, USA

# Segment Self Rules

### Segment Self Rules

Segment Self Rules enable certain data elements in a segment to be used or not based on the value of another data elements in the same segment.

### Example

If the value in element 2 of segment NM1 is equal to 1 then elements 3 and 4 are used and elements 5 and 6 are not used.

### Adding Self Rules To Segments

• From the TEMPLATE SEGMENTS tab on the main screen right click on a template segment then select the View/Edit menu option.

When the Template Segment dialog appears click on the Self Rules Tab. You will see a table with 5 columns; Element Ord, Operator, Conditional Values, Used Elements List and Not Used Elements List.

• Click on the NEW RULE button. A new row will appear in the table
• In the Element Ord column enter the element ordinal number of the data element that this Self Rule will be base on
• Enter the conditional operator in Operator column
• Enter the conditional value that you plan to check in the Conditional Values column. More than one element value are separated by a comma
• If the condition is evaluated to be true enter the element ordinal numbers of the data elements that are required in the Used Elements List
• If the condition is evaluated to be true enter the element ordinal numbers of the elements that are NOT USED in the Not Used Elements List

From the above example we can see that if element 2 is EQUAL to 1 then element 4 is required. There are no elements that are not used, so we enter a zero

In row 2 we can see that if element 2 is EQUAL to 2 then element 2 is used and elements 4 and 5 are not used.

• Click on the UPDATE button to update the template segment

Composite element Self Rules are added exactly the same way

### Complex Rules

Complex Rules with multiple conditions can be added directly to the EDI rules file:

SEGMENT SELF RULES

//NM1~2~[EQ]1~4~0
+NM1 = if ( ElemPos[2] == “1”) then ElemList[4] else ElemList[0] end
//NM1~2~[EQ]2~2~4,5
+NM1 = if (ElemPos[2] == “2”) then ElemList[2] else ElemList[4,5] end
COMPOSITE ELEMENT SELF RULES
//C024~1~[EQ]AA~4~0
+C024 = if (ElemPos[1] == “AA”) then ElemList[4] else ElemList[0] end
//C024~2~[EQ]AA~4~0
+C024 = if (ElemPos[2] == “AA”) then ElemList[4] else ElemList[0] end

in Element Formatting and Rules