sap:call-external
Use
Using the statement sap:call-external, you can perform ABAP calls with any number of return values from within an XSLT program.
These calls can take place both at the instance level of ABAP classes and at the class level itself. In the first case, therefore, instance methods are used; in the second, on the other hand, class methods are used.
When calling interface methods, these must be indicated with the name of the interface followed by the interface component selector (intf~).
Syntax
Calling instance methods is performed according to the following syntax:
<sap:call-external name="prefix:localname" method="instanceMethod"> <sap:callvalue param="inParam1" select="expression"/> <sap:callvalue param="inParam2" select="expression"/> ... <sap:callvariable param="exParam1" name="varName1" type="xslType"/> <sap:callvariable param="exParam2" name="varName2" type="xslType"/> ... </sap:call-external>
Description
The statement sap:call-external can be at any position in the XSL source code where xsl:call-template is also allowed otherwise.
Calling an instance method requires the specification of an object name that identifies an ABAP object and the name of the method to be called.
Both sub-statements sap:callvalue and sap:callvariable are required for passing parameter values.
Using sap:callvalue, parameter values are passed to the called method as import parameters. The attribute param specifies one parameter name each from the method definition in ABAP; the value assignment takes place with the attribute select. Here the XSLT types string, number, boolean, and node-setcan be passed to the ABAP parameters.
Example:
Conversion of the types number and node-set, for example, into the corresponding ABAP values is performed according to the following scheme:
A value of the type number can be compiled in ABAP both into an integer as well as into a float type.
A node set is always converted into an iXML node collection. Note that there can be no implicit conversion of node sets into strings. For example, to pass the value of an attribute "attr" to a string parameter in ABAP, the XPath expression string(@attr)must be used.
The values returned from the method call are bound to XSLT variables using the sub-statement sap:callvariable. Here the attribute param specifies the ABAP parameter name from the method definition. The attribute name, on the other hand, identifies the corresponding XSLT variable. In addition, the attribute type can be used to assign the resulting values to a particular XSLT type. Otherwise, the standard conversion is used.
Example:
Data of type C(1) is converted by default into an XSLT string. However, if boolean is specified explicitly in the attribute type, the conversion is into XSLT boolean, accordingly.
When the class methods are called, the attribute name is replaced by class. The value for class must be specified accordingly with the name of the ABAP class, and the value for method with the name of the required class method. Therefore, the syntax is as follows:
<sap:call-external class="className" method="clasMethod"> ... </sap:call-external>
Example
The following example demonstrates an access to the database of the SAPsystem with which additional data is output for a selected flight connection. The call takes place using the class method GET_DETAIL for the class CL_FLIGHT_INFO.
The information received is bound to the corresponding XSLT variables (duration, distance, unit, ...) using sap:callvariable.
<sap:call-external class="CL_FLIGHT_INFO" method="GET_DETAIL"> <sap:callvalue param="AIRLID" select="string($carr/@code)"/> <sap:callvalue param="CONNID" select="string(@code)"/> <sap:callvalue param="FLDATE" select="string(departure/date)"/> <sap:callvariable param="FLIME" name="duration"/> <sap:callvariable param="DIST" name="distance" type="number"/> <sap:callvariable param="UNIT" name="unit"/> <sap:callvariable param="PLTYPE" name="planetype"/> <sap:callvariable param="SEATSM" name="seatsmax"/> </sap:call-external>