Modify Attribute

After an attribute is defined, you can change the definition with the Modify Attribute command.

This page discusses:

Syntax

This command lets you add or remove defining clauses and change the value of clause arguments:

modify attribute NAME [MOD_ITEM {MOD_ITEM}];
  • NAME is the name of the attribute you want to modify.
  • MOD_ITEM is the type of modification you want to make.

You cannot alter the Type clause. If you must change the attribute type, delete the attribute and add it again using a new Type clause.

Modify Attribute Clauses

You can make the following modifications to an existing attribute definition. Each is specified in a Modify Attribute clause, as listed in the following table. You only need to specify the fields to be modified.

Modify Attribute Clause Description
name NAME 
The current attribute name changes to the new name entered.
keepformat forcenotransition

Sets the keepformat flag on an existing attribute with instance data without transitioning it.

modify attribute NAME keepformat forcenotransition;

This allows an attribute with instance data to become keepformat without transitioning the values so that attribute.inputvalue selectable output can keep the same inputvalue.

default VALUE 
The current default value, if any, is set to the value entered.
!hasdefault

You can convert an attribute to a !hasdefault attribute (an attribute without a default value) using the following command.

mod attribute AttributeName !hasdefault;

This applies even if the attribute was created with a default clause or was later assigned a default with mod attribute … default VALUE. The attribute definition is updated to !hasdefault and the schema default is removed. Existing values on business object instances are not modified.

For example:

print attribute MyType.MyAttr select default;
                    mod attribute MyType.MyAttr !hasdefault;
                    print attribute MyType.MyAttr select default;

After the modification, print attribute no longer reports a default for the attribute definition.

If you have defined !hasdefault for an attribute, you cannot modify it to have a default value.

Attributes with no default values cannot be part of a uniquekey definition or an attribute index.

unset attribute ATTRIBUTE_NAME You can unset an attribute previously set to a value using the following clause:
unset attribute ATTRIBUTE_NAME

For example, for a business object T N R with nothasdefault attribute attrib1, which was previosly set to a value, you can unset the instance of an attribute using the following syntax:

modify businessobject T N R unset attribute attrib1
Note: Unsetting an attribute is accepted only for !hasdefault attributes. This applies to regular rangevalue attributes as well. Unsetting the regular attribute returns an error.

Unsetting nothasdefault attribute on the object generates a mod history entry in the following format:

history = modify - user: creator time: <DATE TIME> state: one myIntAttribute:##UNSET## was: 10

Unsetting binary attribute is equivalent to assigning an empty string to the attribute. For multi-valued attributes, unsetting removes all the values.

description VALUE 
The current description value, if any, is set to the value entered.
icon FILENAME
The image is changed to the new image in the file specified.
dimension DIMENSION_NAME 
Adds an existing dimension DIMENSION_NAME to an integer or real attribute.

When adding dimensions to attributes that already belong to business object instantiations, see Applying a Dimension to an Existing Attribute.

Note: Dimensions are not supported with attributes that have range values.
icon FILENAME 
The image is changed to the new image in the file specified.
owner ADMIN 
Changes the attribute owner to the specified ADMIN object.
[!|not]multivalue 
Changes the attribute to be multivalue or not. Only existing singlevalue attributes can be modified to become multivalue . If the attribute is already a rangevalue, an error will be thrown.

Note: Dimensions are not supported with attributes that have range values.

For more information, see MQL Concepts: Multi-Value and Range-Value Attributes.

[!|not]rangevalue 
Changes the attribute to specify a range values or not.

For more information, see MQL Concepts: Multi-Value and Range-Value Attributes.

[!|not]resetonclone 
Resets the attribute value to its default value in new business object and connection clones, or when using the prefix ! or not, the current attribute value is retained in new business object and connection clones.
[!|not]resetonminorrevision 
Resets the attribute value to its default value in new business object and connection revisions, or when using the prefix ! or not, the current attribute value is retained in new business object and connection revisions.
maxlength VALUE 
The maximum number of characters the attribute's value can contain. If you modify the maximum length definition for an attribute to a number less than the current number, existing attributes will be maintained with their longer values and new attributes will need to follow the new maximum length.

If the attribute is part of an enabled index or uniquekey definition, you must disable the index or umiquekey, modify the maxlength, then re-enable the index or uniquekey.

add |dimension DIMENSION_NAME               |
    |range RANGE_ITEM                       |
    |TRIGGER PROG_NAME                      |
    |rule NAME                              |
    |property NAME [value STRING]           |
    |property NAME to ADMIN [value STRING} |

where RANGE_ITEM is one of:

|| = | != | < | > | <= | >= | VALUE        |
|| smatch|!smatch|match|!match | PATTERN   |
| between VALUE|inclusive|VALUE|inclusive| |
               |exclusive|     |exclusive| |
| program PROG_NAME [input ARG_STRING]     |

where TRIGGER is:

trigger EVENT_TYPE | action    |
                   | check     |
                   | override  | 

where EVENT_TYPE is:

           | modify    |

where ADMIN is:

           | TYPE_NAME | 
Adds the named dimension to an integer or real attribute.

Adds the specified Range clause to the existing list of Range clauses. This Range clause must obey the same construction and syntax rules as when defining an attribute.

Changes the trigger program to PROG_NAME. TRIGGER is the type of trigger program (action, check, or override) and PROG_NAME is the name of the program that replaces the current trigger program. "modify" is the only supported trigger event for attributes.

Adds the named access rule.

Adds the named property.

Adds the named property to the specified administrative object.

remove | dimension DIMENSION_NAME |
        | range RANGE_ITEM         |
        | TRIGGER                  |
        | rule NAME                |
        | keepformat               |
        | format                   |
        | property NAME            |
        | property NAME to ADMIN   | 
Removes the dimension DIMENSION_NAME from an integer or real attribute.

Removes the specified Range clause from the existing list of Range clauses. The given Range clause must exist, or an error message is displayed.

The specified trigger program is removed. PROG_TYPE is the type of trigger program (check, override, or action).

Removes the named access rule.

Removes the named property.

Removes the named property from the specified administrative object.

history STRING 
Adds a history record marked "custom" to the attribute that is being modified. The STRING argument is a free-text string that allows you to enter some information describing the nature of the modification. For more information, see Adding History to Administrative Objects.

Each modification clause is related to the clauses and arguments that define the attribute. For example, you would use the Default clause of the Modify Attribute command to modify the Default clause that you used in the Add Attribute command.

Assume you have the following attribute definition:

attribute Units
   description "Measuring units"
   type string
   default "Linear Feet"
   range = Quarts
   range = "Linear Feet";

Now you have decided to use the attribute for measuring distances only. While it might be faster to define a new attribute, you could modify this attribute with the following command:

modify attribute Units
   description "Units for Measuring Distances"
   remove range = Quarts
   add range = "Linear Yards";

After this command is processed, the attribute definition for the Units attribute is:

attribute Units
   description "Units for Measuring Distances"
   type string
   default "Linear Feet"
   range = "Linear Feet"
   range = "Linear Yards";