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: 

* How to update a field in Z-Table

Former Member
0 Kudos
2,051

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.

8 REPLIES 8

Former Member
0 Kudos
342

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

0 Kudos
342

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

Former Member
0 Kudos
342

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.

Former Member
0 Kudos
342

Hi,

If you are sure that there will be entries then,

UPDATE ZABC set LIFNR = '2000' where LIFNR = '2617' and BUKRS = '143'.

Regards

Subramanian

Shivaji16
Active Participant
0 Kudos
342

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.

Former Member
0 Kudos
342

Hi,

update ZDB SET LIFNR = '3000'

where lifnr = '2617' and

bukrs = '143'.

regards,

keerthi

Former Member
0 Kudos
342

Use the below code:

UPDATE ZABC set LIFNR = '0000002000'

where LIFNR = '0000002617' and BUKRS = '0143'.

Thanks.

Former Member
0 Kudos
342

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.