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

ITAB_DUPLICATE_KEY

Former Member
0 Likes
389

We are getting a "ITAB duplicate key" error in a DataSource enhancement for BW that selects data from table MBEW into a hash table.  The internal table has the same fields as the key of the table.  I don't understand how we could be getting ITAB_DUPLICATE_KEY error when the where clause on the select statement has the key of the table.  Is this a buffering issue?  Here's a subset of the important code:

    TYPES:
   
BEGIN OF TY_MBEW,          "Material Valuation
      MATNR
TYPE MBEW-MATNR,   "Material Number
      BWKEY
TYPE MBEW-BWKEY,   "Valuation Area
      BWTAR 
TYPE MBEW-BWTAR,   "Valuation Type
      STPRS
TYPE MBEW-STPRS,   "Standard Price
      PEINH
TYPE MBEW-PEINH,   "Price Unit
      VERPR
TYPE MBEW-VERPR,   "Moving Average Price/Periodic Unit Price
      VPRSV
TYPE MBEW-VPRSV,   "Price Control Indicator
   
END OF TY_MBEW.

  DATA:

        IT_MBEW_HSH TYPE HASHED TABLE OF TY_MBEW
       
WITH UNIQUE KEY MATNR BWKEY BWTAR,

  SELECT MATNR
         BWKEY
         BWTAR
         STPRS
         PEINH
         VERPR  
"Moving Average Price/Periodic Unit Price
         VPRSV  
"Price Control Indicator
   
FROM MBEW
   
INTO CORRESPONDING FIELDS OF TABLE it_mbew_hsh
   
FOR ALL ENTRIES IN LI_DATA
   
WHERE MATNR = LI_DATA-MATNR AND
          BWKEY
= LI_DATA-WERKS AND
          BWTAR
= ''.

1 REPLY 1
Read only

Former Member
0 Likes
332

Hi,

When you use for all entries in the select statement u should not use the table in the into clause as Hashed table instead use the standard table along with where clause with all primary key fields.

Regards,

Vineesh.