Hello folks,
I've been coming across the new capabilities ABAP 7.40 has to offer which really has helped transform the traditional convention and reduced the coding effort and complexity. However, there are some areas where I'm unable to get any explanation in terms of reading a table which has been declared inline on OpenSQL while querying from a HANA database:
Apparently it is advised to use SORTED or HASHED table declarations as this does not require additional BINARY SEARCH mechanism which is used to read a record from internal table very fast as we all know that the functionality of binary search it divides the into parts and searches. For example(Before ABAP 7.40):
* Sorted Table Declaration DATA: lt_vbpa TYPE SORTED TABLE t_vbpa WITH UNIQUE KEY vbeln. SELECT vbeln posnr FROM vbpa INTO TABLE lt_vbpa WHERE vbeln IN s_vbeln. "Input from Selection Screen IF sy-subrc EQ 0. * Reading Table (No Binary Search Required) READ TABLE lt_vbpa ASSIGNING FIELD-SYMBOL(<fs_vbpa>) WITH KEY vbeln = '1200873520'. IF sy-subrc EQ 0. lv_posnr = <fs_vbpa>-posnr. ENDIF. ENDIF.
(After ABAP 7.40 HANA)
* OpenSQL statement SELECT vbeln posnr FROM vbpa INTO TABLE @DATA(lt_vbpa) "Inline declaration with dynamic type assignment WHERE vbeln IN s_vbeln. "Input from Selection Screen IF sy-subrc EQ 0. * New read statement replacement in 7.40 table expression lv_posnr = lt_vbpa[ vbeln = '1200873520' ]-posnr. ENDIF.
In the above example with OpenSQL statement with inline internal table declaration and table expression for reading and assigning value to a variable we can understand that no sorted table declaration or explicit sorting is being performed before the table expression, hence no binary search. I want to confirm whether the new syntax automatically takes care of such things or is there a way to perform such operations if required in terms of performance improvement.
Thanks.