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.
![](https://img.haomeiwen.com/i2085791/2b5a58048c996a52.png)
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.
![](https://img.haomeiwen.com/i2085791/31e0cea9d77cade4.png)
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.
![](https://img.haomeiwen.com/i2085791/d7ca0a814255de46.png)
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:
![](https://img.haomeiwen.com/i2085791/b00ceb7f7ae8fdf4.png)
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.
![](https://img.haomeiwen.com/i2085791/f52d4857115e0ced.png)
![](https://img.haomeiwen.com/i2085791/8f70910f9ee82b48.png)
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
![](https://img.haomeiwen.com/i2085791/fc7ecd97deb67090.png)
网友评论