Skip to end of metadata
Go to start of metadata

                                                                       Expressions and Association Handling

Expressions :

Literals:

Syntax       

              "<literal string>" | true | false | decDigit ]?;

Description   

The following literals can be used:

                        ->Literal strings that are included in quotation marks ("..”)
                       ->Numeric literals allowed are positive and negative integers and floating points
                       ->The boolean values true and false

Example    

                 var counter = 0;
                strVar = "test";
                this.ActionName(true);

Logical Expressions:

Syntax     

                      [stage:!]? <conditional expression> [ && | || [stage:!]?<conditional expression> ]*

Description   

                   The logical operators AND (&&) and OR (||) always evaluate the overall expression to a boolean value.
                   The operands themselves are conditional expressions, which in turn are comprised of arithmetic expressions,
                   finally breaking down to atomic expressions, such as literals,variable identifiers,
                   and member path expressions.

Example

  if (fulfillment >= 0.8 && fulfillment < 1.0)

                 check = !(this.Element > 42);

                 this.ActionName(true);

Conditional Expressions:

Syntax       

               <arithmetic expressions> == | != | < | > | <= | >= <arithmetical expression>

Description   

               Conditional expressions evaluate boolean values.

Example            

                if (fulfillment >= 0.8 && fulfillment < 1.0)

Arithmetic Expressions:

Syntax       

        literal | <varName> | <path expression>
        [ + | stage:--- | * | / | % ] <arithmetic expression>;

Description   

          The arithmetic expressions support the common mathematical operators for addition, subtraction,multiplication, division, and modulo calculations.         
          Operands can be atomic expressions, such as literals, variable identifiers, path expressions, or other arithmetic expressions.

Example    

                var result = (-0.234e-5 + this.Total) * currentValue;
            var resultString = "Hello " + "world!";

Path Expressions:

Syntax       

        <root item>
        [.<data type element> | business object feature | method name [stage: ( <param>* ) ] ]*;

Description   

        Member path expressions always start with a root item.The root item can either be a variable identifier,             
         the this context, or static access to imported business objects or reuse libraries, as well as messages declared in         
         the business object definition. If the root item is a variable of a structured type, the member path expressions address subelements of the data type.

Example    

                var product = this.ProductName;

Action Execution

Syntax      

        Static execution:
        <business object name>[stage:.<node name>].<action name>([stage:<param>]*);
        Instance-based execution:
        <node instance var>.<action name>([stage:<param>]*);

Description

         An action execution is a special form of a path expression. The code completion offers actions that are based on business         
         object nodes in the same way as common method calls.

Example

        //Instance-based execution ([1:1])//
        foreach (so in SalesOrder.Header.Execute())

        Static execution ([stage:0..0]):
        BOName.NodeName.ActionName();

Association Handling:

Association Access:

Syntax       

         <root entry>.<association name>[stage:.<path expression>];

Description   

          The association access is a special form of the path expression.         
           Associations can be defined to be optional and the multiplicity can be [stage:0..1], [stage:1..1] or [stage:1..n]. [stage:1..n]
           associations can only be implemented but not modeled.

Example   

       //Intra or cross-business-object association write access ([stage:1..1] multiplicity)//
        this.AssocToOtherBONode.Value = 42;
        Composition association access ([stage:1..n] multiplicity).

        foreach (item in this.Items)        //Associate node instance to current node ([stage:1..1] multiplicity)//
        this.AssocToBONode = <node instance>;

Settings Association:

Syntax    

         <path expression>.<association name> = <path expression>;

Description   

          You can navigate along associations that have been set by the user interface but you can also
           set associated node instances explicitly. For this, you can use a simple standard assignment
           expression that on the left provides a path expression, whose last element is an association.

Example

        //Assign node instance retrieved by query execution//
        foreach (item in query.execute(selParams))

        //Assign newly created node instance//
        var data : elementsof TargetBO;
        data.Name = "Created";
        this.ToTarget = TargetBO.Create(data);

Checking Association (Is Set):

Syntax      

         <path expression>.<association name>.IsSet();

Description   

           You can use this method for [stage:1..1] or [stage:0..1] associations to check whether the association was set before.
            Otherwise any access to an association that was not set causes a runtime error.

Example    

        var targetNode = this.ToTarget;
        if (this.ToTarget.IsSet())         this.Name = "Assoc set to: " + targetNode.Name; else  this.Name = "Assoc not set.";

Resetting Association:

Syntax       

       <path expression>.<association name>.Reset();

Description   

       This built-in method allows you to reset an association.

Example    

        var targetNode = this.ToTarget;
        if (targetNode.IsSet())  targetNode.Delete();

  • No labels