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

hi

Former Member
0 Likes
717

hi mine is small critial doubt

what is the procedure to delete a record from internal table which is only once in that table .

i mean that i want duplicate records and i dont want a single existing record in an internal table pls help me for this

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
689

Hi,

Try the below logic, u can get the required output.

itab2[] = itab1[].

loop at itab1.

count = 0.

Loop at itab2 where itab2-keyfields = itab1-keyfields.

count = count + 1.

endloop.

if count = 1.

delete itab1.

endif.

endloop.

Result will be available in ITab1.

6 REPLIES 6
Read only

Former Member
0 Likes
689

Hi,

First sort your internal table using key fields, then with the help of DELETE ADJACENT DUPLICATES from I_TAB comparing fields(key fields).

Cheers,

Bujji

Read only

0 Likes
689

bujji have u read my query ,

i need exact opposite for this k pls read my query once again

Read only

former_member386202
Active Contributor
0 Likes
689

Hi,

Refer this code

*--Sort table by Personnel Number and Pay Scale Level

SORT it_final BY pernr endda begda.

LOOP AT it_final INTO wa_final.

lv_index = sy-tabix.

lv_index1 = lv_index - 1.

*--Clear

CLEAR : wa_final1.

READ TABLE it_final INTO wa_final1 INDEX lv_index1.

IF sy-subrc EQ 0 AND " check ur condition here

wa_final1-pernr EQ wa_final-pernr.

wa_final-incre = wa_final-bet01 - wa_final1-bet01.

else.

delete itab. delete if condition fails

ENDIF.

MODIFY it_final FROM wa_final INDEX lv_index

TRANSPORTING incre.

*--Clear

CLEAR : wa_final,

wa_final1.

ENDLOOP.

Regards,

PRashant

Read only

Former Member
0 Likes
690

Hi,

Try the below logic, u can get the required output.

itab2[] = itab1[].

loop at itab1.

count = 0.

Loop at itab2 where itab2-keyfields = itab1-keyfields.

count = count + 1.

endloop.

if count = 1.

delete itab1.

endif.

endloop.

Result will be available in ITab1.

Read only

rajesh_akarte2
Active Participant
0 Likes
689

Hi Chaaya,

You can follow the following steps to get desired result.

assume u have internal table itab1

1) itab2[] = itab1[].

2) Delete all adjacent records from itab2.Now u will have the records which have single entry.

3) Now loop at itab2 and delete all the records present in itab1.

In this way u will get the desired result.

Reward if useful.

Regards,

Rajesh Akarte

Message was edited by:

Rajesh Akarte

Read only

Former Member
0 Likes
689

read that record into header and write :

<b>delete itab.</b>

plz reward points if helps.

regards,

rahul