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

create unique handle for ALV grid layout

Clemenss
Active Contributor
0 Likes
1,040

Hi,

in some generic classes we display internal tables in a grid. We want to activate the save&maintain layouts feature by passing the DISVARIANT structure, Here wen have to give Report and handle. As we display some more tables using the same method, we must set a unique handle so that saved ALV layouts do not get merged /confused. As we do not have a table name at this point, my idea is to create a hash key based on the fields in the field catalog (field catalog is only distinguishable object here).

I need an algorithm to create the 4-character handle as a hash value based on the (concatenated) field names in field catalog.

Or a better idea to create unique handles in the generic ALV calls in one program.

Please: Serious answers only.

Regards,

Clemens

1 ACCEPTED SOLUTION
Read only

former_member194669
Active Contributor
0 Likes
683

Have you tried with fm ENQUEUECOMPUTEHASH

( I think for this fm you need to concatenate field catalog and pass into this fm) and give INPUT_LEN as length of concatenated field catalog and HASH_LEN as 4

a®s

Edited by: a®s on Jun 18, 2008 4:19 PM

3 REPLIES 3
Read only

former_member194669
Active Contributor
0 Likes
684

Have you tried with fm ENQUEUECOMPUTEHASH

( I think for this fm you need to concatenate field catalog and pass into this fm) and give INPUT_LEN as length of concatenated field catalog and HASH_LEN as 4

a®s

Edited by: a®s on Jun 18, 2008 4:19 PM

Read only

0 Likes
683

Thank you a®s,

unfortunately we are still on 470/620. No such FM ENQUEUECOMPUTEHASH in our system.

If the code is not too big, could you please post it?

Regards,

Clemens

Read only

0 Likes
683

Here it is


function enqueuecomputehash.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(INPUT) TYPE  STRING
*"     VALUE(INPUT_LEN) TYPE  I
*"     VALUE(HASH_LEN) TYPE  I
*"  EXPORTING
*"     REFERENCE(HASH) TYPE  STRING
*"     REFERENCE(TIME_USEC) TYPE  I
*"  EXCEPTIONS
*"      INVALID_ARGUMENT
*"----------------------------------------------------------------------

field-symbols <text>.
field-symbols <hash>.

data: tmp_input type text8192.
data: tmp_hash  type text8192.

if input_len < 1 or hash_len < 1.
   raise invalid_argument.
endif.

assign tmp_input(input_len) to <text>.
assign tmp_hash(hash_len) to <hash>.

data: t1 type i,
      t2 type i.

<text> = input.

get run time field t1.

call 'C_ENQ_WILDCARD' id 'TEXT'     field <text>
                      id 'TEXTHASH' field <hash>.

get run time field t2.

hash = <hash>.

time_usec = t2 - t1.

endfunction.