‎2006 Oct 05 4:24 PM
I have a TABLE it_knvp
with fields kunnr
parvw
kunn2.
In this table for every Kunn2 there could be multiple kunnr, and if so then i have to find that kunn2 and do an action on other internal table.
SO i want an internal table itab which have the records of it_knvv only for duplicate kunn2.
select zzsd
kunn2
into table itab
from zzsd0010
for all entries in it_knvp
where kunn2 = it_knvp-kunn2.
thanks in advance.
Shejal.
‎2006 Oct 05 4:34 PM
U can try the below logic.
it_knvp1[] = it_knvp[].
sort it_knvp1 by kunn2.
loop at it_knvp.
lcnt = 0.
loop at it_knvp1 where kunn2 = it_knvp-kunn2.
lcnt = lcnt + 1.
endloop.
if lcnt =< 1.
delete it_knvp.
endif.
endloop.
select zzsd
kunn2
into table itab
from zzsd0010
for all entries in it_knvp
where kunn2 = it_knvp-kunn2.
‎2006 Oct 05 4:31 PM
Hi,
Try this,
Loop at it_knvp.
Onchange of it_knvp-kunn2.
continue.
endon.
select zzsd
kunn2
into table itab
from zzsd0010
where kunn2 = it_knvp-kunn2.
endloop.
Hope this shall help you.
thanks and regards,
Prashanth
‎2006 Oct 05 4:34 PM
U can try the below logic.
it_knvp1[] = it_knvp[].
sort it_knvp1 by kunn2.
loop at it_knvp.
lcnt = 0.
loop at it_knvp1 where kunn2 = it_knvp-kunn2.
lcnt = lcnt + 1.
endloop.
if lcnt =< 1.
delete it_knvp.
endif.
endloop.
select zzsd
kunn2
into table itab
from zzsd0010
for all entries in it_knvp
where kunn2 = it_knvp-kunn2.
‎2006 Oct 05 4:39 PM
Hi,
Try this..The below logic will get the kunn2 which has more than one kunnr.
IT_KNVV_TMP = IT_KNVV.
SORT IT_KNVV_TMP KUNNR KUNN2.
DELETE ADJACENT DUPLICATES FROM IT_KNVV
COMPARING KUNNR KUNN2.
SORT IT_KNVV_TMP BY KUNN2.
DATA: IT_KNVV_FINAL LIKE IT_KNVV OCCURS 0
WITH HEADER LINE.
DATA: V_PREV_KUNN2 TYPE KNVP-KUNN2.
DATA: V_FIRST.
DATA: V_TOTAL TYPE IN4.
LOOP AT IT_KNVV_TMP.
AT FIRST.
V_FIRST = 'X'.
ENDAT.
IF V_FIRST IS INITIAL.
IF V_PREV_KUNN2 <> IT_KNVV_TMP-KUNN2.
IF V_TOTAL > 1.
MOVE-CORRESPONDING IT_KNVV_TMP TO IT_KNVV_FINAL.
CLEAR: V_TOTAL.
ENDIF.
ENDIF.
ENDIF.
V_TOTAL = V_TOTAL + 1.
AT LAST.
IF V_TOTAL > 1.
MOVE-CORRESPONDING IT_KNVV_TMP TO IT_KNVV_FINAL.
CLEAR: V_TOTAL.
ENDIF.
ENDDAT.
CLEAR V_FIRST.
V_PREV_KUNN2 = IT_KNVV_TMP-KUNN2.
ENDLOOP.
Thanks,
Naren
‎2006 Oct 05 4:48 PM
Hi Shejal,
Try with this code.
DATA IT_DUP_KNVP TYPE IT_KNVP WITH HEADER LINE.
DATA V_COUNT TYPE I.
SORT IT_KNVP BY KUNN2.
LOOP AT IT_KNVP.
AT NEW KUNN2.
V_COUNT = 1.
ENDAT.
V_COUNT = V_COUNT + 1.
AT END OF KUNN2.
IF V_COUNT > 1.
APPEND IT_KNVP TO IT_DUP_KNVP.
CLEAR IT_DUP_KNVP.
CLEAR V_COUNT.
ENDIF.
ENDAT.
select zzsd
kunn2
into table itab
from zzsd0010
for all entries in IT_DUP_KNVP
where kunn2 = it_knvp-kunn2.
Thanks,
Vinay
ENDLOOP.