Application Development and Automation 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: 
Read only

Activate table entries?

Former Member
0 Likes
936

Hello there,

in my bw 3.5 i have two tables: ztest_new (internal) and /bic/pvcom1_u02. they are identical. if it occurs that some of their data records differ, i want the data from ztest_new to be transferred to /bic/pvcom1_u02.

here is part of the ABAP code to accomplish that:

LOOP AT ztest_new.

MOVE ztest_new-/bic/vcom1 TO /bic/pvcom1_u02-/bic/vcom1_u02.

MOVE ztest_new-/bic/vcom2 TO /bic/pvcom1_u02-/bic/vcom2_u02.

MODIFY /bic/pvcom1_u02.

COMMIT WORK.

ENDLOOP.

it does work half way. after executing the program, the table /bic/pvcom1_u02 contains twice as many data records. to every record another one was added, with the identical key field (vcom1_u02).

though the new records (which are partly identical to the active ones and are partly updated due to changes in ztest_new) are not active.

i would like to activate the new records and throw the old ones out. i thought MOVE would carry out an update query. well maybe it does, but the activation of the updated data is missing...

any solutions?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
795

Hi Stefan,

1. to delete entire contents contents of a table,

DELETE <TABLENAME> where <condition>.

(Give some condition like the key fields not equal to space).

2. To insert entire internal table data to a table,

INSERT <TABLE> FROM <ITAB>.

Hope this helps.

Sajan.

5 REPLIES 5
Read only

Former Member
0 Likes
795

hi Stefan,

if you are sure that you have all the records in your new table which you wanted to maintain in the old one...delete all the entries from old one and do a mass update..i mean insert from the internal table ztest_new.

Hope this helps.

Sajan.

Message was edited by: Sajan Joseph

Read only

0 Likes
795

yeah i could do that. what commands do i use to delete the data in the old table /bic/pvcom1_u02?

and then, instead of MOVE ... TO ..., I use INSERT ... ? ok for that one, i'll look up the documentation...

Read only

Former Member
0 Likes
796

Hi Stefan,

1. to delete entire contents contents of a table,

DELETE <TABLENAME> where <condition>.

(Give some condition like the key fields not equal to space).

2. To insert entire internal table data to a table,

INSERT <TABLE> FROM <ITAB>.

Hope this helps.

Sajan.

Read only

0 Likes
795

Sajan,

thanks for the advice.

why should i put in a where clause instead of just deleting everything? because something like "Where keyfield <> ' ' " would leave the blank initial record in the table. and that would lead to a non-matching number of rows in the two tables.

thanks,

stefan

Read only

Former Member
0 Likes
795

Hi Stefan,

I understood that you want to load the Delta Data into the table /bic/pvcom1_u02.To do that fetch the entire data from /bic/pvcom1_u02 into an Internal Table I_/bic/pvcom1_u02.Compare it with the data in the Internal Table ztest_new.

LOOP AT ztest_new.

V_INDEX = SY-TABIX.

READ TABLE I_/bic/pvcom1_u02 WITH KEY <SPECIFY THE KEY>

IF SY-SUBRC = 0.

DELETE ztest_new INDEX V_INDEX.

ENDIF.

ENDLOOP.

Now the internal table ztest_new will contain only records which are not available in /bic/pvcom1_u02.Now u can update the table.

MODIFY /bic/pvcom1_u02 FROM TABLE ztest_new.

COMMIT WORK.

Regards,

Srinivas.