‎2009 May 06 4:55 PM
Hi ,
I have a table with 10 fields. 8 of them are key fields. In program when I am trying to update the table it fails.
data: wa_ztable type zsd_table.
update zsd_table from wa_ztable.
the issue is I am not setting all the 8 fields each time. some of the 8 key fields will be blank some time.
What exactly is the issue with this.
Thanks,
Gopi
‎2009 May 06 9:17 PM
>
> Hi ,
>
> I have a table with 10 fields. 8 of them are key fields. In program when I am trying to update the table it fails.
>
> data: wa_ztable type zsd_table.
>
> update zsd_table from wa_ztable.
>
> the issue is I am not setting all the 8 fields each time. some of the 8 key fields will be blank some time.
>
> What exactly is the issue with this.
>
> Thanks,
> Gopi
You already know the issue, you have to set all the key fields, i.e if you want to change only one line in the db , otherwise use a where clause if it has to update multiple records.
[See here|http://help.sap.com/erp2005_ehp_04/helpdata/EN/43/41341147041806e10000000a1553f6/frameset.htm]
regards,
Advait
‎2009 May 06 5:21 PM
HI,
While updating the database key fields should not be blank. you must pass the key fields.
regards,
S>Chaitanya.
‎2009 May 06 5:27 PM
what you can do is when you Read the data from the database table. catch the table index (sy-tabix) to some variable and then use that index to update the table.
* your select
lv_tabix = sy-tabix.
update zsd_table from wa_ztable index lv_tabix.Regards,
Lalit Mohan Gupta.
‎2009 May 06 5:37 PM
Hi,
Updating multiple entries
Examle updating the field zchecked to 'X'
UPDATE zcostcheck set zchecked = 'X'
WHERE zcostcheck-zaar = zaar and
zcostcheck-zmaaned = zmaaned and
zcostcheck-zbukrs = zbukrs and
zcostcheck-zsaknr = zsaknr2 and
zcostcheck-zgsber = zgsber.
if sy-subrc = 0.
commit work.
else.
roll back.
endif.
or try to use modify statement..
Read records from the database table where name is space, into an internal table
select * from personal into table itab
where name = space.
Update name in the internal table to Unknown
loop at itab.
itab-name = 'Unknown'
endloop.
Modify records in the database table. Only records with the same key values as then
internal table is modified
MODIFY personel from table itab.
Regards,
prabhudas
‎2009 May 06 8:54 PM
Gopi,
You can not change the contents of the key fields. If some of them were blank when inserted, they should remain blank. Only non-key field values can be changed.
I believe this is not a restriction placed by the underlying database system, but by ABAP Open SQL engine.
I had a similar requirement in one of my programs. The way I implemented it is to delete the existing record and insert the new record. You have to make sure that there will not be any referential integrity issues.
‎2009 May 06 9:17 PM
>
> Hi ,
>
> I have a table with 10 fields. 8 of them are key fields. In program when I am trying to update the table it fails.
>
> data: wa_ztable type zsd_table.
>
> update zsd_table from wa_ztable.
>
> the issue is I am not setting all the 8 fields each time. some of the 8 key fields will be blank some time.
>
> What exactly is the issue with this.
>
> Thanks,
> Gopi
You already know the issue, you have to set all the key fields, i.e if you want to change only one line in the db , otherwise use a where clause if it has to update multiple records.
[See here|http://help.sap.com/erp2005_ehp_04/helpdata/EN/43/41341147041806e10000000a1553f6/frameset.htm]
regards,
Advait