SAP CALCULATE_HMAC_FOR_RAW Function Module for
CALCULATE_HMAC_FOR_RAW is a standard calculate hmac for raw SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used to perform a specific ABAP function and below is the pattern details, showing its interface including any import and export parameters, exceptions etc. there is also a full "cut and paste" ABAP pattern code example, along with implementation ABAP coding, documentation and contribution comments specific to this or related objects.
See here to view full function module documentation and code listing for calculate hmac for raw FM, simply by entering the name CALCULATE_HMAC_FOR_RAW into the relevant SAP transaction such as SE37 or SE38.
Function Group: SECH
Program Name: SAPLSECH
Main Program: SAPLSECH
Appliation area:
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function CALCULATE_HMAC_FOR_RAW pattern details
In-order to call this FM within your sap programs, simply using the below ABAP pattern details to trigger the function call...or see the full ABAP code listing at the end of this article. You can simply cut and paste this code into your ABAP progrom as it is, including variable declarations.CALL FUNCTION 'CALCULATE_HMAC_FOR_RAW'".
EXPORTING
* ALG = 'SHA1' "
DATA = "
* LENGTH = 0 "
* CLIENT_INDEPENDENT = "
* RECORD_NUMBER = '00' "
* KEY_MUST_EXIST = ' ' "
IMPORTING
HMAC = "
HMACLEN = "
HMACX = "
HMACXLEN = "
HMACBASE64 = "
HMACBASE64LEN = "
EXCEPTIONS
UNKNOWN_ALG = 1 RSEC_RECORD_ACCESS_DENIED = 10 RSEC_SECSTORE_ACCESS_DENIED = 11 RSEC_ERROR = 12 RNG_ERROR = 13 RECORD_NUMBER_ERROR = 14 RSEC_SYSTEM_DATA_CHANGED = 15 RSEC_SYSTEM_DATA_CHANGED_SID = 16 ENQUEUE_SET_FAILED = 17 ENQUEUE_RELEASE_FAILED = 18 ENQUEUE_INTERNAL_ERROR = 19 PARAM_LENGTH_ERROR = 2 INTERNAL_ERROR = 3 PARAM_MISSING = 4 MALLOC_ERROR = 5 ABAP_CALLER_ERROR = 6 BASE64_ERROR = 7 CALC_HMAC_ERROR = 8 RSEC_RECORD_NOT_FOUND = 9
IMPORTING Parameters details for CALCULATE_HMAC_FOR_RAW
ALG -
Data type: HASHALGDefault: 'SHA1'
Optional: Yes
Call by Reference: No ( called with pass by value option)
DATA -
Data type: XSTRINGOptional: No
Call by Reference: Yes
LENGTH -
Data type: IOptional: Yes
Call by Reference: No ( called with pass by value option)
CLIENT_INDEPENDENT -
Data type: RSECCLINDEPOptional: Yes
Call by Reference: Yes
RECORD_NUMBER -
Data type: NUMC2Default: '00'
Optional: Yes
Call by Reference: Yes
KEY_MUST_EXIST -
Data type: CDefault: ' '
Optional: Yes
Call by Reference: Yes
EXPORTING Parameters details for CALCULATE_HMAC_FOR_RAW
HMAC -
Data type: HASH512_HEXOptional: No
Call by Reference: No ( called with pass by value option)
HMACLEN -
Data type: IOptional: No
Call by Reference: No ( called with pass by value option)
HMACX -
Data type: HASH512_RAWOptional: No
Call by Reference: No ( called with pass by value option)
HMACXLEN -
Data type: IOptional: No
Call by Reference: No ( called with pass by value option)
HMACBASE64 -
Data type: HASH512_BASE_64Optional: No
Call by Reference: No ( called with pass by value option)
HMACBASE64LEN -
Data type: IOptional: No
Call by Reference: No ( called with pass by value option)
EXCEPTIONS details
UNKNOWN_ALG -
Data type:Optional: No
Call by Reference: Yes
RSEC_RECORD_ACCESS_DENIED -
Data type:Optional: No
Call by Reference: Yes
RSEC_SECSTORE_ACCESS_DENIED -
Data type:Optional: No
Call by Reference: Yes
RSEC_ERROR -
Data type:Optional: No
Call by Reference: Yes
RNG_ERROR -
Data type:Optional: No
Call by Reference: Yes
RECORD_NUMBER_ERROR -
Data type:Optional: No
Call by Reference: Yes
RSEC_SYSTEM_DATA_CHANGED -
Data type:Optional: No
Call by Reference: Yes
RSEC_SYSTEM_DATA_CHANGED_SID -
Data type:Optional: No
Call by Reference: Yes
ENQUEUE_SET_FAILED -
Data type:Optional: No
Call by Reference: Yes
ENQUEUE_RELEASE_FAILED -
Data type:Optional: No
Call by Reference: Yes
ENQUEUE_INTERNAL_ERROR -
Data type:Optional: No
Call by Reference: Yes
PARAM_LENGTH_ERROR -
Data type:Optional: No
Call by Reference: Yes
INTERNAL_ERROR -
Data type:Optional: No
Call by Reference: Yes
PARAM_MISSING -
Data type:Optional: No
Call by Reference: Yes
MALLOC_ERROR -
Data type:Optional: No
Call by Reference: Yes
ABAP_CALLER_ERROR -
Data type:Optional: No
Call by Reference: Yes
BASE64_ERROR -
Data type:Optional: No
Call by Reference: Yes
CALC_HMAC_ERROR -
Data type:Optional: No
Call by Reference: Yes
RSEC_RECORD_NOT_FOUND -
Data type:Optional: No
Call by Reference: Yes
Copy and paste ABAP code example for CALCULATE_HMAC_FOR_RAW Function Module
The ABAP code below is a full code listing to execute function module POPUP_TO_CONFIRM including all data declarations. The code uses the original data declarations rather than the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the newer method of declaring data variables on the fly. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8), which i why i have stuck to the origianl for this example.| DATA: | ||||
| lv_alg | TYPE HASHALG, " 'SHA1' | |||
| lv_hmac | TYPE HASH512_HEX, " | |||
| lv_unknown_alg | TYPE HASH512_HEX, " | |||
| lv_rsec_record_access_denied | TYPE HASH512_HEX, " | |||
| lv_rsec_secstore_access_denied | TYPE HASH512_HEX, " | |||
| lv_rsec_error | TYPE HASH512_HEX, " | |||
| lv_rng_error | TYPE HASH512_HEX, " | |||
| lv_record_number_error | TYPE HASH512_HEX, " | |||
| lv_rsec_system_data_changed | TYPE HASH512_HEX, " | |||
| lv_rsec_system_data_changed_sid | TYPE HASH512_HEX, " | |||
| lv_enqueue_set_failed | TYPE HASH512_HEX, " | |||
| lv_enqueue_release_failed | TYPE HASH512_HEX, " | |||
| lv_enqueue_internal_error | TYPE HASH512_HEX, " | |||
| lv_data | TYPE XSTRING, " | |||
| lv_hmaclen | TYPE I, " | |||
| lv_param_length_error | TYPE I, " | |||
| lv_hmacx | TYPE HASH512_RAW, " | |||
| lv_length | TYPE I, " 0 | |||
| lv_internal_error | TYPE I, " | |||
| lv_hmacxlen | TYPE I, " | |||
| lv_param_missing | TYPE I, " | |||
| lv_client_independent | TYPE RSECCLINDEP, " | |||
| lv_hmacbase64 | TYPE HASH512_BASE_64, " | |||
| lv_malloc_error | TYPE HASH512_BASE_64, " | |||
| lv_record_number | TYPE NUMC2, " '00' | |||
| lv_hmacbase64len | TYPE I, " | |||
| lv_key_must_exist | TYPE C, " ' ' | |||
| lv_abap_caller_error | TYPE C, " | |||
| lv_base64_error | TYPE C, " | |||
| lv_calc_hmac_error | TYPE C, " | |||
| lv_rsec_record_not_found | TYPE C. " |
|   CALL FUNCTION 'CALCULATE_HMAC_FOR_RAW' " |
| EXPORTING | ||
| ALG | = lv_alg | |
| DATA | = lv_data | |
| LENGTH | = lv_length | |
| CLIENT_INDEPENDENT | = lv_client_independent | |
| RECORD_NUMBER | = lv_record_number | |
| KEY_MUST_EXIST | = lv_key_must_exist | |
| IMPORTING | ||
| HMAC | = lv_hmac | |
| HMACLEN | = lv_hmaclen | |
| HMACX | = lv_hmacx | |
| HMACXLEN | = lv_hmacxlen | |
| HMACBASE64 | = lv_hmacbase64 | |
| HMACBASE64LEN | = lv_hmacbase64len | |
| EXCEPTIONS | ||
| UNKNOWN_ALG = 1 | ||
| RSEC_RECORD_ACCESS_DENIED = 10 | ||
| RSEC_SECSTORE_ACCESS_DENIED = 11 | ||
| RSEC_ERROR = 12 | ||
| RNG_ERROR = 13 | ||
| RECORD_NUMBER_ERROR = 14 | ||
| RSEC_SYSTEM_DATA_CHANGED = 15 | ||
| RSEC_SYSTEM_DATA_CHANGED_SID = 16 | ||
| ENQUEUE_SET_FAILED = 17 | ||
| ENQUEUE_RELEASE_FAILED = 18 | ||
| ENQUEUE_INTERNAL_ERROR = 19 | ||
| PARAM_LENGTH_ERROR = 2 | ||
| INTERNAL_ERROR = 3 | ||
| PARAM_MISSING = 4 | ||
| MALLOC_ERROR = 5 | ||
| ABAP_CALLER_ERROR = 6 | ||
| BASE64_ERROR = 7 | ||
| CALC_HMAC_ERROR = 8 | ||
| RSEC_RECORD_NOT_FOUND = 9 | ||
| . " CALCULATE_HMAC_FOR_RAW | ||
ABAP code using 7.40 inline data declarations to call FM CALCULATE_HMAC_FOR_RAW
The below ABAP code uses the newer in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. Please note some of the newer syntax below, such as the @DATA is not available until 4.70 EHP 8.| DATA(ld_alg) | = 'SHA1'. | |||
| DATA(ld_record_number) | = '00'. | |||
| DATA(ld_key_must_exist) | = ' '. | |||
Search for further information about these or an SAP related objects