具有未知XML的SAP简单转换
发布时间:2020-12-16 23:29:13 所属栏目:百科 来源:网络整理
导读:我有未知结构的 XML,我想在它上面应用ST(简单转换),以“某种方式”将XML中的内容转换为ABAP结构. 现在我有以下测试报告: report ztbu_st_with_copy.data: lf_xml type string.concatenate 'tabobj' 'idA1/id' 'firstErste/first' 'secondZweite/second' '/o
我有未知结构的
XML,我想在它上面应用ST(简单转换),以“某种方式”将XML中的内容转换为ABAP结构.
现在我有以下测试报告: report ztbu_st_with_copy. data: lf_xml type string. concatenate '<tab><obj>' '<id>A1</id>' '<first>Erste</first>' '<second>Zweite</second>' '</obj><obj>' '<id>B2</id>' '<item>' '<here>Tady</here>' '<there>Tam</there>' '</item>' '</obj>' '</tab>' into lf_xml. types: begin of ys_obj,id type string,rest type string,end of ys_obj,yt_obj type standard table of ys_obj. data: lt_obj type yt_obj. call transformation ztbu_st_copy_test source xml lf_xml result root = lt_obj. uline. data: ls_obj like line of lt_obj. loop at lt_obj into ls_obj. write: / sy-tabix,ls_obj-id. endloop. uline. 我跟随ST转换ZTBU_ST_COPY_TEST(上面调用的那个): <?sap.transform simple?> <tt:transform xmlns:tt="http://www.sap.com/transformation-templates"> <tt:root name="ROOT"/> <tt:template> <tab> <tt:loop ref=".ROOT" name="obj"> <obj> <id> <tt:value ref="$obj.ID" /> </id> <tt:skip /> </obj> </tt:loop> </tab> </tt:template> </tt:transform> 现在它工作正常,它会将ID带入表LT_OBJ的字段中.然而,由于使用< TT:SKIP>,其余部分被忽略.我的目标是将剩余的XML文档(这些FIRST,SECOND,HERE和THERE或任意XML)以“某种”格式存入字段REST – 可能是存储在STRING变量中的粗略XML. 我知道我需要替换< TT:SKIP>用更聪明的东西,但我无法弄明白应该是什么……任何想法? 旁注:是的,我知道,最好使用XSLT或其他东西,而不是ST,但我别无选择,我需要使用ST. 解决方法
ST是约束因为可以两种方式使用(abap< - > xml).他们很棒,因为他们很快.但是他们将ABAP值映射到XML节点,那里没有太多选择.我相信你不能用ST做到这一点. SXML最适合您的Senario.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |