Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How can I use Hash Table when processing the data from cdpos and cdhdr

Hello Guru,

I've a question,

I need to reduce the access time to both cdhdr and cdpos.

Because may be I'll get a huge number of entries.

It looks like that by processing cdhdr and cdpos data will take many secondes,

it depends on how many data you need to find.

Hints : Putting instructions inside a form will slow down the program?

Also, I just want use Hash table and I need to put a loop-instruction going on the hash-table in form.

I know that it's no possible but I can declare an index inside my customized hash table.

For example :


READ TABLE FOR specific_hash_table WITH KEY TABLE oindex = d_oindex.


  • Process data


d_oindex += 1.

UNTIL d_oindex = c_max_lines + 1.

Doing this would actually not necessary improve the performance.

Because It looks like I'm having a standard table, may be there's a hash function, but it could be a bad function.

Also I need to use for example COUNT (*) to know how many lines I get with the select.

FORM find_cdpos_data_with_loop
    i_otf_objcs TYPE STANDARD TABLE
    i_cdhdr_data TYPE HASHED TABLE
    i_objcl TYPE j_objnr
*    i_obj_lst TYPE any
    i_option TYPE c

  " Hint: cdpos is a cluster-table

  CONSTANTS : objectid TYPE string VALUE 'objectid = i_obj_lst-objectid',
              changenr TYPE string VALUE 'changenr = i_obj_lst-changenr',
              tabname TYPE string VALUE 'tabname = i_otf_objcs-tablename',
              tabnameo1 TYPE string VALUE 'tabname NE ''''',
              tabnameo2 TYPE string VALUE 'tabname NE ''DRAD''',
              fname TYPE string VALUE 'fname = i_otf_objcs-fieldname'.

  DATA : BEGIN OF i_object_list OCCURS 0,
            objectclas LIKE cdpos-objectclas,
            objectid LIKE cdpos-objectid,
            changenr LIKE cdpos-changenr,
         END OF i_object_list.

  DATA : i_cdpos LIKE TABLE OF i_object_list WITH HEADER LINE,
         i_obj_lst LIKE LINE OF i_cdpos.

  DATA : tabnamev2 TYPE string.

  IF i_option EQ 'X'.
    MOVE tabnameo2 TO tabnamev2.
    MOVE tabnameo1 TO tabnamev2.

*LOOP AT i_cdhdr_data TO i_obj_lst.

  SELECT objectclas objectid changenr
    INTO TABLE i_cdpos
    FROM cdpos
    FOR ALL ENTRIES IN i_otf_objcs
    WHERE objectclas = i_objcl AND
          (objectid) AND
          (changenr) AND
          (tabname) AND
          (tabnamev2) AND

  LOOP AT i_cdpos.
    APPEND i_cdpos-objectid TO i_global.


ENDFORM.                    "find_cdpos_data

Former Member
Former Member replied

Hi Kais,

Think i am probably missunderstanding what you are after here, but can you do somthing like the below code to retrieve your data from cdpos. Then use the i_cdpos internal table to do your processing. Not sure this will be any faster but i would say it is the fastest it is going to get when processing data in the cluster table cdpos. Shouldnt be that slow though as you would be hitting 3 of the key fields of the table cdpos!

Also If the resultant internal table(i_cdpos) is still quite big you can find a few tips here to [improve the internal table processing performance|]



Tables: cdpos.

data: r_fname type RANGE OF cdpos-fname,
      wa_fname like line of r_fname,
      r_tabname TYPE RANGE OF cdpos-tabname,
      wa_tabname like line of r_tabname,
      r_objclass TYPE RANGE OF cdpos-objectclas,
      wa_objclass like line of r_objclass,      
      wa_otf_objcs like line of i_otf_objcs.

  wa_fname-option = 'EQ'.
  wa_fname-sign = 'I'.
  wa_tabname-option = 'EQ'.
  wa_tabname-sign = 'I'.    
  wa_objclass-option = 'EQ'.
  wa_objclass-sign = 'I'.  
loop at i_otf_objcs into wa_otf_objcs.
  wa_fname-low = wa_otf_objcs-fieldname.
  append wa_fname to r_fname.
  clear: wa_fname-low.
  wa_tabname-low = wa_otf_objcs-tabname.
  append wa_tabname to r_tabname.
  clear: wa_tabname-low.
  wa_objclass-low = wa_otf_objcs-objectclass.
  append wa_objclass to r_objclass.
  clear: wa_objclass-low.  

SELECT objectid
    appending CORRESPONDING FIELDS OF TABLE i_cdpos 
    FROM cdpos
    WHERE objectclas in r_objclass AND
          tabname in r_tabname AND
          fname in r_fname.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question