‎2007 Mar 28 11:40 AM
there is internal table as follows: itab
a b c d e
1 rr 11 55 1001
2 pp 22 87 1001
3 uu 33 99 1002
now in the above table a,b,c,d,e are field names.
in the above table in the e field , i have to check, if first row value is matching any of the other subsequent rows e values. if it is matching, then it should pop up the error message.
that is in the above table, first row e value is 1001. it should check with the remaining rows 2 and 3 e values. now , because the value of e in the first row is matching with the second row , it should populate the error message. plz let me know the code releavant to this issue. this is urgent requirement. plz let me know as soon as possible. points will be awarded.
thanking u in advance,
a.srinivas rao.
‎2007 Mar 28 11:46 AM
hi
u can use following code
sort itab a b c d e. " try to sort by key fields.
delete adjecent comparing all fields.
if sy-subrc = 0.
error msg.
endif.
Regards,
kapil Soni
reward if usefull
Message was edited by:
Kapil Soni
‎2007 Mar 28 11:46 AM
You have to check only the 1st record e field or every record's e field value to any other record?
‎2007 Mar 28 11:48 AM
data : wtab like itab .
read table itab into wtab index 1.
read table itab with key f3 = wtab-f3.
if sy-subrc = 0.
<error message>
endif.
regards
shiba dutta
‎2007 Mar 28 11:58 AM
hi i make one demo program for u. pl go through it and implement in ur program.
data : begin of itab occurs 0,
a(4),
b(4),
c(4),
d(4),
e(4),
end of itab.
itab-a = 'a'.
itab-b = 'b'.
itab-c = 'c'.
itab-d = 'd'.
itab-e = 'e'.
append itab.
clear itab.
itab-a = 'aa'.
itab-b = 'bb'.
itab-c = 'cc'.
itab-d = 'dd'.
itab-e = 'ee'.
append itab.
clear itab.
itab-a = 'aaa'.
itab-b = 'bbb'.
itab-c = 'ccc'.
itab-d = 'ddd'.
itab-e = 'eee'.
append itab.
clear itab.
itab-a = 'a'.
itab-b = 'b'.
itab-c = 'c'.
itab-d = 'd'.
itab-e = 'e'.
append itab.
clear itab.
sort itab. " here you have to sort internal table by ur key fields
delete adjacent duplicates from itab comparing all fields.
if sy-subrc = 0.
write : 'duplicate entry'.
endif.
waiting for good reward points
Regards,
kapil Soni
‎2007 Mar 28 11:58 AM
hi
couldn't understand completely your requirement as you say that you want to throw an error message, is it in an exit or in a module pool...moreover, if you want to check against only the last col. or with any combination of itab...anyway, i am assuming that you want to move only the correct records to another int. table so that there are unique entries of e..
loop at itab_1.
read table itab_2 with key e eq itab_1-e.
if sy-subrc eq 0.
continue.
else.
move-corresponding itab_1 to itab_2.
endif.
endloop.
if helpful, reward
Sathish. R
‎2007 Mar 28 11:59 AM
Hi,
another way of doing it. Works fine on my server.
Regards,
Alfonso
-
>
REPORT zinternal.
DATA: BEGIN OF internal OCCURS 0,
a(4) TYPE c,
b(4) TYPE c,
c(4) TYPE c,
d(4) TYPE c,
END OF internal.
DATA: tabix LIKE sy-tabix.
START-OF-SELECTION.
internal-a = '1'.
internal-b = 'RR'.
internal-c = '55'.
internal-d = '1001'.
APPEND internal.
internal-a = '2'.
internal-b = 'PP'.
internal-c = '87'.
internal-d = '1001'.
APPEND internal.
internal-a = '1'.
internal-b = 'UU'.
internal-c = '99'.
internal-d = '1002'.
APPEND internal.
LOOP AT internal.
tabix = sy-tabix.
READ TABLE internal WITH KEY d = internal-d.
IF sy-subrc EQ 0 AND sy-tabix NE tabix. WRITE: 'error'. ENDIF.
ENDLOOP.
‎2007 Mar 28 12:01 PM
u can give like
first
sort table itab by e.
loop at itab.
read table itab with key e = itab-e,.
if sy-subrc = 0.
error message
endif.
endloop.
‎2007 Mar 28 12:02 PM