2007 Feb 13 5:36 AM
Hi Friends,
I have requirement as follow plz guide on this whether to use update or modify statement.
I have a Z-table called Zabc with fields-
PERNR BUDAT LIFNR BUKRS
421 01/02/2000 2617 143
422 02/02/2000 2617 143
423 03/03/200 2617 143
424 04/02/2000 3000 143
425 05/02/2000 2617 143
426 06/03/200 2617 143
Now my requirement is in any record If LIFNR = 2617 and BUKRS = 143.
Then I need to change the LIFNR = 2000. For this how to code and what statement to use whether UPDATE or MODIFY?
Finally it has to appear as follows-
421 01/02/2000 2000 143
422 02/02/2000 2000 143
423 03/03/200 2000 143
424 04/02/2000 3000 143
425 05/02/2000 2000 143
426 06/03/200 2000 143
Thanks in advance.
Your suggestions will be rewarded.
2007 Feb 13 5:38 AM
Hi,
Use UPDATE statement.
Proceed this way,
Fill all the records which needs to be updated in a internal table.
then use the statement
UPDATE <dbtab> FROM TABLE itab.
Rgds,
Prakash
2007 Feb 13 5:44 AM
Hi
upto my knowledge the difference between Update and Modify is:
Modify will modify the the exising records.
Update will updates if the specified records existed otherwise it will creates the records.
Regards,
kumar
2007 Feb 13 5:40 AM
Hi,
1) Update will only update the record in teh database table ,depending upon the condition u specified in the updata command.
it will fail if the record does not exists in the table..mean to say it wil return Sy-subrc as zero then.
2) Modify - will do an update if record exists otherwise it wil create a new record in db table if record does not exists.
Press F1 in ur code on Update or MOdify ,u will find more on tht
go through this link...
Regards,
Priyanka.
2007 Feb 13 5:42 AM
Hi,
If you are sure that there will be entries then,
UPDATE ZABC set LIFNR = '2000' where LIFNR = '2617' and BUKRS = '143'.
Regards
Subramanian
2007 Feb 13 5:42 AM
loop at it_table assigning <fs>.
if ( ( <ls>-lifnr eq '2617' )
and ( <ls>-bukrs eq '143' ) ).
<ls>-lifnr = 2000'.
endif.
endloop.
update z_table from table it_table.
if sy-subrc eq 0.
commit work.
endif.
2007 Feb 13 5:43 AM
Hi,
update ZDB SET LIFNR = '3000'
where lifnr = '2617' and
bukrs = '143'.
regards,
keerthi
2007 Feb 13 5:48 AM
Use the below code:
UPDATE ZABC set LIFNR = '0000002000'
where LIFNR = '0000002617' and BUKRS = '0143'.
Thanks.
2007 Feb 13 5:54 AM
Dear You can use two way
1st way update statment it hing u know it, its by code in program
2nd way
you can do this in manual way
1.Tcode SE11
2.type Ztable name
3.Press Change button
4.Press CtrlShiftF10
5.you can change table data
Rewards if helpful.