Skip to Content

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

How to append the data to hash internal table ?

Dear Guru ,

I am writing an abap program that using the hash internal table ?

but i don't know how to append data from one internal table to this hash internal table .

When i use "insert wa to itab" or "append hashitab" , the editor always told me :

"You cannot use explicit or implicit index operations on tables with

types "HASHED TABLE" or "ANY TABLE". "HASH_IBASE" has the type "HASHED

TABLE".

Can you give me a sample ? Thanks .

Best Regards,

Carlos

Former Member
Former Member replied

Hi Carlos, <li>First point INDEX access is not possible if you use hashed tables. <li>Define hashed internal table with header line like below

DATA: BEGIN OF wa_lst, "
        budat LIKE mkpf-budat,
        mblnr LIKE mseg-mblnr,
        lifnr LIKE mseg-lifnr,
        name1 LIKE lfa1-name1,
        xblnr LIKE mkpf-xblnr,
        zeile LIKE mseg-zeile,
        charg LIKE mseg-charg,
        matnr LIKE mseg-matnr,
        maktx LIKE makt-maktx,
        erfmg LIKE mseg-erfmg,
        erfme LIKE mseg-erfme,
        mjahr LIKE mseg-mjahr,
      END OF wa_lst.
DATA: ht_lst LIKE HASHED TABLE OF wa_lst WITH UNIQUE KEY mblnr mjahr zeile WITH HEADER LINE.
<li>As ht_lst table has header also, you can use below statement directly.
INSERT table ht_lst.
<li>Reference code
*&---------------------------------------------------------------------*
*&      Form  fill_ht_lst
*&---------------------------------------------------------------------*
FORM fill_ht_lst.
  REFRESH ht_lst.
  LOOP AT ht_mseg.
    CHECK ht_mseg-bwart = '101' OR ht_mseg-bwart = '901'.
    CHECK ht_mseg-matnr IN so_matnr.
    READ TABLE ht_mkpf WITH TABLE KEY mblnr = ht_mseg-mblnr
    mjahr = ht_mseg-mjahr.
    CLEAR ht_lst.
    MOVE-CORRESPONDING ht_mkpf TO ht_lst.
    MOVE-CORRESPONDING ht_mseg TO ht_lst.

    PERFORM read_lfa1 USING ht_mseg-lifnr CHANGING ht_lst-name1.
    PERFORM read_material USING ht_mseg-matnr CHANGING ht_lst-maktx.
    INSERT table ht_lst.
  ENDLOOP.
ENDFORM.                    "fill_ht_lst
Thanks Venkat.O

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