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

print and delete records from same internal table..

Former Member
0 Likes
712

Hi experts

I have one internal table , i need to print and delete duplicate material no respective to the period...means it should check from internal table weather for same period two or more same material is there or not...if there give error msg and delete..

Plz give sample code..

usefull ans will b rewarded...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
685

Hi,

we can code this like----

DELETE ADJASCENT DUPLICATES FROM ITAB COMPARING <FLD>...

IF SY-SUBRC EQ 0.

MESSAGE '............' TYPE 'I'.

Hope it may b helpful.

Thanks.

Hi experts

I have one internal table , i need to print and delete duplicate material no respective to the period...means it should check from internal table weather for same period two or more same material is there or not...if there give error msg and delete..

Plz give sample code..

usefull ans will b rewarded...

5 REPLIES 5
Read only

Former Member
0 Likes
685

Hi,

new_table = old_table.

Sort the new_table by peiod and material and delete adjacent duplicates.

loop at new_table.

loop at old_table where period = new_table-period and matnr = new_table-matnr.

count. = count + 1.

endloop.

if count GT 1.

"print error.

endif.

endloop.

New_table has unique entries

Edited by: Shruthi R on May 22, 2008 6:57 AM

Read only

0 Likes
685

Hi,

sort old_table by period matnr.

loop at old_table where period = new_table-period and matnr = new_table-matnr.

if l_period = old_table-period and l_matnr = old_table-matnr.

"print duplicate.

delete old_table index sy-tabix.

else.

l_period = old_table-period.

l_matnr = old_table-matnr.

endif.

endloop.

Read only

Former Member
0 Likes
685

Hi,

data: begin of itab,

period,

matnr,

...

end of itab.

sort itab by period and matnr.

loop at itab.

at new matnr.

loop at itab where period = itab-period and matnr = itab-matnr.

message.

exit.

endloop.

endat.

endloop.

Cheers.

...Reward if useful.

Read only

0 Likes
685

hi friend

i need to find out the duplicate material no. from same ineternal table..if duplicate mat no is there print error msg......its not working

Read only

Former Member
0 Likes
686

Hi,

we can code this like----

DELETE ADJASCENT DUPLICATES FROM ITAB COMPARING <FLD>...

IF SY-SUBRC EQ 0.

MESSAGE '............' TYPE 'I'.

Hope it may b helpful.

Thanks.