加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

SAP xml 的解析

发布时间:2020-12-15 22:26:09 所属栏目:百科 来源:网络整理
导读:*---------------------------------------------------------------------* *ReportZEXPOT * *---------------------------------------------------------------------* * * *---------------------------------------------------------------------* REP
*&---------------------------------------------------------------------*
*&ReportZEXPOT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORTZEXPOT.

TYPE-POOLS:IXML,ABAP.

types:beginofXML_LINE,
DATA(256)typeX,
endofXML_LINE.

DATA:L_XML_TABLETYPETABLEOFXML_LINE,
L_XML_SIZETYPEI,
L_RCTYPEI.

DATAXMLDATATYPEXSTRING.
DATA:RESULT_XMLTYPESTANDARDTABLEOFSMUM_XMLTB.
DATA:RETURNTYPESTANDARDTABLEOFBAPIRET2.
DATA:WA_XMLTYPESMUM_XMLTB.

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

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

CALLFUNCTION'SMUM_XML_PARSE'
EXPORTING
XML_INPUT=XMLDATA
TABLES
XML_TABLE=RESULT_XML
RETURN=RETURN.

LOOPATRESULT_XMLINTOWA_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</to> <departure>100000</departure> <arrival>182500</arrival> <type>Scheduled</type> </flight> <flight number="1699"> <from airport="JFK">NEW YORK,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,DE</to> <departure>183000</departure> <arrival>074500</arrival> <type>Scheduled</type> </flight> <flight number="0400"> <from airport="FRA">FRANKFURT,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,DE</to> <departure>150000</departure> <arrival>103000</arrival> <type>Scheduled</type> </flight> <flight number="3516"> <from airport="JFK">NEW YORK,DE</to> <departure>162000</departure> <arrival>054500</arrival> <type>Scheduled</type> </flight> <flight number="3517"> <from airport="FRA">FRANKFURT,US</to> <departure>104000</departure> <arrival>125500</arrival> <type>Scheduled</type> </flight> </airline> </flights>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读