M3 Company and Division

You can use M3 API calls to use the M3 Settings for the Company (CONO) and Division (DIVI) configurations.

Sequence overview

Follow these guidelines:

  • Place an M3 Settings function before the M3 API call.

  • Set the Company and Division by assigning variables to the Company and Division parameters.

  • Instead of using variables, you can also, for example, use input elements that contain the Company and Division.

The Company and Division that are set by the M3 Settings function are used in all succeeding API calls.

You can use another M3 Settings function later in the sequence to change Company or Division again, if needed.

Use inside a loop

If you use an M3 Settings function inside a loop that is controlled by a repetitive M3 API, the data from the M3 API controlling the loop is fetched using the Company and Division set when entering the loop. The Company and Division that are set by the M3 Settings function inside the loop are not used. This is because the actual API call for the loop is only started once, when entering the loop.

If you perform an M3 Settings function inside a loop in the first iteration, but not in the succeeding iterations, the Company and Division that are set by the M3 Settings function in the loop are used. This Company and Division set is used for all succeeding M3 API calls in the loop, that is, even for iteration two, three, and more. This set is also used for all succeeding M3 API calls after the loop.

Use of default values

If you use the default Company and Division values as defined by IEC control properties, API reference parameters, or the setting in MNS150, do so by specifying null values for both Company and Division, for example, use the widget and do not map anything to the input parameters.

This action is necessary for these events:

  • If you dynamically change the Division by using the M3 Settings function to fetch data from several M3 Divisions, and then you go back to the original settings as defined by IEC control properties, API reference parameters, or the setting in MNS150 for the last API call.

  • If you use the default Company or Division values as defined by IEC control properties, API reference parameters, or the setting in MNS150 for all M3 API calls in the mapping. In this event, you do not need to use the M3 Settings function.

Variable values

Use the String data type for Company and Division variable values. String values must be enclosed in "" (double quotation marks), for example, "123". Even if the Company is an integer value, use double quotation marks. If the Division is specified, Company must also be specified, or else a runtime error occurs. In cases where only the Company is specified, the default "blank" Division is used.

  • Company must be an integer value between 0 and 999.

    The parameter value has a maximum length 3 of characters and is trimmed before the integer check.

    So, "1", " 1 ", " 1", " 01", and "001", are all valid companies and are used when establishing a new API connection to M3.

  • Division must be an alphanumerical value with a maximum length 3 of characters.

    The parameter value is not trimmed.

    The default value is an empty string ("").

    So, "A", "A ", "A ", " A " and " A", are different divisions in M3 and are used as is, including leading blanks, when establishing a new API connection to M3.