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

Hashed table give ITAB_DUPLICATE_ERROR dump

Former Member
0 Likes
2,001

Dear experts,

I get this error on mentioned line.Here i have some doubts also.How can i expedite retrieval by which unique key combinations.

Further why i am getting this error ?

data : begin of ty_mkpf,
       mblnr type mkpf-mblnr,
       mjahr type mkpf-mjahr,
       budat type mkpf-budat,
       end of ty_mkpf.

data: begin of ty_mseg,
       mblnr type mseg-mblnr,
       matnr type mseg-matnr,
       menge type mseg-menge,
       shkzg type mseg-shkzg,
       bwart type mseg-bwart,
       lgort type mseg-lgort,
       dmbtr type mseg-dmbtr,
       meins type mseg-meins,
       lifnr type mseg-lifnr,
       end of ty_mseg.

data: begin of ty_mbew,
       matnr type mara-matnr,
       bklas type mbew-bklas,
       end of ty_mbew.

data:begin of ty_t025t,
      bklas type t025t-bklas,
      bkbez type t025t-bkbez,
      end of ty_t025t.

data:begin of ty_maktg,
      matnr type makt-matnr,
      maktg type makt-maktg,
      end of ty_maktg.



data: ht_mkpf like hashed table of ty_mkpf
      with unique key mblnr mjahr
      with header line.

data: ht_mseg like hashed table of ty_mseg
      with unique key mblnr matnr lifnr bwart lgort
      with header line.

data: ht_t025t like hashed table of ty_t025t
      with unique key bklas
      with header line.

data: ht_maktg like hashed table of ty_maktg
      with unique key matnr
      with header line.

data: ht_mbew like hashed table of ty_mbew
      with unique key matnr
      with header line.

data: t_mkpf like ty_mkpf occurs 0 with header line.
data: t_mseg like ty_mseg occurs 0 with header line.
data: t_t025t like ty_t025t occurs 0 with header line.
data: t_maktg like ty_maktg occurs 0 with header line.
data: t_mbew like ty_mbew occurs 0 with header line.


select mblnr mjahr budat from mkpf into table ht_mkpf
where budat in s_budat.

select mblnr matnr menge shkzg bwart lgort dmbtr meins lifnr from mseg into table ht_mseg for
all entries in ht_mkpf where mblnr = ht_mkpf-mblnr and
mjahr = ht_mkpf-mjahr and werks = p_werks and matnr in s_matnr         <----- *getting error here*
and lifnr in s_lifnr and bwart in s_bwart and lgort in s_lgort.

select bklas bkbez from t025t into table ht_t025t where spras eq 'EN'
and bklas in s_bklas.

select matnr bklas from mbew into table ht_mbew for all entries in ht_mseg
where matnr = ht_mseg-matnr.

select matnr maktg from makt into table ht_maktg  for all entries in ht_mseg
where matnr = ht_mseg-matnr

.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,415

data : begin of ty_mkpf,

mblnr type mkpf-mblnr,

mjahr type mkpf-mjahr,

budat type mkpf-budat,

end of ty_mkpf.

data: begin of ty_mseg,

mblnr type mseg-mblnr,

matnr type mseg-matnr,

menge type mseg-menge,

shkzg type mseg-shkzg,

bwart type mseg-bwart,

lgort type mseg-lgort,

dmbtr type mseg-dmbtr,

meins type mseg-meins,

lifnr type mseg-lifnr,

end of ty_mseg.

data: begin of ty_mbew,

matnr type mara-matnr,

bklas type mbew-bklas,

end of ty_mbew.

data:begin of ty_t025t,

bklas type t025t-bklas,

bkbez type t025t-bkbez,

end of ty_t025t.

data:begin of ty_maktg,

matnr type makt-matnr,

maktg type makt-maktg,

end of ty_maktg.

data: ht_mkpf like hashed table of ty_mkpf

with unique key mblnr mjahr

with header line.

data: ht_mseg like hashed table of ty_mseg

with unique key mblnr matnr lifnr bwart lgort

with header line.

data: ht_t025t like hashed table of ty_t025t

with unique key bklas

with header line.

data: ht_maktg like hashed table of ty_maktg

with unique key matnr

with header line.

data: ht_mbew like hashed table of ty_mbew

with unique key matnr

with header line.

data: t_mkpf like ty_mkpf occurs 0 with header line.

data: t_mseg like ty_mseg occurs 0 with header line.

data: t_t025t like ty_t025t occurs 0 with header line.

data: t_maktg like ty_maktg occurs 0 with header line.

data: t_mbew like ty_mbew occurs 0 with header line.

