SAP xml 的解析

*&---------------------------------------------------------------------*
*& Report  ZEXPOT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZEXPOT.

TYPE-POOLSIXML,ABAP.

typesbegin of XML_LINE,
        DATA(256type X,
       end of XML_LINE.

DATAL_XML_TABLE       TYPE TABLE OF XML_LINE,
      L_XML_SIZE        TYPE I,
      L_RC              TYPE I.

DATA XMLDATA TYPE XSTRING .
DATARESULT_XML TYPE STANDARD TABLE OF SMUM_XMLTB .
DATARETURN TYPE STANDARD TABLE OF BAPIRET2 .
DATAWA_XML TYPE SMUM_XMLTB.

*如果需要上载XML可以用一下方法
CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    FILENAME   'C:\sou.xml'
    FILETYPE   'BIN'
  IMPORTING
    FILELENGTH L_XML_SIZE
  TABLES
    DATA_TAB   L_XML_TABLE.

*--将XML数据导入到内表
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
  EXPORTING
    INPUT_LENGTH L_XML_SIZE
  IMPORTING
    BUFFER       XMLDATA
  TABLES
    BINARY_TAB   L_XML_TABLE
  EXCEPTIONS
    FAILED       1
    OTHERS       2.

CALL FUNCTION 'SMUM_XML_PARSE'
  EXPORTING
    XML_INPUT XMLDATA
  TABLES
    XML_TABLE RESULT_XML
    RETURN    RETURN.

LOOP AT RESULT_XML INTO WA_XML .

ENDLOOP.

============================

对应的XML文件,内表中的数据和XML文件要请仔细作比对

才知道需要取什么数据

============================

<?xml version="1.0"?>
<flights>


 <airline code="AA" name="American Airlines">
  <flight number="0017">
   <from airport="JFK">NEW YORK,US</from>
   <to airport="SFO">SAN FRANCISCO,US</to>
   <departure>110000</departure>
   <arrival>140100</arrival>
   <type>Scheduled</type>
  </flight>

  <flight number="0064">
   <from airport="SFO">SAN FRANCISCO,US</from>
   <to airport="JFK">NEW YORK,US</to>
   <departure>090000</departure>
   <arrival>172100</arrival>
   <type>Scheduled</type>
  </flight>
 </airline>



 <airline code="AZ" name="Alitalia">
  <flight number="0555">
   <from airport="FCO">ROME,IT</from>
   <to airport="FRA">FRANKFURT,DE</to>
   <departure>190000</departure>
   <arrival>210500</arrival>
   <type>Scheduled</type>
  </flight>
  <flight number="0788">
   <from airport="FCO">ROME,IT</from>
   <to airport="TYO">TOKYO,JP</to>
   <departure>120000</departure>
   <arrival>085500</arrival>
   <type>Scheduled</type>
  </flight>
  <flight number="0789">
   <from airport="TYO">TOKYO,JP</from>
   <to airport="FCO">ROME,IT</to>
   <departure>114500</departure>
   <arrival>192500</arrival>
   <type>Scheduled</type>
  </flight>
  <flight number="0790">
   <from airport="FCO">ROME,IT</from>
   <to airport="KIX">OSAKA,JP</to>
   <departure>103500</departure>
   <arrival>081000</arrival>
   <type>Charter</type>
  </flight>
 </airline>



 <airline code="DL" name="Delta Airlines">
  <flight number="1984">
   <from airport="SFO">SAN FRANCISCO,US</from>
   <to airport="JFK">NEW YORK,US</to>
   <departure>100000</departure>
   <arrival>182500</arrival>
   <type>Scheduled</type>
  </flight>
  <flight number="1699">
   <from airport="JFK">NEW YORK,US</from>
   <to airport="SFO">SAN FRANCISCO,US</to>
   <departure>171500</departure>
   <arrival>203700</arrival>
   <type>Scheduled</type>
  </flight>
  <flight number="0106">
   <from airport="JFK">NEW YORK,US</from>
   <to airport="FRA">FRANKFURT,DE</to>
   <departure>193500</departure>
   <arrival>093000</arrival>
   <type>Scheduled</type>
  </flight>
 </airline>


 <airline code="JL" name="Japan Airlines">
  <flight number="0407">
   <from airport="NRT">TOKYO,JP</from>
   <to airport="FRA">FRANKFURT,DE</to>
   <departure>133000</departure>
   <arrival>173500</arrival>
   <type>Scheduled</type>
  </flight>
  <flight number="0408">
   <from airport="FRA">FRANKFURT,DE</from>
   <to airport="NRT">TOKYO,JP</to>
   <departure>202500</departure>
   <arrival>154000</arrival>
   <type>Charter</type>
  </flight>
 </airline>


 <airline code="LH" name="Lufthansa">
  <flight number="2407">
   <from airport="TXL">BERLIN,DE</from>
   <to airport="FRA">FRANKFURT,DE</to>
   <departure>071000</departure>
   <arrival>081500</arrival>
   <type>Scheduled</type>
  </flight>
  <flight number="2402">
   <from airport="FRA">FRANKFURT,DE</from>
   <to airport="SXF">BERLIN,DE</to>
   <departure>103000</departure>
   <arrival>113500</arrival>
   <type>Scheduled</type>
  </flight>
  <flight number="0402">
   <from airport="FRA">FRANKFURT,DE</from>
   <to airport="JFK">NEW YORK,US</to>
   <departure>133000</departure>
   <arrival>150500</arrival>
   <type>Charter</type>
  </flight>
  <flight number="0401">
   <from airport="JFK">NEW YORK,US</from>
   <to airport="FRA">FRANKFURT,DE</to>
   <departure>183000</departure>
   <arrival>074500</arrival>
   <type>Scheduled</type>
  </flight>
  <flight number="0400">
   <from airport="FRA">FRANKFURT,DE</from>
   <to airport="JFK">NEW YORK,US</to>
   <departure>101000</departure>
   <arrival>113400</arrival>
   <type>Scheduled</type>
  </flight>
 </airline>



 <airline code="QF" name="Qantas Airways">
  <flight number="0005">
   <from airport="SIN">SINGAPORE,SG</from>
   <to airport="FRA">FRANKFURT,DE</to>
   <departure>225000</departure>
   <arrival>053500</arrival>
   <type>Scheduled</type>
  </flight>
  <flight number="0006">
   <from airport="FRA">FRANKFURT,DE</from>
   <to airport="SIN">SINGAPORE,SG</to>
   <departure>205500</departure>
   <arrival>150500</arrival>
   <type>Scheduled</type>
  </flight>
 </airline>



 <airline code="SQ" name="Singapore Airlines">
  <flight number="0988">
   <from airport="SIN">SINGAPORE,SG</from>
   <to airport="TYO">TOKYO,JP</to>
   <departure>163500</departure>
   <arrival>001500</arrival>
   <type>Scheduled</type>
  </flight>
  <flight number="0158">
   <from airport="SIN">SINGAPORE,SG</from>
   <to airport="JKT">JAKARTA,ID</to>
   <departure>152500</departure>
   <arrival>160000</arrival>
   <type>Scheduled</type>
  </flight>
  <flight number="0015">
   <from airport="SFO">SAN FRANCISCO,US</from>
   <to airport="SIN">SINGAPORE,SG</to>
   <departure>160000</departure>
   <arrival>024500</arrival>
   <type>Scheduled</type>
  </flight>
  <flight number="0002">
   <from airport="SIN">SINGAPORE,SG</from>
   <to airport="SFO">SAN FRANCISCO,US</to>
   <departure>170000</departure>
   <arrival>192500</arrival>
   <type>Scheduled</type>
  </flight>
 </airline>



 <airline code="UA" name="United Airlines">
  <flight number="0941">
   <from airport="FRA">FRANKFURT,DE</from>
   <to airport="SFO">SAN FRANCISCO,US</to>
   <departure>143000</departure>
   <arrival>170600</arrival>
   <type>Scheduled</type>
  </flight>
  <flight number="3504">
   <from airport="SFO">SAN FRANCISCO,US</from>
   <to airport="FRA">FRANKFURT,DE</to>
   <departure>150000</departure>
   <arrival>103000</arrival>
   <type>Scheduled</type>
  </flight>
  <flight number="3516">
   <from airport="JFK">NEW YORK,US</from>
   <to airport="FRA">FRANKFURT,DE</to>
   <departure>162000</departure>
   <arrival>054500</arrival>
   <type>Scheduled</type>
  </flight>
  <flight number="3517">
   <from airport="FRA">FRANKFURT,DE</from>
   <to airport="JFK">NEW YORK,US</to>
   <departure>104000</departure>
   <arrival>125500</arrival>
   <type>Scheduled</type>
  </flight>
 </airline>
</flights>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值