XML Verarbeitung in ABAP Betriebliche Anwendungssysteme II Sommersemester 2006 - University of Applied Sciences Cologne Dipl. Math. Tobias Trapp
AOK Systems: Das Unternehmen
Gründung Rechtsform Gesellschafter
1999 GmbH AOK-Beteiligungsgesellschaft
Geschäftssitz Niederlassungen Umsatz (2005)
Troisdorf Frankfurt/M., Hamburg, München, Stuttgart 73 Mio. €
Mitarbeiter (2003) Mitarbeiter (2004) Mitarbeiter (2005)
321 370 404
© AOK Systems GmbH 2006
2
SAP Kompetenz Special Expertise Partner der SAP im Bereich Versicherungen (SEP) Außerordentliche SAP-Lösungs- und Beratungskompetenz für die GKV Entwicklung und Implementierung der GKV-Branchenlösung oscare®
Einführung von SAP R/3-Komponenten
FI CO MM HR
SAP Customer Competence Center (CCC) (3. und 4. -Level)
© AOK Systems GmbH 2006
3
Inhalt XML im Datenaustausch XML Technologie bei SAP XML Library XSLT Simple Transformations Ausblick: Java Integration
© AOK Systems GmbH 2006
4
Einleitung Was ist XML? Was ist die „XML-Familie“ ?
Generische Syntax für baumartige Datenstrukturen: <Element Attribut="Wert"> Inhaltstext
Eine syntaktische Katastrofe
„XML Middleware“: Familie von (XML basierenden) Standards - für Transformationen von XML-Dokumenten, - für Datenmodellierung durch Schemasprachen
© AOK Systems GmbH 2006
5
XML Datenaustausch im Gesundheitswesen Wo wird XML verwendet? Kodierung medizinischer Informationen Datenaustausch mit externen Partnern (Stammdaten, Rechnungsprozesse, geplant: Begutachtungen, Meldeverfahren)
Große Chance: Vereinheitlichung der verschiedenen Datenaustauschstandards im Gesundheitswesen: xDT-Formate, HL7, VDDS, EDIFACT, satzbasierte Verfahren… Für Meldeverfahren XÖV-Framework (z.B. XMeld)
© AOK Systems GmbH 2006
6
Warum verwenden wir XML ? Einige Gründe:
Gute Unterstützung durch APIs – insbesondere Open Source XML ist strikt Möglichkeit der formalen Spezifikation und Verifikation: Validierung gegen XML Schemata Wiederverwendung von Software: XSLT wird für jede Plattform unterstützt – wir übernehmen die Programme auf die SAP Plattform
Wo ist der Einsatz (fast) alternativlos? Anwendungsintegration Webservices, Webservices, Webservices
© AOK Systems GmbH 2006
7
Semantische Integration durch XML? ACORD - XML for the Insurance Industry aecXML Working Group - Architecture, Engineering and Construction ANSI ASC X12/XML and DISA ATLA Serials Project (ATLAS) Alexandria Digital Library Project Apache XML Project Australia New Zealand Land Information Council (ANZLIC) Bank Internet Payment System (BIPS) Bean Markup Language (BML) BizTalk Framework BMEcat Broadcast Hypertext Markup Language (BHTML) Business Rules Markup Language (BRML) Business Process Execution Language for Webservices (BPEL4WS) Business Travel Management in XML ( CDIF XML-Based Transfer Format Call Policy Markup Language (ML) Call Processing Language (L) Capability Card: An Attribute Certificate in XML Channel Definition Format, CDF (Based on XML) Chemical Markup Language Chinese XML Now! Classified Advertising Data 5.5 Clinical Trial Data Model Clinical Document Architecture (CDA) Cold Fusion Markup Language (CFML) Commerce XML (cXML) CommerceNet Industry Initiative Common Business Library (CBL) Customer Profile Exchange (EX) Working Group Customer Consortium DAV Searching and Locating (DASL) DII Common Operating Environment (COE) XML Registry DMTF Common Information Model (CIM) Digest Values for DOM (DOMHASH) Digital Property Rights Language (DPRL) Digital Receipt Infrastructure Initiative Directory Services Markup Language (DSML) Document Content Description for XML (DCD) Document Definition Markup Language (DDML) ECIX Component Information Dictionary Standard (CIDS) ECIX QuickData Specifications ECIX Timing Diagram Markup Language (TDML) eCl@ss ECMData - Electronic Component Manufacturer Data Sheet Inventory Specification
eCo Framework Project and Working Group eCo Interoperability Framework Specification EDGARspace Portal EEMA EDI/EC Work Group - XML/EDI Educom Instructional Management Systems Project (IMS) Electronic Business XML Initiative (ebXML) Electronic Component Information Exchange (ECIX) ElectronicHealthData (ehd) Encoded Archival Description (EAD) European XML/EDI Pilot Project Extensible Financial Reporting Markup Language (XFRML) Extensible Forms Description Language (XFDL) Extensible Interface Language (XUL) FIXML - A Markup Language for the FIX Application Message Layer Formal Language for Business Communication) (FJBC) FinXML - 'The Digital Language for Capital Markets' Financial Products Markup Language (FpML) Georgia State University Electronic Court Filing Project Graphic Communications Association - GCA 'Paper' DTD Guideline XML (gXML) Health Level 7 Messages HR-XML Consortium HTML Threading - Use of HTML in Email HTTP Distribution and Replication Protocol (DRP) Human Resource Management Markup Language (HRMML) iCalendar XML DTD IEEE LTSC XML Ad Hoc Group IEEE Standard DTD ISO 12083 XML DTDs Information and Content Exchange (ICE) InterX.org Initiative Interactive Financial Exchange (IFX) International Development Markup Language (IDML) Java Speech Markup Language (JSML) Jigsaw XML Format (JXML) LACITO Projet Archivage de données linguistiques LASG BTM-Rechnungssatz Legal XML Working Group and UELP MDC Open Information Model (OIM) MIX - Mediation of Information Using XML Media Object Server - XML (MOS-X) Mathematical Markup Language Meta Content Framework Using XML (MCF) Metadata - PICS Mortgage Bankers Association of America XML Workgroup News Industry Text Format (NITF) NewsML and IPTC2000
Newspaper Association of America (NAA) - Standard for NuDoc Technology OMG Common Warehouse Metadata Interchange (CWMI) Specification Object Management Group XML/Value RFP Ontology and Conceptual Knowledge Markup Languages Open Applications Group - OAGIS Open Catalog Protocol (O) Open Content Syndication (OCS) Open Financial Exchange (OFX/OFE) Open Settlement Protocol (OSP) - ETSI/TIPHON Open Software Description Format (OSD) Open Trading Protocol (OTP) OpenMLS - Real Estate DTD Design OpenMath Standard OpenTag Markup P3P Syntax Specification Pinnacles Component Information Standard (PCIS) Portal Markup Language (PML) Precision Graphics Markup Language (PGML) Predictive Model Markup Language (PMML) Procedural Markup Language (PML) Process Interchange Format XML (PIF-XML) Process Specification Language (PSL) and XML Product Data Markup Language (PDML) Product Definition Exchange (PDX) QAML - The Q&A Markup Language Real Estate Transaction Markup Language (RETML) Resource Description Framework (RDF) RosettaNet SABLE: A Standard for Text-to-Speech Synthesis Markup Simple Object Access Protocol (SOAP) SWAP - Simple Workflow Access Protocol Schema for Object-oriented XML (SOX) Scripting News in XML Signed Document Markup Language (SDML) Simple Object Definition Language (SODL) and XMOP Service SpeechML Structured Graph Format (SGF) Synchronized Multimedia Integration Language (SMIL) TalkML Telecommunications Interchange Markup (TIM, TCIF/IPI) Telephony Markup Language (TML) Text Encoding Initiative (TEI) The Data Documentation Initiative (DDI) The Koala Bean Markup Language (KBML) The XML Bookmark Exchange Language (XBEL)
Translation Memory eXchange (TMX) Tutorial Markup Language (TML) UML eXchange Format (UXF) Interface Markup Language (UIML) vCard Electronic Business Card Vector Markup Language (VML) Virtual Hyperglossary (VHG) VoiceXML Forum (Voice Extensible Markup Language Forum) VoxML Markup Language WAP Wireless Markup Language Specification Weather Observation Definition Format (OMF) Web Collections using XML WEBDAV (IETF 'Extensions for Distributed Authoring and Versioning on the Web') Web Distributed Data Exchange (WDDX) Web Interface Definition Language (WIDL) Web Service Description Language (WDSL) Web Standards Project (WSP) WebBroker: Distributed Object Communication on the Web X-ACT - XML Active Content Technologies Council XLF (Extensible Log Format) Initiative XBau XJustiz XMeld XML Belief Network File Format (Bayesian Networks) XML Court Interface (XCI) XML DTD for Phone Books XML Data Binding Specification XML Digital Signature (Signed XML - IETF/W3C) XML Forms Architecture (XFA) XML Metadata Interchange Format (XMI) Object Management Group (OMG) XML and Corba XML and Music XML and VRML (Virtual Reality Modeling Language) - X3D XML for Workflow Management [NIST] XML for the Automotive Industry - SAE J2008 XML-Based Process Management Standard (Wf-XML) XML-F ('XML for FAX') XML-HR Initiative - Human Resources XML.ORG - The XML Industry Portal XML/EDI - Electronic Data Interchange XML/EDI Repository Working Group XMLNews: XMLNews-Story and XMLNews-Meta XMLTP.Org - XML Transfer Protocol XOL - XML-Based Ontology Exchange Language XSchema
© AOK Systems GmbH 2006
8
Schwächen von XML und der XML-Familie Mit welchen Problemen haben wir zu kämpfen?
Datenvolumen Performance
Schlechte Spezifikationen:
unausgegoren (teilweise semantischer Nonsens in XSLT 1.0) zu umständlich (z.B. XML Namespaces) sehr komplex (z.B. W3C XML Schema) XML Infoset nicht einheitlich (XML 1.0, SAX, DOM, W3C XML Schema…) zu viel Spielraum für Implementierungen (XSLT 2.0)
© AOK Systems GmbH 2006
9
Inhalt XML im Datenaustausch XML Technologie bei SAP XML Library XSLT Simple Transformations Ausblick: Java Integration
© AOK Systems GmbH 2006
10
XML Technologie bei SAP Wo verwendet SAP XML-Technologie?
Middleware (RFC-Aufrufe, IDoc-Repräsentation, Webservices) Datenströme zu Drittsystemen (XSF-Daten für Druckausgaben) Serialisierungen (eCATT, Archivierungsobjekte) GUI (BSP Programmierung, Web Dynpro Protokoll) Codegenerierung (Web Dynpro) Konfigurationsdateien (EJB Deployment Deskriptoren) In vielen weiteren Produkten (SAP Knowledge Warehouse, Business Information Warehouse…) Zentraler Bestandteil der Integrationstechnologie (SAP Business Connector, SAP Exchange Infrastrucure)
© AOK Systems GmbH 2006
11
Inhalt XML im Datenaustausch XML Technologie bei SAP XML Library XSLT Simple Transformations Ausblick: Java Integration
© AOK Systems GmbH 2006
12
XML Library Die XML Library ist die älteste Technologie zur XML-Verarbeitung (Release 4.6D) besitzt eine Vielzahl von Interfaces (DOM Level 1 inkl. Namensräume, ~SAX 1.1, XML-Renderer, DTD Validierung …) kann auf non-Unicode-Systemen UTF-8 Dokumente verarbeiten iXML Nodesets können auch auch in den XSLT Prozessor übergeben werden
Achtung: Die Programmierung ist aufwändiger als bei Transformationssprachen.
© AOK Systems GmbH 2006
13
Wichtige Interfaces Die XML Library stellt ihre Funktionen durch Interfaces im Sinne von ABAP OO zur Verfügung. Wichtig sind:
if_ixml if_ixml_document if_ixml_node if_ixml_stream if_ixml_parser
Gute Doku in der XML-Library: iXML ABAP Objects Jumpstart
© AOK Systems GmbH 2006
14
Eventbasiertes Parsen – Teil 1 DATA: l_rif_factory TYPE REF TO if_ixml_stream_factory, l_rif_parser TYPE REF TO if_ixml_parser, l_rif_istream TYPE REF TO if_ixml_istream, l_rif_document TYPE REF TO if_ixml_document, l_rif_ixml TYPE REF TO if_ixml, l_var_xmldata TYPE string, l_rif_event_sink TYPE REF TO if_ixml_event, l_var_rval TYPE boolean, l_var_events TYPE i, l_rif_node TYPE REF TO if_ixml_node, l_rif_iterator TYPE REF TO if_ixml_node_iterator. OPEN DATASET '/xch/cxml.xml' FOR INPUT IN BINARY MODE. READ DATASET '/xch/cxml.xml' INTO l_var_xmldata. CLOSE DATASET '/xch/cxml.xml'. * Ermittele das zentrale Factory Objekt l_rif_ixml = cl_ixml=>create( ). * Erzeuge ein FactoryObjekt für den Eingabestrom l_rif_factory = l_rif_ixml>create_stream_factory( ). * Erzeuge den Eingabestrom l_rif_istream = l_rif_factory>create_istream_string( string = l_var_xmldata ). * Erzeuge ein temporäres Dokument l_rif_document = l_rif_ixml>create_document( ).
© AOK Systems GmbH 2006
15
Eventbasiertes Parsen – Teil 2 * Erzeuge den XML Parser l_rif_parser = l_rif_ixml>create_parser( document = l_rif_document stream_factory = l_rif_factory istream = l_rif_istream ). l_rif_factory = l_rif_ixml>create_stream_factory( ). * Schalte DOMGenerierung aus CALL METHOD l_rif_parser>set_dom_generating EXPORTING is_generating = space RECEIVING rval = l_var_rval. * Bei diesem Ereignis sind der Elementname und alle Attribute * bekannt. l_var_events = if_ixml_event=>co_event_element_pre2. * Melde die Events beim Parser an. l_rif_parser>set_event_subscription( events = l_var_events ). * Ermittele das erste Event l_rif_event_sink = l_rif_parser>parse_event( ). WHILE NOT l_rif_event_sink IS INITIAL. * Ermittele den aktuellen Knoten l_rif_node = l_rif_event_sink>get_node( ). * Frage das nächste Ereignis ab. l_rif_event_sink = l_rif_parser>parse_event( ). ENDWHILE. © AOK Systems GmbH 2006
16
Inhalt XML im Datenaustausch XML Technologie bei SAP XML Library XSLT Simple Transformations Ausblick: Java Integration
© AOK Systems GmbH 2006
17
XSLT XSLT ist eine regelbasierte, funktionale Transformationsprache. Der SAP XSLT-Prozessor: seit Release 6.10 in ABAP integriert Aufruf von ABAP aus XSLT heraus: nur noch objektorientiert! angelehnt an XSLT 2.0 Working Draft vom 30.4.2002: - Gruppierungen xsl:foreachgroup - mehrere Ausgabedokumente xsl:resultdocument - XPath Funktionen xsl:function - Ausgabeformatierung durch xsl:output - kein Result Fragment Tree (eine der dämlichsten Sachen in XSLT 1.0)
© AOK Systems GmbH 2006
18
Integration in die ABAP Workbench
© AOK Systems GmbH 2006
19
XSLT Debugger
© AOK Systems GmbH 2006
20
Aufruf von XSLT aus ABAP Ausführen einer Transformation CALL TRANSFORMATION transformation [PARAMETERS parameters] SOURCE source RESULT result.
Einsatzmöglichkeiten:
XML → XML, ABAP → XML, XML → ABAP, ABAP → ABAP
Zugriff auf ABAP-Daten durch XML-Repräsentation im sog. asXML-Format
© AOK Systems GmbH 2006
21
asXML - Beispiel TYPES: BEGIN OF l_typ_test, chars TYPE c LENGTH 10, string TYPE string, numc TYPE n LENGTH 5, packed TYPE p LENGTH 4 DECIMALS 2, float TYPE f, date TYPE d, time TYPE t, xstring TYPE xstring, END OF l_typ_test. DATA: l_str_test TYPE l_test_typ, l_var_output TYPE string. l_str_testchars = ' ABC '. l_str_teststring = ` ABC `. l_str_testnumc = '01234'. l_str_testpacked = '123.45'. l_str_testfloat = '123.45'. l_str_testdate = '20060614'. l_str_testtime = '1201'. l_str_testxstring = 'ABCDEFG'. CALL TRANSFORMATION id SOURCE root = l_str_test RESULT XML l_var_output.
Transformationsergebnis:
ABC
<STRING> ABC
01234
123.45
1.2345E2
20060614
<TIME>12:01:00 <XSTRING>q83v
© AOK Systems GmbH 2006
22
Suchen & Ersetzen mit XPath <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" xmlns:util="urn:utilities"> <xsl:function name="util:replace"> <xsl:param name="eingabe"/> <xsl:param name="suche"/> <xsl:param name="ersetzung"/> <xsl:result select= "sap:if($suche and contains($eingabe,$suche), concat(substringbefore($eingabe,$suche),$ersetzung, util:replace(substringafter($eingabe,$suche),$suche, $ersetzung)), $eingabe) " /> <xsl:template match="*"> <xsl:valueof select="util:replace(text(),'a', 'o') "/> <xsl:applytemplates select="*"/> © AOK Systems GmbH 2006
23
Inhalt XML im Datenaustausch XML Technologie bei SAP XML-Libary XSLT Simple Transformations Ausblick: Java Integration
© AOK Systems GmbH 2006
24
Simple Transformations Serielle Transformationssprachen skalieren linear mit der Größe des Eingabedokumentes. Da kein DOM-Baum aufgebaut wird, sind ST-Programme erfahrungsgemäß um den Faktor 10 bis 20 schneller als XSLT. ST ist
ab Release 6.40 in den SAP Kernel integriert prozedural symmetrisch (XML ↔ ABAP) Komfortabel beim Zugriff auf ABAP-Daten (kein asXML) nicht so ausdrucksstark wie XSLT: - keine ABAP Integration - keine Berechnungen
Gute Beispielprogramme: Paket SST_DEMO
© AOK Systems GmbH 2006
25
Erstellung und Aufruf eines STProgramms ST-Programme werden wie XSLT-Programme aufgerufen:
DATA l_var_input TYPE STRING VALUE '
Test‘, l_var_string TYPE STRING. CALL TRANSFORMATION z_st_first SOURCE XML l_var_input RESULT root = l_var_string.
© AOK Systems GmbH 2006
26
Grundstruktur eines ST Programms
© AOK Systems GmbH 2006
27
Einführung in Fallunterscheidungen
optional Wert
© AOK Systems GmbH 2006
28
Inhalt XML im Datenaustausch XML Technologie bei SAP XML Library XSLT Simple Transformations Ausblick: Java Integration
© AOK Systems GmbH 2006
29
Ausblick Wofür Java-Technologie im Web Application Server? J2EE Infrastruktur Portal Technologie
Was bringt das im Datenaustausch?
Validierung gegen W3C XML Schema (JAXP!) XML Signature, XML Encryption Serielle Transformationen: STX (http://stx.sourceforge.net) XSLT 2.0 (z.B. SAXON) JAXB
Validierung durch JAXP im Rahmen einer EJB-Anwendung und Zugriff durch einen Webservice!
© AOK Systems GmbH 2006
30
Session Bean für Validierung
© AOK Systems GmbH 2006
31
Bereitstellung als Web Service
© AOK Systems GmbH 2006
32
Definition eines Client Proxy in ABAP
© AOK Systems GmbH 2006
33
Weiterführende Literatur SAP Press ABAP Fortgeschrittene Techniken und Tools XML-Datenaustausch in ABAP
© AOK Systems GmbH 2006
34
Geschafft!
Vielen Dank für Ihre Aufmerksamkeit! Fragen? Kritik? Kommentare?
© AOK Systems GmbH 2006
35