10-18-2007 5:03 AM
hi
there is a record in internal table itab1 as below
|0000000110|AGILENT TECHNOLOGIES <TEST1 ><
|0000000110|AGILENT TECHNOLOGIES <TEST2 ><
|0000000110|AGILENT TECHNOLOGIES <TEST3 ><
|0000000110|AGILENT TECHNOLOGIES <TEST4TOTEST5 ><
and there are recored in table ztesttable having 3 fields cutomern number name and email and all are primary key
|0000000110|AGILENT TECHNOLOGIES <TEST1 ><
|0000000110|AGILENT TECHNOLOGIES <TEST2 ><
|0000000110|AGILENT TECHNOLOGIES <TEST3 ><
<b> |0000000110|AGILENT TECHNOLOGIES <TEST4 ><</b>
|0000000110|AGILENT TECHNOLOGIES <TEST4TOTEST5 ><
i want to delted the bolded r ecored ie third value as test 4 which is not in the internal table itab1 ie i want to compare the records with the itab to that of the zdatabase table ztesttable and then delete the recored which do not match to t he internal table
pls suggest the way and code
pls suggest how to delte the recroed which are not in the internal table...
the three fields are cutomer name email in the table and internal table and data as above
basically my aim ot to compare the data in ztable with this internal table and deleted the recoed which do nt match with this internal table
and point to be noted is that customer name and emal all are primary key in the database table.
regards
Arora
10-18-2007 5:12 AM
Try following code...
select *
into table itab2
for all entries in itab1
from ztesttable
where customer ne ztesttable-customer
and name ne ztesttable-name
and emial ne ztesttable-email.
loop at itab2.
*delete corresponding entry from ztesttable...
endloop.
10-18-2007 5:12 AM
Try following code...
select *
into table itab2
for all entries in itab1
from ztesttable
where customer ne ztesttable-customer
and name ne ztesttable-name
and emial ne ztesttable-email.
loop at itab2.
*delete corresponding entry from ztesttable...
endloop.
10-18-2007 5:14 AM
Hi Arora,
Use this.
select *
into table itab
for all entries in itab1
from ztesttable
where customer ne ztesttable-customer and
name ne ztesttable-name and
email ne ztesttable-email.
loop at itab.
delete corresponding entry from ztesttable...
endloop.
or use this
DELETE ADJACENT DUPLICATES FROM itab
COMPARING fld1 fld2 fld3.
Reward if Useful.
Regards,
Chitra
Message was edited by:
Chitra Parameswaran
10-18-2007 5:16 AM
Hi,
Try this.
**Declare the database internal table
DATA: ITAB_ztable TYPE STANDARD TABLE OF ZTESTTABLE.
DATA: WA_ztable TYPE ZTESTTABLE.
DATA: ITAB_DELETE TYPE STANDARD TABLE OF ZTESTTABLE.
* get the database records available in the internal table ITAB1.
IF NOT ITAB1[] IS INITIAL.
SELECT * FROM ZTESTTABLE
INTO TABLE ITAB_ZTABLE
FOR ALL ENTRIES IN ITAB1
WHERE CUSTOMER_NUMBER = ITAB1-CUSTOMER_NUMBER
AND CUSTOMER_NAME = ITAB1-CUSTOMER_NAME
AND EMAIL = ITAB1-EMAIL.
ENDIF.
* Delete the records from the database table.
LOOP AT ITAB1 INTO WA.
* Check the database internal table.
READ TABLE ITAB_ZTABLE
INTO WA_ZTABLE
WITH KEY CUSTOMER_NUMBER = WA-CUSTOMER_NUMBER
CUSTOMER_NUMBER = WA-CUSTOMER_NAME
EMAIL = WA-EMAIL.
* Check the return code.
IF SY-SUBRC <> 0. " If there is no record found in the database
* Prepare the delete internal table.
* Move the key fields to the internal table ITAB_DELETE...
MOVE-CORRESPONDING WA TO wa_ztable.
APPEND wa_ztable TO ITAB_DELETE.
ENDIF.
ENDLOOP.
* Delete the records available in the internal table ITAB_DELETE.
DELETE ZTABLE FROM TABLE ITAB_DELETE.
COMMIT WORK.
Thanks
Naren
10-18-2007 10:06 AM
hi naren
able to modify ur code and do the changes looping was othe way round for
rather it was loop at ITAB_ZTABLE and then comparing.
anyhow thanks for the detailed code whti i was looking for
can u please explaing the diffrenece between ur code and the code as pasted above but comparing ne
regards
nishant