select mblnr mjahr budat from mkpf into table ht_mkpf

where budat in s_budat.

select mblnr matnr menge shkzg bwart lgort dmbtr meins lifnr from mseg into table ht_mseg for

all entries in ht_mkpf where mblnr = ht_mkpf-mblnr and

mjahr = ht_mkpf-mjahr and werks = p_werks and matnr in s_matnr

and lifnr in s_lifnr and bwart in s_bwart and lgort in s_lgort.

select bklas bkbez from t025t into table ht_t025t where spras eq 'EN'

and bklas in s_bklas.

select matnr bklas from mbew into table ht_mbew for all entries in ht_mseg

where matnr = ht_mseg-matnr.

select matnr maktg from makt into table ht_maktg for all entries in ht_mseg

where matnr = ht_mseg-matnr.

5 REPLIES 5
Read only

Former Member
0 Likes
1,415

Is this a website or junkyard .................

Read only

Former Member
0 Likes
1,416

data : begin of ty_mkpf,

mblnr type mkpf-mblnr,

mjahr type mkpf-mjahr,

budat type mkpf-budat,

end of ty_mkpf.

data: begin of ty_mseg,

mblnr type mseg-mblnr,

matnr type mseg-matnr,

menge type mseg-menge,

shkzg type mseg-shkzg,

bwart type mseg-bwart,

lgort type mseg-lgort,

dmbtr type mseg-dmbtr,

meins type mseg-meins,

lifnr type mseg-lifnr,

end of ty_mseg.

data: begin of ty_mbew,

matnr type mara-matnr,

bklas type mbew-bklas,

end of ty_mbew.

data:begin of ty_t025t,

bklas type t025t-bklas,

bkbez type t025t-bkbez,

end of ty_t025t.

data:begin of ty_maktg,

matnr type makt-matnr,

maktg type makt-maktg,

end of ty_maktg.

data: ht_mkpf like hashed table of ty_mkpf

with unique key mblnr mjahr

with header line.

data: ht_mseg like hashed table of ty_mseg

with unique key mblnr matnr lifnr bwart lgort

with header line.

data: ht_t025t like hashed table of ty_t025t

with unique key bklas

with header line.

data: ht_maktg like hashed table of ty_maktg

with unique key matnr

with header line.

data: ht_mbew like hashed table of ty_mbew

with unique key matnr

with header line.

data: t_mkpf like ty_mkpf occurs 0 with header line.

data: t_mseg like ty_mseg occurs 0 with header line.

data: t_t025t like ty_t025t occurs 0 with header line.

data: t_maktg like ty_maktg occurs 0 with header line.

data: t_mbew like ty_mbew occurs 0 with header line.

select mblnr mjahr budat from mkpf into table ht_mkpf

where budat in s_budat.

select mblnr matnr menge shkzg bwart lgort dmbtr meins lifnr from mseg into table ht_mseg for

all entries in ht_mkpf where mblnr = ht_mkpf-mblnr and

mjahr = ht_mkpf-mjahr and werks = p_werks and matnr in s_matnr

and lifnr in s_lifnr and bwart in s_bwart and lgort in s_lgort.

select bklas bkbez from t025t into table ht_t025t where spras eq 'EN'

and bklas in s_bklas.

select matnr bklas from mbew into table ht_mbew for all entries in ht_mseg

where matnr = ht_mseg-matnr.

select matnr maktg from makt into table ht_maktg for all entries in ht_mseg

where matnr = ht_mseg-matnr.

Read only

0 Likes
1,415

Hi,

Can you be more clear in your requirement...

Read only

0 Likes
1,415

Hi,

The only place where i feel you can have duplicate entries in from MSEG since you have not included ZEILE. Try including ZEILE in the key for the hashed table ht_mseg and check.

Regards,

Ankur Parab

Read only

Former Member
0 Likes
1,415

Hi Aditya,

It seems as the data that is populating your hash table contains duplicate entries in the key fields that you have selected. You can try to change the composition of the key fields in the table where you are getting the dump. As you are using hash table to insert data into you will get a dump if two set of recrds with the key fields defined in the inetrnal table are same. If can change the table type from hashed to standard so that duplicate entries do not throw dump.

As per your code you say that the error you are getting is when you populate the internal table ht_mkpf from the database table MKPF, it means a set of records with same key fields are being inserted into the internal table. The possible solution could be to change the key fields in the definition of the internal table ht_mkpf or change the internal table type to standard.

If this error occurs on any select statement, check the table type and the combination of keys fields and take appropriate action.

Hope this helps in solving your issue.

Regards,

Sachin