Nested data hash calculating
Why do we need another class?
ABAP has a lot of methods to calutae md5, sha1 or sha256 hashes. But there are some limitation with:
- Data references
- Strings & xStrings
- Tables with complex data types
DATA(lo_crc64) = NEW zcl_eui_crc64( ). lo_crc64->add_to_hash( zsaqo3_general_info ). lo_crc64->add_to_hash( mt_fld_value ). rv_hash = lo_crc64->get_hash( ).
By default mc_dref-data_value, you can calculate and add referenced data to the resulting hash.
Also you can skip them mc_dref-no_info or just compare types mc_dref-type_info.
By default public attributes values are added to the resulting hash.
If you also want to calculate private attributes hashes just add ZCL_EUI_CRC64 to friends.
Strings & xStrings
Processing these data types a little bit tricky. First of all SHA1 hashes are calculating via
CALL FUNCTION 'CALCULATE_HASH_FOR_CHAR' CALL FUNCTION 'CALCULATE_HASH_FOR_RAW'
respectively. And then these hashes are added to the final result.
Tables with complex data types
Since structures fields and table rows can contain all above mentioned data types, they are processed separately and the resulting hashes are added to the final result.
SE38 -> ZEUI_TEST_CRC64
Thanks for sharing...
I was wondering if/how this could be enhanced in order to calculate Hash sum for a file (AL11) out of ABAP?
for "ordinary" files in user file system you can use the following code
Unfortunately ZCL_EUI_FILE class can only download file via to_app_server( ) method
You can use OPEN, READ, CLOSE DATASET for this purpose
Recently I used zcl_eui_crc64 class to detect if something was changed in the state of an app to activate SAVE button in PBO event