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: 

Updating the new value

Former Member
0 Kudos
111

Hi ,

I have one issue in my report i.e i have one field in data base table that is ARCHIVE ID . In the selection screen im giving

the Arcchive id old value and ARCHIVE ID new value my issue when im using Modify statement in the report im getting two

values in the data base table.

Ex ; Archive id value = x(old) database table

After updating im getting two values like archive id = x

archiveid = y.

i want to overlap y on x. how to do this

Note : Archive id is primary key field.

Thanks,

Narasimha.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
78

Ok..try like this...

UPDATE <table>

SET archiveid = 'y'

WHERE archiveid = 'x'.

Value u2018Xu2019 will be replaced by u2018Yu2019 though it is key field..

9 REPLIES 9

Former Member
0 Kudos
78

Well modify seems to create new records if you want to manipulate key fields. I dont really wonder on this one.

So Scratch modify statement, and rather have something like:


update xxx
from    wa.

if sy-subrc NE 0.
  insert wa into xxx.
endif.

Former Member
0 Kudos
78

Hi,

Florian's suggestion absolutely corret.

And more over work area from which you are updating data base table is of same type as database table.

EX: WA_TAB TYPE KNA1.

BR,

Lokeswari.

0 Kudos
78

Hi ,

I gone through Floarin solutin but still it is not working my question i want to Update the new value on oldvalue.but i dont

want to see the old value in the database table after updating the new value. for that i want to overlap new value on

old value.

How?

Thanks,

Narasimha.

0 Kudos
78

well what about if you delete the record first and THEN do your modify.

That works for sure.

0 Kudos
78

Hi Floarin ,

I used the delete statment its working perfectly , but we cant delete the database table record . so thats why im thinking

for another sloution other than delete statement if you had that colud you please provide the solution.

Thanks in advance.

Narasimha.

0 Kudos
78

1st INSERT new entry

2nd DELETE old entry

to keep the informations of the other table fields. Or keep the information within your programm in a workarea (1 entry) or internal table (more than 1 entry).

0 Kudos
78

Erm, i dont understand that.

Lets make an example:

This is an excert of your database table you wish to update.


Database table:
--------------------
yyy(key)     atribute1     attribute2     ...
001             x                 y
002             x                 x

So you want to change 002 to 003, which doesnt work sind it is a key field. Let us assume it WOULD work what would be the outcome?


Database table:
--------------------
yyy(key)     atribute1     attribute2     ...
001             x                 y
003             x                 x

If i understoof you correctly that is the desired outcome you wish to have.

So lets go the delete way:

first READ the record you wish to delete into some wa.


Select * from xxx 
into wa 
where yyy = old_value.

delete xxx where yyy = old_value.

leaves you this:

Database table:
--------------------
yyy(key)     atribute1     attribute2     ...
001             x                 y

and now do: wa-yyy = new_value.
modify xxx from wa.

and then you got:
Database table:
--------------------
xxx(key)     atribute1     attribute2     ...
001             x                 y
003             x                 x

Which then would be exact smae as above, so i dont really understand where your problem is. Tho i hardly suspect it is somehwere around the understanding of key fields and relational databases.

I mean i really wonder, I one case you tell us you got one record too much in your table after the modify.

Once we offer you a way to get rid of the unwanted record you tell us that you can not delete it because it would miss then.

Edited by: Florian Kemmer on Nov 8, 2010 2:10 PM

former_member195402
Active Contributor
0 Kudos
78

Hi,

Select alle entries with matichg IG into an internal table (or read single if there may only be one).

Insert new key entries and delete old key entries (looping at internal table or from your single record workarea).

Regards,

Klaus

Former Member
0 Kudos
79

Ok..try like this...

UPDATE <table>

SET archiveid = 'y'

WHERE archiveid = 'x'.

Value u2018Xu2019 will be replaced by u2018Yu2019 though it is key field..