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: 
Read only

Code/FM/CLASS that calculate CRC32.

Former Member
0 Likes
2,825

I've tried the method cl_abap_zip=>crc32 but the output don't work for my parameters.

Other solutions?

thanks for answers.

Are you in Unicode, if yes use CL_UJF_ZIP=>crc32.

Regards,

Raymond

6 REPLIES 6
Read only

Former Member
0 Likes
1,669

check this fm FI_MT100_CRC_CALC it calculates CRC but i'm not if its standard CRC32

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,669

Are you in Unicode, if yes use CL_UJF_ZIP=>crc32.

Regards,

Raymond

Read only

0 Likes
1,669

No

Read only

Former Member
0 Likes
1,669

check this code


method crc32. 

  constants: magic_nr(4)  type x value 'EDB88320', 
             mffffffff(4) type x value 'FFFFFFFF', 
             m7fffffff(4) type x value '7FFFFFFF', 
             m00ffffff(4) type x value '00FFFFFF', 
             m000000ff(4) type x value '000000FF', 
             m000000(3)   type x value '000000'. 

  if xstrlen( crc32_map ) = 0. 
    do 256 times. 
      data: c(4) type x, low_bit(4) type x. 
      c = sy-index - 1. 
      do 8 times. 
        low_bit = '00000001'. low_bit = c bit-and low_bit.   " c  & 1 
        c = c div 2. c = c bit-and m7fffffff. " c >> 1 (top is zero, but in ABAP signed!) 
        if low_bit is not initial. 
          c = c bit-xor magic_nr. 
        endif. 
      enddo. 
      concatenate crc32_map c into crc32_map in byte mode. 
    enddo. 
  endif. 

  data: len type i, n type i. "#EC * 
  data: crc(4) type x value mffffffff, x4(4) type x, idx(4) type x. 

  len = xstrlen( content ). 
  do len times. 
    n = sy-index - 1. 
    concatenate m000000 content+n(1) into idx in byte mode. 
    idx = ( crc bit-xor idx ) bit-and m000000ff. 
    idx = idx * 4. 
    x4  = crc32_map+idx(4). 
    crc = crc div 256. crc = crc bit-and m00ffffff. " c >> 8 
    crc = x4 bit-xor crc. 
  enddo. 
  crc = crc bit-xor mffffffff. 

  crc32 = crc. 

endmethod. 


Got the code from here http://www.sapnet.ru/viewtopic.php?p=6364

Edited by: Kartik Tarla on Oct 2, 2009 5:09 PM

Read only

0 Likes
1,669

In fact this is the exact code of CL_UJF_ZIP=>CRC32 (take a look at [Note 1283040 - Replacement of CL_ABAP_ZIP for supporting of Unicode|https://service.sap.com/sap/support/notes/1283040] Correction Instruction of CL_UJF_ZIP CRC32 if you don't have this object/method on your system...)

Regards,

Raymond

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,669

Raymond, I don't see any difference between codes of CL_ABAP_ZIP=>CRC32 and CL_UJF_ZIP=>CRC32.

Avalor, maybe the problem is about the XSTRING parameter you passed to CRC32 method, are you really sure it's correct, what code did you use to load the xstring?