[XML] ABAP Read write XML

ABAP XML 实例包:SST_DEMO
CALL TRANSFORMATION

XML processing in ABAP

03 Aug 2006 | Tobias Trapp/SDN
Part 1 - Expressiveness of Simple Transformations
Simple Transformations are a SAP proprietary programming language that is integrated into ABAP by CALL TRANSFORMATION in kernel release 6.40. Its concept differs from other transformation languages, like JiBX, which is used for XML-Java mapping, or languages suitable both for queries and transformations, like Lore, XCerpt, XDuce or even XSLT, which is also supported in ABAP by CALL TRANSFORMATION. By looking at examples of ABAP package SST_DEMO you will understand how ST works. In contrast to XSLT, Simple Transformations (ST) are fast, memory efficient and symmetric, but lack of expressiveness.

Unfortunately I can't describe the power of ST in a mathematical way because, as usual, conditions cause most technical problems and the seems to be difficult to handle. In fact, despite its name, Simple Transformations have very powerful and sometimes complicated commands.

So, when I'm asked about expressiveness, usually I tell how many times an ABAP or XML node can be accessed, mention the linear order during processing, lookahead of 1 and so on. If I start to tell about the possibilities to use parameters and breaking symmetry between serilization and deserilization, clever people will start to think how far they can go. A typical question is:

Can I create relational data models from nested structures with an unbounded number of occurrences during deserialization?

This is a natural question when you are doing data exchange with non-SAP systems using standardized XML frameworks and you want to save your data in transparent tables with additional foreign keys. If you are working with small datasets you won't have problems when you copy nested internal tables into the target data structure in ABAP. But let's ask the question if we can avoid heavy postprocessing. Of course, I would accept a pragmatic solution. Simple post processing in ABAP without copying data from one internal table into another would be acceptable.

The answer to the question above is, "no chance. You have to do heavy post processing." The reason is very simple and has to do with the statement. Let's go into detail. In the following we consider an XML-document with a simple nested structure:

            A10102
            
            A203
            

A typical example for a ST is to transform. this XML document into an internal table whose table line contains an component 'nummer' and another internal table:

<?sap.transform. simple?>
            
            
            

Note that the transformation above is symmetric and can be used in both directions to serialize and deserialize.

If we want to transform. the XML stream above to a relational data model first we have to break up the nested structure. The values of elements have to be put into one internal table and then elements into another one. Afterwards we have to deal with the problem of how to link these internal tables. Without ABAP calls from ST we will have problems generating the foreign keys we need. But perhaps this could be done using clever mapping methods. If there is a new

 
  
 

 
  
 

 
  
 

 
  
 

 
  
 

 
  
 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/99072/viewspace-531631/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/99072/viewspace-531631/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值