Application Development 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: 

duplicate entries in table & email count

Former Member
0 Kudos

hi,,

In my selection screen i have 3 fields-

billing doc--vbeln

customer no--kunnr

email id -


when i give inputs in this selection screen fields and execute it mail is sent and

the inputs given for the fields are stored in a ZTABLE.

my requirement is if user is entering 90073336,66789 and daniel

once it gets stored in the ztable. if once again i am giving the

same input, it doesnot get stored in my ztable.

can i get duplicate entries in my ztable. if yes how?

and if my receiver mail id is daniel

no of times email count should be one.if again daniel then two.

if harry.the one.

thnx..

6 REPLIES 6

valter_oliveira
Active Contributor
0 Kudos

I'm not sure if I undrestood your requirement. But it depends of the key of your ZTABLE. What is it?

If you want duplicates, you must have a field that distinguish the record in the table. Suposing your ZTABLE has this key: MANDT-VBELN-KUNNR. If you want the possibility of duplicate records (same kunnr, in same order, with different email), email must be added to the key.

If you want duplicates with same email too, must add a counter to the key like: MANDT-VBELN-KUNNR-EMAIL-COUNTER (this counter could be type n, 3 places, for example).

Regards,

Valter Oliveira.

0 Kudos

Hi,

please help me in that counter loop code..how to do this!!

and how to code for duplicate entries.

DATA: ITAB21 TYPE hashed TABLE OF zmailhist WITH UNIQUE key mandt vbeln kunnr,

WA LIKE LINE OF ITAB21.

WA-VBELN = P_VBELN.

INSERT WA INTO TABLE ITAB21.

WA-KUNNR = P_KUNNR.

INSERT WA INTO TABLE ITAB21.

TRANSLATE V_ID TO LOWER CASE.

CONCATENATE V_ID '@cadence.com' INTO CHAR1.

WA-UNAME = CHAR1.

INSERT WA INTO TABLE ITAB21.

WA-VSURA = SY-UZEIT.

INSERT WA INTO TABLE ITAB21.

WA-ERDAT = SY-DATUM.

INSERT WA INTO TABLE ITAB21.

IF SY-SUBRC = 0.

V_VSTAT = '0'.

ELSE.

V_VSTAT = '1'.

ENDIF.

WA-VSTAT = V_VSTAT.

INSERT WA INTO TABLE ITAB21.

WA-NAME1 = I_TAB1-EMAIL.

INSERT WA INTO TABLE ITAB21.

INSERT zmailhist FROM TABLE ITAB21 ACCEPTING DUPLICATE KEYS.

its not picking the duplicate entries..pls help

0 Kudos

Hi again. It's not accepting duplicate entries in table zmailhist because this table has key MANDT-VBELN-KUNNR, so this way you can only have one record with this combination, for example 100(mandt)-0000000001(vbeln)-0000100123(kunnr).

But I don't understand one thing. Why do you do all those inserts to your hashed table? I think it should be:


DATA: ITAB21 TYPE hashed TABLE OF zmailhist WITH UNIQUE key mandt vbeln kunnr,
      WA LIKE LINE OF ITAB21.

WA-VBELN = P_VBELN.
WA-KUNNR = P_KUNNR.
WA-VSURA = SY-UZEIT.
WA-ERDAT = SY-DATUM.

TRANSLATE V_ID TO LOWER CASE.
CONCATENATE V_ID '@cadence.com' INTO CHAR1.
WA-UNAME = CHAR1.

WA-NAME1 = I_TAB1-EMAIL.

* I don't know why is this subrc here for ...
IF SY-SUBRC = 0.
V_VSTAT = '0'.
ELSE.
V_VSTAT = '1'.
ENDIF.
WA-VSTAT = V_VSTAT.

INSERT WA INTO TABLE ITAB21. "ONLY ONE INSERT

INSERT zmailhist FROM TABLE ITAB21.

Regards,

Valter Oliveira.

0 Kudos

Hi

I have only mandt as primary key....

still the code is not working..any idea how to loop the counter

for email.

if the emailid id same then counter 1..if again that same email id

then 2..if new email id then 1.

thnx..

0 Kudos

I have only mandt as primary key....

This is your problem!!! If mandt is your primary key, you will never be able to have more than one row in your ztable!

Let me try to explain. If your primary key is only mandt, you can only have 1 record for each mandt. Since you only work in one mandt, you can only have one row in your table, like:

MANDT VBELN KUNNR

100 1 10 <---- ok

200 1 10 <---- ok

100 2 10 <---- not ok ... (1)

(1) you cannot insert this field because you already have a record with mandt 100.

So, your key must be composed by the fields that can be repeated and in your case should be:

MANDT-VBELN (if you can only have one email per kunnr and one kunnr per vbeln)

MANDT-VBELN-KUNNR (if you can only have one email per kunnr but several kunnr per vbeln)

MANDT-VBELN-KUNNR-EMAIL (if you can have several email per kunnr and several kunnr per vbeln)

Regards,

Valter Oliveira.

Former Member
0 Kudos

try using MODIFY ztable from itab.

if the input already exists, will be modified, if it's a new one, it will create the new entry

regards

Edited by: Sebastian Bustamante on Sep 17, 2008 6:25 PM