35
XML Verarbeitung in ABAP XML Verarbeitung in ABAP Betriebliche Anwendungssysteme II Betriebliche Anwendungssysteme II Sommersemester 2006 - University of Applied Sciences Cologne Sommersemester 2006 - University of Applied Sciences Cologne Dipl. Math. Tobias Trapp

XML Verarbeitung

  • Upload
    nstomar

  • View
    174

  • Download
    5

Embed Size (px)

Citation preview

Page 1: XML Verarbeitung

XML Verarbeitung in ABAPXML Verarbeitung in ABAPBetriebliche Anwendungssysteme II Betriebliche Anwendungssysteme II

Sommersemester 2006 - University of Applied Sciences Cologne Sommersemester 2006 - University of Applied Sciences Cologne

Dipl. Math. Tobias Trapp

Page 2: XML Verarbeitung

© AOK Systems GmbH 2006 2

AOK Systems: Das UnternehmenAOK Systems: Das Unternehmen

1999

GmbH

AOK-Beteiligungsgesellschaft

Troisdorf

Frankfurt/M., Hamburg, München,

Stuttgart

73 Mio. €

321

370

404

Gründung

Rechtsform

Gesellschafter

Geschäftssitz

Niederlassungen

Umsatz (2005)

Mitarbeiter (2003)

Mitarbeiter (2004)

Mitarbeiter (2005)

Page 3: XML Verarbeitung

© AOK Systems GmbH 2006 3

SAP KompetenzSAP 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. Support-Level)

Page 4: XML Verarbeitung

© AOK Systems GmbH 2006 4

InhaltInhalt

XML Library

XML im Datenaustausch

XSLT

Simple Transformations

Ausblick: Java Integration

XML Technologie bei SAP

Page 5: XML Verarbeitung

© AOK Systems GmbH 2006 5

EinleitungEinleitung

Was ist XML? Was ist die „XML-Familie“ ?

Generische Syntax für baumartige Datenstrukturen:

<Element Attribut="Wert">

Inhaltstext

<Kindelement/>

</Element>

Eine syntaktische Katastrofe

„XML Middleware“: Familie von (XML basierenden) Standards

- für Transformationen von XML-Dokumenten,- für Datenmodellierung durch Schemasprachen

Page 6: XML Verarbeitung

© AOK Systems GmbH 2006 6

XML Datenaustausch im GesundheitswesenXML 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)

Page 7: XML Verarbeitung

© AOK Systems GmbH 2006 7

Warum verwenden wir XML ?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

Page 8: XML Verarbeitung

© AOK Systems GmbH 2006 8

Semantische Integration durch XML?Semantische Integration durch XML?

ACORD - XML for the Insurance Industry aecXML Working Group - Architecture, Engineering and ConstructionANSI 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 BMEcatBroadcast 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 (CPML) Call Processing Language (CPL) Capability Card: An Attribute Certificate in XML Channel Definition Format, CDF (Based on XML) Chemical Markup Language Chinese XML Now! Classified Advertising Data 5.5Clinical 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 (CPEX) Working Group Customer Support 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@ssECMData - 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 User 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 MessagesHR-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 linguistiquesLASG BTM-RechnungssatzLegal 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 forNuDoc 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 (OCP) 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)User 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 XMLWEBDAV (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 XBauXJustizXMeldXML 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 CorbaXML and Music XML and VRML (Virtual Reality Modeling Language) - X3D XML for Workflow Management [NIST] XML for the Automotive Industry - SAE J2008XML-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

Page 9: XML Verarbeitung

© AOK Systems GmbH 2006 9

Schwächen von XML und der XML-FamilieSchwä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)

Page 10: XML Verarbeitung

© AOK Systems GmbH 2006 10

InhaltInhalt

XML Library

XML im Datenaustausch

XSLT

Simple Transformations

Ausblick: Java Integration

XML Technologie bei SAP

Page 11: XML Verarbeitung

© AOK Systems GmbH 2006 11

XML Technologie bei SAPXML 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)

Page 12: XML Verarbeitung

© AOK Systems GmbH 2006 12

InhaltInhalt

XML Library

XML im Datenaustausch

XSLT

Simple Transformations

Ausblick: Java Integration

XML Technologie bei SAP

Page 13: XML Verarbeitung

© AOK Systems GmbH 2006 13

XML LibraryXML 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.

Page 14: XML Verarbeitung

© AOK Systems GmbH 2006 14

Wichtige InterfacesWichtige 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

Page 15: XML Verarbeitung

© AOK Systems GmbH 2006 15

Eventbasiertes Parsen – Teil 1Eventbasiertes 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 Factory­Objekt 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( ).

Page 16: XML Verarbeitung

© AOK Systems GmbH 2006 16

Eventbasiertes Parsen – Teil 2Eventbasiertes 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 DOM­Generierung 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.

Page 17: XML Verarbeitung

© AOK Systems GmbH 2006 17

InhaltInhalt

XML Library

XML im Datenaustausch

XSLT

Simple Transformations

Ausblick: Java Integration

XML Technologie bei SAP

Page 18: XML Verarbeitung

© AOK Systems GmbH 2006 18

XSLTXSLT

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:for­each­group- mehrere Ausgabedokumente xsl:result­document- XPath Funktionen xsl:function- Ausgabeformatierung durch xsl:output- kein Result Fragment Tree (eine der dämlichsten Sachen in XSLT 1.0)

