Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

MD5 Hash value of file in AL11

sureshkumar_pnv
Participant
0 Kudos
2,678

Hi All

I need to collect MD5 Hash value for a file placed in AL11 path.

File contains ~~ as a delimiter.

Method 1:

i have calculated MD5 hash value on an internal table, but this doesn't match with same file in UNIX.

in Unix, they're doing on filename, it contains delimiters, whereas i'm doing on internal table before placing file in AL11.

FM used: MD5_CAALCULATE_HASH_FOR_CHAR

Method 2:

Even i have read the dataset after placing file into an internal table (table type string), and got the MD5 value, even this is not matching with UNIX command.

FM used: MD5_CAALCULATE_HASH_FOR_RAW

Is there anyway, to calculate MD5 value on a filename in a AL11 path?

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
0 Kudos
1,166

If you want to do it for files in application server, then log in the Unix (?) application server, start a console, and do it via an adequate Unix command (search the web). Possibly you may execute this command via transaction code SM49, and eventually execute it from an ABAP program (function modules SXPG_*) .

If you want to do it in ABAP, then use the MD5_* function modules. If it doesn't work for you, then your code is buggy.

Or you're not looking for MD5, but maybe for SHA or CRC...

If you want to help you more adequately, please attach a binary file as an example, tell us what MD5 you get versus what is expected + the ABAP code you have written (should be very small !)

8 REPLIES 8

muttepawar-2009
Active Participant
0 Kudos
1,166

Hi

Generating MD5 hash value for flat file

Hope this will be usefull

Regards

Prashant

0 Kudos
1,166

Thanks for response Prashant, but it's not working.

Moreover i need to calculate hash value on file in AL11, not on internal table.

Regards,

Suresh

Sandra_Rossi
Active Contributor
0 Kudos
1,167

If you want to do it for files in application server, then log in the Unix (?) application server, start a console, and do it via an adequate Unix command (search the web). Possibly you may execute this command via transaction code SM49, and eventually execute it from an ABAP program (function modules SXPG_*) .

If you want to do it in ABAP, then use the MD5_* function modules. If it doesn't work for you, then your code is buggy.

Or you're not looking for MD5, but maybe for SHA or CRC...

If you want to help you more adequately, please attach a binary file as an example, tell us what MD5 you get versus what is expected + the ABAP code you have written (should be very small !)

0 Kudos
1,166

Thanks for the input Sandra, solved my problem.

0 Kudos
1,166

sureshkumar.pnv thx for the feedback. How did you solve?

1,166

Hi Sandra,

1. Kept file in AL11 with .sh extension contains unix commands.

2. Executed this shell programming through SXPG_COMMAND_EXECUTE FM and achieved the results.

Regards,

Suresh

daniel_duras2
Participant
0 Kudos
1,166

Hello sandra.rossi

I am struggling quite long time with very simillar issue. I mean hashing MD5 files from AL11. Unfortunatelly there is no any well described how it can be done.

What I have done is hashing 1 row file from AL11 . It makes hashing MD5 in RAW mode correctly. When the file has more than one row it did not hash correctly. How can that be.

This is my ABAP:

DATA: lv_xstring TYPE xstring.
OPEN DATASET lc_const FOR INPUT IN BINARY MODE.

DO.
READ DATASET lc_const INTO lv_xstring. //it always takes one time ( one iteriation )
IF sy-subrc <> 0.
EXIT.
ENDIF.
CALL FUNCTION 'CALCULATE_HASH_FOR_RAW'
EXPORTING
alg = 'MD5'
data = lv_xstring
* length = lv_len
IMPORTING
hash = hash.
ENDDO.

CLOSE DATASET lc_const.

thanks in advance,

Daniel

0 Kudos
1,166

Please ask a new distinct question.