美文网首页SAP 修行SAP 实用篇
DEFAULT keyword in ABAP and Opti

DEFAULT keyword in ABAP and Opti

作者: 华山令狐冲 | 来源:发表于2020-01-01 14:38 被阅读0次

It is ok to use this new ABAP syntax about table expression here since object_ext is passed from UI framework and it is rarely possible that there would be partner or customer to manually pass any other value to parameter it_data.

According to ABAP help, if no row by specified key could be found, exception will be raised, instead of sy-subrc set to a non-zero value for READ TABLE XXX.

so ABAP provides another key word DEFAULT which allows you to provide a default value if specified row does not exist to avoid exception. In example below, line 17 will raise exception while line 19 not.

In Java 8 there is similar mechanism: new class Optional is introduced to avoid application developers' endless of If XXX != null code to check null:

Unlike many other annotation, this Utility class is not implemented in JVM layer, but just in language layer, as a result it is very easy to develop an Optional class in ABAP as well.


要获取更多Jerry的原创文章,请关注公众号"汪子熙":


相关文章

网友评论

    本文标题:DEFAULT keyword in ABAP and Opti

    本文链接:https://www.haomeiwen.com/subject/pkzwoctx.html