Page 19: XML Verarbeitung

© AOK Systems GmbH 2006 19

Integration in die ABAP WorkbenchIntegration in die ABAP Workbench

Page 20: XML Verarbeitung

© AOK Systems GmbH 2006 20

XSLT DebuggerXSLT Debugger

Page 21: XML Verarbeitung

© AOK Systems GmbH 2006 21

Aufruf von XSLT aus ABAPAufruf 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

Page 22: XML Verarbeitung

© AOK Systems GmbH 2006 22

asXML - BeispielasXML - Beispiel

Transformationsergebnis:

<?xml version="1.0" encoding="iso­8859­1"?><asx:abap xmlns:asx="http://www.sap.com/abapxml"  version= 1.0 >″ ″  <asx:values>

<ROOT>  <CHARS>ABC</CHARS>  <STRING> ABC </STRING>  <NUMC>01234</NUMC>   <PACKED>123.45</PACKED>   <FLOAT>1.2345E2</FLOAT>   <DATE>2006­06­14</DATE>   <TIME>12:01:00</TIME>   <XSTRING>q83v</XSTRING></ROOT>

  </asx:values></asx:abap>

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_test­chars   = ' ABC '.       l_str_test­string  = ` ABC `.       l_str_test­numc    = '01234'.       l_str_test­packed  = '123.45'.       l_str_test­float   = '123.45'.       l_str_test­date    = '20060614'.       l_str_test­time    = '1201'.       l_str_test­xstring = 'ABCDEFG'.CALL TRANSFORMATION id     SOURCE root = l_str_test     RESULT XML    l_var_output.

Page 23: XML Verarbeitung

© AOK Systems GmbH 2006 23

Suchen & Ersetzen mit XPathSuchen & 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(substring­before($eingabe,$suche),$ersetzung,

      util:replace(substring­after($eingabe,$suche),$suche, $ersetzung)),

      $eingabe) " />

  </xsl:function>

  <xsl:template match="*">

    <xsl:value­of select="util:replace(text(),'a', 'o') "/>

    <xsl:apply­templates select="*"/>

  </xsl:template>

</xsl:transform>

Page 24: XML Verarbeitung

© AOK Systems GmbH 2006 24

InhaltInhalt

XML-Libary

XML im Datenaustausch

XSLT

Simple Transformations

Ausblick: Java Integration

XML Technologie bei SAP

Page 25: XML Verarbeitung

© AOK Systems GmbH 2006 25

Simple TransformationsSimple 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

Page 26: XML Verarbeitung

© AOK Systems GmbH 2006 26

Erstellung und Aufruf eines ST- Erstellung und Aufruf eines ST- ProgrammsProgramms

ST-Programme werden wie XSLT-Programme aufgerufen:

DATA l_var_input TYPE STRING VALUE '<A>Test</A>‘,

     l_var_string TYPE STRING.

CALL TRANSFORMATION z_st_first

SOURCE XML l_var_input

RESULT root = l_var_string.

Page 27: XML Verarbeitung

© AOK Systems GmbH 2006 27

Grundstruktur eines ST ProgrammsGrundstruktur eines ST Programms

<?sap.transform simple?>

<tt:transform xmlns:tt="http://www.sap.com/transformation­

  templates" template="MAIN">

  <tt:root name="ROOT"/>

  <tt:template name="MAIN">

    <A>

      <tt:value ref="ROOT"/>

    </A>

  </tt:template>

</tt:transform>

Page 28: XML Verarbeitung

© AOK Systems GmbH 2006 28

Einführung in FallunterscheidungenEinführung in Fallunterscheidungen

<DATA>  <A>optional</A> <!­­  kann wegfallen ­­>  <B>Wert</B></DATA>

<tt:transform template="temp1"   xmlns:tt="http://www.sap.com/transformation­templates">  <tt:root name="ROOT1"/>  <tt:root name="ROOT2"/>          <tt:template name="temp1">    <DATA>      <tt:cond>        <A tt:value­ref=".ROOT1"/>      </tt:cond>      <B tt:value­ref=".ROOT2"/>     </DATA>  </tt:template></tt:transform>

Page 29: XML Verarbeitung

© AOK Systems GmbH 2006 29

InhaltInhalt

XML Library

XML im Datenaustausch

XSLT

Simple Transformations

Ausblick: Java Integration

XML Technologie bei SAP

Page 30: XML Verarbeitung

© AOK Systems GmbH 2006 30

AusblickAusblick

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!

Page 31: XML Verarbeitung

© AOK Systems GmbH 2006 31

Session Bean für ValidierungSession Bean für Validierung

Page 32: XML Verarbeitung

© AOK Systems GmbH 2006 32

Bereitstellung als Web ServiceBereitstellung als Web Service

Page 33: XML Verarbeitung

© AOK Systems GmbH 2006 33

Definition eines Client Proxy in ABAPDefinition eines Client Proxy in ABAP

Page 34: XML Verarbeitung

© AOK Systems GmbH 2006 34

Weiterführende LiteraturWeiterführende Literatur

SAP Press

ABAP Fortgeschrittene Techniken und Tools

XML-Datenaustausch in ABAP

Page 35: XML Verarbeitung

© AOK Systems GmbH 2006 35

Geschafft!Geschafft!

Vielen Dank für Ihre Aufmerksamkeit!

Fragen? Kritik? Kommentare?