In part 1 of this weblog series a gave a short introduction into Semantic Web technologies and in part 2 I discussed possible business cases. Now I want to show how to use Semantic Web Technologies to look into AS ABAP.
Package Usages within AS ABAP
The former development classes in ABAP have been replaced by packages. The biggest advantage is that we are able to control dependencies between packages. AS ABAP offers tools to define them and report violations of package interfaces.
Now we want to solve a simple problem: We want to visualize dependencies between packages. Therefore we create a simple RDF vocabulary which we use to express usages. In the following example we state two facts:
- package SWW uses package SILM
- package SWW uses package SIRM
The RDF/XML syntax of those facts is a bit awkward but I'll use it instead of a better syntax like N3 because XML can be generated easily using XML transformations and can be imported quickly in most RDF tools:
Now we can use a RDF visualization tool like RDF Gravity to look at those two simple facts - we only have to load the data as a file:
Getting All the Information
Now lets get all package dependencies with no error severity of the NSP demosystem. This is simple using the following report:
REPORT z_rdf_package_usages.
TYPES: BEGIN OF t_access,
client_pak TYPE devclass,
pack_name TYPE devclass,
END OF t_access.
DATA:
lt_packages TYPE STANDARD TABLE OF t_access,
lv_out TYPE xstring.
SELECT p1~client_pak p2~pack_name
FROM permission AS p1 LEFT OUTER JOIN intf AS p2 ON p1~intf_name = p2~intf_name
INTO CORRESPONDING FIELDS OF TABLE lt_packages
WHERE p1~err_sever = 'NONE'.
SORT lt_packages.
DELETE ADJACENT DUPLICATES FROM lt_packages.
DELETE lt_packages WHERE pack_name IS INITIAL.
CALL TRANSFORMATION z_rdf_package_usages
SOURCE root = lt_packages
RESULT XML lv_out.
CALL FUNCTION 'DISPLAY_XML_STRING'
EXPORTING
xml_string = lv_out
title = 'Paketverwendungen'
EXCEPTIONS
no_xml_document = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Within the report I'm using following Simple Transformation which transforms the internal table containing facts into XML/RDF:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ex="http://code.google.com/p/axl-project/package">
<tt:root name="ROOT"/>
<tt:template>
<rdf:RDF>
<tt:loop ref="ROOT">
<rdf:Description>
<tt:attribute name="rdf:about" value-ref="$ref.client_pak"/>
<ex:usage>
<rdf:Description>
<tt:attribute name="rdf:about" value-ref="$ref.pack_name"/>
</rdf:Description>
</ex:usage>
</rdf:Description>
</tt:loop>
</rdf:RDF>
</tt:template>
</tt:transform>
If you load the result of this report into an RDF Viewer it will be difficult to discover anything, even if you look only at small parts of the result like this one here:
Querying Package Usages using RDQL
If we want to explore the structure of package dependencies we can use RDF query languages to give our more information. The RDF Gravity tool supports RDQL which allows SQL like queries. I very simple one is the following:
SELECT ?x
WHERE (?x , ex:usage, <S_IRM>)
USING ex FOR <http://code.google.com/p/axl-project/package>
I'm asking for all packages that use package S_IRM. The result can be displayed within RDF Gravity:
Of course this tiny example is very limited. The package S_IRM is not a proper resource but it would be an easy task to create a proper resource containg more package information that could be exposed be a REST web services for example.
And what it is good for?
You might think that this tiny example is boring because we can the same with an ABAP eport and an additional graph viewing tool. But think of the case you want to expand your model ro express more complicated facts about packages:
- software components with different releases,
- switches and enhancement spots
- date of creation,
- date of last modification,
- error severities of use accesses,
- violations of package interfaces,
- implicit usages (perhaps using dynamic calls like BDT),
- package hierarchies...
I think the strength of a generic vocabulary and ontologies will become more obvious. And last but not least you can use query languages and reasoners to explore the the set of facts.
Summary
In the instalment of this weblog series we learned that Semantic Web Technologies can be used to express facts about technical resources like package usages of AS ABAP.