Application Development 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: 

Many keys in a table

Former Member
0 Kudos
116

Hi Experts,

Sap receives a segment (idoc) with 15 fields (100 char each). When I analize the next segment, I must know whether the record has been saved before or not.

I can´t save the fields as key in a table because they exceed the limit, and someone suggested me to save them in a table with a guid field and the rest of the fields in the records.

The question is: when the next segment comes, I must calculate the Guid from the fields I have in the segment.

Do you know if there is a way to know the value of the Guid field if I only have the fields?

Please help me out in this.

Thanks in Advance,

Regards,

Liliana.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
71

Hello Liliana.

You could use the function module MD5_CALCULATE_HASH_FOR_CHAR.

(Maybe also suitable MD5_CALCULATE_HASH_FOR_RAW)

The import parameter data will be your segment and if it is the same the MD5 number will also be the same.


CALL FUNCTION 'MD5_CALCULATE_HASH_FOR_CHAR'
  EXPORTING
    DATA                 = segment1
  IMPORTING
    HASH                 = hash1
  EXCEPTIONS
    OTHERS               = 1.

CALL FUNCTION  'MD5...'
                         = segment2
..
                         = hash2

If segment1 and segment2 are equal then are also hash 1 and hash2.

Regards,

Tim

3 REPLIES 3

Former Member
0 Kudos
72

Hello Liliana.

You could use the function module MD5_CALCULATE_HASH_FOR_CHAR.

(Maybe also suitable MD5_CALCULATE_HASH_FOR_RAW)

The import parameter data will be your segment and if it is the same the MD5 number will also be the same.


CALL FUNCTION 'MD5_CALCULATE_HASH_FOR_CHAR'
  EXPORTING
    DATA                 = segment1
  IMPORTING
    HASH                 = hash1
  EXCEPTIONS
    OTHERS               = 1.

CALL FUNCTION  'MD5...'
                         = segment2
..
                         = hash2

If segment1 and segment2 are equal then are also hash 1 and hash2.

Regards,

Tim

0 Kudos
71

Thanks Timo, this function also has a table, and one of its parameters is the lenght.

I am testing your function...I will let you know soon.

0 Kudos
71

It solved the problem, thanks!