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

update db table for duplicate entries.

Former Member
0 Likes
1,173

Hi,

If i want to update a ztable

i have 3 to 5 different ways.

1. UPDATE ztab FROM workarea.

2. UPDATE ztable SET field1 = wa-f1 field2 = wa-f2

WHERE keyf1 = wa-kf1

AND keyf2 = wa-kf2.

3. UPDATE ztable FROM TABLE itab.

4. MODIFY ztable FROM TABLE itable or from wa.

but if i want to update some 2 to 3 fields

by checking with the fields in db table with values in flat file

and when i check the dbtable values with flat file and i find the entries in dbtable are multiple because i am not putting all key fields in where condition

because i know only some of them .

so duplicate entries are available and i wanted to update the same values to all those duplicate records .

then how should i update them.

i don't want to use update between

select and end-select because the records that i am updating are many.

i will store records into itab and then i will compare with values i file

and for all records i want to update the two or three fields with the values in flat file.

help me.

Hi,

If i want to update a ztable

i have 3 to 5 different ways.

1. UPDATE ztab FROM workarea.

2. UPDATE ztable SET field1 = wa-f1 field2 = wa-f2

WHERE keyf1 = wa-kf1

AND keyf2 = wa-kf2.

3. UPDATE ztable FROM TABLE itab.

4. MODIFY ztable FROM TABLE itable or from wa.

but if i want to update some 2 to 3 fields

by checking with the fields in db table with values in flat file

and when i check the dbtable values with flat file and i find the entries in dbtable are multiple because i am not putting all key fields in where condition

because i know only some of them .

so duplicate entries are available and i wanted to update the same values to all those duplicate records .

then how should i update them.

i don't want to use update between

select and end-select because the records that i am updating are many.

i will store records into itab and then i will compare with values i file

and for all records i want to update the two or three fields with the values in flat file.

help me.

3 REPLIES 3
Read only

Former Member
0 Likes
803

Hi Any body can answer this.

Need help.

Thanks,

Neetu.

Read only

0 Likes
803

Here is a pseudo logic, i hope it will help.

Get all the data from file into internal table IT_FILE.

Loop at IT_FILE.

For each record, check if there is entry in db table to be updated.

Use update statement to update db table use SET clause as you need to update certain fields and provide appropriate condition in WHERE clause. As you do not have all key values, it will update all records which satisfy this WHERE condition.

Check for SY-SUBRC and if it is successful, commit work.

Endloop.

Read only

0 Likes
803

Hi Ashish,

Thanks for your help.

If i do this way always it satisfies the first record of the multiple records that are satisfied when we put where condition with some of the key fields.

then always it might update the same record.

I stead i can loop through the itab having the DB table and read the file.

Anyways thanks for the help.

and i am waiting for the correct file, once i get it, then i will try this and update points.

Thanks,

Neetu.