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: 

update ztable records

Former Member
0 Kudos

Hi,

I am trying to move Internal table contents to Z TABLE.

I am having data issue. In debugging I see ITAB enteries say for example 100

all are not getting in to ZTABLE.

I am not filtering anywhere

I have 100 records in itab with fld1 = 'ZBC'.

LOOP AT t_data WHERE fld1= 'ABC'.

ZTAB-FLD1 = t_data-FLD1.

ZTAB-FLD2 = t_data-FLD2.

ZTAB-FLD3 = t_data-FLD3.

ZTAB-FLD4 = t_data-FLD4.

modify ZTAB .

commit work.

endloop.

Anything wrong in my code?

Rgds

Praveen

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi,

instead of modify use update statement.

UPDATE TABLE SET COLUMN-UPDATE STATEMENT

or use this

Single-line inserts

LOOP AT INT-TAB

INSERT INTO TABLE VALUES INT-TAB

ENDLOOP

wtih regards

janani

4 REPLIES 4

former_member194669
Active Contributor
0 Kudos

For example in ITAB FLD1 is key then before going into loop

make sure sort it and delete adjacent duplicates using the field FLD1

former_member212653
Active Contributor
0 Kudos

As you are using modify statement, while updation it will update the table with the exsistng key fields of the database table.

Former Member
0 Kudos

Hi, First try using the INSERT statement and then check sy-subrc. If sy-subrc <> 0, then go for the MODIFY statement.

Eg:

ztable-fld 1 = t_itab-fld1.

ztable-fld 2 = t_itab-fld2.

ztable-fld 3 = t_itab-fld3.

ztable-fld 4 = t_itab-fld4.

insert ztable.

if sy-subrc <> 0.

modify ztable.

endif.

Try this code, it should work.

Former Member
0 Kudos

hi,

instead of modify use update statement.

UPDATE TABLE SET COLUMN-UPDATE STATEMENT

or use this

Single-line inserts

LOOP AT INT-TAB

INSERT INTO TABLE VALUES INT-TAB

ENDLOOP

wtih regards

janani