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: 

very very urjent comparing two tables and delete extra records

Former Member
0 Kudos

hi experts,

this is very very urjent issue can u please provide logic.

1. i am having two tables kondd and kotd001.

2. here kondd table having 27 records and kotd001 having 16 records.

3. the issue is what ever extra records(27-16=11) 11 diff records should be delete

in the table kondd and deleted records(11) should be display in list.

4. deleted records download in application sever and presentation server

5. both tables should be equal records(16).

can u please solve this issue.

REPORT ZCONDITION.

tables: kondd,kotd001.

types: BEGIN OF T_KONDD, 27

KNUMH TYPE KONDD-KNUMH, "key field

SMATN TYPE KONDD-SMATN,

MEINS TYPE KONDD-MEINS,

SUGRD TYPE KONDD-SUGRD,

PSDSP TYPE KONDD-PSDSP,

LSTACS TYPE KONDD-LSTACS,

END OF T_KONDD.

types: BEGIN OF T_KOTD001, 16

KAPPL TYPE KOTD001-KAPPL,

KSCHL TYPE KOTD001-KSCHL,

MATWA TYPE KOTD001-MATWA,

DATBI TYPE KOTD001-DATBI,

DATAB TYPE KOTD001-DATAB,

KNUMH TYPE KOTD001-KNUMH,

END OF T_KOTD001.

4 REPLIES 4

Former Member
0 Kudos

loop at it1 into wa1.

read table it2 from wa with key field = wa-field.

if sy-subrc = 0.

append it3 to wa.

endif.

endloop.

Former Member
0 Kudos

try this....

1) select * ....from both tables into 2 internal tables........say itab1 and itab2

2) describe table itab1 lines var1.

describe table itab2 lines var2.

3) if var1 = var2.

*---no need to do any operation.

exit.

elseif var1 > var2.

loop at itab1.

read table itab2 with key ......

if sy-subrc = 0.

*--delete records existing in itab2

delete itab1 index sy-tabix.

endif.

endloop.

*--now itab1 contains only records not there in itab2

if not itab1[] is initial.

delete <databasetable of itab1> from itab1.

endif.

else.

*vice versa....

endif.

Regards

Vasu

Former Member
0 Kudos

DATA: ITAB TYPE TABLE OF kondd,

WA TYPE kondd.

SELECT * FROM kondd INTO TABLE ITAB.

LOOP AT ITAB INTO WA.

SELECT SINGLE * FROM kotd001 INTO WA WHERE KNUMH = WA-KNUMH.

IF SY-SUBRC NE 0.

DELETE FROM kondd WHERE KNUMH = WA-KNUMH.

ENDIF.

ENDLOOP.

Former Member
0 Kudos

hi,

data: kondd type standard table of T_KONDD with header line,

kotd001 type standard table of T_KOTD001 with header line,

kondd1 type standard table of T_KONDD with header line.

loop at tkondd.

read table kontd with key knumh = tkondd-knumh.

if sy-subrc ne 0.

delete table tkondd index sy-tabix.

move tkondd to tkondd1[]. " all different records are now at tkondd1.

endif.

endloop.

loop at tkondd1.

write:/10 tkondd1-...........

endloop.

call function 'GUI_DOWNLOAD'.

................

..................

in filename give ur path for presentation n application server.

if helpful reward some points.

with regards,

Suresh Aluri.