0% found this document useful (0 votes)
41 views5 pages

Bpath Lesson 01 What Is Bpath

The document introduces BPath, an interpreted computer language developed by SAP for accessing business objects. BPath allows dynamic access to SAP's business object layer in an XPath-like manner. The document provides examples of basic BPath statements and explains how BPath differs from XPath in handling business data rather than XML data. It demonstrates retrieving attributes, relations, and collecting results into a table using BPath syntax.

Uploaded by

Diego
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views5 pages

Bpath Lesson 01 What Is Bpath

The document introduces BPath, an interpreted computer language developed by SAP for accessing business objects. BPath allows dynamic access to SAP's business object layer in an XPath-like manner. The document provides examples of basic BPath statements and explains how BPath differs from XPath in handling business data rather than XML data. It demonstrates retrieving attributes, relations, and collecting results into a table using BPath syntax.

Uploaded by

Diego
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

SAP CRM: Webclient UI - Framework: BPath.

Lesson 01: What is BPath?

Posted by Juergen Gatter Apr 7, 2011

Table of Contents ... ... Table of Code Examples


- 02: Interpreter, integration, structures and filtering >>

To answer the question in the header at the very beginning, here comes a quote, raised some time ago after
the first part of of development was done:

BPath is a new way to access BOL objects, which allows data / object access controlled by a dynamic,
XPATH-like character string.
The initial request is very simple. Dynamic access to SAPs BOL/Genil Layer. Something that evaluates
requests such as

"../AddressRelation[@MAIN="X"]/EmailAddressRelation[@BUSINESS="X"]/@EMAILADR".

Something like XPath for XML data. Some of the concepts were taken over, some didn't fit, and somehow the
topic got its own life.

Well, these statements are still valid, with two remarks: The "own life" expressed in the statement got us
already pretty far away from the origins. And with the latest enhancements it is possible to attach BPath to
other frameworks also, not only to BOL. But since we should begin at the beginning and anyway only one other
"driver" (which allows access to internal tables) is developed as of now, above "definition" remains to be fine for
the moment.

My name is Jürgen Gatter, at the time of development I was part of the CRM UI Framework team (which turned
into a TIP Core UI framwork team nowadays). With this blog here I want to showcase the feasibilities of an
interpreted computer language developed over the past years within our team, which is called BPath and is
available with WEBCUIF 7.0 EhP1. More exactly it is the starting point to a blog series covering the features of
BPath, as for today we only discuss the fundamentals and ideas behind.
The beginning of the development was nearly as simple as expressed in the quote above. BOL should be
enriched with a feature allowing to access the data in an XPath-like manner returning either a Business
Collection or the data itself. So let us first take a look on the question to which extend we can compare XML
data and Business objects:
• XML data is always organized as a hierarchical, finite tree. This is not the case for Business Data.
Even though business data may appear to be hierarchical organized (on storing a Business Object
one typically saves an hierarchically organized sub-tree), in general it is not. Relations can occur
from any node to any other node and infinite pathes can be found without problem. So we have to
conclude that Business data is neither hierarchical nor finite. Consequently it is not possible to apply
some of the features of XPATH (as the searches on all nodes of the subtree).

Generated by Jive on 2016-07-14Z


1
SAP CRM: Webclient UI - Framework: BPath. Lesson 01: What is BPath?

• The start object for the Bpath has to be provided always (equally the XML document has to be
provided for XPath). Since we always operate from the starting object the differentiation between
relative and absolute pathes makes hardly sense.
• Since hierarchy and finiteness are not guaranteed even for a (business) root object, there is no way
to "scan" the complete tree. As a consequence the "//" operation as known in XPath (I cite from
w3schools: "Selects nodes in the document from the current node that match the selection no matter
where they are") has no counterpart in Bpath.
• The data returned by the XPath is also an XML entity and can be structured very inhomogeneous.
The return of BPATH is either a flat collection or an data structure. In both cases there are limitations
in respect to the inhomogeneity we can handle. For example it is practically not possible to deal with
requests as //book | //cd
• Some concepts as "Parent" and the prefixing of attributes with @ and the notation in respect to
relations are quite similar in both concepts. Note that in XML the names refer to the objects, whereas
the names used in BPATH refer to the relations between the objects.

Even though the comparison with XPath is very good to illustrate the startup, we will leave these grounds
already in lesson 2 or 3. So I will no more point to similarities and differences with XPath from here.

Enuff theory, let us try out some BPath statements, even though you still do not know how to apply them -
that's one of the topics of the next lesson. Just some remarks in advance to sketch the environment:
• BPath is available with WEBCUIF 7.0 EhP1, shipped with CRM 7.0 EhP1 (and to my knowledge with
the SAP Business Suite 7 Innovation 2010)
• Base of a query is either a Business Object or a "Business Collection with Uniform Entity
Type" (CL_CRM_BOL_ENTITY_COL_UT)
• for all examples we use the standard "FLIGHT" model, more exactly we use an UIFSearchResFlight
query result object or collection as base.
• If a query execution runs into a problem, a shortdump will be raised. This might be either the dump
from the underlying layers or a CX_WCF_BPATH_PARSING_ERROR.

So, here comes the examples:

*
Code Example 1: *, fetching the attribute structure
The "shortest BPath statement which does something". Well ok, it is not the shortest BPath statement of all,
since the emtpy statement is also a valid statement. But - surprise - the empty statement does nothing.
The '*' is a bit overloaded in BPath, it is used as multiply operator, and as we have it here, as "get it all"-
operator. And 'all' means the complete attribute structure. If your statement was fired from a Business
Object, the query returns the attribute structure from the respective object. If it was executed from a Business
Collection, it returns the attribute structure of the first found object in the collection.

@CITYTO

Code Example 2: @attr, fetching an attribute


CITYTO is one of the attributes in the attribute structure, and exactly this attribute is returned (correctly typed)
from the first object. As you might notice, the usage of the @-symbol is similar to XPath.

./@CARRID

Code Example 3, ./ , relation to myself

Generated by Jive on 2016-07-14Z


2
SAP CRM: Webclient UI - Framework: BPath. Lesson 01: What is BPath?

We are nearing ourselves to a different topic, the usage of pathes. The first is the path to the object itself, doing
not much, but making the code slightly more readable.

SearchResFlightRel/FlightBookRel/*

Code Example 4, Relations


This examples uses two relations to reach the object we finally retrieve all attributes from. The first relation
brings us from the Query Result Object to the root object, whereas the second relation brings us to the
UIFBook object dealing with the bookings. Note that FlightBookRel is a 1:n relation, so even if we are starting
from a business object, the entity which we are working on is now a collection. But still, only the first entity is
returned.
As in XPath the slash is used as separator. Unfortunately this turned out to be a problem in our case, since
the slash might be used within relation or attribute names also. This was detected quite late (otherwise I would
have chosen the backslash instead). In case your names contain slashes, these slashes have to be masked
with a prceeding backslash and note 1535509 has to be applied. See for more information there.

../*

Code Example 5, .. (Parent relation)


Just for completeness reasons I mention here the parent relation which is defined for every access/dependent
object (root objects don't have parents) and is represented by two dots following standard patterns. Technically
there is another small difference to other relations since the parent relation returns the parent object, whereas
normal relations return a collection. As for BPATH users this difference is hidden.
As for query result objects the parent is not defined also, above query would result in a parser error when
executed on a UIFSearchResFlight object complaining that the target of the parent relation is either not existing
or not ambigous. The second case will be treated later.
With the first examples we always returned a single element. But what if you wan to assemble the complete
information? This is shown in the next example:

SearchResFlightRel/FlightBookRel/*$
Code Example 6, $ (add to table)
The dollar sign makes the difference. Up to now, the evaluation was stopped after the first entry found and the
corresponding attribute or structure was returned. Now a table (of structures or of the attribute) is returned. This
is also the case if only one entry is found.

The return structure is built up during procession, this can not be done if no data is found. In general applies to
all BPath queries: If no data is found, NULL is returned.
The dollar may appear after any relation, but as it is used here we suggest to add it at the end. The differences
between the approaches will be explained later.

That's it for today.


With the next lesson we cover the proper integration (including ABAP code) and we do further BPath examples
highlighting structures and filtering.
5294 Views

Generated by Jive on 2016-07-14Z


3
SAP CRM: Webclient UI - Framework: BPath. Lesson 01: What is BPath?

Vikas Singh
Jul 13, 2014 2:33 AM
Thanks for the document - very useful indeed !

John Paul
Jul 3, 2013 3:05 PM
A very useful document. It will definetly save a lot of time.Thanks for sharing such a good concept.

Regards JP

Juergen Gatter
Apr 8, 2011 1:50 AM
... I hope the second lesson is ready by mid/end of next week. So stay tuned :-)

To shortly answer your questions:


[Layering, structured data access] Yes, access to tree-like data and also assembly of tree-like data are
interesting topics which may be targeted by BPath. Well, at the early days BPath was quite much interwoven
with the BOL/GenIL layer, so the idea to isolate the framework access parts came up pretty late. This means,
yes, it is there, but only in the coming EhP2 version. This version allows to program the framework access
against an interface. The required classes to access (structured) internal tables (by references as well as table
in table approach) are already provided.

[real life examples]. I have to admit they are still rare...so that's your job ;-). The original targeted usage
(tagging feature) was solved in a different way, so it is implemented for one feature only at the moment. I
will speak with the colleagues whether we spend some lines on this integration in one of the coming lessons
(lesson 3 or higher I suppose).

Best regards, Juergen

Tobias Trapp
Apr 7, 2011 8:47 AM
Thanks for sharing this! I think it’s really useful and I would like to know whether this framework
is limited to SAPs BOL/Genil Layer or can be used for somehow arbitrary deep ABAP structures?

In my opinion access to tree liked objects is quite a common task in AS ABAP and often an XPath-
like syntax is needed: think of access to parts of WDA contexts and in private communication I
could give you more examples in AS ABAP that can deal with data references. So sometimes I’m
asking whether a general tool would be useful because I can imagine many more use cases.

Best Regards,
Tobias Trapp

Luís Pérez Grau


Apr 7, 2011 8:43 AM
I like it! I want to read more!

Regards,

Generated by Jive on 2016-07-14Z


4
SAP CRM: Webclient UI - Framework: BPath. Lesson 01: What is BPath?

Luis

Shobhit Srivastava
Apr 7, 2011 8:22 AM
Thanks Juergen for giving insight to this new area. I was really wondering from last few weeks when I first
heard about this term. We are waiting for more and if you can include some real time requirement where we
need to use this BPath then it would be really appreciable.

Thanks again.

Best Regards,
Shobhit

Generated by Jive on 2016-07-14Z


5

You might also like