<< 07. Model Check, exceptions and attribute longtext Lesson 09. Groupings >>

Hello everybody,

the last lesson caused some discussions on various difficulties to formulate correct BPath statements as some pieces of information were simply not yet communicated fully in this Blog Series. So before describing new content I want to go back some steps and clarify some topics and provide some tables with information.

A rule for in-between: 1+1+1 is not 3, but a BPath Error.

Keep in mind that the BPath Parser only deals with operations with 2 operands, so (1+1+1) will result in an error and should be rephrased to ((1+1)+1). This of course also applies to comparisons, so ((x=0)&(y=0)&(z=0)) cannot be parsed. Instead (((x=0)&(y=0))&(z=0)) should be used.

Available data types

There was a request in respect to raw data types, this is not supported. Raw fields might be read, but the content can not be compared to literals or other values as now corresponding data type exists.








Character strings, encapsulated with “. Every “-character in the string has to be escaped with “” (double double quotes).




numeric values without sign, e.g 3.141. Negative literals have to be written as 0-value




Date values in the following format #yyyymmdd#.




true/false value


Data ref.

reference to data entity, typically returned by a sub function


Object ref.

reference to object



internally used for invalid objects, which are later handled by the GET() function

The Null value is the only value of the specific type where the function NOT(…) returns true.

Operation/Function Table




S & S -> S (concat)
B & B -> B (and)
B | B -> B (or)

add, add days,

number to string

string to number

S + S -> S (concat)
S + N -> S *3
N + N -> N (add)
N + S -> N *4
D + N -> D *1
B + B -> B (or)

minus, substr

replace first,

substract days,

remove last chars

S – S -> S *6
S – N -> S *7
N – N -> N (substr.)
D – N -> D *2
B – B -> B *5
(string) multiply,if
S * N -> N *8
S * B -> S *9
N * N -> N (mlt)
N * B -> N *9
D * B -> D *9
B * B -> S (and / if)

divide, replace all,

remove first chars

S % S -> S *10
S % N -> S *11
N % N -> N (Div)
B % B -> B *12
S X S -> B
N X N -> B
D X D -> B
B X B -> B
NOT(S) -> B
NOT(N) -> B
NOT(D) -> B
NOT(B) -> B
? Operator

1. Adds number of days to a date

2. Subtracts number of days from a date

3. Converts number into string (as provided by ABAP) and concatenates it to the given string

4. Converts string into number (as provided by ABAP) and adds it to number.

5. Op1 = True or Op2 = False

6. Replace first occurrence of op2 in Op1 with empty string

7. Removes last n characters from string (if n <= strlen)

8. String multiplication (e.g. “la” * 3 = “lalala” ) [if n >= 0]

9. Logical if. If Boolean value is true original element is returned otherwise NULL element (“” / 0 / #19000101# / FALSE ).

10. Replace all occurrences of op2 in Op1 with empty string

11. Removes first n characters from string (if n <= strlen)

12. Op1 = True and Op2 = False

13. Supported are the standard comparisons =, <, >, <=, >=, <>. The types of the compared elements must be equal.

14. NOT: returns true if element is equal to NULL element

15. IFF: returns Parameter 2 if Parameter 1 is true otherwise Parameter 3. Parameter 1 must be of type Boolean, the other parameters are not checked (theoretically P2 and P3 must not be of the same type, but logically they should)

Additional remark:

As BPath has no concept of returnings errors some of the functions are defined in a way that the error case is caught and a Special value is returned. This is the case for the simple divide operation X % 0, which will always return 0 if the second Operand is 0. Attempts to convert a string, which does not contain a number to a number, will also result in a 0. Example would be the Expression: 1+”test”

Numeric Values

With version 2.2 BPath was enhanced to Support full numeric values (instead of integer), internally they base on DECFLOAT34. Some remarks:

  • the return types of fields basing on internal calculations are also DECFLOAT34 now
  • numeric literals including decimal points as 0.5 and 23.001 are possible
  • The dot may not be the first character of the literal. Use 0.5 instead of .5
  • negative numeric literals as -1 can still not be expressed directly, since the the minus sign would be interpreted as minus. Use 0-1 instead.


Code Example 35, [@LUGGWEIGTH>23.5], numeric calculations

Direct Attribute Retrieval

In case you simply want to copy an attribute from the current structure you might use the syntax as specified in the example:

Code Example 36,{@FORCURAM;@FORCURKEY;@@CUSTTYPE}, direct attribute retrieval

This should work for enhanceable structures as well as for non-enhanceable structures. For normal fields a target with the same name is used, for long text fields the suffix ‘_LONG’ will be appended to the target name. The assignment block in the example above is simply a shortcut for the slightly longer syntax: {!FORCURAM:=@FORCURAM;!FORCURKEY:=@FORCURKEY;!CUSTTYPE_LONG:=@@CUSTTYPE}.

Non-reliable assignments using subs (note 1533088 in case your version is 2.3)

Typically any assignment based on expressions or functions has a well defined result. This may be no more true in case the right side of the assignment contains a sub-function, since the sub function returns initial if the BPATH query can not be executed till the end (typically if a relation is used which delivers no elements).

Originally the initial reference was assigned to the target structure, but this leads to problems (means dumps) in case a following entry returns a valid entry which is not of type ‘data reference’.

This leads to the following change: Assignments to initial references are not executed. If there is a valid entry following afterwards, the column will be created then including the omitted entries. If there is no valid entry following the column will not be part of the target structure.

Please note that this handling has some side effects:

  • If the mentioned column is the only one returned in the query all entries till the first valid entries are omitted and not constructed afterwards. If this is a problem add a second field to the target structure with a dummy entry.
  • It is not guaranteed that a column using a non-reliable assignment is actually available in the result. If this is a problem add a initialization sequence before the sub ( e.g. {!X=””;!X=SUB(…)}).
  • internally the value is still an initial reference. So if a sub-method is used within a calculation (e.g. !X=1+SUB(…) ) it is responsibility of the user that the initial case is never occurring. If this can not be guaranteed it is advisable to use results of sub-functions only after a assignment. A “safe” solution would be: {!X=0;!X=SUB(…);!Y=1+!X}.

Masking of slashes in relation names, structures, attributes and targets (note 1535509 if your version is 2.3)

As with the language definition it was overseen that it is allowed to have relation names, structure names and field names containing a slash. This is very uncommon in development (at least in the areas we developed) but may occur at customer site.

The change, which is available with the mentioned note (or with version 2.4 of course) allows to mask a slash with a preceeding backslash within the following entites:

  • relation names
  • target names
  • attribute names
  • structure names
  • function names (hardly useful, we still recommend to define function names without slashes).

This means, if your BPATH wants to make use of a relation CRM/CustomerRel with the attribute CRM/CustomerNumer the BPATH fragment in this respect looks like: /CRM\/CustomerRel/@CRM\/CustomerNumber.

All surrounding generic consumers of BPATH should be able to handle this accordingly.

As the following topics are of a bigger size, I will stop the lesson here. Next Topic is Groupings.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply