<<06: Unstructured returns, sorting and performance | 08: Data types, Operation table, ....... >> |
Hello everybody,
due to work on other things I had to stopped my blog series on BPath quite some time ago with lesson 6. Unfortunately there are - beside several nice additional features - some features pending which are quite useful when working with BPath. So I will give an insight on the main features for designing BPath statements here and may continue with additional features in some further lesson.
The old blog series was published under my personal blog, but starting with this blog I moved the blogs to the Webclient UI Framework blog as BPath is actually a feature realized together with BOL / GenIL.
All described features require BPath of version 2.3 at least, but I suppose there is hardly a lesser version out somewhere.
Before we take a look on the main part of this lesson, we do a brief look on a new feature which in a way rounds up the performance considerations described in lesson 6.
This is a change to improve performance in certain use cases.
When started, the parser has to build up the parse table and when the parser receives the source code a preparsing is done. The first step is unnecessary for all but the first execution if several BPATH statements are executed in a sequence, the second step is unecessary in case the source code has not changed.
To allow a reuse of the parser object and consequently an omitting of the unecessary steps, the parser object might be instantiated under the control of the application and handed over to the corresponding BOL method as in the following ABAP example:
Data MyParser type ref to CL_WCF_BPATH_PARSER.
create object MyParser.
LV_SOURCECODE =
'SearchResFlightRel/*$'
.
MyResult1 = lv_object->GET_PROPERTIES_BY_BPATH(
IV_BPATH_STATEMENT = LV_SOURCECODE
IO_PARSER = MyParser ).
MyResult2 = lv_other_object->GET_PROPERTIES_BY_BPATH(
IV_BPATH_STATEMENT = LV_SOURCECODE
IO_PARSER = MyParser ).
The second call reuses the parsing tables of the first call and - since the source code is the same - the preparsing tables also.
There was demand for a mode which does not execute the query as such but ...
Till version 2.2 the parser knew two modi, 1 which checks the syntax of the source code (and does some preparsing) and 3 which executes the query. Now there is a new mode 2, which attempts to fulfill above requirements. Please note that the modi 2 and 3 do a preparsing before execution, this means internally a run in mode 1 is executed before.
Since mode 2 runs against the model and not against actual objects/collections, the object name (plus namespace which is otherwise defaulted with '') is required instead of object or collection instance. An example syntax looks as follows:
DATA: lv_bol_core TYPE REF TO cl_crm_bol_core.
lv_bol_core = cl_crm_bol_core=>get_instance( ).
MyResult = lv_bol_core->GET_PROPERTIES_BY_BPATH(
IV_BPATH_STATEMENT = LV_SOURCECODE
IV_BASE_NAMESPACE =
''
IV_BASE_OBJECTNAME =
'UIFSearchResFlight'
IV_EVAL_MODE =
2
).
Please note that the GET_PROPERTIES_BY_BPATH of BOL core is called, the above can not work on an instantiated BOL object or collection, as the signature of the corresponding methods do not have a IV_BASE_OBJECTNAME parameter. Btw, you may call GET_PROPERTIES_BY_BPATH on the BOL core directly also in execution mode (default or 3). You have to handover the object/collection using the IV_BASE_ENTITY or IV_BASE_COLLECTION parameter then.
Some technical comments to the mode:
To use the syntax check or model check the exceptions caused by snytax errors have to be caught.
Exception | Syntax Check | Model Check | Execution | Description | Example |
---|---|---|---|---|---|
CX_CRM_GENIL_MODEL_ERROR2 | X | attribute unknown | ~*/./@NoAttribute | ||
CX_CRM_UNSUPPORTED_RELATION | X | X | relation unknown | ~*/PlumpaQuatsch | |
CX_WCF_BPATH_PARSING_ERROR | X | X | X | General parsing error | ~*/+-*^1 |
The CX_WCF_BPATH_PARSING_ERROR exception provides more information with the TEXT_ID according to the following table:
TextID | 1 | 2 | 3 | Description |
---|---|---|---|---|
CX_WCF_BPATH_PARSING_ERROR | X | X | X | Current token is not allowed at this place (possible entries will be listed) Example: ~*/$ |
INCOMPATIBLE_OPERATION_TYPES | X | X | operation is not supported with specified types Example: ~*/.{!A=Today()*"Hello"} | |
NUMBER_OF_PARAMS_MISSMATCH | X | X | Number of parameters in statement does not match function declaration Example: ~*/.{!A=Upper()} | |
PARAMETER_WRONG | X | X | Parameter type does not match function declaration Example: ~*/.{!A=Upper(1)} | |
PARENT_OBJECT_NAME_INCORRECT | X | *) | specified parent object name is incorrect Example: ~*/.._NoNsEnSe | |
PARENT_REL_NOT_UNAMBIGOUS | X | *) | parent is either not there (we are already on root) or not unambiguous Example: ~*/.. | |
UNSUPP_TYPE_IN_TARGET_STRUCT | X | X | creation of a target of used type is not supported | |
UNSUPPORTED_FUNCTION | X | X | There is no such thing as a function with this name Example: ~*/.{!A=Test(1)} |
*) both dumps do not appear in code execution (more exactly PARENT_REL_NOT_UNAMBIGOUS only if no parent was found), but it is likely that the code is not fitting to the object structures and consequently it can not be guaranteed that the code is executed without problems and/or dumps.
Typically the dumps returns the code position as source code extract, where the program pointer is visualized with '_^_'.
To avoid the problems described above, the parent relation ('..') may have an attribute which should hold the object name of the parent as in the following (hardly usable) example:
~*/SearchResFlightRel/FlightBookRel/.._UIFFlight/*$
Code Example 33, .._OBJECT, attributed parent relation
Please note, that this is not a syntax change, for BPATH the relation name is '.._UIFFlight'. The object name of the parent object is used to identify the object on which the check is proceeded during model check. As for normal statement execution, the object name information is ignored.
Using a double @ as prefix, BPATH will return the result of the GET_TEXT method as result, instead of the attribute directly. This is the longtext, if available, otherwise an empty string. Result type will be always string.
~*/SearchResFlightRel/FlightBookRel{!A=@@CUSTTYPE;!B=@@CARRID;!D=@@CLASS;!E=@@FORCURKEY}$
Code Example 34, @@CARRID, attribute longtext
That's it for today. The content of the next lesson has to be assembled first. The remaining part of version 2.3 contains rather technical stuff. And with version 2.4 it gets really complicated, and also a bit in pretty unexplored universes.
Best regards, Juergen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
13 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |